Shaders: lower s_sext_i32_i8 and s_sext_i32_i16 in pure 32-bit DXIL #2077

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

@⁠geiyiliyabumo on GitHub · 2026-11-25 04:24 UTC · original
geiyiliyabumo:feat/shader-s-sext → main · +83 −0 · 2 files · 1 commits · open

Summary

  • Lowers GFX10 SOP1 instructions s_sext_i32_i8 (opcode 0x19) and s_sext_i32_i16 (opcode 0x1a) in crates/victory-shader/src/emit/lower.rs using pure 32-bit DXIL (shl + ashr by 24/16), without enabling Int64 / WIDE_OPS and while preserving SCC.
  • Adds synthetic IR, DXIL-validation, and GPU execution tests in crates/victory-shader/src/emit/valu_tests.rs covering 10 boundary input vectors across both instructions with both SCC = 0 and SCC = 1, verifying single-dword operand/result widths and that Int64 is not set.

Verification

  • cargo xtask policy: passed
  • cargo clippy -p victory-shader --tests -- -D warnings: passed
  • cargo test -p victory-shader --lib s_sext_i32 with Microsoft dxil.dll: 2/2 passed on AMD Radeon RX 9060 XT (RDNA4) and Microsoft Basic Render Driver (WARP)
  • Zero game files or game-derived data used (synthetic tests only).
**@⁠geiyiliyabumo** on GitHub · 2026-11-25 04:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/2077) `geiyiliyabumo:feat/shader-s-sext` → `main` · +83 −0 · 2 files · 1 commits · open ## Summary - Lowers GFX10 SOP1 instructions `s_sext_i32_i8` (opcode `0x19`) and `s_sext_i32_i16` (opcode `0x1a`) in `crates/victory-shader/src/emit/lower.rs` using pure 32-bit DXIL (`shl` + `ashr` by 24/16), without enabling `Int64` / `WIDE_OPS` and while preserving `SCC`. - Adds synthetic IR, DXIL-validation, and GPU execution tests in `crates/victory-shader/src/emit/valu_tests.rs` covering 10 boundary input vectors across both instructions with both `SCC = 0` and `SCC = 1`, verifying single-dword operand/result widths and that `Int64` is not set. ## Verification - `cargo xtask policy`: passed - `cargo clippy -p victory-shader --tests -- -D warnings`: passed - `cargo test -p victory-shader --lib s_sext_i32` with Microsoft `dxil.dll`: 2/2 passed on **AMD Radeon RX 9060 XT (RDNA4)** and **Microsoft Basic Render Driver (WARP)** - Zero game files or game-derived data used (synthetic tests only).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:54:10 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-25 04:33 UTC · original

Triage verdict — Keep the focused sign extension and reconcile #120’s overlap (b92ae69)

Evidence

  • @⁠geiyiliyabumo’s patch and @⁠tedin7’s #120 use the same 32-bit shift pairs for the two sign-extension instructions and leave SCC unchanged. #120 separately implements absolute difference and three halfword packing instructions that current main still lacks. Current patch · #120 patch

Checks and limits

  • Both exact-head focused tests passed independently with the DXIL validator required. Hardware and WARP each ran the synthetic cases. The fixture checks the sign-extended value and SCC through separate shaders. @⁠n-romanovich’s earlier #142 has a useful combined result that keeps the arithmetic result live while checking SCC. Earlier test

Next step

  • Retain one sign-extension implementation and these boundary tests. If this lands first, remove only the two repeated arms when rebasing #120 and preserve its four independent operations.

This verification was AI-assisted.

**@⁠jeremygold02** on GitHub · 2026-11-25 04:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2077#issuecomment-7152945550) **Triage verdict — Keep the focused sign extension and reconcile #120’s overlap** (`b92ae69`) **Evidence** - @⁠geiyiliyabumo’s patch and @⁠tedin7’s #120 use the same 32-bit shift pairs for the two sign-extension instructions and leave SCC unchanged. #120 separately implements absolute difference and three halfword packing instructions that current `main` still lacks. [Current patch](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2077/files) · [#120 patch](https://git.gtahub.st/github/Marvisak--VIctory/pulls/120/files) **Checks and limits** - Both exact-head focused tests passed independently with the DXIL validator required. Hardware and WARP each ran the synthetic cases. The fixture checks the sign-extended value and SCC through separate shaders. @⁠n-romanovich’s earlier #142 has a useful combined result that keeps the arithmetic result live while checking SCC. [Earlier test](https://git.gtahub.st/github/Marvisak--VIctory/pulls/142/files) **Next step** - Retain one sign-extension implementation and these boundary tests. If this lands first, remove only the two repeated arms when rebasing #120 and preserve its four independent operations. This verification was AI-assisted.
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 04:41 UTC · original

Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at b92ae69. victory-shader: 246 passed, 3 failed, 3 ignored; the new s_sext_i32_has_single_dword_operands_and_preserves_scc_in_ir and s_sext_i32_lowers_without_int64_and_preserves_scc_on_gpu pass. The 3 failures are #1744's NVIDIA failures on main. Same as main on this hardware. Not run: a title.

AI-assisted (Claude Code).

**@⁠upipibi** on GitHub · 2026-11-25 04:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2077#issuecomment-7153077865) Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at `b92ae69`. `victory-shader`: 246 passed, 3 failed, 3 ignored; the new `s_sext_i32_has_single_dword_operands_and_preserves_scc_in_ir` and `s_sext_i32_lowers_without_int64_and_preserves_scc_on_gpu` pass. The 3 failures are #1744's NVIDIA failures on `main`. Same as `main` on this hardware. Not run: a title. AI-assisted (Claude Code).
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 09:14 UTC · original

Offline measurement on a retail dump

Result: no count change against main.

I merged head b92ae691 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-25 09:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/2077#issuecomment-7158054040) ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head b92ae691 onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:29 UTC · original

Automated triage for the maintainers.

This lowers s_sext_i32_i8 and s_sext_i32_i16 in Lower::sop (crates/victory-shader/src/emit/lower.rs) as shl followed by ashr by 24 or 16. That matches the GFX10 ISA: the low byte or halfword is sign-extended and SCC is not written. Main already decodes both opcodes (0x19 and 0x1a in gfx10/opcodes.rs) but did not lower them. The new tests check operand widths and SCC flow in the IR, that the shader does not use the Int64 feature, and boundary values on the GPU and WARP. CI passes.

This overlaps two arms of #120, which needs a rebase and only checks that lowering succeeds. If this merges first, #120 should drop those two arms. One retail census in the comments found no change in validated counts, so the title's benefit is not yet shown.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 10:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/2077#issuecomment-7159766645) <!-- victory-triage v1 head=b92ae69133a0630d4833aef7c0379bef68991cd6 verdict=merge-candidate at=2026-11-25T10:29:21Z --> Automated triage for the maintainers. This lowers `s_sext_i32_i8` and `s_sext_i32_i16` in `Lower::sop` (`crates/victory-shader/src/emit/lower.rs`) as `shl` followed by `ashr` by 24 or 16. That matches the GFX10 ISA: the low byte or halfword is sign-extended and SCC is not written. Main already decodes both opcodes (0x19 and 0x1a in `gfx10/opcodes.rs`) but did not lower them. The new tests check operand widths and SCC flow in the IR, that the shader does not use the Int64 feature, and boundary values on the GPU and WARP. CI passes. This overlaps two arms of #120, which needs a rebase and only checks that lowering succeeds. If this merges first, #120 should drop those two arms. One retail census in the comments found no change in validated counts, so the title's benefit is not yet shown. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 01:42 UTC · original

Code review and RTX 5090 + WARP + DXIL verification at head b92ae69133a0 merged cleanly onto main (63bcca43c6a0; emit/lower.rs = 520,887 B, 3,401 B under the 512 KiB cap):

  • Code review (crates/victory-shader/src/emit/lower.rs:3995-4000):
    • Pure 32-bit Shl(a, 24/16) followed by AShr(..., 24/16) cleanly masks dirty upper bits and sign-extends low 8/16-bit values without touching SCC or requiring Int64.
  • Verified (Windows 11, NVIDIA RTX 5090 + WARP, dxil.dll 10.0.26100.0, VICTORY_D3D12_DEBUG=1, Rust 1.98.1):
    • cargo xtask policy: 191 files ok; cargo clippy (default + --features diagnostics): 0 warnings
    • s_sext_i32 (2/2), emit::lower::tests (33/33), and emit::semantics_tests (34/34 on both RTX 5090 and WARP, 1 ignored) all passed.

LGTM.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 01:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2077#issuecomment-7180047724) Code review and RTX 5090 + WARP + DXIL verification at head `b92ae69133a0` merged cleanly onto `main` (`63bcca43c6a0`; `emit/lower.rs` = `520,887` B, `3,401` B under the 512 KiB cap): - **Code review (`crates/victory-shader/src/emit/lower.rs:3995-4000`)**: - Pure 32-bit `Shl(a, 24/16)` followed by `AShr(..., 24/16)` cleanly masks dirty upper bits and sign-extends low 8/16-bit values without touching `SCC` or requiring `Int64`. - **Verified (Windows 11, NVIDIA RTX 5090 + WARP, `dxil.dll` 10.0.26100.0, `VICTORY_D3D12_DEBUG=1`, Rust 1.98.1)**: - `cargo xtask policy`: `191 files ok`; `cargo clippy` (default + `--features diagnostics`): 0 warnings - `s_sext_i32` (2/2), `emit::lower::tests` (33/33), and `emit::semantics_tests` (34/34 on both RTX 5090 and WARP, 1 ignored) all passed. LGTM.
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/2077/head:github-bot/gh-2077'
git switch 'github-bot/gh-2077'

Merge

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