mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:55:52 +01:00
[PR #399] [CLOSED] rdna2spirv: support VOP3 clamp across the SAD/QSAD/MQSAD family with gfx1036 hardware evidence (SHADER-QSAD-CLAMP) #451
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#451
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/399
Author: @tahffo68hk-hash
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:fix/shader-qsad-clamp📝 Commits (1)
d740bdfrdna2spirv: support VOP3 clamp saturation on v_qsad_pk_u16_u8, v_mqsad_pk_u16_u8, and v_mqsad_u32_u8 (SHADER-QSAD-CLAMP)📊 Changes
4 files changed (+73 additions, -23 deletions)
View changed files
📝
docs/design.md(+1 -1)📝
tests/semantic/test_alu_mqsad_u32.py(+28 -8)📝
tests/semantic/test_alu_qsad.py(+17 -3)📝
tools/rdna2spirv.py(+27 -11)📄 Description
Claimed in the coordination issue as:
SHADER-QSAD-CLAMPProblem
tools/rdna2spirv.pyrejectedv_qsad_pk_u16_u8,v_mqsad_pk_u16_u8, andv_mqsad_u32_u8withUnsupportedwhenever VOP3clampwas set.On native AMD RDNA2 hardware (
gfx1036), VOP3clampsaturates each packed output lane independently:v_qsad_pk_u16_u8/v_mqsad_pk_u16_u8: each of the four 16-bit lanes saturates to[0, 0xFFFF].v_mqsad_u32_u8: each of the four 32-bit lanes saturates to[0, 0xFFFFFFFF].(Note:
v_sad_*/v_msad_u8are intentionally untouched so this PR does not overlap with #275.)Fix
tools/rdna2spirv.py:v_qsad_pk_u16_u8andv_mqsad_pk_u16_u8withclamp, saturate each 16-bit lane withUMin total 0xFFFFinstead of masking& 0xFFFF.v_mqsad_u32_u8withclamp, accumulate the four masked byte-diffs (at most1020) and add toaccs[k]viaOpIAddCarry, selecting0xFFFFFFFFon carry.clamptests intests/semantic/test_alu_qsad.pyandtests/semantic/test_alu_mqsad_u32.pyto verify saturating, boundary, and non-saturating lanes across all three opcodes.docs/design.md.Verification
python -I tests/semantic/test_alu_qsad.py-> 6/6 OKpython -I tests/semantic/test_alu_mqsad_u32.py-> 29/29 OKspirv-val):tools/hw_oracle-> 8 dwords across all three opcodes (v_qsad_pk_u16_u8,v_mqsad_pk_u16_u8,v_mqsad_u32_u8).vk_compute_test.exe:spirv-valPASS)--wave64-emulate): 8/8 exact dwords (spirv-valPASS)中文翻译
在协调帖 #14 中认领的 ID:
SHADER-QSAD-CLAMP问题描述
tools/rdna2spirv.py在v_qsad_pk_u16_u8、v_mqsad_pk_u16_u8和v_mqsad_u32_u8携带 VOP3clamp修饰符时直接抛出Unsupported。经原生 AMD RDNA2(
gfx1036)硬件实测,VOP3clamp会对每个打包通道独立饱和:v_qsad_pk_u16_u8/v_mqsad_pk_u16_u8:4 个 16 位通道各自饱和至[0, 0xFFFF]。v_mqsad_u32_u8:4 个 32 位通道各自饱和至[0, 0xFFFFFFFF]。(注:未改动
v_sad_*/v_msad_u8,避免与 #275 冲突。)修复方案
tools/rdna2spirv.py中对上述三条指令实现基于硬件实测的clamp饱和逻辑(16 位UMin 0xFFFF与 32 位OpIAddCarry饱和)。tests/semantic/test_alu_qsad.py与tests/semantic/test_alu_mqsad_u32.py中的clamp回归测试。docs/design.md契约表中记录硬件实测结论。验证结果
test_alu_qsad.py(6/6)与test_alu_mqsad_u32.py(29/29)全部通过。--wave64-emulate)8/8 精确一致,spirv-val全部通过。🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.