Shaders: lower root UAV accesses as ROVs in POPS pixel shaders #2490

Open
github-bot wants to merge 1 commit from github-bot/gh-2490 into main AGit
Owner

@⁠reeledMarek on GitHub · 2026-11-25 14:48 UTC · original
reeledMarek:fix/shader-pops-root-uav-rov → main · +232 −22 · 2 files · 1 commits · open

Problem

In crates/victory-shader/src/emit/lower.rs:

  1. When a pixel shader uses POPS (self.pops == true, DB_SHADER_CONTROL bit 16), Lower::handle() ORs the ROV flag (0x2000) into props.0 for UAV handles (0x100B -> 0x300B). However, the Source::Built match arms only matched 0x100B and 11, causing any root UAV store/atomic/UAV-annotated load in a POPS pixel shader to fail translation with "a root UAV or typed root view".
  2. Lower::root_view() hardcoded (11 | 0x1000, 0) without checking self.pops, so root UAV heap handles in POPS shaders lost the 0x2000 ROV annotation (and global_load_* on a root UAV, which passes props.0 == 11 into handle(), also skipped setting flags::ROVS).

Fix

  • Match props.0 & !0x2000 in Lower::handle() for Source::Built root descriptors so ROV-annotated raw UAV handles (0x300B) route to root_view(..., true) (or root_uav_handle when root_memory is active).
  • In Lower::root_view(), when uav && self.pops, set self.s.flags |= flags::ROVS and annotate the heap handle with (11 | 0x1000 | 0x2000, 0). (Shader::heap_handle still records view_index because 0x300B & 0x1000 != 0 and 0x300B & 0xFF == 11, so write marks keep working.)
  • Added synthetic unit tests in emit::lower::tests::pops_pixel_shader_lowers_root_uav_accesses_as_rovs covering buffer_store_dword, global_store_dword, and global_load_dword on root UAVs in POPS and non-POPS pixel shaders (with and without view_marks).

Verification

  • cargo test -p victory-shader --locked (145 passed, 0 failed)
  • cargo test -p xtask --locked (repository_passes_policy passed)
  • cargo clippy -p victory-shader --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings (0 warnings)
**@⁠reeledMarek** on GitHub · 2026-11-25 14:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2490) `reeledMarek:fix/shader-pops-root-uav-rov` → `main` · +232 −22 · 2 files · 1 commits · open ### Problem In `crates/victory-shader/src/emit/lower.rs`: 1. When a pixel shader uses POPS (`self.pops == true`, `DB_SHADER_CONTROL` bit 16), `Lower::handle()` ORs the ROV flag (`0x2000`) into `props.0` for UAV handles (`0x100B` -> `0x300B`). However, the `Source::Built` match arms only matched `0x100B` and `11`, causing any root UAV store/atomic/UAV-annotated load in a POPS pixel shader to fail translation with `"a root UAV or typed root view"`. 2. `Lower::root_view()` hardcoded `(11 | 0x1000, 0)` without checking `self.pops`, so root UAV heap handles in POPS shaders lost the `0x2000` ROV annotation (and `global_load_*` on a root UAV, which passes `props.0 == 11` into `handle()`, also skipped setting `flags::ROVS`). ### Fix - Match `props.0 & !0x2000` in `Lower::handle()` for `Source::Built` root descriptors so ROV-annotated raw UAV handles (`0x300B`) route to `root_view(..., true)` (or `root_uav_handle` when `root_memory` is active). - In `Lower::root_view()`, when `uav && self.pops`, set `self.s.flags |= flags::ROVS` and annotate the heap handle with `(11 | 0x1000 | 0x2000, 0)`. (`Shader::heap_handle` still records `view_index` because `0x300B & 0x1000 != 0` and `0x300B & 0xFF == 11`, so write marks keep working.) - Added synthetic unit tests in `emit::lower::tests::pops_pixel_shader_lowers_root_uav_accesses_as_rovs` covering `buffer_store_dword`, `global_store_dword`, and `global_load_dword` on root UAVs in POPS and non-POPS pixel shaders (with and without `view_marks`). ### Verification - `cargo test -p victory-shader --locked` (145 passed, 0 failed) - `cargo test -p xtask --locked` (`repository_passes_policy` passed) - `cargo clippy -p victory-shader --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings` (0 warnings)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:07:18 +00:00
github-bot force-pushed github-bot/gh-2490 from 839803a2e5 to f11c1b43ea 2026-11-26 06:31:10 +00:00 Compare
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:58 UTC · original · edited 2026-11-26 07:22 UTC

Automated triage for the maintainers.

Needs work: CI fails. Thanks for the rebase and the root_memory change. The logic reads right. classify_root_descriptor in crates/victory-shader/src/emit/lower.rs accepts the ROV bit (0x2000) only on the !root_memory view arms. With root_memory, POPS root UAVs stay refused instead of becoming unordered root_uav_handles. root_view sets flags::ROVS and 0x300B for POPS.

However, the check run on f11c1b4 fails xtask policy::tests::repository_passes_policy: crates/victory-shader/src/emit/lower.rs: 526918 bytes exceeds the 524288-byte limit. The ~160-line test pushes the file over the policy's size cap. Please move pops_pixel_shader_lowers_root_uav_accesses_as_rovs (and, if needed, RootBinding/classify_root_descriptor) into a separate file, for example a #[cfg(test)] module next to lower.rs. Do not change xtask/src/policy.rs. With CI green this would be back to a merge candidate.

CI: failing (asset policy size limit).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 15:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/2490#issuecomment-7167475928) · edited 2026-11-26 07:22 UTC <!-- victory-triage v1 head=f11c1b43ea4604d921bebee2fbe474a99b924d32 verdict=needs-work at=2026-11-26T07:22:21Z --> Automated triage for the maintainers. **Needs work: CI fails.** Thanks for the rebase and the `root_memory` change. The logic reads right. `classify_root_descriptor` in `crates/victory-shader/src/emit/lower.rs` accepts the ROV bit (`0x2000`) only on the `!root_memory` view arms. With `root_memory`, POPS root UAVs stay refused instead of becoming unordered `root_uav_handle`s. `root_view` sets `flags::ROVS` and `0x300B` for POPS. However, the `check` run on `f11c1b4` fails `xtask` `policy::tests::repository_passes_policy`: `crates/victory-shader/src/emit/lower.rs: 526918 bytes exceeds the 524288-byte limit`. The ~160-line test pushes the file over the policy's size cap. Please move `pops_pixel_shader_lowers_root_uav_accesses_as_rovs` (and, if needed, `RootBinding`/`classify_root_descriptor`) into a separate file, for example a `#[cfg(test)]` module next to `lower.rs`. Do not change `xtask/src/policy.rs`. With CI green this would be back to a merge candidate. CI: failing (asset policy size limit). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠reeledMarek on GitHub · 2026-11-25 20:05 UTC · original

Updated to address the triage feedback:

  • Restricted the 0x2000 ROV bit mask to the !self.root_memory arms via classify_root_descriptor, keeping self.root_memory + POPS root UAV refused (Err("a root UAV or typed root view")) instead of silently lowering to an unordered Shader::root_uav_handle.
  • Added unit test assertions covering root_memory = true (both POPS refused and non-POPS allowed) alongside root_memory = false.
**@⁠reeledMarek** on GitHub · 2026-11-25 20:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/2490#issuecomment-7173172919) Updated to address the triage feedback: - Restricted the `0x2000` ROV bit mask to the `!self.root_memory` arms via `classify_root_descriptor`, keeping `self.root_memory` + POPS root UAV refused (`Err("a root UAV or typed root view")`) instead of silently lowering to an unordered `Shader::root_uav_handle`. - Added unit test assertions covering `root_memory = true` (both POPS refused and non-POPS allowed) alongside `root_memory = false`.
Author
Owner

@⁠reeledMarek on GitHub · 2026-11-26 05:55 UTC · original

Rebased cleanly onto current main (63bcca4) and verified cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings passes.

**@⁠reeledMarek** on GitHub · 2026-11-26 05:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/2490#issuecomment-7183936057) Rebased cleanly onto current `main` (`63bcca4`) and verified `cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings` passes.
github-bot force-pushed github-bot/gh-2490 from f11c1b43ea to a4f4c72a67 2026-11-26 11:10:35 +00:00 Compare
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 15:08 UTC · original · reviewed

Independent verification on Windows, VICTORY_D3D12_WARP=1 (WARP only, no hardware GPU touched). Tested commit d8e54fd834998271d3e6e315b8fe2a312519e32e (clean detached checkout).

  • cargo test -p victory-shader --locked --lib pops_pixel_shader_lowers_root_uav — 1 passed, 0 failed, 0 ignored.
  • Mutation check: with the if self.pops branch in root_view forced off, the same test fails (panic at the first l.rovs assert), so it guards the change.
  • cargo test -p victory-shader --locked --lib — 248 passed, 0 failed, 3 ignored (the ignored ones are pre-existing).

Code read: root_view(.., uav=true) now sets flags::ROVS and 0x2000 under POPS. This covers the global_load route, where handle() sees props.0 == 11 without 0x1000 and so never adds the ROV bit itself. The props.0 & !0x2000 mask in the root-descriptor match keeps the 0x100B and (Uav, 11) arms matching. The non-POPS path is unchanged, and the test asserts rovs == false for it. No problems found.

AI-assisted (Claude Code / Claude Sonnet 5.5)

**@⁠oni-swr** on GitHub · 2026-11-25 15:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2490#pullrequestreview-6060181085) · **reviewed** Independent verification on Windows, `VICTORY_D3D12_WARP=1` (WARP only, no hardware GPU touched). Tested commit `d8e54fd834998271d3e6e315b8fe2a312519e32e` (clean detached checkout). - `cargo test -p victory-shader --locked --lib pops_pixel_shader_lowers_root_uav` — 1 passed, 0 failed, 0 ignored. - Mutation check: with the `if self.pops` branch in `root_view` forced off, the same test fails (panic at the first `l.rovs` assert), so it guards the change. - `cargo test -p victory-shader --locked --lib` — 248 passed, 0 failed, 3 ignored (the ignored ones are pre-existing). Code read: `root_view(.., uav=true)` now sets `flags::ROVS` and `0x2000` under POPS. This covers the `global_load` route, where `handle()` sees `props.0 == 11` without `0x1000` and so never adds the ROV bit itself. The `props.0 & !0x2000` mask in the root-descriptor match keeps the `0x100B` and `(Uav, 11)` arms matching. The non-POPS path is unchanged, and the test asserts `rovs == false` for it. No problems found. AI-assisted (Claude Code / Claude Sonnet 5.5)
Author
Owner

@⁠reeledMarek on GitHub · 2026-11-26 10:21 UTC · original

Moved pops_pixel_shader_lowers_root_uav_accesses_as_rovs into crates/victory-shader/src/emit/lower/pops_tests.rs (#[cfg(test)] mod pops_tests;) so lower.rs stays well below the 512 KiB asset-policy file size cap. Verified cargo test -p xtask --locked (6/6 passed) and Windows cross-clippy (-D warnings).

**@⁠reeledMarek** on GitHub · 2026-11-26 10:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/2490#issuecomment-7189252319) Moved `pops_pixel_shader_lowers_root_uav_accesses_as_rovs` into `crates/victory-shader/src/emit/lower/pops_tests.rs` (`#[cfg(test)] mod pops_tests;`) so `lower.rs` stays well below the 512 KiB asset-policy file size cap. Verified `cargo test -p xtask --locked` (6/6 passed) and Windows cross-clippy (`-D warnings`).
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2490/head:github-bot/gh-2490'
git switch 'github-bot/gh-2490'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2490'
git switch 'github-bot/gh-2490'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2490'
git switch 'github-bot/gh-2490'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2490'
git switch 'main'
git merge --squash 'github-bot/gh-2490'
git switch 'main'
git merge --ff-only 'github-bot/gh-2490'
git switch 'main'
git merge 'github-bot/gh-2490'
git push origin 'main'
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!2490
No description provided.