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

Closed
github-bot wants to merge 2 commits from gh-pr/1376/head into gh-pr/1376/base
Owner

@⁠wbkepler on GitHub · 2026-11-24 17:39 UTC · original
wbkepler:shader/scalar-and-descriptor-data → main · +1338 −123 · 2 files · 2 commits · closed without merging

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
**@⁠wbkepler** on GitHub · 2026-11-24 17:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/1376) `wbkepler:shader/scalar-and-descriptor-data` → `main` · +1338 −123 · 2 files · 2 commits · closed without merging ## 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
- Lower s_load_dword* directly on RootType::Descriptor views (root_cbv_handle / root_srv_handle) instead of falling through to descriptor_data.

- Unify 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.

- Reconstruct descriptor metadata across multi-slot s_load_dword* loads, populate buffer V# dword 1 stride bits, support Cube/2DMS/2DMSArray image dimensions and atomic image UAV annotations, infer view kinds from twin dynamic/waterfall loads and UsedResource table entries, and ignore dead descriptor-dword phi edges when another reachable path carries scalar data.

- Add 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.
buffer_srv_uav_props chose a structured view for s_buffer_load_dword*
whenever the resource table recorded a stride, even when no buffer_*
access of the descriptor indexes records. The table's stride alone does
not show the title's view is structured: on a title whose view is raw,
the structured annotation read zeros and the whole presented frame went
black (every pass fed by those loads saw 0).

On a 32-lane NVIDIA host a mismatched heap annotation reads zeros either
way, so the byte-offset loads now take a structured view only when a
buffer_* access of the same descriptor indexes records (as that access
itself lowers), and stay raw otherwise, as before this branch. The
descriptor-as-data query keeps the recorded stride.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:29:22 +00:00
github-bot closed this pull request 2026-11-26 04:29:23 +00:00
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-24 18:21 UTC · original

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).

**@⁠sinan-cmyk** on GitHub · 2026-11-24 18:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/1376#issuecomment-7140535248) ### 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://git.gtahub.st/github/Marvisak--VIctory/pulls/1402)). 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).
Author
Owner

@⁠wbkepler on GitHub · 2026-11-24 20:26 UTC · original

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.

**@⁠wbkepler** on GitHub · 2026-11-24 20:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/1376#issuecomment-7143544995) 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._
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:39 UTC · original

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.

**@⁠Marvisak** on GitHub · 2026-11-25 00:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/1376#issuecomment-7148733252) 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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!1376
No description provided.