Shaders: lower unlisted table constant buffer loads as guarded raw SRVs #2066

Closed
fuzeofficlal wants to merge 1 commit from upstream-pr/2068 into main
fuzeofficlal commented 2026-11-25 04:20:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T04:20:32Z.


Closes #1595.

Summary

  • Lower scalar buffer loads (s_buffer_load_dword*) from RootType::Table descriptors with no matching UsedResource entry (kind.is_none()) as guarded raw buffer SRVs (11, 0) instead of cbufferLoadLegacy CBV handles (13, 0x1_0000).
  • Restrict heap_constants, unlisted-table self.heap tracking, and Lower::buffer_guard strictly to descriptors whose leaves are all tracked loads from RootType::ResourceHeap or RootType::Table (is_view_heap / is_unlisted_table), leaving Source::Constant, Source::Built, other root parameters, and VIEW_STRIDES buffer-vs-non-buffer (stride == 0) semantics unchanged.

Verification

  • emit::stride_tests::an_unlisted_table_constant_load_reads_as_a_raw_buffer: tests unlisted RootType::Table s_buffer_load_dword against View::NullTexture1d (slot 0 -> 0), View::Texture (slot 1 -> 0), and View::Buffer (slot 2 -> 9) across NVIDIA GeForce RTX 5090, AMD Radeon(TM) Graphics, and D3D12 WARP.
  • emit::stride_tests::unlisted_table_constant_lowering_rejects_non_heap_sources: verifies Source::Constant, RootType::Constants, and mixed Table+Constant phis remain rejected while pure Table phis lower and validate via dxil.dll.
  • cargo clippy -p victory-shader --tests --locked -- -D warnings and cargo xtask policy: passed.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6597130898 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2068). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T04:20:32Z. --- Closes #1595. ### Summary - Lower scalar buffer loads (`s_buffer_load_dword*`) from `RootType::Table` descriptors with no matching `UsedResource` entry (`kind.is_none()`) as guarded raw buffer SRVs `(11, 0)` instead of `cbufferLoadLegacy` CBV handles `(13, 0x1_0000)`. - Restrict `heap_constants`, unlisted-table `self.heap` tracking, and `Lower::buffer_guard` strictly to descriptors whose leaves are all tracked loads from `RootType::ResourceHeap` or `RootType::Table` (`is_view_heap` / `is_unlisted_table`), leaving `Source::Constant`, `Source::Built`, other root parameters, and `VIEW_STRIDES` buffer-vs-non-buffer (`stride == 0`) semantics unchanged. ### Verification - `emit::stride_tests::an_unlisted_table_constant_load_reads_as_a_raw_buffer`: tests unlisted `RootType::Table` `s_buffer_load_dword` against `View::NullTexture1d` (slot 0 -> 0), `View::Texture` (slot 1 -> 0), and `View::Buffer` (slot 2 -> 9) across **NVIDIA GeForce RTX 5090**, **AMD Radeon(TM) Graphics**, and **D3D12 WARP**. - `emit::stride_tests::unlisted_table_constant_lowering_rejects_non_heap_sources`: verifies `Source::Constant`, `RootType::Constants`, and mixed `Table`+`Constant` phis remain rejected while pure `Table` phis lower and validate via `dxil.dll`. - `cargo clippy -p victory-shader --tests --locked -- -D warnings` and `cargo xtask policy`: passed.
DenRakEiw commented 2026-11-25 05:05:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:31:10Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):

  • cargo test -p victory-shader --lib an_unlisted_table_constant_load_reads_as_a_raw_buffer — passed on both RTX 5090 hardware and VICTORY_D3D12_WARP=1
  • cargo test -p victory-gpu --lib table_stride_separates_shader_and_unordered_buffers — passed
  • cargo clippy -p victory-shader -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean lowering of unlisted table constant loads as raw SRVs and separation of SRV/UAV buffer guards across victory-shader and victory-gpu. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6051882967 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2068#pullrequestreview-6051882967). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T04:31:10Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC): - `cargo test -p victory-shader --lib an_unlisted_table_constant_load_reads_as_a_raw_buffer` — passed on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` - `cargo test -p victory-gpu --lib table_stride_separates_shader_and_unordered_buffers` — passed - `cargo clippy -p victory-shader -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean lowering of unlisted table constant loads as raw SRVs and separation of SRV/UAV buffer guards across `victory-shader` and `victory-gpu`. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 05:05:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T04:33:53Z.

Review: APPROVED


Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, cargo test -p victory-shader --locked.

144 passed / 0 failed / 2 ignored. Unlisted table constant loads as raw SRVs — table-constant fallback path; mixed gpu+shader, gpu half Windows-only.

<!-- greyfinch-sync:Marvisak/VIctory:review:6051901586 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2068#pullrequestreview-6051901586). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T04:33:53Z. **Review:** APPROVED --- Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 144 passed / 0 failed / 2 ignored. Unlisted table constant loads as raw SRVs — table-constant fallback path; mixed gpu+shader, gpu half Windows-only.
jeremygold02 commented 2026-11-25 05:06:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T04:27:36Z.


Triage verdict — Keep the descriptor-kind fixes, leave #1595 open for typed-null coverage (cba3f26)

Evidence

  • @fuzeofficlal changes unlisted table loads to raw SRVs and distinguishes buffer polarity in the guard. The #1595 descriptor at slot 0 is a null Texture1D SRV. The submitted table fixture instead gives slot 0 a raw null-buffer SRV. The unlisted table path still bypasses the heap-direct guard, so it can use the texture slot for a raw-buffer load. Table lowering · Guard predicate · Fixture descriptor
  • This patch and #2030 both assign bit 31 of the same side table to different meanings. A combined signed UAV guard would accept #2030’s normalized texture tag as a UAV buffer. #2030 view tags

Checks and limits

  • Both focused submitted tests passed independently. The table fixture ran on hardware and WARP. The polarity case ran on WARP and skipped the capped hardware heap. A disposable WARP fixture with a null Texture1D at slot 0 returned zero, but GPU-based validation was unavailable. That result does not establish that the mismatched null binding is valid. D3D12 null-descriptor rules

Next step

  • Cover the actual typed-null table slot from #1595 and route it to a matching null buffer. Coordinate disjoint texture and buffer-kind encodings with #2030 and null-slot placement with the heap-cap work.

This verification was AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152861719 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2068#issuecomment-7152861719). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-25T04:27:36Z. --- **Triage verdict — Keep the descriptor-kind fixes, leave #1595 open for typed-null coverage** (`cba3f26`) **Evidence** - @fuzeofficlal changes unlisted table loads to raw SRVs and distinguishes buffer polarity in the guard. The #1595 descriptor at slot 0 is a null Texture1D SRV. The submitted table fixture instead gives slot 0 a raw null-buffer SRV. The unlisted table path still bypasses the heap-direct guard, so it can use the texture slot for a raw-buffer load. [Table lowering](https://github.com/Marvisak/VIctory/blob/cba3f269abd89d4e2d48a6b00b1e4d877a8a03ed/crates/victory-shader/src/emit/lower.rs#L3905-L3924) · [Guard predicate](https://github.com/Marvisak/VIctory/blob/cba3f269abd89d4e2d48a6b00b1e4d877a8a03ed/crates/victory-shader/src/emit/lower.rs#L5039-L5075) · [Fixture descriptor](https://github.com/Marvisak/VIctory/blob/cba3f269abd89d4e2d48a6b00b1e4d877a8a03ed/crates/victory-shader/src/emit/host.rs#L1674-L1707) - This patch and #2030 both assign bit 31 of the same side table to different meanings. A combined signed UAV guard would accept #2030’s normalized texture tag as a UAV buffer. [#2030 view tags](https://github.com/Marvisak/VIctory/blob/f6058b0e83cf9173c5372717c9d17b948b49e06b/crates/victory-shader/src/emit/shader.rs#L16-L25) **Checks and limits** - Both focused submitted tests passed independently. The table fixture ran on hardware and WARP. The polarity case ran on WARP and skipped the capped hardware heap. A disposable WARP fixture with a null Texture1D at slot 0 returned zero, but GPU-based validation was unavailable. That result does not establish that the mismatched null binding is valid. [D3D12 null-descriptor rules](https://learn.microsoft.com/en-us/windows/win32/direct3d12/descriptors-overview#null-descriptors) **Next step** - Cover the actual typed-null table slot from #1595 and route it to a matching null buffer. Coordinate disjoint texture and buffer-kind encodings with #2030 and null-slot placement with the heap-cap work. This verification was AI-assisted.
fuzeofficlal commented 2026-11-25 06:02:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T05:10:49Z.


Thanks @jeremygold02 — pushed 421de01c addressing all three points:

  1. Bit orthogonality with #2030 texture D16 rounding tags: moved VIEW_STRIDE_UAV down to 1 << 28 (VIEW_BUFFER_STRIDE_MASK = (1 << 28) - 1), leaving bits 29..=31 untouched for texture metadata while covering the 14-bit GFX10 buffer stride range (0..=16383).
  2. Unlisted RootType::Table buffer handles: when self.used_kind(src).is_none(), buffer_guard and self.heap[0] = true now run alongside the dynamic-heap path so unlisted table constant loads get the exact SRV byte-length guard and refresh the stride table.
  3. Coverage: expanded the end-to-end test to verify View::NullTexture1d at heap slot 0 alongside normalized texture tag bits (0xC000_0000 / 0xE000_0000) and SRV vs. UAV stride separation.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7153523091 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2068#issuecomment-7153523091). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T05:10:49Z. --- Thanks @jeremygold02 — pushed `421de01c` addressing all three points: 1. **Bit orthogonality with `#2030` texture D16 rounding tags**: moved `VIEW_STRIDE_UAV` down to `1 << 28` (`VIEW_BUFFER_STRIDE_MASK = (1 << 28) - 1`), leaving bits `29..=31` untouched for texture metadata while covering the 14-bit GFX10 buffer stride range (`0..=16383`). 2. **Unlisted `RootType::Table` buffer handles**: when `self.used_kind(src).is_none()`, `buffer_guard` and `self.heap[0] = true` now run alongside the dynamic-heap path so unlisted table constant loads get the exact SRV byte-length guard and refresh the stride table. 3. **Coverage**: expanded the end-to-end test to verify `View::NullTexture1d` at heap slot `0` alongside normalized texture tag bits (`0xC000_0000` / `0xE000_0000`) and SRV vs. UAV stride separation.
sinan-cmyk commented 2026-11-25 10:07:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T09:18:16Z.


Offline measurement on a retail dump

Result: no count change against main.

I merged head 421de01c onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158149495 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2068#issuecomment-7158149495). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T09:18:16Z. --- ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 421de01c onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
upstream-sync changed title from [PR #2068] Shaders, GPU: lower unlisted table constant loads as raw SRVs and separate SRV/UAV buffer guards to [PR #2068] Shaders: lower unlisted table constant buffer loads as guarded raw SRVs 2026-11-25 11:03:41 +00:00
Marvisak commented 2026-11-25 11:05:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:25:20Z.


Automated triage for the maintainers.

Recommended for a look (merge candidate). After the rebase, scalar buffer loads whose descriptor comes from a table slot with no used-resource entry are lowered as raw buffer SRV reads, guarded through the view-stride table, instead of cbufferLoadLegacy (Lower in crates/victory-shader/src/emit/lower.rs: heap_constants, buffer_guard, and the new is_view_heap/is_unlisted_table). Such reads also mark the program as heap-reading. I checked that the new predicate only accepts descriptors whose leaves are all loads from ResourceHeap/Table parameters, so constants, built descriptors and mixed phis keep the old path (the new unlisted_table_constant_lowering_rejects_non_heap_sources test covers this). View::NullTexture1d in emit/host.rs is used only by the test fixture. This head no longer contains the polarity and bit-31 changes discussed above, and #1595 supplies the behaviour being fixed. A retail offline run reported no change in validated programs. CI: check passing on this head.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159672141 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2068#issuecomment-7159672141). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T10:25:20Z. --- <!-- victory-triage v1 head=05361f451c6b75b2d17df3f9da0e5dd6da5dd2aa verdict=merge-candidate at=2026-11-25T16:24:00Z --> Automated triage for the maintainers. Recommended for a look (merge candidate). After the rebase, scalar buffer loads whose descriptor comes from a table slot with no used-resource entry are lowered as raw buffer SRV reads, guarded through the view-stride table, instead of `cbufferLoadLegacy` (`Lower` in `crates/victory-shader/src/emit/lower.rs`: `heap_constants`, `buffer_guard`, and the new `is_view_heap`/`is_unlisted_table`). Such reads also mark the program as heap-reading. I checked that the new predicate only accepts descriptors whose leaves are all loads from `ResourceHeap`/`Table` parameters, so constants, built descriptors and mixed phis keep the old path (the new `unlisted_table_constant_lowering_rejects_non_heap_sources` test covers this). `View::NullTexture1d` in `emit/host.rs` is used only by the test fixture. This head no longer contains the polarity and bit-31 changes discussed above, and #1595 supplies the behaviour being fixed. A retail offline run reported no change in validated programs. CI: `check` passing on this head. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-25 11:05:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T11:02:18Z.


Updated in 7c8c0f7d per triage feedback:

  • Split out and reverted the VIEW_STRIDE_UAV / Lower::buffer_guard SRV-vs-UAV polarity changes (crates/victory-gpu/src/descriptor/host.rs and shader.rs are untouched relative to main, and buffer_guard only redirects stride == 0 non-buffer slots as on main).
  • Restricted smem's heap_constants expansion and unlisted-table self.heap / buffer_guard handling strictly to descriptors whose leaves are all tracked loads from RootType::ResourceHeap or RootType::Table (is_view_heap / is_unlisted_table), adding unlisted_table_constant_lowering_rejects_non_heap_sources to lock out Constant, RootType::Constants, and mixed Table+Constant phis.
  • Removed all references to #2030's normalized-format tag encoding.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7160503421 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2068#issuecomment-7160503421). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T11:02:18Z. --- Updated in `7c8c0f7d` per triage feedback: - Split out and reverted the `VIEW_STRIDE_UAV` / `Lower::buffer_guard` SRV-vs-UAV polarity changes (`crates/victory-gpu/src/descriptor/host.rs` and `shader.rs` are untouched relative to `main`, and `buffer_guard` only redirects `stride == 0` non-buffer slots as on `main`). - Restricted `smem`'s `heap_constants` expansion and unlisted-table `self.heap` / `buffer_guard` handling strictly to descriptors whose leaves are all tracked loads from `RootType::ResourceHeap` or `RootType::Table` (`is_view_heap` / `is_unlisted_table`), adding `unlisted_table_constant_lowering_rejects_non_heap_sources` to lock out `Constant`, `RootType::Constants`, and mixed `Table`+`Constant` phis. - Removed all references to `#2030`'s normalized-format tag encoding.
upstream-sync closed this pull request 2026-11-25 23:03:41 +00:00
Marvisak commented 2026-11-25 23:05:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:05:36Z.


Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing because the issue it closes, #1595, is fixed in main at the source: heap-direct constant data is read through raw views (c75fdba3), and a zero view-stride entry selects a null buffer view (d71c3889). What this adds is the case of a table descriptor that no used-resource entry covers, and no title program has one (a whole-set run on main reports "0 traced parameters not listed"). The tests also add their own adapter enumeration and a new VICTORY_WARP switch beside the existing Host::new(warp).

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175925415 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2068#issuecomment-7175925415). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:05:36Z. --- Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing because the issue it closes, #1595, is fixed in `main` at the source: heap-direct constant data is read through raw views (c75fdba3), and a zero view-stride entry selects a null buffer view (d71c3889). What this adds is the case of a table descriptor that no used-resource entry covers, and no title program has one (a whole-set run on `main` reports "0 traced parameters not listed"). The tests also add their own adapter enumeration and a new `VICTORY_WARP` switch beside the existing `Host::new(warp)`. If this is mistaken, reply here with what was missed 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!2066
No description provided.