tombox-xshader: decode and translate v_qsad_pk_u16_u8, v_mqsad_pk_u16_u8 and v_mqsad_u32_u8 #247
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!247
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/247/head"
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?
@azerioxfr on GitHub · 2026-11-23 07:21 UTC · original
azerioxfr:xshader-vop3-qsad-mqsad→main· +159 −1 · 4 files · 1 commits · closed without mergingLibrary / area: tombox-xshader, VOP3 multi-SAD ops (
hlsl.rsnext tov_sad_*/v_msad_u8)Exports changed (exports.txt rows): none
Source of the behaviour: opcodes from
tests/isa_table/gfx1013.txt(VOP3 0x172, 0x173, 0x175). Semantics from the RDNA2 ISA definitions. The masked form skips zero bytes of S1, as the existingv_msad_u8lowering does.One topic, +159 / -1: 2 lines in
rdna2/mnem.rs, 83 inhlsl.rs, the rest tests.What was missing
tests/isa_table.rslists these three under "vop3: gfx1013 opcodes not named by the decoder".The change
v_qsad_pk_u16_u8(0x172)v_mqsad_pk_u16_u8(0x173)v_mqsad_u32_u8(0x175)v_sad_u32/v_msad_u8do here.CLAMP on the two packed 16-bit forms is refused with an explicit error, because the hardware saturation width for the 16-bit fields is not established. Sources are copied to temporaries first, so a destination that overlaps a source reads the issue-time values.
Tests
--release, DXC 1.9.2609)sad_quad_packed(Rust reference model: cross-dword slices, zero reference bytes, 16-bit wrap, 32-bit wrap with CLAMP onv_mqsad_u32_u8)--test opcodes(translation rows + newpacked_multi_sad_refuses_clamp)--test isa_tableRun on
x86_64-pc-windows-gnu(no MSVC linker here). Integer only.cargo test -p tombox-xshader --test exec -- --exact sad_quad_packedpassesmissingwith a note@omonkeyz on GitHub · 2026-11-23 14:07 UTC · original
Applied locally on main with your authorship kept (cherry-picked,
74ea579); the tombox-xshader suite passes in a sandbox (exec 155/155 on WARP). It ships in the next release; this PR will be closed when that is pushed. Thanks.@SchmashinPrunes on GitHub · 2026-11-24 13:20 UTC · original
I recorded these three ops on RDNA2 silicon: a gfx1036 iGPU (Ryzen 5 9600X), ROCm/HIP 5.7.1, raw wave32 kernels. It's RDNA2, not the console's gfx1013.
sad4, with the zero-byte mask for themqsadforms). I did not run the PR's code.Results:
v_qsad_pk_u16_u8,v_mqsad_pk_u16_u8andv_mqsad_u32_u8without CLAMP match the model on all cases.v_mqsad_u32_u8with CLAMP matchest < c ? 0xffffffff : ton all cases, including 5,096 where the clamp changes the result.0xffff: field = min(SAD + acc16, 0xffff). That matched all 65,536 cases of each form, including 14,610 (qsad) and 13,895 (mqsad_pk) where the clamp changes the result. So the CLAMP path could be lowered withmin(..., 0xffffu)per field instead of refused, if you want it.(Measured with an AI assistant, Claude.)
@omonkeyz on GitHub · 2026-11-25 13:07 UTC · original
Applied on main in
74ea579(cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.Pull request closed