Port shader and texture fixes from VIctory-NVIDIA, and get CI passing #72

Closed
github-bot wants to merge 0 commits from github-bot/gh-72 into main AGit
Owner

@⁠Rezerost on GitHub · 2026-12-01 00:52 UTC · original
Rezerost:nvidia-ports → main · +1 −1 · 1 files · 45 commits · closed without merging

Ports shader and texture fixes from VIctory-NVIDIA that apply to this tree. Original authors are kept on each commit. The combo: commits are the small changes needed to make them fit here.

This is a batch, not one change. If you'd rather review it as separate PRs (shader fixes / alias-copy layouts / neutral stand-ins), say so and I'll split it.

What's in it

Shader translator (TRANSLATOR_VERSION 4 → 6, so caches rebuild once):

  • Centroid reads mixed with center reads use evalCentroid.
  • No double rounding in float-to-integer conversion.
  • Empty root-constant slices bind a zero dword.
  • Loops with a fixed trip count run in full, past the stage's loop cap (with tests).
  • Dword scalar and buffer accesses drop the two low address bits, as the console does.
  • Packed Z offsets are kept in 3D samples.
  • Immediate static sampler MipLODBias is clamped to D3D12 bounds.
  • Cube-array slice and face are decoded in image lowering.
  • A packed word written to all four channels is stored as an integer (adapted to this tree's u8 register numbers).

GPU:

  • Alias copies rebuild their layouts when the view's source texture changed. Here alias copies always go through a buffer, so the buffer flag check is dropped.
  • 1D, 3D and cube slots waiting for their texture show a gray stand-in of their own kind instead of black. Switch: VICTORY_NEUTRAL_ALL_KINDS (on by default, 0 turns it off).

CI fixes (main itself fails these with the pinned 1.98.1 toolchain):

  • Clippy: two same-type casts in draw.rs, plus is_multiple_of and assert! in victory-hle.
  • switches::documented_switches_are_read: the README placeholder VICTORY_NAME is now VICTORY_..., which the test skips.
  • repository_passes_policy: the ported tests would push lower.rs past the 640 KiB limit, so they live in lower/trip_offset_tests.rs. lower.rs is now about 635 KiB.

Left out on purpose:

  • The folded-mask-join read: this tree has no crate::fold.
  • The centroid-only signature test: NVIDIA's signature code isn't ported.
  • NVIDIA's eviction, 512 MB-free and loader fixes: they conflict with this tree's code.

Testing

PC: RX 6800 XT 16 GB, driver 32.0.21045.29003, Ryzen 5 9600X, 32 GB DDR5, Windows 11.

  • Build and tests: cargo build --release --locked -p victory builds without warnings, and both CI clippy passes (default and --all-features) are clean. cargo test --workspace --locked --exclude victory-gpu passes, including 332 victory-shader tests (5 ignored) and xtask's policy checks. I did not run the victory-gpu suite, per CONTRIBUTING.
  • Warm: 93,575 pipelines compiled with the new translator, no failures.
  • Play: one 2-hour session (Low, 1080p, Series S, FSR 4 upscaling with FSR 3 FG fallback) with no crash and 0 errors in the log. Fps median 21.2, max 43.
    • Shared memory stayed flat and RAM pressure cleared after about 30 minutes, so there's no sign of a leak.
    • Visually there was less dotting and ghosting than on main.
  • Not measured: no matched before/after fps run with the same settings and place, so I'm not claiming an fps change.
  • Seen once, not confirmed as related: a car's body disappeared while "stolen vehicle reported" was showing. VRAM was near full at the time.

🤖 Generated with Claude Code

**@⁠Rezerost** on GitHub · 2026-12-01 00:52 UTC · [original](https://github.com/eikkapine/justanxboxemulator/pull/72) `Rezerost:nvidia-ports` → `main` · +1 −1 · 1 files · 45 commits · closed without merging Ports shader and texture fixes from [VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA) that apply to this tree. Original authors are kept on each commit. The `combo:` commits are the small changes needed to make them fit here. This is a batch, not one change. If you'd rather review it as separate PRs (shader fixes / alias-copy layouts / neutral stand-ins), say so and I'll split it. ## What's in it **Shader translator** (TRANSLATOR_VERSION 4 → 6, so caches rebuild once): - Centroid reads mixed with center reads use `evalCentroid`. - No double rounding in float-to-integer conversion. - Empty root-constant slices bind a zero dword. - Loops with a fixed trip count run in full, past the stage's loop cap (with tests). - Dword scalar and buffer accesses drop the two low address bits, as the console does. - Packed Z offsets are kept in 3D samples. - Immediate static sampler MipLODBias is clamped to D3D12 bounds. - Cube-array slice and face are decoded in image lowering. - A packed word written to all four channels is stored as an integer (adapted to this tree's `u8` register numbers). **GPU:** - Alias copies rebuild their layouts when the view's source texture changed. Here alias copies always go through a buffer, so the buffer flag check is dropped. - 1D, 3D and cube slots waiting for their texture show a gray stand-in of their own kind instead of black. Switch: `VICTORY_NEUTRAL_ALL_KINDS` (on by default, `0` turns it off). **CI fixes** (main itself fails these with the pinned 1.98.1 toolchain): - Clippy: two same-type casts in `draw.rs`, plus `is_multiple_of` and `assert!` in victory-hle. - `switches::documented_switches_are_read`: the README placeholder `VICTORY_NAME` is now `VICTORY_...`, which the test skips. - `repository_passes_policy`: the ported tests would push `lower.rs` past the 640 KiB limit, so they live in `lower/trip_offset_tests.rs`. `lower.rs` is now about 635 KiB. **Left out on purpose:** - The folded-mask-join read: this tree has no `crate::fold`. - The centroid-only signature test: NVIDIA's signature code isn't ported. - NVIDIA's eviction, 512 MB-free and loader fixes: they conflict with this tree's code. ## Testing **PC:** RX 6800 XT 16 GB, driver 32.0.21045.29003, Ryzen 5 9600X, 32 GB DDR5, Windows 11. - **Build and tests:** `cargo build --release --locked -p victory` builds without warnings, and both CI clippy passes (default and `--all-features`) are clean. `cargo test --workspace --locked --exclude victory-gpu` passes, including 332 victory-shader tests (5 ignored) and xtask's policy checks. I did not run the victory-gpu suite, per CONTRIBUTING. - **Warm:** 93,575 pipelines compiled with the new translator, no failures. - **Play:** one 2-hour session (Low, 1080p, Series S, FSR 4 upscaling with FSR 3 FG fallback) with no crash and 0 errors in the log. Fps median 21.2, max 43. - Shared memory stayed flat and RAM pressure cleared after about 30 minutes, so there's no sign of a leak. - Visually there was less dotting and ghosting than on main. - **Not measured:** no matched before/after fps run with the same settings and place, so I'm not claiming an fps change. - **Seen once, not confirmed as related:** a car's body disappeared while "stolen vehicle reported" was showing. VRAM was near full at the time. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A folded wave64 compute program asks which half holds the first lane
wherever the console reads one (`s_cmp_lg_u32 E.lo, 0`), so it reads its
EXEC pair as a number. Where that pair came through a join that only a
loop header's join reads, the join was not marked as read and its
incoming masks became zero without a word (the shortcut
VICTORY_STRICT_JOINS names). From the second iteration on the read then
said "no lane in the lower half", took the upper half's first lane, and
with no lane there a stale value.

In `ptfx_CS_lightAtlas_Sprite` (2561af9577c47289) the counter of the
loop over the light mask's words is read that way: in every wave of 32
sprites or fewer it never moved, the loop ran to the iteration limit
(4,096) with a light's whole body in each round, 60-80 ms of the card a
dispatch, and its lanes left without their store, so the title asked
for the same sprites again in every frame.

In folded programs the joins of lane masks are now read too, whatever
the switch: a mask has a DXIL form, the ballot of its lanes. Other
joins keep the shortcut.

Of the title's 26,084 programs 18 come out otherwise, all folded: the
particles' light atlas (2), the shadow masks (6), the water's volume
light (4), the scattering gather (2) and the particle updates (4). All
26,084 still translate.

RTX 5090, Series X profile, 2560x1440, DLSS Quality, 32-lane waves, on
a deck at night facing a house: the card's time in the title's lists
40-77 ms a frame before, 22.5 ms after; the frame 78-112 ms before,
65-75 ms after (diagnostics build).

(cherry picked from commit b8f365ad998596f86158b8ae4da8ac4b7b904218)
Pre-scan reachable pixel interpolations in Lower::plan_interp_modes. When a non-per-vertex float input is read at both center and centroid (perspective or linear), declare the input signature element at center and emit dx.op.evalCentroid.f32 (opcode 89) for centroid reads in eval_channel regardless of instruction order, while preserving single-mode lowering and rejecting incompatible mode mixes.

(cherry picked from commit 9f155ce3df0597ee31bf0b6a45d1ead2ec4a7821)
(cherry picked from commit 4355f3843c44cb2fdc13982137cc46651e004ddd)
root_signature_for declares user_data_dwords().max(1) root constants even when a shader reads no user data. Passing Vec::new().as_ptr() (0x4) with count 0 to SetComputeRoot32BitConstants or SetGraphicsRoot32BitConstants causes NVIDIA's D3D12 driver to dereference 0x4 (STATUS_ACCESS_VIOLATION), while skipping the call leaves the declared slot unset. Bind &[0u32] when the slice is empty and test both Host::dispatch and Host::draw on hardware and WARP.

(cherry picked from commit b7dff4874c2dc4bb98e64433286aa290fa837dcd)
b8f365ad reads FOLDED, which comes with NVIDIA's crate::fold (wave64 folded
onto 32-lane hosts). This tree runs wave64 natively (WaveSize(64)) and has
no fold module, so no program is folded: the fix stays dormant and the tree
builds again.
loop_cap cuts pixel loops at 128 iterations (vertex and mesh 256, compute
4096), for loops whose count comes from data the host does not have yet. A
loop whose counter starts from a constant, steps by constants and leaves on
a compare with a constant cannot run away; it now gets its own trip count
(up to 2^16) as its limit. PS_IntegrateEnvBRDF a467d848ace5810d's loops of
256, 256 and 512 samples were cut to 128.

Covered: one back edge, an s_cbranch_scc0/1 on an s_cmp(k) of an SGPR
counter with a constant; the counter a header phi entering as one constant
and coming back as itself plus constants (s_add/s_sub _i32/_u32,
s_addk_i32). Everything else keeps the cap, as does a limit a switch names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

(cherry picked from commit 1d5362804a736c7b4f4d36857ee3da323c2a9115)

[combo] Adapted: the AMD tree's count_iteration computed the cap inline;
it now asks loop_cap(h). Tests went into lower.rs's inline tests module
(the tree has no lower/tests.rs).
In this tree emit::tests::dump_dxil was private, so victory-shader's tests
did not build after aa0cf628.
Co-Authored-By: Claude Opus 5.5 <[email protected]>

(cherry picked from commit 04ad99757dedc7c6588b7c72a933616cd9693671)

[combo] The test went into lower.rs's inline tests module.
(cherry picked from commit 844200e93b0b3b57c07793747a4771b30de34ff8)

[combo] Adapted: VICTORY_VMEM_ALIGN4 joins the switch list inside
shader_cache::build (this tree has no KEYED array). The test went into
lower.rs's inline tests module, with the INSPECT_OFFSETS hook and the
bitcode call_args/clears_low_bits test helpers it needs.
(cherry picked from commit 171c102351b8b1653ef206263a87b91b2873e166)

[combo] lower.rs merged as is. Tests: the CPU ones went into lower.rs's
inline tests module with the bitcode address_value test helper; the GPU
test's harness got the View::Texture3D view it needs.
The console's immediate sampler descriptor (SQ_IMG_SAMP_WORD2[13:0]) encodes a signed 14-bit 6.8 fixed-point mip LOD bias spanning [-32.0, +31.996], whereas D3D12_STATIC_SAMPLER_DESC::MipLODBias only accepts [-16.0, 15.99]. Add StaticSampler::mip_lod_bias_for_host() clamping to [-16.0, 15.99] (with NaN mapped to 0.0) and use it when building D3D12_STATIC_SAMPLER_DESC in both victory-gpu and victory-shader.

(cherry picked from commit 200e6dbb59f1e5c637dcfccb5161c340562f7551)

[combo] Both sides' sampler tests kept; the root-signature test went to
the end of pipeline/host.rs's tests module.
RDNA2 encodes the face operand of dim:CUBE samples and gathers on a cube-map array as 8 * slice + face, with no separate array dimension bit in MIMG, and reports image_get_resinfo channel 2 in faces rather than cubes. Infer TextureCubeArray (DXIL kind 9) in lower/cube_array.rs, split the face operand into face & 7 (clamping 6 and 7 to face 5) and face >> 3 as the fourth sampling coordinate, keep integer offsets undef for kind 9, refuse cube gathers with offsets, and scale D3D's cube count by 6 for resinfo.

(cherry picked from commit bb81cda31bc0eff5ca9a5336dcfd3d3b040dc506)

[combo] Adapted: this tree's VGPR numbers are u8 (cube_array.rs); the
cube_arrays field sits beside the trip-count fields. Tests: the host
harness keeps the AMD adapter_name/translation_caps/runs_wave32 and gains
adapters(); the valu cube tests are appended; lower.rs's inline test
helpers S_ENDPGM, lower_with and texture_tables are pub(super) for them.
The double-rounding, centroid, empty root-constant slice, constant-trip
loop, dword-alignment, packed Z offset and cube-array ports all change
translations; this tree keys its shader cache on TRANSLATOR_VERSION, so
the translations cached at version 4 are made again.
texture::alias keeps the buffer and both sides' copy layouts of a view the
title placed, in another format, in the memory of a texture the host writes
(THROUGH), by the view alone. The source is the newest such texture at the
view's memory (resource::alias_of), and alias_with asks only for the view's
size and a texel of the same bytes. A target the title makes there later
can be of another format of that width (R16G16_FLOAT where R32_UINT was):
the kept layouts still named the old format, and the copy of the new
texture into them is one the host refuses, so the list does not close
(0x80070057). The same held for a view's host copy with fewer levels than
when the layouts were made.

through_fits checks the part count of both sides, each side's format and
whether a buffer is wanted (direct); an entry that does not fit is made
again, with an info line ("an alias copy's layouts were made for other
textures: made again"). Found while tracing the late "did not close" under
texture pressure (#3135, #3254); not shown to be that one's command.

Test: texture::alias_layout_tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 2a6376178f6b2baf0e73f656b78c216fdfb5eb9c)
neutral_for gave only 2D views and 2D arrays the 1x1 gray (0x80)
stand-in; 1D, 3D and cube views (and their arrays) got a null view, which
reads as zeros: black where a material samples a volume or a cube whose
texture is waiting, unmade or let go, while a 2D slot in the same state
reads gray. Now a 1-texel 1D, a 1x1x1 3D and a 1x1 six-face cube texture
of 0x80 are made once and shown through a view of the slot's own
dimension. Multisampled views and buffers keep their null views.
VICTORY_NEUTRAL_ALL_KINDS=0: a null view, as before.

Defensive: which in-game black blotches this accounts for is not yet
attributed. NEUTRAL_KINDS counts the slots given each kind of stand-in
(logged beside the VICTORY_GONE_NEUTRAL count in a diagnostics build);
any build logs once "textures: gray stand-in made for <Line|Volume|Cube>
views" when the first one is made.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit b4c33f1b7eb042afd2a3009ec852ea062c5eaf28)

combo: keeps victory-amd's stand-in alpha 0x7F (foliage cutouts discard while streaming); no before_send hook here.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 033c372cbbc93d3d5d5ca7b9b01996302783d3c0)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 00:57:12 +00:00
Author
Owner

@⁠motioncsgo on GitHub · 2026-12-01 07:59 UTC · original

Tested this on an RX 7900 XTX (RDNA3) with a Ryzen 9 5950X and 64 GB of RAM. Settings: Series X, FSR 4 quality to 4K, RT off and on. The build was v2026.11.30.8 with this PR merged (no conflicts), plus #74 and a few local patches.

Translation and pipelines:

  • 25,790 shaders translated after the version bump, 195 untranslated (same as before).
  • The 5,343 pipelines earlier runs used were rebuilt with warm --used: none bad, none crashed.

In game: no new picture problems, RT off or on. The existing RT shadow speckles on characters look the same as before the PR. RT off: 55.5 ms median (18 fps), same as before. One run each, at a different spot from our older runs, so this isn't a precise speed comparison.

Tests:

  • victory-hle and the app pass.
  • victory-shader: 330 pass, 2 fail. emit::barycentric_tests::mixed_input_interpolation_center_and_centroid needs dxc -dumpbin, and dxc isn't installed here. emit::tests::interpolated_f16_writes_the_op_sel_half_with_modifiers fails only in the parallel run and passes alone.
  • victory-gpu: host::refresh_tests::only_what_differs_goes_up is flaky, about one in three runs alone. It was flaky before this PR too.
**@⁠motioncsgo** on GitHub · 2026-12-01 07:59 UTC · [original](https://github.com/eikkapine/victory-amd/pull/72#issuecomment-7304732627) Tested this on an RX 7900 XTX (RDNA3) with a Ryzen 9 5950X and 64 GB of RAM. Settings: Series X, FSR 4 quality to 4K, RT off and on. The build was v2026.11.30.8 with this PR merged (no conflicts), plus #74 and a few local patches. **Translation and pipelines:** - 25,790 shaders translated after the version bump, 195 untranslated (same as before). - The 5,343 pipelines earlier runs used were rebuilt with `warm --used`: none bad, none crashed. **In game:** no new picture problems, RT off or on. The existing RT shadow speckles on characters look the same as before the PR. RT off: 55.5 ms median (18 fps), same as before. One run each, at a different spot from our older runs, so this isn't a precise speed comparison. **Tests:** - victory-hle and the app pass. - victory-shader: 330 pass, 2 fail. `emit::barycentric_tests::mixed_input_interpolation_center_and_centroid` needs `dxc -dumpbin`, and dxc isn't installed here. `emit::tests::interpolated_f16_writes_the_op_sel_half_with_modifiers` fails only in the parallel run and passes alone. - victory-gpu: `host::refresh_tests::only_what_differs_goes_up` is flaky, about one in three runs alone. It was flaky before this PR too.
github-bot closed this pull request 2026-12-01 19:52:20 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.