Shader: lower scalar Root CBV/SRV loads and descriptor-as-data queries #1376

Closed
wbkepler wants to merge 2 commits from upstream-pr/1376 into main
wbkepler commented 2026-11-24 17:39:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by wbkepler on 2026-11-24T17:39:39Z.


Summary

Rebased cleanly onto upstream/main (ffe310e):

  • Lowers s_load_dword* directly on RootType::Descriptor views (root_cbv_handle / root_srv_handle) instead of falling through to descriptor_data.
  • Unifies SRV/UAV buffer handle selection (buffer_srv_uav_props) across s_buffer_load_dword*, buffer_*, and descriptor_data, supporting scalar loads from structured buffers and Fields::Smem consumers.
  • Reconstructs descriptor metadata across multi-slot s_load_dword* loads, populates buffer V# dword 1 stride bits, supports Cube/2DMS/2DMSArray image dimensions and atomic image UAV annotations, infers view kinds from twin dynamic/waterfall loads and UsedResource table entries, and ignores dead descriptor-dword phi edges when another reachable path carries scalar data.
  • Adds 3 dxil.dll + hardware GPU + WARP execution tests in valu_tests covering structured s_buffer_load_dwordx2 + multi-slot s_load_dwordx16 metadata, Root CBV/SRV scalar loads, and twin bindless loads + descriptor-only UsedResource queries + dead descriptor-dword phi joins.

Verification

  • cargo clippy -p victory-shader --all-targets — passed
  • cargo test -p victory-shader — passed
  • cargo xtask policy — passed
<!-- greyfinch-sync:Marvisak/VIctory:issue:6587810383 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1376). Originally posted by [wbkepler](https://github.com/wbkepler) on 2026-11-24T17:39:39Z. --- ## Summary Rebased cleanly onto `upstream/main` (`ffe310e`): - Lowers `s_load_dword*` directly on `RootType::Descriptor` views (`root_cbv_handle` / `root_srv_handle`) instead of falling through to `descriptor_data`. - Unifies SRV/UAV buffer handle selection (`buffer_srv_uav_props`) across `s_buffer_load_dword*`, `buffer_*`, and `descriptor_data`, supporting scalar loads from structured buffers and `Fields::Smem` consumers. - Reconstructs descriptor metadata across multi-slot `s_load_dword*` loads, populates buffer `V#` dword 1 stride bits, supports `Cube`/`2DMS`/`2DMSArray` image dimensions and atomic image UAV annotations, infers view kinds from twin dynamic/waterfall loads and `UsedResource` table entries, and ignores dead descriptor-dword `phi` edges when another reachable path carries scalar data. - Adds 3 `dxil.dll` + hardware GPU + WARP execution tests in `valu_tests` covering structured `s_buffer_load_dwordx2` + multi-slot `s_load_dwordx16` metadata, Root CBV/SRV scalar loads, and twin bindless loads + descriptor-only `UsedResource` queries + dead descriptor-dword `phi` joins. ## Verification - `cargo clippy -p victory-shader --all-targets` — passed - `cargo test -p victory-shader` — passed - `cargo xtask policy` — passed
catminou4 commented 2026-11-24 18:05:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T17:52:34Z.

Review: APPROVED


Scalar root CBV/SRV loads and descriptor-as-data queries. root_smem handles s_load_dword{,x2,x4,x8,x16} from RootType::Descriptor params: SRV via rawBufferLoad.f32 per dword, CBV via cbufferLoadLegacy with 16-byte row caching for static offsets and cbuffer_dword for dynamic ones, UAV/typed roots rejected conservatively; s_dcache_inv/s_gl1_inv become no-ops (cache hints, no correctness impact). buffer_srv_uav_props keeps heap view kinds consistent across s_buffer_load/buffer_*/descriptor_data. Large diff (+1365) — the structure is sound and merge is clean; the valu_tests additions are Windows-gated, so please make sure the Windows run covers the CBV row-index units (cbufferLoadLegacy index granularity) since that's the one thing macOS can't check. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, cargo test -p victory-shader --locked. Shader execution tests (valu_tests/host/diff_tests) are #[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. 96 passed, 0 failed.

<!-- greyfinch-sync:Marvisak/VIctory:review:6044528078 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1376#pullrequestreview-6044528078). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T17:52:34Z. **Review:** APPROVED --- Scalar root CBV/SRV loads and descriptor-as-data queries. root_smem handles s_load_dword{,x2,x4,x8,x16} from RootType::Descriptor params: SRV via rawBufferLoad.f32 per dword, CBV via cbufferLoadLegacy with 16-byte row caching for static offsets and cbuffer_dword for dynamic ones, UAV/typed roots rejected conservatively; s_dcache_inv/s_gl1_inv become no-ops (cache hints, no correctness impact). buffer_srv_uav_props keeps heap view kinds consistent across s_buffer_load/buffer_*/descriptor_data. Large diff (+1365) — the structure is sound and merge is clean; the valu_tests additions are Windows-gated, so please make sure the Windows run covers the CBV row-index units (cbufferLoadLegacy index granularity) since that's the one thing macOS can't check. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, `cargo test -p victory-shader --locked`. Shader execution tests (valu_tests/host/diff_tests) are `#[cfg(all(test, windows))]`, so macOS covers lowering/decode/unit tests only. 96 passed, 0 failed.
sinan-cmyk commented 2026-11-24 19:04:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T18:21:42Z.


Data from a retail dump: what this PR would meet after #1402

Summary: #1402 makes "a descriptor's address or format read as data" the largest failure. This PR targets the same area, but it conflicts with #1402.

I measured #1402 on a retail dump (details). With #1402, "a descriptor's address or format read as data" becomes the largest failure: 809 programs, against 92 on main. This PR touches the same code, so here is what those 809 programs read.

To get the breakdown, I made a local build that adds the descriptor dword and the view kind to the reason. Counts by the dword read as data:

View descriptor_data builds Dword read as data Programs
raw buffer (props 11) 1 370
raw buffer 0 251
raw buffer 3 110
2D image 0 37
2D image 5 14
typed buffer (props 10) 3 14
structured buffer (props 12) 3 6
others (dwords 5–7 of 3D and UAV images, one 2D image dword 7) 7

Most of these are raw buffers, so a real address dword is read. In one program I traced (a mesh shader), the descriptor's registers are reused for s_buffer_load data on one branch only. At the join, a phi then mixes descriptor dwords with data, and the data path is what the program really consumes. That looks like the case this PR describes as "dead descriptor-dword phi edges". The stride bits in dword 1 may cover part of the dword-1 row as well.

This PR conflicts with #1402 in emit/lower.rs and emit/valu_tests.rs. So do #259, #329, #995, #317, #109, #180, #1083, #1333 and #1409, which I tried to stack on #1402 in the same run. If you rebase onto #1402 (or onto main once it lands), I can measure the result on the dump and post the program-by-program comparison here.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140535248 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1376#issuecomment-7140535248). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-24T18:21:42Z. --- ### Data from a retail dump: what this PR would meet after #1402 **Summary:** #1402 makes "a descriptor's address or format read as data" the largest failure. This PR targets the same area, but it conflicts with #1402. I measured #1402 on a retail dump ([details](https://github.com/Marvisak/VIctory/pull/1402#issuecomment-7140318094)). With #1402, "a descriptor's address or format read as data" becomes the largest failure: **809 programs**, against 92 on `main`. This PR touches the same code, so here is what those 809 programs read. To get the breakdown, I made a local build that adds the descriptor dword and the view kind to the reason. Counts by the dword read as data: | View `descriptor_data` builds | Dword read as data | Programs | |---|---|---| | raw buffer (props 11) | 1 | 370 | | raw buffer | 0 | 251 | | raw buffer | 3 | 110 | | 2D image | 0 | 37 | | 2D image | 5 | 14 | | typed buffer (props 10) | 3 | 14 | | structured buffer (props 12) | 3 | 6 | | others (dwords 5–7 of 3D and UAV images, one 2D image dword 7) | | 7 | Most of these are raw buffers, so a real address dword is read. In one program I traced (a mesh shader), the descriptor's registers are reused for `s_buffer_load` data on one branch only. At the join, a phi then mixes descriptor dwords with data, and the data path is what the program really consumes. That looks like the case this PR describes as "dead descriptor-dword phi edges". The stride bits in dword 1 may cover part of the dword-1 row as well. **This PR conflicts with #1402** in `emit/lower.rs` and `emit/valu_tests.rs`. So do #259, #329, #995, #317, #109, #180, #1083, #1333 and #1409, which I tried to stack on #1402 in the same run. If you rebase onto #1402 (or onto `main` once it lands), I can measure the result on the dump and post the program-by-program comparison here. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
wbkepler commented 2026-11-24 21:03:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by wbkepler on 2026-11-24T20:26:11Z.


Pushed 272c262: fixes a regression this branch introduced.

Symptom: on an RTX 5090 (Windows 11), a title that rendered its boot/menu screens on main presented only black frames with this branch merged. Draw counts were unchanged and there were no debug-layer errors. I bisected the integration branch to this merge, then narrowed it to one hunk with env toggles.

Cause: buffer_srv_uav_props gave s_buffer_load_dword* a structured annotation (12, stride from the resource table) whenever the table recorded a stride, even when no buffer_* access of that descriptor indexes records. In that title the table records stride 64, but the view is raw. NVIDIA returns zeros for a mismatched heap annotation in both directions: the old s_buffer_load_and_multi_descriptor_data_execute also reads zeros on this GPU if the loads are raw over its structured view. So the table stride alone can't choose the kind.

Fix: the byte-offset loads are structured only when a buffer_* access of the same descriptor indexes records (the same rule that access lowers with). Otherwise they stay raw, as on main. The descriptor-as-data query (descriptor_data) keeps the recorded stride.

  • New s_buffer_load_with_table_stride_reads_raw_view test (raw view, table stride 64), passing on hardware and WARP.
  • The old combined test is now multi_descriptor_data_execute and still checks record count, stride and UAV size.
  • Verified once on the integration branch: menus render again.

AI-assisted fix, checked on Windows 11 / RTX 5090.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7143544995 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1376#issuecomment-7143544995). Originally posted by [wbkepler](https://github.com/wbkepler) on 2026-11-24T20:26:11Z. --- Pushed `272c262`: fixes a regression this branch introduced. **Symptom:** on an RTX 5090 (Windows 11), a title that rendered its boot/menu screens on `main` presented only black frames with this branch merged. Draw counts were unchanged and there were no debug-layer errors. I bisected the integration branch to this merge, then narrowed it to one hunk with env toggles. **Cause:** `buffer_srv_uav_props` gave `s_buffer_load_dword*` a **structured** annotation (`12`, stride from the resource table) whenever the table recorded a stride, even when no `buffer_*` access of that descriptor indexes records. In that title the table records stride 64, but the view is raw. NVIDIA returns zeros for a mismatched heap annotation in **both** directions: the old `s_buffer_load_and_multi_descriptor_data_execute` also reads zeros on this GPU if the loads are raw over its structured view. So the table stride alone can't choose the kind. **Fix:** the byte-offset loads are structured only when a `buffer_*` access of the same descriptor indexes records (the same rule that access lowers with). Otherwise they stay raw, as on `main`. The descriptor-as-data query (`descriptor_data`) keeps the recorded stride. - New `s_buffer_load_with_table_stride_reads_raw_view` test (raw view, table stride 64), passing on hardware and WARP. - The old combined test is now `multi_descriptor_data_execute` and still checks record count, stride and UAV size. - Verified once on the integration branch: menus render again. _AI-assisted fix, checked on Windows 11 / RTX 5090._
upstream-sync closed this pull request 2026-11-25 01:06:24 +00:00
Marvisak commented 2026-11-25 01:08:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:39:02Z.


Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

1,338 lines on scalar root-view loads and descriptors read as data, written against ffe310e. Main covers the same ground since (75677cb8 sizes and twin loads, 27c3dc9d and d71c3889 root views, 683ad7a9 table constants); what is left (cube/MSAA dimensions) is #317.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148733252 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1376#issuecomment-7148733252). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:39:02Z. --- Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. 1,338 lines on scalar root-view loads and descriptors read as data, written against ffe310e. Main covers the same ground since (75677cb8 sizes and twin loads, 27c3dc9d and d71c3889 root views, 683ad7a9 table constants); what is left (cube/MSAA dimensions) is #317. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

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!1376
No description provided.