Shaders: lower s_absdiff_i32, s_sext_i32_i8/i16 and s_pack_ll/lh/hh_b32_b16 #120
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/120"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by tedin7 on 2026-11-24T00:40:48Z.
What
s_absdiff_i32(|a - b| of the wrapped difference, SCC = result != 0),s_sext_i32_i8,s_sext_i32_i16, ands_pack_ll_b32_b16,s_pack_lh_b32_b16,s_pack_hh_b32_b16(halves picked as in the GFX10 ISA).Why
sop()rejected them, so any shader using one failed to translate withUnsupported.Tested
cargo test -j4 -p victory-shader scalar_packwith the lowering disabled (test only): fails withUnsupported { offset: 16, what: "s_absdiff_i32" }.cargo test -j4 -p victory-shaderafter the change: 56 passed (origin/main237f2e8), 0 failed (the new test included).cargo clippy -j4 -p victory-shader --tests: no new warnings (existing: dead_codeconstant_colorin emit/mod.rs, a boolean-simplification note in resource.rs).rustfmt --edition 2024 --checkon lower.rs: clean.lowers()helper in the tests module.Imported from Marvisak/VIctory. Originally posted by lordon1a on 2026-11-24T00:51:43Z.
Verified
cb40cdcc2on Windows 11 (x86_64-pc-windows-gnullvm,rustc 1.100.0, applied cleanly tomain@4c0bb89): pass.cargo xtask policy: 151 files okcargo test -p victory-shader -- --skip v_med3_f32_matches_rdna2_with_nan: 69 passed, 0 failed (skipped the pre-existingmainIntel Iris Xemed3failure tracked in #110).AI-assisted.
Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T01:10:04Z.
Tested
cb40cdcon Arch Linux x86_64, rustc 1.98.1: pass.cargo test -p victory-shader: 56 passed, 0 failed (2 test binaries), including the 1 test this PR adds.s_absdiff_i32/s_sext_i32_i8/i16/s_pack_*, and is open; one of the two should be closed.victory-gpuE0425.Imported from Marvisak/VIctory. Originally posted by Lyrnc on 2026-11-24T06:26:44Z.
RDNA2 hardware check of the new scalar instructions: all match, including
s_absdiff_i32on the wrapped difference.Setup. AMD Radeon iGPU of a Ryzen 7 9800X3D, gfx1036 (RDNA2), AMD driver 32.0.21042.62, Windows 11 Pro 26200. Hand-written instructions in a HIP kernel (assembled by the AMD driver's amd_comgr). RDNA2 desktop silicon, not the console's. No game data. 141 operand pairs: all pairs of
0, 1, 2, 0x7fffffff, 0x80000000, 0xffffffff, 0x40000000, 0xc0000000, 0x12345678, plus 60 random. SCC was read right after each instruction.s_absdiff_i32:|a - b|of the difference wrapped to 32 bits, SCC = result != 0: 141/141. For example,|1 - 0x80000000|gives0x7fffffff(not0x80000001), and|0 - 0x80000000|gives0x80000000, as your lowering computes.s_pack_ll_b32_b16,s_pack_lh_b32_b16,s_pack_hh_b32_b16:{lo/hi(src1), lo/hi(src0)}: 141/141 each.s_sext_i32_i8/s_sext_i32_i16, measured for #142: sign extension, SCC unchanged.AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run.
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T09:37:30Z.
Review: APPROVED
Tested
cb40cdcon Windows 11, RTX 5070, MSVC: the workspace passes (186 outsidevictory-shader;victory-shader --libsingle-threaded: 69).victory translate <title exe> --validate --pipelinesgives the same counts before and after: 12 of 12 programs emitted, 12 validated, 12 pipelines.Checked against the GFX10 ISA:
s_absdiff_i32:|a − b|of the wrapping difference, with SCC = result ≠ 0.s_sext_i32_i8/i16: shift left, then arithmetic shift right.s_pack_llgives{b.lo, a.lo},s_pack_lhgives{b.hi, a.lo}, ands_pack_hhgives{b.hi, a.hi}, written high:low.SCC is only written where the decoder says the instruction writes it (
inst.write(Reg::Scc)), so sext and pack correctly leave SCC alone.No issues found.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by alexdeliu on 2026-11-24T17:22:44Z.
Merged onto
main@ffe310eb, this PR (cb40cdcc) no longer compiles its tests.crates/victory-shader/src/emit/lower.rs:7391calls thelowers(&words)test helper. Since25b0f888it islowers(words, rsrc2); main's tests pass0.Checked with CI's steps (both clippy runs with
-D warnings,cargo test --workspace) on Windows 11, AMD RX 9070. Every open PR: https://gist.github.com/alexdeliu/ef9ef0ebc1776ff104b5aa8eaea18e87Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:25:14Z.
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-shader/src/emit/lower.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.