Shaders: structured access through a root SRV or UAV uses its raw view (stacked on #294) #709

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

@⁠itsRevela on GitHub · 2026-11-24 07:11 UTC · original
itsRevela:shaders/structured-root-views → main · +1562 −131 · 10 files · 4 commits · closed without merging

Depends on: #294 (root UAVs). This branch is on top of it; only the last two commits are new.

What

An indexed (structured) buffer_load_*, buffer_store_* or buffer_atomic_* through a descriptor built around a root SRV or UAV now goes through the root view's raw handle, at byte index * stride + offset. The stride is the one the title declares for that root parameter (UsedResource::stride).

A root descriptor is a bare address on the host, with no stride of its own. These accesses used to ask handle for a structured view (12 | u), which root descriptors don't have, so they stopped with a typed root view. That message was misleading for them, since none is a typed (format) access.

A new Lower::structured holds the choice for all three access kinds. Structured buffers in tables and heaps are unchanged, as is their stride check.

Why

With the title, in the opening cutscene, compute programs that write through root UAVs declared with strides of 1 to 64 bytes stopped at a typed root view once #294 was in. Each dropped its dispatches.

I measured in a local build with #302, #489, #294 and some local work on addresses passed as root constants (#614), which those programs need first:

  • with this change, 5 of them translate;
  • the run logs no a typed root view failures left;
  • the host accepted all 5 pipelines. The run's other host pipeline refused lines (129 without this change) don't involve them.

Tested

Windows 11 Pro 10.0.26200, NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.1088), Rust 1.98.1, on #294's head.

  • New GPU test. emit::valu_tests::structured_access_through_a_root_uav_reaches_index_times_stride declares a root UAV with a stride of 8. It does an indexed store (element 2, offset 4), an indexed atomic add (element 2, offset 0) and an indexed load, then checks the buffer the root UAV binds on the hardware GPU and on WARP. With #294's lower.rs, it fails at emit with a typed root view.
  • Crate checks:
    • cargo test -p victory-shader: 72 passed.
    • cargo clippy -p victory-shader --tests: nothing in the changed files.
    • cargo fmt -p victory-shader --check: clean.
    • cargo xtask policy: ok.

AI-assisted (Claude Code). The title runs used my own copy; no game data is in this PR.

🤖 Generated with Claude Code

**@⁠itsRevela** on GitHub · 2026-11-24 07:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/709) `itsRevela:shaders/structured-root-views` → `main` · +1562 −131 · 10 files · 4 commits · closed without merging Depends on: #294 (root UAVs). This branch is on top of it; only the last two commits are new. ## What An indexed (structured) `buffer_load_*`, `buffer_store_*` or `buffer_atomic_*` through a descriptor built around a **root SRV or UAV** now goes through the root view's raw handle, at byte `index * stride + offset`. The stride is the one the title declares for that root parameter (`UsedResource::stride`). A root descriptor is a bare address on the host, with no stride of its own. These accesses used to ask `handle` for a structured view (`12 | u`), which root descriptors don't have, so they stopped with `a typed root view`. That message was misleading for them, since none is a typed (format) access. A new `Lower::structured` holds the choice for all three access kinds. Structured buffers in tables and heaps are unchanged, as is their stride check. ## Why With the title, in the opening cutscene, compute programs that write through root UAVs declared with strides of 1 to 64 bytes stopped at `a typed root view` once #294 was in. Each dropped its dispatches. I measured in a local build with #302, #489, #294 and some local work on addresses passed as root constants (#614), which those programs need first: - with this change, **5 of them translate**; - the run logs no `a typed root view` failures left; - the host accepted all 5 pipelines. The run's other `host pipeline refused` lines (129 without this change) don't involve them. ## Tested Windows 11 Pro 10.0.26200, NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.1088), Rust 1.98.1, on #294's head. - **New GPU test.** `emit::valu_tests::structured_access_through_a_root_uav_reaches_index_times_stride` declares a root UAV with a stride of 8. It does an indexed store (element 2, offset 4), an indexed atomic add (element 2, offset 0) and an indexed load, then checks the buffer the root UAV binds on the hardware GPU and on WARP. With #294's `lower.rs`, it fails at emit with `a typed root view`. - **Crate checks:** - `cargo test -p victory-shader`: 72 passed. - `cargo clippy -p victory-shader --tests`: nothing in the changed files. - `cargo fmt -p victory-shader --check`: clean. - `cargo xtask policy`: ok. AI-assisted (Claude Code). The title runs used my own copy; no game data is in this PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
- Refresh the full remaining Shadow buffer extent for Root SRVs and Root UAVs instead of truncating at 1 MiB (keeping Root CBVs at the 64 KiB D3D12 limit).

- Guard shadow::find/loose against low (<0x10000) and uncommitted addresses, and bind permanently-alive 4 MiB zeroed/sink fallback GPU VAs instead of skipping Set*Root*View when a root view is unset, null, or unmapped.

- Support Root UAVs (u<slot>, space1 RWByteAddressBuffer) end-to-end across victory-shader (descriptor handle, global_store_dword*, s_load_dword* on root descriptors, PSV0/dx.resources metadata, SFI0/ShaderFlags UAVsAtEveryStage=1<<16), shader_cache (VSH2), pipeline::host (deduplicating shared (kind, slot) root views across stages), and draw (binding, gpu_writes write-back, and post-draw/dispatch UAV barriers).

- Add unit, dxil.dll validation, WARP, and host GPU tests covering >1 MiB Root SRV dirty-page refresh, null/unmapped fallback VAs, cross-stage root view deduplication, and Root UAV execution/write-back.
Root SRVs and UAVs took the whole rest of their buffer's host copy, so a
root UAV near the start of a very large backing copy kept and compared
that whole range on every submission. A root view has no size and the
translated shader does not report its range yet, so bound them: root
SRVs refresh at most 4 MiB, root UAVs refresh, snapshot and copy back at
most 2 MiB, constant buffers keep the 64 KiB D3D12 maximum. A cut is
logged once per view kind.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A root descriptor is a bare address on the host, with no stride of its own: an indexed (structured) load, store or atomic through one reads or writes its raw view at byte index * stride + offset. These stopped with "a typed root view".

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

@⁠raffclar on GitHub · 2026-11-24 08:59 UTC · original

#294 has some issues but this branch on top is okay.

**@⁠raffclar** on GitHub · 2026-11-24 08:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/709#issuecomment-7126825410) #294 has some issues but this branch on top is okay.
Author
Owner

@⁠MartinIndra02 on GitHub · 2026-11-24 09:19 UTC · original

Independent Windows + NVIDIA Ampere verification for e50ed36:

  • Setup: Windows 11 Pro 26200, NVIDIA GeForce RTX 3080 (10 GB, driver 621.24), Ryzen 7 5800X3D, Rust 1.98.1 (x86_64-pc-windows-msvc).
  • cargo test -p victory-shader --lib -- --test-threads=1: 72 passed, 0 failed (including structured_access_through_a_root_uav_reaches_index_times_stride on both hardware D3D12 and WARP).

No game data used. AI-assisted; tests run on my machine.

**@⁠MartinIndra02** on GitHub · 2026-11-24 09:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/709#issuecomment-7127262834) Independent Windows + NVIDIA Ampere verification for `e50ed36`: - **Setup:** Windows 11 Pro 26200, NVIDIA GeForce RTX 3080 (10 GB, driver `621.24`), Ryzen 7 5800X3D, Rust 1.98.1 (`x86_64-pc-windows-msvc`). - `cargo test -p victory-shader --lib -- --test-threads=1`: **72 passed, 0 failed** (including `structured_access_through_a_root_uav_reaches_index_times_stride` on both hardware D3D12 and WARP). *No game data used. AI-assisted; tests run on my machine.*
Author
Owner

@⁠erLCoder on GitHub · 2026-11-24 13:08 UTC · original

Independent structured root UAV GPU readback on GTX 1660 Ti, NVIDIA 581.42, Windows 10 22H2 build 19045.6466, Ryzen 5 3600, Rust 1.98.1 MSVC and Agility SDK 1.620.2. PR e50ed36 includes #294 dependency 0050ce5. Local SDK exports were added to the test executable; the fixture was restricted to hardware and asserts NVIDIA LUID 00000000:00017c52.

cargo test --offline --locked -p victory-shader --features host --lib structured_access_through_a_root_uav_reaches_index_times_stride -- --nocapture --test-threads=1 — 1 passed, 0 failed, 0 ignored, 71 filtered out. The synthetic dispatch wrote the expected words at index times stride and read them back successfully. The number of recovered title dispatches and effects on lighting remain untested.

Codex prepared the worktree, ran the test and drafted this report.

**@⁠erLCoder** on GitHub · 2026-11-24 13:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/709#issuecomment-7132407167) Independent structured root UAV GPU readback on GTX 1660 Ti, NVIDIA 581.42, Windows 10 22H2 build 19045.6466, Ryzen 5 3600, Rust 1.98.1 MSVC and Agility SDK 1.620.2. PR e50ed36 includes #294 dependency 0050ce5. Local SDK exports were added to the test executable; the fixture was restricted to hardware and asserts NVIDIA LUID 00000000:00017c52. `cargo test --offline --locked -p victory-shader --features host --lib structured_access_through_a_root_uav_reaches_index_times_stride -- --nocapture --test-threads=1` — 1 passed, 0 failed, 0 ignored, 71 filtered out. The synthetic dispatch wrote the expected words at index times stride and read them back successfully. The number of recovered title dispatches and effects on lighting remain untested. Codex prepared the worktree, ran the test and drafted this report.
Author
Owner

@⁠qntic on GitHub · 2026-11-24 13:25 UTC · original

integrated this with the newer main ffe310e. the structured buffer access paths conflict with the stride table changes, so i merged both into a shared implementation.

tested on rx 6600 xt. 359 workspace tests passed after the root uav integration, with both clippy configurations clean.

integration:
https://github.com/qntic/VIctory/tree/exp4/main-stack

**@⁠qntic** on GitHub · 2026-11-24 13:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/709#issuecomment-7132801795) integrated this with the newer main ffe310e. the structured buffer access paths conflict with the stride table changes, so i merged both into a shared implementation. tested on rx 6600 xt. 359 workspace tests passed after the root uav integration, with both clippy configurations clean. integration: https://github.com/qntic/VIctory/tree/exp4/main-stack
Author
Owner

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

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

Stacked on #294; main already indexes a descriptor built around a root view by its own stride into the raw root view (emit/lower.rs, 'A descriptor built around a root view has the stride...').

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:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/709#issuecomment-7148538467) Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. Stacked on #294; main already indexes a descriptor built around a root view by its own stride into the raw root view (emit/lower.rs, 'A descriptor built around a root view has the stride...'). 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!709
No description provided.