Shaders, GPU: root UAVs (stacked on #489) #1077

Closed
DuarttBR wants to merge 5 commits from upstream-pr/1077 into main
DuarttBR commented 2026-11-24 15:30:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DuarttBR on 2026-11-24T15:30:14Z.


Stacked on #489 (which carries #302): its four commits come first here; only the last commit, 873548f, is new.

What

A compute program can build a buffer descriptor around a root descriptor's address and write through it. Emit refused that as a root UAV or typed root view; only root CBVs and read-only root SRVs had a handle.

  • Shader: Shader::root_uav_handle declares u<slot> in the root-view space (ROOT_CBV_SPACE), as a RWByteAddressBuffer (raw buffer, PSV0 kind 7). lower.rs takes (Descriptor, Uav, class 0x100b) there; any other typed root view is still refused, now as a typed root view.
  • HostShader::root_uavs, stored by the shader cache next to the CBV and SRV lists.
  • Host: each root UAV is a one-view table (a D3D12_DESCRIPTOR_RANGE_TYPE_UAV range). In bind, its view is a raw UAV of the title buffer's host copy from the root address, at most 1 MiB (ROOT_UAV_BYTES: a root view has no size), in a dynamic slot per heap and address per list. The range is refreshed before the submission and copied back after it (Shadow::refresh + gpu_writes), as for a table's buffer UAV. Without a host copy, or not on 16 bytes, the view is null: writes are dropped instead of landing elsewhere.

Why

With the spill table read (#302, #489), the 34 compute programs with spilled root arguments that Grand Theft Auto VI's world dispatches get past resource tracking in 13 cases, and 11 of those then stop at this refusal. Among them is the program that dropped the most dispatches per world frame in our runs.

Measured

Offline, over those 34 programs (victory translate --validate --pipelines, RTX 3080, driver 617.42, dxil.dll 1.9.2609):

emitted validated host pipelines
main + #489 0 of 13 0 0
+ this commit 7 of 13 7 6

The seventh is a wave64 program this card refuses (WaveSize(64) on a 32-lane GPU), which the wave64 work (#189, #233) addresses separately. What still stops the other 6 of the 13 is unrelated: a select on an untracked mask (3), LDS writes of bytes or halves, buffer_load_ushort and one typed root view (1 each).

In the game (same stack plus #493, #483, #189, #333 and others on our integration branch, Series S mode, RTX 3080): 5.5 minutes in the world with no device removal and no error, and 3b90165a77d95cdf (about 1,040 dispatches per frame before) no longer in the drop summary. One run, so please take the runtime part as a data point.

Checks

  • cargo clippy --workspace --all-targets --locked -- -D warnings and with --all-features: clean.
  • cargo test --workspace --locked: passes (the shader cache round trip now includes a root UAV).
  • No test drives a root UAV on a GPU yet; if you want one, I can add a synthetic program to the emit tests.

AI use: Claude Code (Claude Fable 5.2 and Claude Opus 5.5) wrote the change, ran the checks and the measurements on my machine, and drafted this description; I reviewed and posted it.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6585360167 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1077). Originally posted by [DuarttBR](https://github.com/DuarttBR) on 2026-11-24T15:30:14Z. --- Stacked on #489 (which carries #302): its four commits come first here; only the last commit, `873548f`, is new. ## What A compute program can build a buffer descriptor around a root descriptor's address and write through it. Emit refused that as `a root UAV or typed root view`; only root CBVs and read-only root SRVs had a handle. - **Shader:** `Shader::root_uav_handle` declares `u<slot>` in the root-view space (`ROOT_CBV_SPACE`), as a `RWByteAddressBuffer` (raw buffer, PSV0 kind 7). `lower.rs` takes `(Descriptor, Uav, class 0x100b)` there; any other typed root view is still refused, now as `a typed root view`. - **`HostShader::root_uavs`**, stored by the shader cache next to the CBV and SRV lists. - **Host:** each root UAV is a one-view table (a `D3D12_DESCRIPTOR_RANGE_TYPE_UAV` range). In `bind`, its view is a raw UAV of the title buffer's host copy from the root address, at most 1 MiB (`ROOT_UAV_BYTES`: a root view has no size), in a dynamic slot per heap and address per list. The range is refreshed before the submission and copied back after it (`Shadow::refresh` + `gpu_writes`), as for a table's buffer UAV. Without a host copy, or not on 16 bytes, the view is null: writes are dropped instead of landing elsewhere. ## Why With the spill table read (#302, #489), the 34 compute programs with spilled root arguments that Grand Theft Auto VI's world dispatches get past resource tracking in 13 cases, and 11 of those then stop at this refusal. Among them is the program that dropped the most dispatches per world frame in our runs. ## Measured Offline, over those 34 programs (`victory translate --validate --pipelines`, RTX 3080, driver 617.42, `dxil.dll` 1.9.2609): | | emitted | validated | host pipelines | |---|---:|---:|---:| | `main` + #489 | 0 of 13 | 0 | 0 | | + this commit | 7 of 13 | 7 | 6 | The seventh is a wave64 program this card refuses (`WaveSize(64)` on a 32-lane GPU), which the wave64 work (#189, #233) addresses separately. What still stops the other 6 of the 13 is unrelated: `a select on an untracked mask` (3), LDS writes of bytes or halves, `buffer_load_ushort` and one typed root view (1 each). In the game (same stack plus #493, #483, #189, #333 and others on our integration branch, Series S mode, RTX 3080): 5.5 minutes in the world with no device removal and no error, and `3b90165a77d95cdf` (about 1,040 dispatches per frame before) no longer in the drop summary. One run, so please take the runtime part as a data point. ## Checks - `cargo clippy --workspace --all-targets --locked -- -D warnings` and with `--all-features`: clean. - `cargo test --workspace --locked`: passes (the shader cache round trip now includes a root UAV). - No test drives a root UAV on a GPU yet; if you want one, I can add a synthetic program to the emit tests. **AI use:** Claude Code (Claude Fable 5.2 and Claude Opus 5.5) wrote the change, ran the checks and the measurements on my machine, and drafted this description; I reviewed and posted it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
NuraadGit commented 2026-11-24 17:04:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by NuraadGit on 2026-11-24T16:26:45Z.


World sizing for this from an RTX 2080, on a stack with #489 but without root UAVs (JMAN730's fork + #493 + #189 + #206 + #667 + #704 + #878 + #489, 12 minutes, loop limit 32):

  • 15 compute programs are refused in the world with a root UAV or typed root view.
  • About 155 dropped dispatches per frame come from two of them: 3b90165a77d95cdf (~90) and c42a31951201f9a0 (~65). The stack drops about 665 per frame for a missing host pipeline in total, so that's close to a quarter. 3b90165a77d95cdf is the single most dropped program.
  • Two more sit next to them with another reason (an address not from a root parameter): 5062bc7a48e842f8 and 5279ae36796c31fc, ~65 per frame each.

These four are missing from victory translate --list of the shader archive here, so offline counts over the archive can't show their gain. A runtime count like yours can.

Overlap: #294 + #709 (wbkepler, itsRevela) also give root UAVs, as root descriptors with write-back. In a full offline census of my stack with #489 + #294/#709, a root UAV or typed root view is at 0 (I haven't run that build in the world). The designs differ: a one-view table per root UAV here, root descriptors there. It'd help to settle on one before both grow. If you post your 13 programs' hashes, I can say what each of them does offline with #294/#709, where they are in the archive.

AI-assisted (Claude Code): the runs and log analysis were automated. The hardware, title copy and runs are the user's.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137677287 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1077#issuecomment-7137677287). Originally posted by [NuraadGit](https://github.com/NuraadGit) on 2026-11-24T16:26:45Z. --- World sizing for this from an RTX 2080, on a stack with #489 but without root UAVs (JMAN730's fork + #493 + #189 + #206 + #667 + #704 + #878 + #489, 12 minutes, loop limit 32): - **15 compute programs** are refused in the world with `a root UAV or typed root view`. - **About 155 dropped dispatches per frame come from two of them:** `3b90165a77d95cdf` (~90) and `c42a31951201f9a0` (~65). The stack drops about 665 per frame for a missing host pipeline in total, so that's close to a quarter. `3b90165a77d95cdf` is the single most dropped program. - **Two more sit next to them with another reason** (`an address not from a root parameter`): `5062bc7a48e842f8` and `5279ae36796c31fc`, ~65 per frame each. These four are missing from `victory translate --list` of the shader archive here, so offline counts over the archive can't show their gain. A runtime count like yours can. **Overlap:** #294 + #709 (wbkepler, itsRevela) also give root UAVs, as root descriptors with write-back. In a full offline census of my stack with #489 + #294/#709, `a root UAV or typed root view` is at 0 (I haven't run that build in the world). The designs differ: a one-view table per root UAV here, root descriptors there. It'd help to settle on one before both grow. If you post your 13 programs' hashes, I can say what each of them does offline with #294/#709, where they are in the archive. *AI-assisted (Claude Code): the runs and log analysis were automated. The hardware, title copy and runs are the user's.*
Zipettte commented 2026-11-24 17:04:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T16:29:54Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 873548f: cargo test -p victory -p victory-gpu -p victory-shader passes, 176 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137758201 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1077#issuecomment-7137758201). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T16:29:54Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 873548f: `cargo test -p victory -p victory-gpu -p victory-shader` passes, 176 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
DuarttBR commented 2026-11-24 17:04:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DuarttBR on 2026-11-24T16:30:01Z.


Thanks, that matches what we see: 3b90165a77d95cdf was our single largest drop too, and it is one of the seven this PR gets through.

The 11 programs that stop at a root UAV or typed root view on main + #489:

Program With this PR (Series S runtime stack)
3b90165a77d95cdf emits, validates, host pipeline
4ddd6f9702fab2a7 emits, validates, host pipeline
c42a31951201f9a0 emits, validates, host pipeline
5c09eb42b7a3c362 emits, validates, host pipeline
bb55c842c391589f emits, validates, host pipeline
f94e5d8bf4e1cf05 emits, validates, host pipeline
14394a322f6dd5c2 emits and validates; pipeline refused on plain main (WaveSize(64) on a 32-lane card), made with #189
caa78b8ca62bc3d6 next: LDS without a uniform fence in split wave64 (with #189)
28918b7150a7aad5 next: same as above
e63d22c4def9ba6a next: a select on an untracked mask
5552dac6a2b7a1fd next: a typed root view (a formatted root UAV, not raw)

On the overlap with #294/#709: agreed it is worth settling on one. Our reason for a one-view table is the same as #493's for root SRVs: a root descriptor has no size, so a write past the title buffer's host copy lands in whatever follows it. A table view ends at the copy (capped at 1 MiB here), and out-of-range writes are dropped. If #294/#709 bound the range another way, I'm happy to rebase onto them, or to close this in their favour. I can run #294/#709 on the same stack in the world and report the drop counts.

AI use: Claude Code (Claude Opus 5.5) gathered the per-program results from our runs and drafted this reply; I reviewed and posted it.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137761353 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1077#issuecomment-7137761353). Originally posted by [DuarttBR](https://github.com/DuarttBR) on 2026-11-24T16:30:01Z. --- Thanks, that matches what we see: `3b90165a77d95cdf` was our single largest drop too, and it is one of the seven this PR gets through. The 11 programs that stop at `a root UAV or typed root view` on `main` + #489: | Program | With this PR (Series S runtime stack) | |---|---| | `3b90165a77d95cdf` | emits, validates, host pipeline | | `4ddd6f9702fab2a7` | emits, validates, host pipeline | | `c42a31951201f9a0` | emits, validates, host pipeline | | `5c09eb42b7a3c362` | emits, validates, host pipeline | | `bb55c842c391589f` | emits, validates, host pipeline | | `f94e5d8bf4e1cf05` | emits, validates, host pipeline | | `14394a322f6dd5c2` | emits and validates; pipeline refused on plain `main` (WaveSize(64) on a 32-lane card), made with #189 | | `caa78b8ca62bc3d6` | next: LDS without a uniform fence in split wave64 (with #189) | | `28918b7150a7aad5` | next: same as above | | `e63d22c4def9ba6a` | next: `a select on an untracked mask` | | `5552dac6a2b7a1fd` | next: `a typed root view` (a formatted root UAV, not raw) | On the overlap with #294/#709: agreed it is worth settling on one. Our reason for a one-view table is the same as #493's for root SRVs: a root descriptor has no size, so a write past the title buffer's host copy lands in whatever follows it. A table view ends at the copy (capped at 1 MiB here), and out-of-range writes are dropped. If #294/#709 bound the range another way, I'm happy to rebase onto them, or to close this in their favour. I can run #294/#709 on the same stack in the world and report the drop counts. AI use: Claude Code (Claude Opus 5.5) gathered the per-program results from our runs and drafted this reply; I reviewed and posted it.
MamaLeVrai commented 2026-11-24 21:03:21 +00:00 (Migrated from github.com)

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


For reference: on top of the shader stack (#1319 to #1511) this merges without a conflict but does not compile, in two places. draw.rs pushes a root UAV's dynamic slot on self.dynamic, which #1056 replaced with the list's keep_dynamic; the stack's tests that build a HostShader lack the new root_uavs field. Both are fixed, with the rest of Impre-visible's list, in #1632. AI-assisted (Claude Code); no game data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7143089963 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1077#issuecomment-7143089963). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-24T20:08:08Z. --- For reference: on top of the shader stack (#1319 to #1511) this merges without a conflict but does not compile, in two places. `draw.rs` pushes a root UAV's dynamic slot on `self.dynamic`, which #1056 replaced with the list's `keep_dynamic`; the stack's tests that build a `HostShader` lack the new `root_uavs` field. Both are fixed, with the rest of Impre-visible's list, in #1632. AI-assisted (Claude Code); no game data.
upstream-sync closed this pull request 2026-11-25 01:05:29 +00:00
Marvisak commented 2026-11-25 01:07:59 +00:00 (Migrated from github.com)

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


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

Root UAVs stacked on #489/#302: main has HostShader::root_uavs, u<slot> space1 and title-memory root views (27c3dc9d, 0f637570).

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:7148601570 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1077#issuecomment-7148601570). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:31:49Z. --- Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. Root UAVs stacked on #489/#302: main has `HostShader::root_uavs`, `u<slot> space1` and title-memory root views (27c3dc9d, 0f637570). 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!1077
No description provided.