Shaders: per-lane size queries in the console's waterfall loops (follow-up to ffe310e, for #736) #853

Open
opened 2026-11-26 04:14:04 +00:00 by github-bot · 7 comments
Owner

@⁠FabianDU on GitHub · 2026-11-24 12:30 UTC · original

Pull requests here are limited to collaborators, so I'm offering this change as an issue. It's ready on my fork, one commit on top of the current main (ffe310e), and it merges cleanly:

Anyone with access can bring it in:

git fetch https://github.com/FabianDU/VIctory claude/elegant-newton-vly8mr
git cherry-pick aabd9a7

What it does

ffe310e handled the console compiler's waterfall loops that sample a per-lane table entry. Its message noted that the programs behind #736 also need per-lane size queries in loops without an access. This commit handles those loops.

The loop: v_readfirstlane_b32 of the lane's table offset, v_cmpx_eq_u32, s_load_dwordx8 of that entry, s_bfe_u32 of a size field from the descriptor bits into a VGPR for the matching lanes, s_andn2_wrexec. There's no sample or load in it, so nothing proved it a waterfall and every lane got the first lane's size.

  • resource::track: such a load goes through the waterfall proof, with the loop's per-lane VGPR writes standing in for the access. It's only taken when another load of the same entry (same table address, same lane offset) is used by an access, because that access tells the view's kind. Matches are recorded in the new Waterfall::sizes. Without such a load nothing changes: the size stays the first lane's.
  • Lower::descriptor_data: when its own load has no access, it takes the view's kind from that other load. The per-lane handle comes from Waterfall::loads, as for the sampling loops.

Tests

  • resource: tracking tests for the proven size loop and for one with no access to its entry (stays unproven).
  • lower: both handles read each lane's own entry, and no wave operations are left.
  • waterfall_tests (GPU, Windows-only): even lanes sample a 1x1 texture, odd lanes a 1x3 one; the result is red plus height − 1.

Verification

  • cargo test -p victory-shader passes on Linux (99 tests).
  • cargo clippy -p victory-shader --all-targets -- -D warnings is clean for x86_64-pc-windows-msvc.
  • Not run yet: the GPU test (needs Windows and D3D12) and the translation census over the title's programs. The synthetic test program follows the loop form described above, not the real programs, so a census run would confirm it covers the 249 programs.

The change was written with Claude Code.

**@⁠FabianDU** on GitHub · 2026-11-24 12:30 UTC · [original](https://github.com/Marvisak/VIctory/issues/853) Pull requests here are limited to collaborators, so I'm offering this change as an issue. It's ready on my fork, one commit on top of the current `main` (ffe310e), and it merges cleanly: - Branch: https://github.com/FabianDU/VIctory/tree/claude/elegant-newton-vly8mr - Compare against upstream: https://github.com/Marvisak/VIctory/compare/main...FabianDU:VIctory:claude/elegant-newton-vly8mr - Commit: aabd9a7 Anyone with access can bring it in: ```bash git fetch https://github.com/FabianDU/VIctory claude/elegant-newton-vly8mr git cherry-pick aabd9a7 ``` ## What it does ffe310e handled the console compiler's waterfall loops that sample a per-lane table entry. Its message noted that the programs behind #736 also need per-lane size queries in loops without an access. This commit handles those loops. The loop: `v_readfirstlane_b32` of the lane's table offset, `v_cmpx_eq_u32`, `s_load_dwordx8` of that entry, `s_bfe_u32` of a size field from the descriptor bits into a VGPR for the matching lanes, `s_andn2_wrexec`. There's no sample or load in it, so nothing proved it a waterfall and every lane got the first lane's size. - **`resource::track`**: such a load goes through the waterfall proof, with the loop's per-lane VGPR writes standing in for the access. It's only taken when another load of the same entry (same table address, same lane offset) is used by an access, because that access tells the view's kind. Matches are recorded in the new `Waterfall::sizes`. Without such a load nothing changes: the size stays the first lane's. - **`Lower::descriptor_data`**: when its own load has no access, it takes the view's kind from that other load. The per-lane handle comes from `Waterfall::loads`, as for the sampling loops. ## Tests - `resource`: tracking tests for the proven size loop and for one with no access to its entry (stays unproven). - `lower`: both handles read each lane's own entry, and no wave operations are left. - `waterfall_tests` (GPU, Windows-only): even lanes sample a 1x1 texture, odd lanes a 1x3 one; the result is red plus height − 1. ## Verification - `cargo test -p victory-shader` passes on Linux (99 tests). - `cargo clippy -p victory-shader --all-targets -- -D warnings` is clean for `x86_64-pc-windows-msvc`. - **Not run yet:** the GPU test (needs Windows and D3D12) and the translation census over the title's programs. The synthetic test program follows the loop form described above, not the real programs, so a census run would confirm it covers the 249 programs. The change was written with Claude Code.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:04 +00:00
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-24 12:42 UTC · original

I ran the unchanged waterfall test group at aabd9a7 on Windows 11 build 26200.9974. The five existing tests passed. The new size-and-sample test passed on the default hardware adapter and failed on WARP, which returned alternating 1.0, 2.0 instead of 1.0, 4.0.

I compiled a separate cs_6_6 shader with Windows SDK DXC 1.8. It uses the same synthetic 1×1 and 1×3 textures, the same host test harness and a NonUniformResourceIndex for the texture handle. The independent shader reproduced the same combined result. These are the raw mip-0 GetDimensions heights from the additional controls, over all 32 lanes.

DXC control Hardware WARP
Even lanes query 1×1, odd lanes query 1×3 1, 3 repeated All 1
Reversed lane mapping 3, 1 repeated All 3
Every lane queries 1×3 All 3 All 3

On this WARP build the size returned across the dispatch follows the resource selected by lane 0 in both index orders. The independent DXC result puts this specific discrepancy outside the VIctory translation path. The system WARP DLL file version is 10.0.26100.9818.

**@⁠fuzeofficlal** on GitHub · 2026-11-24 12:42 UTC · [original](https://github.com/Marvisak/VIctory/issues/853#issuecomment-7131800167) I ran the unchanged waterfall test group at `aabd9a7` on Windows 11 build 26200.9974. The five existing tests passed. The new size-and-sample test passed on the default hardware adapter and failed on WARP, which returned alternating `1.0, 2.0` instead of `1.0, 4.0`. I compiled a separate `cs_6_6` shader with Windows SDK DXC 1.8. It uses the same synthetic 1×1 and 1×3 textures, the same host test harness and a `NonUniformResourceIndex` for the texture handle. The independent shader reproduced the same combined result. These are the raw mip-0 `GetDimensions` heights from the additional controls, over all 32 lanes. | DXC control | Hardware | WARP | | --- | --- | --- | | Even lanes query 1×1, odd lanes query 1×3 | `1, 3` repeated | All `1` | | Reversed lane mapping | `3, 1` repeated | All `3` | | Every lane queries 1×3 | All `3` | All `3` | On this WARP build the size returned across the dispatch follows the resource selected by lane 0 in both index orders. The independent DXC result puts this specific discrepancy outside the VIctory translation path. The system WARP DLL file version is `10.0.26100.9818`.
Author
Owner

@⁠KingKaom on GitHub · 2026-11-24 12:43 UTC · original

Census run done — the verification listed as "not run yet." Full title shader dump through victory translate (diag build, every shader the dump contains: 26,148 programs, 40,647,088 IR instructions), baseline main ffe310e vs ffe310e + cherry-picked aabd9a7:

  • Emission counts identical: 12,243 of 14,039 vertex/pixel, 1,441 of 2,582 compute, 8,214 of 8,713 mesh.
  • The failure-reason table is identical down to every bucket (4,084 total; largest: scalar memory read as data 771, 64-bit image atomic 653, descriptor read only as data 394, select on an untracked mask 288, lane mask read as data 250).

So on the real title programs this commit converts none: no program moves out of "a descriptor read only as data" (394) or any other bucket, and nothing that failed emission starts emitting. The counts are deterministic between the two runs (only the example lines rotate), so this is a clean single-variable comparison.

Reading the gating in the commit: the size loop is only taken when another load of the same entry (same table address, same lane offset) is used by an access. The zero-delta is consistent with that pair rarely or never co-firing on the title's actual size loops — either there is no second load of the entry with an access, or the real loops aren't the v_readfirstlane_b32 → v_cmpx_eq_u32 → s_load_dwordx8 → s_bfe_u32 → s_andn2_wrexec form the synthetic test follows. A follow-up could drop the pairing requirement and take the view's kind from the BFE's consumer instead — but that's a guess worth a second census, not a claim.

(The GPU waterfall test and --validate were not run here; this is the translation-coverage axis only.)

AI-assisted Hermes Agent.

**@⁠KingKaom** on GitHub · 2026-11-24 12:43 UTC · [original](https://github.com/Marvisak/VIctory/issues/853#issuecomment-7131836576) Census run done — the verification listed as "not run yet." Full title shader dump through `victory translate` (diag build, every shader the dump contains: 26,148 programs, 40,647,088 IR instructions), baseline `main` ffe310e vs ffe310e + cherry-picked aabd9a7: - Emission counts identical: 12,243 of 14,039 vertex/pixel, 1,441 of 2,582 compute, 8,214 of 8,713 mesh. - The failure-reason table is identical down to every bucket (4,084 total; largest: scalar memory read as data 771, 64-bit image atomic 653, descriptor read only as data 394, select on an untracked mask 288, lane mask read as data 250). So on the real title programs this commit converts **none**: no program moves out of "a descriptor read only as data" (394) or any other bucket, and nothing that failed emission starts emitting. The counts are deterministic between the two runs (only the example lines rotate), so this is a clean single-variable comparison. Reading the gating in the commit: the size loop is only taken when another load of the same entry (same table address, same lane offset) is used by an access. The zero-delta is consistent with that pair rarely or never co-firing on the title's actual size loops — either there is no second load of the entry with an access, or the real loops aren't the `v_readfirstlane_b32 → v_cmpx_eq_u32 → s_load_dwordx8 → s_bfe_u32 → s_andn2_wrexec` form the synthetic test follows. A follow-up could drop the pairing requirement and take the view's kind from the BFE's consumer instead — but that's a guess worth a second census, not a claim. (The GPU waterfall test and `--validate` were not run here; this is the translation-coverage axis only.) AI-assisted Hermes Agent.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-24 12:45 UTC · original

I ran aabd9a7 on native Windows 10 with Agility 1.620.2, the packaged WARP 1.0.22, and the Microsoft DXIL validator from DXC 1.9.2609. The runtime probe confirmed both DLLs loaded from the test executable's directory or its Agility subdirectory, and WARP exposed SM 6.6.

lanes_size_the_entry_their_offset_names_in_the_console_waterfall passed DXIL validation and executed on the packaged WARP. All 32 readback values matched the expected alternating 1.0 and 4.0 for the 1×1 and 1×3 views. This adds a packaged-runtime result alongside the inbox WARP measurements above. The full run passed 124 branch tests plus the local runtime probe, with one benchmark ignored.

AI-assisted. Verified with synthetic shaders on software D3D12.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-24 12:45 UTC · [original](https://github.com/Marvisak/VIctory/issues/853#issuecomment-7131876771) I ran `aabd9a7` on native Windows 10 with Agility 1.620.2, the packaged WARP 1.0.22, and the Microsoft DXIL validator from DXC 1.9.2609. The runtime probe confirmed both DLLs loaded from the test executable's directory or its Agility subdirectory, and WARP exposed SM 6.6. `lanes_size_the_entry_their_offset_names_in_the_console_waterfall` passed DXIL validation and executed on the packaged WARP. All 32 readback values matched the expected alternating `1.0` and `4.0` for the `1×1` and `1×3` views. This adds a packaged-runtime result alongside the inbox WARP measurements above. The full run passed 124 branch tests plus the local runtime probe, with one benchmark ignored. AI-assisted. Verified with synthetic shaders on software D3D12.
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 12:45 UTC · original

Derek ran the unchanged size-and-sample fixture on an RTX 4090 through Wine and vkd3d-proton 3.2. At aabd9a7, all 32 lanes returned the expected alternating 1.0 and 4.0. On ffe310e with only the fixture transplanted, translation stopped at byte 164 with a descriptor read only as data, before dispatch.

Wine mapped the WARP request to the same hardware adapter, so this supplies an additional hardware result. KingKaom’s 26,148-program census above found the same emission totals and refusal counts in both runs. The fixture establishes the per-lane behavior for this loop shape; its effect on pixels in the game remains open.

AI-assisted verification with source-built inputs.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 12:45 UTC · [original](https://github.com/Marvisak/VIctory/issues/853#issuecomment-7131879181) Derek ran the unchanged size-and-sample fixture on an RTX 4090 through Wine and vkd3d-proton 3.2. At `aabd9a7`, all 32 lanes returned the expected alternating 1.0 and 4.0. On `ffe310e` with only the fixture transplanted, translation stopped at byte 164 with `a descriptor read only as data`, before dispatch. Wine mapped the WARP request to the same hardware adapter, so this supplies an additional hardware result. KingKaom’s 26,148-program census above found the same emission totals and refusal counts in both runs. The fixture establishes the per-lane behavior for this loop shape; its effect on pixels in the game remains open. AI-assisted verification with source-built inputs.
Author
Owner

@⁠FabianDU on GitHub · 2026-11-24 12:56 UTC · original

Relation to #180: #180 (c78056c) also handles size-only waterfall loops by taking the view's kind from a twin load. The two are complementary, not duplicates:

  • With #180 alone, the size loop translates but keeps a real waveReadLaneFirst loop (wave operations, tied to the console's wave size).
  • With this change on top, resource::track proves the loop, so each lane reads its own entry's size directly: no wave operations, and the result doesn't depend on the host's wave size.

If #180 is merged first, this change conflicts in one place in descriptor_data. The resolution keeps #180's code and adds the proven twin before its own twin match:

let proven = self.x.res.waterfall.sizes.iter().find(|s| s.0 == site);
let use_at = uses(&|load| load == site)
    .or_else(|| uses(&|load| proven.is_some_and(|s| s.1 == load)))
    .or_else(|| uses(&|load| self.twin_loads(site, load)));

With that resolution, main + #180 + this change passes cargo test -p victory-shader (99 tests) and Windows clippy.

**@⁠FabianDU** on GitHub · 2026-11-24 12:56 UTC · [original](https://github.com/Marvisak/VIctory/issues/853#issuecomment-7132137371) **Relation to #180:** #180 (c78056c) also handles size-only waterfall loops by taking the view's kind from a twin load. The two are complementary, not duplicates: - With **#180 alone**, the size loop translates but keeps a real `waveReadLaneFirst` loop (wave operations, tied to the console's wave size). - With **this change on top**, `resource::track` proves the loop, so each lane reads its own entry's size directly: no wave operations, and the result doesn't depend on the host's wave size. If #180 is merged first, this change conflicts in one place in `descriptor_data`. The resolution keeps #180's code and adds the proven twin before its own twin match: ```rust let proven = self.x.res.waterfall.sizes.iter().find(|s| s.0 == site); let use_at = uses(&|load| load == site) .or_else(|| uses(&|load| proven.is_some_and(|s| s.1 == load))) .or_else(|| uses(&|load| self.twin_loads(site, load))); ``` With that resolution, `main` + #180 + this change passes `cargo test -p victory-shader` (99 tests) and Windows clippy.
Author
Owner

@⁠FabianDU on GitHub · 2026-11-24 13:00 UTC · original

Thanks all, this is exactly the testing I couldn't do.

Census (KingKaom): taken as the result. The change converts none of the title's programs; the 394 "a descriptor read only as data" programs don't have the loop shape the synthetic test was built from (or have no second load of the entry with an access). So this issue no longer claims to help #736. What remains is narrower: for that one loop shape, each lane gets its own size without wave operations. Treat it as optional and low priority; #180 is the change that brings real programs back (240 of the 323 per the #736 breakdown).

WARP (fuzeofficlal): thanks for isolating it with a plain HLSL shader. The WARP in Windows 10.0.26100.9818 returns lane 0's size to every lane of a non-uniform GetDimensions, while hardware and the packaged WARP 1.0.22 (andrewpozdnakov7) give each lane its own. The new test now runs on hardware only and is skipped without a hardware adapter, so cargo test doesn't fail on the system WARP: commit fd8b093 on the branch, also on claude/elegant-newton-vly8mr-after-180.

Hardware results: thanks andrewpozdnakov7 and MichaelSmithAI. The fixture gives the expected 1.0 / 4.0 on packaged WARP and on an RTX 4090 through vkd3d-proton, and is refused on ffe310e as expected.

BFE consumer suggestion (KingKaom): I can't check it without the shader dump. Note that #180 already has a fallback for an image read only for its size (taken as a 2D texture), which may be where those programs go.

**@⁠FabianDU** on GitHub · 2026-11-24 13:00 UTC · [original](https://github.com/Marvisak/VIctory/issues/853#issuecomment-7132218468) Thanks all, this is exactly the testing I couldn't do. **Census (KingKaom):** taken as the result. The change converts none of the title's programs; the 394 "a descriptor read only as data" programs don't have the loop shape the synthetic test was built from (or have no second load of the entry with an access). So this issue no longer claims to help #736. What remains is narrower: for that one loop shape, each lane gets its own size without wave operations. Treat it as optional and low priority; #180 is the change that brings real programs back (240 of the 323 per the #736 breakdown). **WARP (fuzeofficlal):** thanks for isolating it with a plain HLSL shader. The WARP in Windows 10.0.26100.9818 returns lane 0's size to every lane of a non-uniform `GetDimensions`, while hardware and the packaged WARP 1.0.22 (andrewpozdnakov7) give each lane its own. The new test now runs on hardware only and is skipped without a hardware adapter, so `cargo test` doesn't fail on the system WARP: commit fd8b093 on the branch, also on `claude/elegant-newton-vly8mr-after-180`. **Hardware results:** thanks andrewpozdnakov7 and MichaelSmithAI. The fixture gives the expected 1.0 / 4.0 on packaged WARP and on an RTX 4090 through vkd3d-proton, and is refused on ffe310e as expected. **BFE consumer suggestion (KingKaom):** I can't check it without the shader dump. Note that #180 already has a fallback for an image read only for its size (taken as a 2D texture), which may be where those programs go.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 06:52 UTC · original

Automated triage for the maintainers.

This offers a branch (aabd9a7, with the WARP skip in fd8b093) that proves per-lane size-query waterfall loops in resource::track and uses them in Lower::descriptor_data (crates/victory-shader). Pull requests are open to everyone again, so please open one from the branch; none carries this change yet. As the thread established, the census over the title's programs found no program converted, so this no longer bears on #736; the fixture passes on hardware, packaged WARP and vkd3d-proton. Note that #180, which this was written to sit beside, was closed without being merged, so the branch based on main is the one to offer. The decision is left to the maintainers.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 06:52 UTC · [original](https://github.com/Marvisak/VIctory/issues/853#issuecomment-7155250728) <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-24T13:00:28Z at=2026-11-25T06:52:35Z --> Automated triage for the maintainers. This offers a branch (`aabd9a7`, with the WARP skip in `fd8b093`) that proves per-lane size-query waterfall loops in `resource::track` and uses them in `Lower::descriptor_data` (`crates/victory-shader`). Pull requests are open to everyone again, so please open one from the branch; none carries this change yet. As the thread established, the census over the title's programs found no program converted, so this no longer bears on #736; the fixture passes on hardware, packaged WARP and vkd3d-proton. Note that #180, which this was written to sit beside, was closed without being merged, so the branch based on `main` is the one to offer. The decision is left to the maintainers. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#853
No description provided.