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

Closed
github-bot wants to merge 1 commit from gh-pr/2068/head into gh-pr/2068/base
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 04:20 UTC · original
fuzeofficlal:fix/shader-dynamic-heap-cbv-slot0-1595 → main · +511 −38 · 4 files · 1 commits · closed without merging

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.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 04:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2068) `fuzeofficlal:fix/shader-dynamic-heap-cbv-slot0-1595` → `main` · +511 −38 · 4 files · 1 commits · closed without merging 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.
Scalar buffer loads (s_buffer_load_dword*) from descriptor table slots
(RootType::Table) with no matching UsedResource entry (kind.is_none())
previously fell back to createHandleFromHeap annotated as CBV
(13, 0x1_0000) with cbufferLoadLegacy and bypassed Lower::buffer_guard
and heap refresh (self.heap[0]). When an indexed table slot points at a
non-buffer descriptor such as the title's null Texture1D SRV at heap slot 0,
D3D12 GBV and WARP fail with a CBV-over-SRV descriptor type mismatch.

Restrict smem's heap_constants expansion, unlisted-table heap tracking,
and Lower::buffer_guard to descriptors whose leaves are all tracked loads
from RootType::ResourceHeap or RootType::Table, lowering them as raw
buffer SRVs (11, 0) guarded by VIEW_STRIDES against non-buffer slots.
Leave VIEW_STRIDES buffer-vs-non-buffer semantics unchanged so existing
buffer views are never zeroed.

Closes #1595
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:53:50 +00:00
github-bot closed this pull request 2026-11-26 04:53:50 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-25 04:27 UTC · original

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.

**@⁠jeremygold02** on GitHub · 2026-11-25 04:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/2068#issuecomment-7152861719) **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.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 05:10 UTC · original

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.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 05:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2068#issuecomment-7153523091) 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.
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 09:18 UTC · original

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

**@⁠sinan-cmyk** on GitHub · 2026-11-25 09:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/2068#issuecomment-7158149495) ### 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).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:25 UTC · original · edited 2026-11-25 16:17 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 10:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/2068#issuecomment-7159672141) · edited 2026-11-25 16:17 UTC <!-- 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)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 11:02 UTC · original

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.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 11:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/2068#issuecomment-7160503421) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:05 UTC · original

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.

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

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