shader: wave32 pixel programs keep the console's lane numbers and masks in host waves of 64 (general fix for #189) #344

Manually merged
github merged 2 commits from github-bot/gh-344 into gh-pr/344/base 2026-12-03 22:39:01 +00:00 AGit
Owner

@⁠mateozariquiey on GitHub · 2026-12-03 18:15 UTC · original
mateozariquiey:pr/wave32-lanes → main · +504 −25 · 3 files · 2 commits · merged 2026-12-03 21:42 UTC

The general fix #189 suggests, with tests. VICTORY_GLASS_DITHER_OFF (#193) is left as it is.

Cause. RADV runs every pixel program in waves of 64, also the ones the console compiled for 32, and neither pixel nor vertex programs can declare a wave size. Two things were read in the host's wave that the program means in its own:

  • The lane's own number: v_mbcnt_lo of all lanes was 32 in the whole upper half of a host wave (the bands of #189).
  • Lane masks read as numbers: a wave32 mask is one dword and its ballot on the host two, of which only the low one was taken. "Does the whole wave have this value?" (s_ff1 of EXEC, v_readlane, a compare, s_bcnt1 of the lanes that differ) did not ask the upper 32 lanes, which could take the uniform branch with another lane's value.

Change.

  • The lane number is taken in the console's wave: 0 to 31 in both halves. v_mbcnt_hi adds nothing in a wave32 program.
  • Masks read by s_bcnt1, s_ff1, s_cmp_eq_u32, s_cmp_lg_u32 and v_mbcnt take both dwords of the host's ballot.
  • A mask compared with a number: 0 ("no lane") and -1 ("every lane") are compared with both halves; any other number names lanes of the console's 32 and is compared with the lower half alone, as before. In a host wave of 32 the upper dword is 0.
  • TRANSLATOR_VERSION 19 to 20.

Tested. RX 9070, RADV. New tests draw a wave32 pixel program on the host and read back the lane numbers, the counts and the compares (a_wave32_pixel_lane_number_stays_below_32, a_wave32_pixel_mask_counts_the_whole_host_wave, a_wave32_pixel_mask_is_compared_whole, a_wave32_pixel_mask_is_compared_with_a_scalar, a_killed_pixel_is_read_by_its_quad); the emit:: tests pass on 45591b0. On a tree based on 842767a: of the title's 25,889 programs 207 translate differently, all wave32 pixel programs, the rest byte for byte as before; all 94,841 pipelines were made, none refused by the host; an interior scene with ray tracing on ran with no errors.

Limits. Not seen on the house windows of #189: my save has no scene with them. With VICTORY_GLASS_DITHER_OFF unset the bands should be gone with the console's dither kept; a check from someone who has that scene would settle it. Cached translations are made again (the version). Vertex programs get the same treatment; the title has none of wave32.

**@⁠mateozariquiey** on GitHub · 2026-12-03 18:15 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/344) `mateozariquiey:pr/wave32-lanes` → `main` · +504 −25 · 3 files · 2 commits · merged 2026-12-03 21:42 UTC The general fix #189 suggests, with tests. `VICTORY_GLASS_DITHER_OFF` (#193) is left as it is. **Cause.** RADV runs every pixel program in waves of 64, also the ones the console compiled for 32, and neither pixel nor vertex programs can declare a wave size. Two things were read in the host's wave that the program means in its own: - The lane's own number: `v_mbcnt_lo` of all lanes was 32 in the whole upper half of a host wave (the bands of #189). - Lane masks read as numbers: a wave32 mask is one dword and its ballot on the host two, of which only the low one was taken. "Does the whole wave have this value?" (`s_ff1` of EXEC, `v_readlane`, a compare, `s_bcnt1` of the lanes that differ) did not ask the upper 32 lanes, which could take the uniform branch with another lane's value. **Change.** - The lane number is taken in the console's wave: 0 to 31 in both halves. `v_mbcnt_hi` adds nothing in a wave32 program. - Masks read by `s_bcnt1`, `s_ff1`, `s_cmp_eq_u32`, `s_cmp_lg_u32` and `v_mbcnt` take both dwords of the host's ballot. - A mask compared with a number: 0 ("no lane") and -1 ("every lane") are compared with both halves; any other number names lanes of the console's 32 and is compared with the lower half alone, as before. In a host wave of 32 the upper dword is 0. - `TRANSLATOR_VERSION` 19 to 20. **Tested.** RX 9070, RADV. New tests draw a wave32 pixel program on the host and read back the lane numbers, the counts and the compares (`a_wave32_pixel_lane_number_stays_below_32`, `a_wave32_pixel_mask_counts_the_whole_host_wave`, `a_wave32_pixel_mask_is_compared_whole`, `a_wave32_pixel_mask_is_compared_with_a_scalar`, `a_killed_pixel_is_read_by_its_quad`); the `emit::` tests pass on 45591b0. On a tree based on 842767a: of the title's 25,889 programs 207 translate differently, all wave32 pixel programs, the rest byte for byte as before; all 94,841 pipelines were made, none refused by the host; an interior scene with ray tracing on ran with no errors. **Limits.** Not seen on the house windows of #189: my save has no scene with them. With `VICTORY_GLASS_DITHER_OFF` unset the bands should be gone with the console's dither kept; a check from someone who has that scene would settle it. Cached translations are made again (the version). Vertex programs get the same treatment; the title has none of wave32.
The host runs every pixel program in waves of 64 (RADV, and neither pixel
nor vertex programs can declare a wave size), also the ones the console
compiled for 32. Two things were then read in the host's wave that the
program means in its own.

The lane's own number. `v_mbcnt_lo` of all lanes came out as 32 in the whole
upper half of such a wave. The window glass picks the light grid cell of each
pixel by that number and the frame's, so half of each wave read the same cell
(the dark bands that blink every other frame, #189). The number is now taken
in the console's wave, 0 to 31 in both halves. `v_mbcnt_hi` adds nothing in a
wave32 program.

Lane masks read as numbers. A wave32 mask is one dword and its ballot on the
host two, of which only the low one was taken. "Does the whole wave have this
value?" (`s_ff1` of EXEC, `v_readlane`, a compare, `s_bcnt1` of the lanes
that differ) did not ask the upper 32 lanes, which could take the uniform
branch with another lane's value. Such reads now take both dwords: the wave
operations stay those of the host's wave, whole, so that scalars stay the
same in all its lanes.

A mask compared with a number: 0 is "no lane" and all ones "every lane" of a
wave of any size, so both halves are compared with them (`s_cmp_eq_u32
exec_lo, -1` was false in full host waves before). Any other number names
lanes of the console's 32, which the two console waves in a host wave of 64
cannot both answer with the one answer a scalar is: it is compared with the
lower half alone, as before. In a host wave of 32 the upper dword is 0.

Tests draw a wave32 pixel program on the host and read the lane numbers, the
counts and the compares back; one more reads a killed pixel's value through
its quad (the glass programs' screen-door kill).

TRANSLATOR_VERSION 20: wave32 pixel programs translate differently.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 18:20:51 +00:00
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-03 19:11 UTC · original

Tested e5243e4 on Windows 11 native (MSVC target, not Wine) with one NVIDIA desktop card plus WARP.

None of the new tests were skipped. I added a temporary print in pixels_drawn to be sure, and every draw went through on both devices. The card reports 32 lane waves (min and max both 32) and WARP reports 4 (min and max both 4). That means neither device here has the 64 lane host wave this fix is for, so I couldn't get a red on main. I ran the five new tests against main's lower.rs and against the PR, one device at a time. The results were the same both ways.

  • hardware: all five pass on main and on the PR
  • WARP: a_wave32_pixel_mask_counts_the_whole_host_wave and a_killed_pixel_is_read_by_its_quad pass on both. The two masks_compare tests pass when both devices are drawn, but with 4 lane waves every wave is uniform and never full, so on WARP they only cover that one case. If WARP is the only device drawn, the final "uniform > 0 && mixed > 0" check trips, because it adds up pixels from both devices.
  • a_wave32_pixel_lane_number_stays_below_32 fails on WARP on main and on the PR. Lanes 0 to 3 get 1024 pixels each and 4 to 31 get none, so the least * 2 > most check can't hold. That isn't the translator's fault, since a 4 lane host wave only has lane numbers 0 to 3. But WARP is on every Windows machine, so this test is red on any native Windows run. Skipping that check when the host wave is under 32 lanes, the way masks_compare does with lanes >= 32, would fix it.

Full cargo test -p victory-shader --lib on the PR gave 418 passed, 2 failed, 4 ignored (424 total). Main gave 414 passed, 1 failed, 4 ignored. The PR's extra failure is the lane number test on WARP described above. The other one is the same pre-existing failure on main.

cargo clippy -p victory-shader --all-targets shows no new warnings from the PR. The existing ones only shift by a few lines in lower.rs. The guard_runs bench error (private build) is there on main too.

I went through wide_ballot, upper_lanes and upper_compared and didn't find anything I could back up with a test on this hardware. On a 32 lane host upper_compared always gives 0, so the 64 bit forms reduce to the old 32 bit compare. That fits with hardware giving the same results on main and the PR. Someone with a card that runs pixel waves of 64 would need to confirm the actual fix.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-03 19:11 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/344#issuecomment-7389298053) Tested e5243e4 on Windows 11 native (MSVC target, not Wine) with one NVIDIA desktop card plus WARP. None of the new tests were skipped. I added a temporary print in pixels_drawn to be sure, and every draw went through on both devices. The card reports 32 lane waves (min and max both 32) and WARP reports 4 (min and max both 4). That means neither device here has the 64 lane host wave this fix is for, so I couldn't get a red on main. I ran the five new tests against main's lower.rs and against the PR, one device at a time. The results were the same both ways. - hardware: all five pass on main and on the PR - WARP: a_wave32_pixel_mask_counts_the_whole_host_wave and a_killed_pixel_is_read_by_its_quad pass on both. The two masks_compare tests pass when both devices are drawn, but with 4 lane waves every wave is uniform and never full, so on WARP they only cover that one case. If WARP is the only device drawn, the final "uniform > 0 && mixed > 0" check trips, because it adds up pixels from both devices. - a_wave32_pixel_lane_number_stays_below_32 fails on WARP on main and on the PR. Lanes 0 to 3 get 1024 pixels each and 4 to 31 get none, so the least * 2 > most check can't hold. That isn't the translator's fault, since a 4 lane host wave only has lane numbers 0 to 3. But WARP is on every Windows machine, so this test is red on any native Windows run. Skipping that check when the host wave is under 32 lanes, the way masks_compare does with lanes >= 32, would fix it. Full `cargo test -p victory-shader --lib` on the PR gave 418 passed, 2 failed, 4 ignored (424 total). Main gave 414 passed, 1 failed, 4 ignored. The PR's extra failure is the lane number test on WARP described above. The other one is the same pre-existing failure on main. `cargo clippy -p victory-shader --all-targets` shows no new warnings from the PR. The existing ones only shift by a few lines in lower.rs. The guard_runs bench error (private `build`) is there on main too. I went through wide_ballot, upper_lanes and upper_compared and didn't find anything I could back up with a test on this hardware. On a 32 lane host upper_compared always gives 0, so the 64 bit forms reduce to the old 32 bit compare. That fits with hardware giving the same results on main and the PR. Someone with a card that runs pixel waves of 64 would need to confirm the actual fix. AI-assisted: yes
A host wave of fewer lanes than 32 (WARP's have 4) has only its own lane
numbers, and need never hold two values: the even spread is asked over the
numbers the host has, and waves of one value and of several are counted on
hosts of 32 lanes or more.
Author
Owner

@⁠mateozariquiey on GitHub · 2026-12-03 19:43 UTC · original

Thanks for running it natively, WARP is a device these tests never meet under Wine.

Both points are right and fixed in the commit just pushed, tests only:

  • a_wave32_pixel_lane_number_stays_below_32 now asks for the even spread over the lane numbers the host has (0 to 3 on WARP), not over all 32.
  • masks_compare counts waves of one value and of several only on hosts whose waves have 32 lanes or more, so a run with WARP alone no longer trips the last check.

I cannot run WARP here, so I have not seen either go green on it. And agreed on the rest: on a host of 32-lane waves the change reduces to the old compare, so the fix itself needs a card that runs pixel waves of 64 (RADV does).

**@⁠mateozariquiey** on GitHub · 2026-12-03 19:43 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/344#issuecomment-7390137977) Thanks for running it natively, WARP is a device these tests never meet under Wine. Both points are right and fixed in the commit just pushed, tests only: - `a_wave32_pixel_lane_number_stays_below_32` now asks for the even spread over the lane numbers the host has (0 to 3 on WARP), not over all 32. - `masks_compare` counts waves of one value and of several only on hosts whose waves have 32 lanes or more, so a run with WARP alone no longer trips the last check. I cannot run WARP here, so I have not seen either go green on it. And agreed on the rest: on a host of 32-lane waves the change reduces to the old compare, so the fix itself needs a card that runs pixel waves of 64 (RADV does).
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-03 19:50 UTC · original

Reran f0fc990 on the same native Windows (MSVC) setup, only the five wave32/quad pixel tests.
Both devices together: all five pass, 5 runs each, and the draws ran on the card and on WARP every time (nothing skipped).
WARP alone (one run each): all five pass, lane_number now checks only the 4 lanes WARP has. The masks_compare tests pass because WARP no longer counts toward uniform/mixed, so that last check has nothing to look at there.
Card alone (one run each): all five pass.
The diff from e5243e4 only touches tests.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-03 19:50 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/344#issuecomment-7390307379) Reran f0fc990 on the same native Windows (MSVC) setup, only the five wave32/quad pixel tests. Both devices together: all five pass, 5 runs each, and the draws ran on the card and on WARP every time (nothing skipped). WARP alone (one run each): all five pass, lane_number now checks only the 4 lanes WARP has. The masks_compare tests pass because WARP no longer counts toward uniform/mixed, so that last check has nothing to look at there. Card alone (one run each): all five pass. The diff from e5243e4 only touches tests. AI-assisted: yes
github-bot changed target branch from main to gh-pr/344/base 2026-12-03 21:46:42 +00:00
github manually merged commit f0fc9905ca into gh-pr/344/base 2026-12-03 22:39:01 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.