Shaders: lower scalar quadmask instructions (port of VIctory#1443) #192

Open
github-bot wants to merge 2 commits from github-bot/gh-192 into main AGit
Owner

@⁠lcg007xd-c on GitHub · 2026-11-25 20:25 UTC · original
lcg007xd-c:port/vic-1443 → main · +74 −0 · 2 files · 2 commits · open

Port of Marvisak/VIctory#1443 by Luiz Otavio Mello de Campos. It is cherry-picked with -x, so the commit keeps its author and its upstream hash. This fork's main (000ffdd) does not have it, and it is not in #142.

What it fixes

s_quadmask_b32/s_quadmask_b64 were refused (the fork's own opcode audit lists them). They now lower: bit i of the result is set when any bit of quad i of the source is.

Tested (Linux, Rust 1.98.1)

  • The fork's opcode_audit::refused_opcodes reports both lowering with the port and refused without. Upstream's D3D12 test is included (Windows). opcode_refusals.txt was not edited; its two quadmask lines are now stale, which the audit allows.
  • cargo test -p victory-shader --lib on this branch alone: no failures.
  • It applies to main without conflicts, and does not depend on the other open ports.

Not run here: Windows/GPU tests, since I have no Windows machine.

🤖 Generated with Claude Code

**@⁠lcg007xd-c** on GitHub · 2026-11-25 20:25 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/192) `lcg007xd-c:port/vic-1443` → `main` · +74 −0 · 2 files · 2 commits · open Port of [Marvisak/VIctory#1443](https://github.com/Marvisak/VIctory/pull/1443) by Luiz Otavio Mello de Campos. It is cherry-picked with `-x`, so the commit keeps its author and its upstream hash. This fork's `main` (000ffdd) does not have it, and it is not in #142. ## What it fixes `s_quadmask_b32`/`s_quadmask_b64` were refused (the fork's own opcode audit lists them). They now lower: bit i of the result is set when any bit of quad i of the source is. ## Tested (Linux, Rust 1.98.1) - The fork's `opcode_audit::refused_opcodes` reports both lowering with the port and refused without. Upstream's D3D12 test is included (Windows). `opcode_refusals.txt` was not edited; its two quadmask lines are now stale, which the audit allows. - `cargo test -p victory-shader --lib` on this branch alone: no failures. - It applies to `main` without conflicts, and does not depend on the other open ports. **Not run here:** Windows/GPU tests, since I have no Windows machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Reduce each group of four bits to one bit and preserve the scalar condition code.

(cherry picked from commit c3a04e2e4164523f38ffceec23509a0ba4316856)

Conflict resolved against the fork's s_bcnt0/1_i32_b64 and s_cmov arms: the quadmask arms are added beside them.
Check both mask widths, the condition code and the zeroed upper destination.

(cherry picked from commit e3fe5bf94f848c2a6ca36900c2dfa70342083109)

Conflict resolved against the fork's data_only_structured_srv_reads_its_bound_record_count test: both tests kept.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:37:40 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-26 05:00 UTC · original

RDNA2 data point. This PR (871ebc4) merged on main 4f62c2a, cargo test --release -p victory-shader --lib on an RX 6950 XT (Windows 11 build 26300, Rust 1.98.1):

  • main: 275 passed, 2 failed.
  • This PR: 276 passed, 2 failed, in 2 runs out of 2. The new test passes.

The 2 failures are the same as on main: the RDNA2 wave-size tests scalar_counted_in_a_divergent_loop_read_after_it and scalar_counted_in_nested_divergent_loops, fixed by #110 and #204. No regression here. Not run in the game.

harness machine: rx6950xt-w11 | AMD Radeon RX 6950 XT (RDNA2), driver 32.0.21045.29003 | 32 GB RAM | Windows 11 build 26300

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-26 05:00 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/192#issuecomment-7183091321) RDNA2 data point. This PR (`871ebc4`) merged on `main` `4f62c2a`, `cargo test --release -p victory-shader --lib` on an RX 6950 XT (Windows 11 build 26300, Rust 1.98.1): - `main`: 275 passed, 2 failed. - This PR: 276 passed, 2 failed, in 2 runs out of 2. The new test passes. The 2 failures are the same as on `main`: the RDNA2 wave-size tests `scalar_counted_in_a_divergent_loop_read_after_it` and `scalar_counted_in_nested_divergent_loops`, fixed by #110 and #204. No regression here. Not run in the game. harness machine: rx6950xt-w11 | AMD Radeon RX 6950 XT (RDNA2), driver 32.0.21045.29003 | 32 GB RAM | Windows 11 build 26300 AI-assisted (Claude Code); no game data.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-26 19:45 UTC · original

Tested on Windows 11 with an RX 7900 XT (RDNA3, driver 32.0.32029.2010) and Rust 1.98.1. I merged 871ebc4 onto current main 4f62c2a. The merge is clean, because the two changed files are the same in 000ffdd and 4f62c2a.

Windows D3D12 test:

  • emit::valu_tests::scalar_quad_masks_pack_nibbles_and_set_scc passes on both the hardware adapter and WARP.
  • With only the test change applied to 4f62c2a, it fails with emit: Unsupported { offset: 48, what: "s_quadmask_b32" }.
  • cargo test -p victory-shader --lib -- --test-threads=1: 278 passed, 0 failed, 6 ignored. On 4f62c2a alone it is 277/0/6. The only difference is the new test.

Game shaders (whole shaders.rpf, translate --validate --host-lanes 32-64):

  • The disassembly has no s_quadmask_b32 or s_quadmask_b64 instructions.
  • The output is unchanged from 4f62c2a: 26084/26084 programs translated, the same 40,601,701 IR instructions, and all 25,623 emitted DXIL programs are byte-identical.
  • Every emitted program validates. The refusals are the same as on main: 195 "address in an SGPR that is no root parameter" and 71 "mesh outputs beyond the host's 32 KiB".

So the new lowering gives the expected values in the D3D12 test. It does not change any of this title's shaders.

Not tested: wave64 (the test program is wave32), other host-lane configs, and an in-game run.

**@⁠adrianmjim** on GitHub · 2026-11-26 19:45 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/192#issuecomment-7201922234) Tested on Windows 11 with an RX 7900 XT (RDNA3, driver 32.0.32029.2010) and Rust 1.98.1. I merged 871ebc4 onto current main 4f62c2a. The merge is clean, because the two changed files are the same in 000ffdd and 4f62c2a. Windows D3D12 test: - `emit::valu_tests::scalar_quad_masks_pack_nibbles_and_set_scc` passes on both the hardware adapter and WARP. - With only the test change applied to 4f62c2a, it fails with `emit: Unsupported { offset: 48, what: "s_quadmask_b32" }`. - `cargo test -p victory-shader --lib -- --test-threads=1`: 278 passed, 0 failed, 6 ignored. On 4f62c2a alone it is 277/0/6. The only difference is the new test. Game shaders (whole `shaders.rpf`, `translate --validate --host-lanes 32-64`): - The disassembly has no `s_quadmask_b32` or `s_quadmask_b64` instructions. - The output is unchanged from 4f62c2a: 26084/26084 programs translated, the same 40,601,701 IR instructions, and all 25,623 emitted DXIL programs are byte-identical. - Every emitted program validates. The refusals are the same as on main: 195 "address in an SGPR that is no root parameter" and 71 "mesh outputs beyond the host's 32 KiB". So the new lowering gives the expected values in the D3D12 test. It does not change any of this title's shaders. Not tested: wave64 (the test program is wave32), other host-lane configs, and an in-game run.
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/192/head:github-bot/gh-192'
git switch 'github-bot/gh-192'

Merge

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