shader: allow raw root SRV without UsedResource entry #576

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

@⁠tarcisioads on GitHub · 2026-11-28 05:39 UTC · original
tarcisioads:vibe/raw-root-srv-none → main · +92 −2 · 2 files · 1 commits · open

Closes #575

Summary

  • Allow None for ResourceType on raw root SRVs ((RootType::Descriptor, Some(ResourceType::Srv) | None, 11)) in crates/victory-shader/src/emit/lower.rs, matching raw root UAVs (0x100B) and root CBVs (13).
  • Add raw_root_srv_without_used_resource_lowers in crates/victory-shader/src/emit/memory_tests.rs.

How it was tested

  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings (passed, 0 warnings)
  • cargo test -j6 -p victory-shader (420 unit + 5 sweep passed, 0 failed)
  • cargo xtask policy (404 files ok)

Checklist

  • Nothing from the game is in the diff (cargo xtask policy passes)
  • Unit test added that fails without the fix
  • Windows clippy gate (x86_64-pc-windows-gnullvm)
**@⁠tarcisioads** on GitHub · 2026-11-28 05:39 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/572) `tarcisioads:vibe/raw-root-srv-none` → `main` · +92 −2 · 2 files · 1 commits · open Closes #575 ### Summary - Allow `None` for `ResourceType` on raw root SRVs (`(RootType::Descriptor, Some(ResourceType::Srv) | None, 11)`) in `crates/victory-shader/src/emit/lower.rs`, matching raw root UAVs (`0x100B`) and root CBVs (`13`). - Add `raw_root_srv_without_used_resource_lowers` in `crates/victory-shader/src/emit/memory_tests.rs`. ### How it was tested - `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` (passed, 0 warnings) - `cargo test -j6 -p victory-shader` (420 unit + 5 sweep passed, 0 failed) - `cargo xtask policy` (404 files ok) ### Checklist - [x] Nothing from the game is in the diff (`cargo xtask policy` passes) - [x] Unit test added that fails without the fix - [x] Windows clippy gate (`x86_64-pc-windows-gnullvm`)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 05:41:21 +00:00
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 17:07 UTC · original · approved these changes

Read the diff: the raw root SRV arm (resource type 11) now accepts None for ResourceType, matching the raw root UAV (0x100B) and root CBV (13) arms right above it — consistent widening, no behavior change for existing Some(Srv) cases. The new test lives in memory_tests.rs, which is cfg(all(test, windows)) like its neighbours, so it runs on Windows CI; verified the whole workspace compiles warning-free there: cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings clean on the head, and cargo test -p victory-shader --lib builds and passes on macOS. Approving.

**@⁠AnastasisKon** on GitHub · 2026-11-28 17:07 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/572#pullrequestreview-6099190311) · **approved these changes** Read the diff: the raw root SRV arm (resource type 11) now accepts `None` for `ResourceType`, matching the raw root UAV (`0x100B`) and root CBV (`13`) arms right above it — consistent widening, no behavior change for existing `Some(Srv)` cases. The new test lives in `memory_tests.rs`, which is `cfg(all(test, windows))` like its neighbours, so it runs on Windows CI; verified the whole workspace compiles warning-free there: `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` clean on the head, and `cargo test -p victory-shader --lib` builds and passes on macOS. Approving.
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 18:16 UTC · original

Heads-up on the test in this pull request: emit::memory_tests::raw_root_srv_without_used_resource_lowers fails on the Windows gate, and cannot pass as written.

memory_tests is #[cfg(all(test, windows))], so cargo test -p victory-shader on a Mac never runs it. Its program is a compute shader, and Lower::lower sets root_memory false for HwStage::Cs unless the program reads title memory, so a RootType::Descriptor with no UsedResource entry takes Lower::root_view (the host's view of the copy, through ROOT_SRV_VIEW / ROOT_VIEW_OFFSET in the root's user data) and root_srvs stays empty — hence left: [], right: [2]. The raw root SRV binding is taken only in a program that reads title memory. The | None change itself is fine: without it the load lowers to Val::Missing and reads 0.

The behaviour needs no host, so it can be pinned in a module that runs everywhere (gfx_refusal_tests does this for other lowering claims): assert the user-data dwords for the view route ((10, ROOT_SRV_VIEW), (11, ROOT_VIEW_OFFSET)) and, with a pixel program that reads title memory, the root address ((10, 0), (11, 1) with memory true). That fails with | None reverted (left: []), so it still pins this change. I have that version on a branch in the fork this was landed from; happy to hand it over if you would rather keep the fix here.

**@⁠AnastasisKon** on GitHub · 2026-11-28 18:16 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/572#issuecomment-7243661444) Heads-up on the test in this pull request: `emit::memory_tests::raw_root_srv_without_used_resource_lowers` fails on the Windows gate, and cannot pass as written. `memory_tests` is `#[cfg(all(test, windows))]`, so `cargo test -p victory-shader` on a Mac never runs it. Its program is a compute shader, and `Lower::lower` sets `root_memory` false for `HwStage::Cs` unless the program reads title memory, so a `RootType::Descriptor` with no `UsedResource` entry takes `Lower::root_view` (the host's view of the copy, through `ROOT_SRV_VIEW` / `ROOT_VIEW_OFFSET` in the root's user data) and `root_srvs` stays empty — hence `left: []`, `right: [2]`. The raw root SRV binding is taken only in a program that reads title memory. The `| None` change itself is fine: without it the load lowers to `Val::Missing` and reads 0. The behaviour needs no host, so it can be pinned in a module that runs everywhere (`gfx_refusal_tests` does this for other lowering claims): assert the user-data dwords for the view route (`(10, ROOT_SRV_VIEW)`, `(11, ROOT_VIEW_OFFSET)`) and, with a pixel program that reads title memory, the root address (`(10, 0)`, `(11, 1)` with `memory` true). That fails with `| None` reverted (`left: []`), so it still pins this change. I have that version on a branch in the fork this was landed from; happy to hand it over if you would rather keep the fix here.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/576/head:github-bot/gh-572'
git switch 'github-bot/gh-572'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-572'
git switch 'github-bot/gh-572'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-572'
git switch 'github-bot/gh-572'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-572'
git switch 'main'
git merge --squash 'github-bot/gh-572'
git switch 'main'
git merge --ff-only 'github-bot/gh-572'
git switch 'main'
git merge 'github-bot/gh-572'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.