Shaders: implicit-level compute samples run in the console flow in halves (on #439, #2999) #3735

Open
redNSF wants to merge 92 commits from upstream-pr/3735 into main
redNSF commented 2026-11-28 13:12:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by redNSF on 2026-11-28T13:12:47Z.


Stacked on #439 (console flow in halves) and #2999 (lane quads); the last two commits are this change.

Problem. On a host without 64-lane waves, #439 refuses a console wave64 compute program that has an image_sample or image_sample_b ("an implicit-derivative sample in the console flow on a host without 64-lane waves"), because the sample had no valid DXIL form in compute.

Change. With the lane quads of #2999 such a sample is a sampleGrad whose gradients are read from the lane's quad, which is valid in compute. In halves each host wave holds whole quads of the console wave in the console's order (host lane n is console lane n or n + 32), so the quad is read within the host wave and nothing crosses the halves. The refusal now applies only to a sample left without quad gradients (a cube).

Effect. Grand Theft Auto VI, translate --list --host-lanes 32-32: compute programs that translate go from 2,593 (#439) to 2,605; the 12 gained are the ones refused for this reason, none are lost. Among them: indirect_light_probes:CS_IrradianceCache_Shade and ShadeSecondary, the four ptx_prerender light-atlas programs, CS_DensityShadowMapMips, CS_ProjDecalResolve, two rtdirectionalshadows denoisers.

Tests (RTX 3060, 32-lane waves only):

  • New implicit_samples_in_halves_take_the_console_quads: a console wave64 program with a sample and a cross-half lane read, groups of 8x8 and 16x4, run on a 32-lane hardware adapter (skipped elsewhere); every thread's level and texel are checked.
  • implicit_samples_stop_the_console_flow_in_halves becomes implicit_samples_translate_in_the_console_flow_in_halves.
  • The two dispatching tests of #2999 bind the table of view strides where the shader asks for it, as gathers_at_a_level_match_the_hardware does. (With #2885 also merged, their buffer reads gave 0 on this card without it.)
  • cargo test -p victory-shader --lib on WARP: the same 4 synthetic_tests fail here as on #439 alone. On the card gathers_at_a_level_match_the_hardware fails at lane 0 (the NaN coordinate), identically on #439 alone.

In the title. On a local branch that also has #3683, #2885, #3674, #3670 and #2451, these programs ran in the game's first scene on the RTX 3060 without a device loss. The picture did not visibly change, so this PR claims only that the programs translate and compute what the test checks.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:5540471251 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3735). Originally posted by [redNSF](https://github.com/redNSF) on 2026-11-28T13:12:47Z. --- Stacked on #439 (console flow in halves) and #2999 (lane quads); the last two commits are this change. **Problem.** On a host without 64-lane waves, #439 refuses a console wave64 compute program that has an `image_sample` or `image_sample_b` ("an implicit-derivative sample in the console flow on a host without 64-lane waves"), because the sample had no valid DXIL form in compute. **Change.** With the lane quads of #2999 such a sample is a `sampleGrad` whose gradients are read from the lane's quad, which is valid in compute. In halves each host wave holds whole quads of the console wave in the console's order (host lane n is console lane n or n + 32), so the quad is read within the host wave and nothing crosses the halves. The refusal now applies only to a sample left without quad gradients (a cube). **Effect.** Grand Theft Auto VI, `translate --list --host-lanes 32-32`: compute programs that translate go from 2,593 (#439) to 2,605; the 12 gained are the ones refused for this reason, none are lost. Among them: `indirect_light_probes:CS_IrradianceCache_Shade` and `ShadeSecondary`, the four `ptx_prerender` light-atlas programs, `CS_DensityShadowMapMips`, `CS_ProjDecalResolve`, two `rtdirectionalshadows` denoisers. **Tests** (RTX 3060, 32-lane waves only): - New `implicit_samples_in_halves_take_the_console_quads`: a console wave64 program with a sample and a cross-half lane read, groups of 8x8 and 16x4, run on a 32-lane hardware adapter (skipped elsewhere); every thread's level and texel are checked. - `implicit_samples_stop_the_console_flow_in_halves` becomes `implicit_samples_translate_in_the_console_flow_in_halves`. - The two dispatching tests of #2999 bind the table of view strides where the shader asks for it, as `gathers_at_a_level_match_the_hardware` does. (With #2885 also merged, their buffer reads gave 0 on this card without it.) - `cargo test -p victory-shader --lib` on WARP: the same 4 `synthetic_tests` fail here as on #439 alone. On the card `gathers_at_a_level_match_the_hardware` fails at lane 0 (the NaN coordinate), identically on #439 alone. **In the title.** On a local branch that also has #3683, #2885, #3674, #3670 and #2451, these programs ran in the game's first scene on the RTX 3060 without a device loss. The picture did not visibly change, so this PR claims only that the programs translate and compute what the test checks. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upipibi commented 2026-11-28 14:57:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-28T14:57:36Z.


NVIDIA row for this PR: it passes on a second Ampere card, and the new tests fail without the PR's last commit.

RTX 3070 (desktop), driver 616.56, Windows 11 Pro 10.0.26100, debug. Head 359baa6, tested as the PR's own branch. It contains main 63bcca4 and the stack it names: #439 (e2d3cfd) with #2999 (3f6b205) merged in at 134d9cc.

Each test passed in 3 of 3 runs (6 passed, 0 failed):

  • synthetic_tests::implicit_samples_in_halves_take_the_console_quads: ran on the hardware adapter, 8x8 and 16x4, 64 sample and wave-base pairs matched each. Hardware only by design, so WARP is not run.
  • tests::implicit_samples_translate_in_the_console_flow_in_halves: translation only, no device.
  • synthetic_tests::compute_samples_take_derivatives_from_lane_quads: ran on hardware and WARP, wave32 and wave64, Plain, Offset and BiasOffset.
  • synthetic_tests::multirow_samples_and_console_wave_reads_keep_each_guest_thread: hardware Wave32 6x8, 6x16 and 8x8 matched. It printed warp: Wave32 unsupported; skipped and Wave64 unsupported; skipped for both hardware and WARP, so the hardware Wave32 cases are the only ones it ran here.
  • From the #439 stack, lane_read_loop_tests::lane_reads_in_a_loop_lanes_leave_at_different_iterations and lane_read_loop_with_a_joined_exec_back_edge: NVIDIA GeForce RTX 3070: wave32 exact, wave64 exact and joined back edge exact. These tests run on hardware adapters only.

Negative control: the same tests with crates/victory-shader/src/emit/lower.rs from 134d9cc, the PR's parent (git diff --stat HEAD: 1 file, 10 insertions, 18 deletions). In 3 of 3 runs, 4 passed and 2 failed. The 2 failures were the two new tests, both refused with "an implicit-derivative sample in the console flow on a host without 64-lane waves". I used 134d9cc and not main because main's lower.rs comes before the stack.

cargo test --locked -p victory-shader --lib -- --skip heap_direct_texture_reads_mark_their_heap_index:

  • this PR: 347 passed, 3 failed, 3 ignored (the stack adds tests);
  • main 63bcca4: 298 passed, 3 failed, 3 ignored.

The 3 failures are the same on both: stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros and synthetic_tests::gathers_at_a_level_match_the_hardware. The skipped test crashes the binary on this card (open issue #2571).

Not tested: a title run; #439 or #2999 on their own; the lib suite at 134d9cc.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7241072014 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3735#issuecomment-7241072014). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-28T14:57:36Z. --- NVIDIA row for this PR: it passes on a second Ampere card, and the new tests fail without the PR's last commit. RTX 3070 (desktop), driver 616.56, Windows 11 Pro 10.0.26100, debug. Head `359baa6`, tested as the PR's own branch. It contains main `63bcca4` and the stack it names: #439 (`e2d3cfd`) with #2999 (`3f6b205`) merged in at `134d9cc`. Each test passed in 3 of 3 runs (6 passed, 0 failed): - `synthetic_tests::implicit_samples_in_halves_take_the_console_quads`: ran on the hardware adapter, 8x8 and 16x4, 64 sample and wave-base pairs matched each. Hardware only by design, so WARP is not run. - `tests::implicit_samples_translate_in_the_console_flow_in_halves`: translation only, no device. - `synthetic_tests::compute_samples_take_derivatives_from_lane_quads`: ran on hardware and WARP, wave32 and wave64, Plain, Offset and BiasOffset. - `synthetic_tests::multirow_samples_and_console_wave_reads_keep_each_guest_thread`: hardware Wave32 6x8, 6x16 and 8x8 matched. It printed `warp: Wave32 unsupported; skipped` and `Wave64 unsupported; skipped` for both hardware and WARP, so the hardware Wave32 cases are the only ones it ran here. - From the #439 stack, `lane_read_loop_tests::lane_reads_in_a_loop_lanes_leave_at_different_iterations` and `lane_read_loop_with_a_joined_exec_back_edge`: `NVIDIA GeForce RTX 3070: wave32 exact`, `wave64 exact` and `joined back edge exact`. These tests run on hardware adapters only. Negative control: the same tests with `crates/victory-shader/src/emit/lower.rs` from `134d9cc`, the PR's parent (`git diff --stat HEAD`: 1 file, 10 insertions, 18 deletions). In 3 of 3 runs, 4 passed and 2 failed. The 2 failures were the two new tests, both refused with "an implicit-derivative sample in the console flow on a host without 64-lane waves". I used `134d9cc` and not main because main's `lower.rs` comes before the stack. `cargo test --locked -p victory-shader --lib -- --skip heap_direct_texture_reads_mark_their_heap_index`: - this PR: 347 passed, 3 failed, 3 ignored (the stack adds tests); - main `63bcca4`: 298 passed, 3 failed, 3 ignored. The 3 failures are the same on both: `stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride`, `stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` and `synthetic_tests::gathers_at_a_level_match_the_hardware`. The skipped test crashes the binary on this card (open issue #2571). Not tested: a title run; #439 or #2999 on their own; the lib suite at `134d9cc`. AI-assisted (Claude Code, Claude Opus 5.5).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3735:upstream-pr/3735'
git switch 'upstream-pr/3735'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3735'
git switch 'upstream-pr/3735'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3735'
git switch 'upstream-pr/3735'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3735'
git switch 'main'
git merge --squash 'upstream-pr/3735'
git switch 'main'
git merge --ff-only 'upstream-pr/3735'
git switch 'main'
git merge 'upstream-pr/3735'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!3735
No description provided.