Shaders: lower RDNA2 POPS pixel shaders as ROVs #158

Open
IAmTheSween wants to merge 1 commit from upstream-pr/158 into main
IAmTheSween commented 2026-11-25 16:13:06 +00:00 (Migrated from github.com)
First-time contributor

Imported from Zettrox/ztrx. Originally posted by IAmTheSween on 2026-11-25T16:02:35Z.


Lowers RDNA2 POPS (Primitive Ordered Pixel Shading) wait sections in pixel shaders to host DXIL Rasterizer Ordered Views (IsROV).

What is in it

  • In crates/victory-shader/src/emit/lower.rs:
    • Detect pixel shaders with s_sendmsg MSG_ORDERED_PS_DONE (imm & 0xF == 7) and locate the entry SGPR reaching s_setreg_b32 hwreg(HW_REG_POPS_PACKER, ...) (find_pops_sgpr).
    • Provide 0 for that POPS wave-overlap SGPR and for src_pops_exiting_wave_id (Operand::Const(239)) in POPS pixel shaders so the RDNA2 POPS conflict check resolves as non-blocking (bit 31 clear) and leaves other shaders' "a hardware SGPR input" / special-operand checks untouched.
    • Annotate UAV image handles in POPS pixel shaders with IsROV (0x2000) so the host GPU enforces pixel-order mutual exclusion in hardware.
  • Added pops_pixel_wait_lowers_and_validates in crates/victory-shader/src/emit/mod.rs verifying both that non-POPS shaders still reject unknown hardware SGPR inputs and that POPS pixel shaders lower and validate via dxil.dll.

Tested

  • Windows 11 x64, NVIDIA GeForce RTX 5070, Windows SDK dxil.dll 10.0.26100.0:
    • cargo test -p victory-shader --locked --lib pops_pixel_wait: 1 passed, 0 failed.
    • cargo clippy --workspace --all-targets --locked -- -D warnings: 0 warnings.
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: 0 warnings.
    • cargo test --workspace --locked -- --test-threads=1 (--test-threads=1 due to WARP contention documented in valu_tests.rs:198): 497 passed, 0 failed, 7 ignored (4 in victory_formats, 1 in victory_gpu, 2 in victory_shader).
    • victory --release translate --validate on shaders.rpf: 0 remaining emit: a hardware SGPR input errors across all 26,084 programs (all 10 PS_PedTexturedCutOutTint_Zero shaders now emit and pass dxil.dll validation: 14166 emitted, 14055 validated of 14247 VP programs, up from 14156 emitted, 14045 validated on main); also verified D3D12 PSO creation on #aafcf40b30b9df18 and #09cee52e3ebbdf51.

AI use

Written with Antigravity.

<!-- greyfinch-sync:Zettrox/ztrx:issue:6608503412 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/158). Originally posted by [IAmTheSween](https://github.com/IAmTheSween) on 2026-11-25T16:02:35Z. --- Lowers RDNA2 POPS (Primitive Ordered Pixel Shading) wait sections in pixel shaders to host DXIL Rasterizer Ordered Views (`IsROV`). ### What is in it - In `crates/victory-shader/src/emit/lower.rs`: - Detect pixel shaders with `s_sendmsg` `MSG_ORDERED_PS_DONE` (`imm & 0xF == 7`) and locate the entry SGPR reaching `s_setreg_b32 hwreg(HW_REG_POPS_PACKER, ...)` (`find_pops_sgpr`). - Provide `0` for that POPS wave-overlap SGPR and for `src_pops_exiting_wave_id` (`Operand::Const(239)`) in POPS pixel shaders so the RDNA2 POPS conflict check resolves as non-blocking (bit 31 clear) and leaves other shaders' `"a hardware SGPR input"` / special-operand checks untouched. - Annotate UAV image handles in POPS pixel shaders with `IsROV` (`0x2000`) so the host GPU enforces pixel-order mutual exclusion in hardware. - Added `pops_pixel_wait_lowers_and_validates` in `crates/victory-shader/src/emit/mod.rs` verifying both that non-POPS shaders still reject unknown hardware SGPR inputs and that POPS pixel shaders lower and validate via `dxil.dll`. ### Tested - Windows 11 x64, NVIDIA GeForce RTX 5070, Windows SDK `dxil.dll` `10.0.26100.0`: - `cargo test -p victory-shader --locked --lib pops_pixel_wait`: 1 passed, 0 failed. - `cargo clippy --workspace --all-targets --locked -- -D warnings`: 0 warnings. - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: 0 warnings. - `cargo test --workspace --locked -- --test-threads=1` (`--test-threads=1` due to WARP contention documented in `valu_tests.rs:198`): 497 passed, 0 failed, 7 ignored (4 in `victory_formats`, 1 in `victory_gpu`, 2 in `victory_shader`). - `victory --release translate --validate` on `shaders.rpf`: 0 remaining `emit: a hardware SGPR input` errors across all 26,084 programs (all 10 `PS_PedTexturedCutOutTint_Zero` shaders now emit and pass `dxil.dll` validation: `14166 emitted`, `14055 validated` of `14247` VP programs, up from `14156 emitted`, `14045 validated` on `main`); also verified D3D12 PSO creation on `#aafcf40b30b9df18` and `#09cee52e3ebbdf51`. ### AI use Written with Antigravity.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/158:upstream-pr/158'
git switch 'upstream-pr/158'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/158'
git switch 'upstream-pr/158'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/158'
git switch 'upstream-pr/158'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/158'
git switch 'main'
git merge --squash 'upstream-pr/158'
git switch 'main'
git merge --ff-only 'upstream-pr/158'
git switch 'main'
git merge 'upstream-pr/158'
git push origin 'main'
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
Zettrox/ztrx!158
No description provided.