cmake: generated/ exists at configure time and before vk_null_descriptor_test's rule; no "Failed to open file" on a fresh build (BUILD-NULL-DESCRIPTOR-GENERATED-DIR)
XMemVirtualAlloc reads the console's GPU bits of each protection: memory the GPU reaches
without writing it (PAGE_GRAPHICS_NOACCESS, _READONLY, _EXECUTE, _EXECUTE_READ: three
parts of the title's 32-bit graphics heap, 38 MB) is told to leonida-gpu
(title_memory_gpu_read_only). Shader writes declared over it can be nothing on the
console, so Shadow::gpu_writes leaves those parts out of what is kept, compared, fetched
and landed (LEONIDA_GPU_READ_ONLY_NO_BACK, on; 0 as before). Standing at the waterside on
an RTX 4060 Ti: 1,340 MB a frame were declared there, and in turns of 3 s (23 phases)
the frame was 0.76 +-0.72 ms shorter without them (means 1.29 +-0.79). The frame line
counts both. Tests: gpu_read_only_parts_of_a_range, gpu_read_only_protections.
HostHeap::keep_ref: a slot that already holds the resource takes no reference. The
callers cloned it first and it was given back at once: two atomic changes of a count
every list thread changes (keep and the COM counts were 9 % of the list threads'
samples).
LEONIDA_BATCH_DESCRIPTORS (off): a table's listed-view copies in one CopyDescriptors
call, after PL-VIP/sureVI 60cc6e4 (GPL-3.0). In turns of 3 s (66 phases) the frame was
the same (-0.01 +-0.31 ms), no device lost: the list threads have room (43 % of their
samples wait), so it stays off. docs/findings.md: the list threads' profile.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Frame generation (G-buffer path): the title also fills a 960x960 pass that looks like
its G-buffer (a probe's), and the pass recorded last was tagged, recorded at once on the
thin threads before the present of the frame before was served: four switches in four
seconds standing, each a generated frame from another pass's depth and motion vectors.
Now each host list carries the pass it bound to its submission (HostList::mark_gbuffer,
taken in Host::submit), and a present tags the largest one submitted before it; a frame
whose only such pass is under half the last one's area keeps the last. Standing with 2x
(2026-11-29): no switch in the whole run, the probe pass passed over twice, the picture
without the interface tagged on 300 of 300 presents.
XMemVirtualAlloc logs the protections of placeholder parts too (it returned before): the
title's 32-bit graphics heap is five parts, GPU read-only, write-combined executable,
garlic and cached GPU read-write.
Diagnostics (no change unless asked for):
- LEONIDA_INDIRECT_RUNS=1 counts the title's indirect executions by what comes between
them: 13,000 a frame, all of one record with no count buffer, between two of one
pipeline 1.7 tables, 0.9 views and 0.9 constants set.
- LEONIDA_AB switches LEONIDA_EXP_EMPTY_INDIRECT (an empty execution after each mesh one:
+0.67 +-0.77 ms, so merging executions would save nothing), LEONIDA_EXP_MESH_SKIP
(every mesh draw left out: -7.7 ms median of 38 pairs, the frame still about 50 ms,
held by the submitting thread) and LEONIDA_EXP_MESH_ONE_PIXEL (-0.3 +-0.3 ms).
docs/findings.md: where the frame goes at the launcher's default (card 56 ms, submit
thread 55-65 ms, 530-600 ms of CPU a frame), what a copy-free native runtime would
change (D33T0X/Native-Runtime compared: 0.4-0.83 s world frames in its own notes),
copy-back elision (446 ms a frame of list steps here, nothing elided) and card-side
windows (57.0 -> 66.2 ms) measured and not taken, and the defrag program still refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A console program's LDS operations were taken as in bounds, so a read or write past the
program's allocation reached the words the translator keeps after it (the halves'
counter, the wave64 exchange, the thread ticket), a packed neighbour group's slice, or
past the end of the host array. Now every access is checked against the program's own
dwords (Shader::program_lds_dwords): outside, a read gives 0 and a write or atomic is
dropped, as the console does. LEONIDA_LDS_BOUNDS=0 restores the old shortcut.
After D33T0X/Native-Runtime 733b7cc and 745db9a (its xlate crate, GPL-3.0-or-later,
VIctory's translator): there a wave64 program clearing 4,096 bytes of its 3,300 wrote
into the translator's exchange and its shadow tile counts came out as other data.
Test lds_accesses_past_the_allocation_are_dropped_and_read_zero (64 threads, 512 bytes
of LDS) passes on the RTX 4060 Ti. Three game runs on it (2026-11-29, Series X, dynamic
resolution): the same three programs refused as before, no device removal, frames as
before (in-world phases 55-70 ms).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LEONIDA_RENDER_SCALE_MIN (the loader's hooks.rs) sets only the lowest scale of the
title's own upscaler (the immediate at rva 0x28f1e7e) and leaves the scale above it to
the title's dynamic resolution; a valid LEONIDA_RENDER_SCALE still holds one scale.
The launchers take it as -Lowest <height>; scripts\play-d3d12.ps1 now starts Series X
with -Lowest 1080 (a 2560x1440 output, 1080 to 1440 lines rendered) instead of
-Resolution 1440, which still holds 1440.
Same save, RTX 4060 Ti, frame generation off, two series (2026-11-29): median frame
57.0 and 59.6 ms against 66.0 and 67.9 held at 1440; the title's choice sat at its
1080 floor there. A recorded tour at the floor: no device removal, no new pipeline
refusals; the frames the scan flagged are camera turns into the sun.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow-up fixes for Wave64-on-Wave32 loop-region analysis and partial-group
`host_wide` loops:
1. Fixpoint closure over `full_by_head` in `lower::lane_regions` (`lower.rs`):
- Replace the pre-walk `sub_loops` check with a monotone fixpoint over
`full_by_head` (`expanded`), expanding any enclosing loop `full_body`
with `full_body[d]` whenever the non-post-dominated walk reaches `head`,
leaves `full_body`, or reaches a block with an edge to `head` or outside
`full_body`.
- Captures shared-latch per-lane `continue` branches and guarded `break`
exits inside per-lane branches while keeping diamond `if/else` joins and
nested per-lane loops inside uniform outer loops unexpanded.
2. Dead half-wave early exit in `Lower::wave_wide` (`lower.rs`):
- When an entire 32-lane host half-wave is unlaunched (`waveAnyTrue(a) ==
false`, e.g. lanes `32..63` when `USER_DISPATCH_THREADS_X <= 32`), combine
`host_wide`'s branch result with `waveAnyTrue(a)` (`And` when `taken`
cycles back to `b` and `!any`, `Or(!waveAnyTrue(a))` when `not_taken`
cycles back to `b` and `any`) so dead half-waves exit on iteration 1 and
reach post-loop barriers cleanly instead of spinning to `LOOP_LIMIT`.
3. Regression coverage (`paired_tests.rs`):
- Verify live on RTX 3090 + WARP that lane 40's `v6` equals `1` when
`active_in_group <= 32` and `4` when `active_in_group > 32`, and add unit
assertions for shared-latch `continue`, guarded `break` inside a per-lane
branch, diamond `if/else` non-expansion, and nested-loop non-expansion.
Verification (Windows 11 + NVIDIA GeForce RTX 3090 D3D12 & Microsoft WARP):
- `cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader --lib paired_tests -- --test-threads=4`: 21/21 passed.
- `cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader --lib wave64_tests -- --test-threads=4`: 30/30 passed.
- `cargo clippy --manifest-path d3d12/Cargo.toml -p leonida-shader --all-targets`: 0 warnings on touched code.
- `python -I scripts/check_no_game_data.py`: 0 issues.
AI-assisted.
Follow-up fixes for Wave64-on-Wave32 lowering and loop-region analysis:
1. `Lower::wave_wide` `host_wide` partial-group masking (`lower.rs`):
- Mask `mine` by `self.partial_active` (`And(mine, a)` for `any`,
`Or(mine, Xor(a, true))` for `!any`) in the `host_wide` branch so
unlaunched threads kept in the wave for barriers (`USER_DISPATCH_THREADS_X`
in spilled `halves`/`exchange` Wave64 compute programs) never hold
`waveAnyTrue` true until `LOOP_LIMIT` or keep `waveAllTrue` false.
2. Multi-latch & irreducible loop region precision (`lower.rs`):
- Intersect each retreating edge's backward walk from `latch` with forward
reachability from `head` so irreducible multi-entry loops capture only the
exact loop SCC without leaking into entry block `0` or preheaders.
- Merge all loop bodies sharing `head` so per-lane `continue` back-edges
(direct or trampolined) before a uniform latch mark post-dominating
loop-body blocks `all_lane_blocks == false` and include the `continue`
branch in `branches_around`.
3. Paired readlane parity, cached `all_lane_blocks`, and expanded tests
(`paired.rs`, `lower.rs`, `paired_tests.rs`, `wave64_tests.rs`):
- Evaluate `restored_lanes` and post-section `Section::reads` across both
paired halves via `self.both` / `put_lanes` instead of mirroring `lo`.
- Cache `all_lane_blocks(self.x.st)` on `Lower` (`every_lane_block`) and
co-locate `console_lane_read` right below `Lower::shape`.
- Update `wave64_tests` mode-`0` assertion text and add runtime RTX + WARP
coverage for `ds_write_b8`/`ds_read_u8`/`ds_read_i8`, `_d16`/`_d16_hi`
half preservation, `ds_write_b128`/`ds_read_b96`/`ds_read_b128`,
`ds_write2st64_b64`/`ds_read2st64_b64`, counted `host_wide` loops
(`s_cbranch_execnz` & `s_cbranch_execz`), per-lane `continue` before a
uniform latch with cross-half LDS, and irreducible 2-entry loop CFGs.
Verification (Windows 11 + NVIDIA GeForce RTX 3090 D3D12 & Microsoft WARP):
- `cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader --lib paired_tests -- --test-threads=4`: 21/21 passed.
- `cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader -- --test-threads=4`: 360 passed, 0 failed.
- `cargo clippy --manifest-path d3d12/Cargo.toml -p leonida-shader --all-targets`: 0 warnings on touched code.
- `python -I scripts/check_no_game_data.py`: 0 issues.
AI-assisted.
- Validate heap membership, non-sampler heap kind, 32-byte alignment, and
checked_add + heap.index bounds before reading descriptor handles in
check_cast_conflict and begin_written_cast_sources (preventing out-of-bounds
dereferences on sentinel root-indexed constants such as 0xFFFF_FFFF).
- Batch placed R9G9B9E5 lookup in table_r9g9b9e5_views so State::tables takes
views_read at most once per table (zero times when all entries are CBVs/nulls).
- Add sentinel 0xFFFF_FFFF group.indexed + out-of-bounds plan.direct regression
check under active WRITTEN_CAST_SOURCES.
- Thread signed=(format == 96) into Bc6hCalibrator.add_pool_chunk so signed
BC6H_SF16 reference targets clamp to [-32768, 32767] instead of [0, 65535]
and _eval_w_ops sign-extends and unquantizes candidates in signed space.
- Average the full [x0, x1) x [y0, y1) quadrant footprint across multi-level
downsamples in _make_multilevel_quads_getter (caching per-4x4-block sums),
eliminating single-phase column/row aliasing at 4+ mip levels.
- Add DXGI 96 negative-endpoint and 4-level alternating-column BC7 regression
tests in tests/test_dstorage_multilevel_fit.py.
- Hash the resolved cast_serial for placed R9G9B9E5 views in State::tables
fresh_tables keys so mid-list console VA reuse and live LEONIDA_AB flips never
reuse stale dynamic descriptor tables.
- Overwrite stale ListViews slots with null_for and return None when a stale
cast-serial rebuild fails in HostHeap::make_listed, marking cast_serials for
in-place retry instead of copying stale descriptors.
- Require D3D12Options12 EnhancedBarriersSupported alongside
RelaxedFormatCastingSupported in Host::relaxed_format_casting.
- Check group.indexed SRVs for simultaneous read+write cast conflicts, mirror
shows_other cast-aliased slots in heap_textures, preserve retryability on
transient mirror fallback failure, and return copy.serial when fits refuses.
- Add State::tables + make_listed GPU regression test for mid-list VA reuse,
mid-list cast flips, and failed stale rebuilds.
Fixes six Wave64-on-Wave32 translation and lowering gaps across
`d3d12/crates/leonida-shader/src/emit/{mod.rs, wave.rs, paired.rs, lower.rs}`:
1. Host half-wave loop convergence & natural-loop region tracking:
- Default `LEONIDA_LOOPS_WAVE` to `1` when unset (`0` opts out) so Wave64
compute shaders on 32-lane hosts keep each host half-wave converged
across per-lane loops before post-loop ballots, exchanges, and
first-lane reads (`CS_TransmissionVolumetrics_GenerateTiles` and tile
classifiers; after trustno1-coder/VIctory-NVIDIA 64d4931, GPL-3.0).
- Teach `lower::lane_regions` (`all_lane_blocks`, `branches_around`) to
include natural-loop bodies exited per lane so loop headers, mid-loop
breaks, and latches are never misclassified as executed by every lane on
subsequent iterations, while reconverged post-dominating blocks after a
single-exit loop remain wave-converged.
2. Fixed-lane provenance in whole-wave sections (`wave.rs`, `paired.rs`,
`lower.rs`):
- Track source lane provenance in `Sym::Own(Value, u32)` and emit
`Shape::Lane(Value, u32)` when a whole-wave section broadcasts a fixed
console lane (`v_readlane_b32` into SGPR or copied VGPR) instead of
collapsing to each lane's own value (`Shape::Value`).
- Lower `Shape::Lane` across lower/upper paired halves in `paired_shape`
and via `console_lane_read` with half-wave and full-wave convergence
checks in `Lower::shape` (after edsuuu/VI-BR-PORT cf3394b and
TaynanGT/Vice-Tay 5e588e8, GPL-3.0).
3. Paired `v_readlane_b32` parity with `Lower::valu` (`paired.rs`):
- Handle `Resources::restored_lanes` (uniform scalars parked in scratch
VGPRs clobbered by unmodelled whole-wave instructions) and post-section
`Section::reads` before general cross-lane shuffles in `paired_cross`.
4. Bounds-checked multi-dword, strided-64, and sub-dword paired LDS
(`paired.rs`):
- Extend `supports_paired_lds` and `paired_lds` to `_b64`/`_b96`/`_b128`,
`ds_read2`/`ds_write2` (`_b32`/`_b64`), `ds_read2st64`/`ds_write2st64`
(`_b32`/`_b64`), and sub-dword `_u8`/`_i8`/`_u16`/`_i16`/`_b8`/`_b16`
(including `_d16` and `_d16_hi`), using `Rmw::And` + `Rmw::Or` for
sub-dword writes so paired halves sharing an LDS dword never clobber
each other, and guarding every dword index by `index < dwords` (after
TaynanGT/Vice-Tay 5e588e8 and fxceless/victory-fork, GPL-3.0).
5. Spilled & thread-counted (`USER_DISPATCH_THREADS_X`) paired compute
programs (`mod.rs`, `paired.rs`, `lower.rs`):
- Allow spilled Wave64 compute programs in `emit::paired` and decouple the
`BeforeWide` `paired` fallback from the 2-D `tile` gate so refused 1-D
Wave64 groups with divergent cross-half LDS regions are rescued cleanly.
- Compute per-half `partial_active` masks in `Lower::run(counted = true)`
against console group width `cs.threads[0]` without early-exiting host
threads needed at LDS barriers, swap `partial_active` in `swap_lanes`,
and apply `partial_active` / `launched` / `memory_guard` across
`mask_dword`, `scc_some`, `wave_wide`, `paired_f64_constant_sum`, and
`paired_cross`.
Verification (Windows 11 + NVIDIA GeForce RTX 3090 D3D12 & WARP):
- `cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader --lib paired_tests -- --test-threads=4`: 20/20 passed (6 new Red->Green hardware + unit tests).
- `cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader -- --test-threads=4`: 359 passed, 0 failed.
- `cargo clippy --manifest-path d3d12/Cargo.toml -p leonida-shader --all-targets`: 0 warnings on touched code.
- `python -I scripts/check_no_game_data.py`: 0 issues.
AI-assisted.
The title sends the sound of speakers in the world (TVs, phone calls) through
the audio DSP alone, and its reverb sends through it too. The DSP's outputs
were zeros, so those were silent and reverb was dry.
From trustno1-coder/VIctory-NVIDIA eca45ac (GPL-3.0-or-later) (Audio DSP: compute mono
convolutions, by Yve) and 9b712a6 (its clippy fix), with the crate and
variable names of this tree: mono convolutions of 1024-frame blocks are
computed from the impulse responses the title passes to XDspActivate; stereo
and 512-frame convolutions and the other transforms still give zeros.
LEONIDA_DSP_CONVOLVE=0 turns it off; LEONIDA_DSP_GAIN scales it (default 2).
This tree's dsp.rs was the file as it was before that commit (identical after
the renames), so the port is the upstream file as it is now.
Co-Authored-By: Yve <yve@omnicrash.net>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Avoids adding a field to every cached ListView entry (99%+ are non-cast views)
and keeps ListView literal construction conflict-free alongside sibling
descriptor-table changes.
- Create non-reserved single-sample shader-written R32_UINT/R32_SINT Default-heap
textures via ID3D12Device10::CreateCommittedResource3 with
[R32_UINT/SINT, R9G9B9E5_SHAREDEXP] when D3D12Options12
RelaxedFormatCastingSupported is reported (falling back cleanly to
CreateCommittedResource when unavailable or refused).
- Serve placed R9G9B9E5_SHAREDEXP SRVs directly on the source ID3D12Resource
without allocating a duplicate placed HostTexture, Through staging buffer, or
per-read CopyTextureRegion pass (LEONIDA_ALIAS_CAST, default on and
LEONIDA_AB-switchable).
- Track HostTexture::serial across HostHeap::mirror, HostHeap::make_listed, and
texture_views_remade so console VA reuse and live LEONIDA_AB flips invalidate
cached SRVs immediately.
- Detect same-draw/dispatch simultaneous UAV/RTV write + aliased SRV read on the
same source texture via WRITTEN_CAST_SOURCES and fall back to the separate
placed copy for that pass to avoid whole-resource barrier conflicts.
- Add D3D12 GPU correctness tests (2D/mip-chain/cube/3D, live toggle + VA
replacement, simultaneous UAV+SRV hazard fallback) and a 59-view / 86-read
waterside timestamp benchmark.
ps_cndmask_sign_mods and ps_valu16_mad_sel fail 4096/4096 on KosmicKrisp
(Mesa 26.3.1) and pass on llvmpipe with the same Mesa and on MoltenVK
1.4.2; both read back 0x7fc00000 where the shader wrote a non-canonical
NaN or 0xffffffff, the same nir_to_msl constant path already recorded
for cs_bvh. Measured on an Apple M3, macOS 27.0.
The console's OMSetSampleMaskX mask lasts until the next graphics pipeline is set, which restores that pipeline's own
sample mask (the title sets the mask again after the pipeline where it wants one). The draw state kept it across
pipeline sets: draws of later pipelines took their masked twin and lost a quarter to three quarters of their pixels
in a 2x2 pattern. A compute pipeline set leaves it, as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>