mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:50:52 +01:00
[PR #398] rdna2spirv: support VOP3 clamp on v_mad_u64_u32 and v_mad_i64_i32 (SHADER-MAD64-CLAMP) #449
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#449
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/398
Author: @tahffo68hk-hash
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:fix/shader-mad64-clamp📝 Commits (1)
44f9113rdna2spirv: support VOP3 clamp saturation on v_mad_u64_u32 and v_mad_i64_i32 (SHADER-MAD64-CLAMP)📊 Changes
3 files changed (+64 additions, -5 deletions)
View changed files
📝
docs/design.md(+1 -1)📝
tests/semantic/test_alu_mad64.py(+44 -2)📝
tools/rdna2spirv.py(+19 -2)📄 Description
Claimed in the coordination issue as:
SHADER-MAD64-CLAMPProblem
tools/rdna2spirv.pyrejectedv_mad_u64_u32andv_mad_i64_i32withUnsupportedwhenever VOP3clampwas set.On native AMD RDNA2 hardware (
gfx1036), VOP3clampsaturates the 64-bit destination pairv[d:d+1]to0xFFFFFFFFFFFFFFFF(forv_mad_u64_u32) or[0x8000000000000000, 0x7FFFFFFFFFFFFFFF](forv_mad_i64_i32), whilesdstcontinues to report the exact bit 64 (unsigned carry out / exact 65-bit sign).Fix
clampinv_mad_u64_u32/v_mad_i64_i32intools/rdna2spirv.py:(r_lo, r_hi)to(0xFFFFFFFF, 0xFFFFFFFF)whenbit64 != 0.bit64 != sr(exact 65-bit sign differs from wrapped sign) and saturate toINT64_MIN/INT64_MAXaccordingly.sdstreporting the unmodifiedbit64lane mask.Mad64Tests.test_clamp_saturation_preserves_sdstintests/semantic/test_alu_mad64.py(directed + randomized cases).docs/design.md.Verification
python -I tests/semantic/test_alu_mad64.py-> all tests OK.spirv-val):tools/hw_oracle-> 12 dwords across u64 overflow/exact-max and i64 positive/negative overflow +sdstbits.vk_compute_test.exe:spirv-valPASS)--wave64-emulate): 12/12 exact dwords (spirv-valPASS)中文翻译
在协调帖 #14 中认领的 ID:
SHADER-MAD64-CLAMP问题描述
tools/rdna2spirv.py在v_mad_u64_u32与v_mad_i64_i32携带 VOP3clamp修饰符时直接抛出Unsupported。经原生 AMD RDNA2(
gfx1036)硬件实测,VOP3clamp会将 64 位目标寄存器对v[d:d+1]饱和至0xFFFFFFFFFFFFFFFF(无符号)或[0x8000000000000000, 0x7FFFFFFFFFFFFFFF](有符号),同时sdst仍保持报告真实的第 64 位(无符号进位 / 精确 65 位符号位)。修复方案
tools/rdna2spirv.py中支持v_mad_u64_u32与v_mad_i64_i32的clamp饱和,同时保留sdst原始掩码输出。tests/semantic/test_alu_mad64.py中新增定向及随机回归测试(test_clamp_saturation_preserves_sdst)。docs/design.md契约表中记录硬件实测结论。验证结果
tests/semantic/test_alu_mad64.py全部通过。--wave64-emulate)12/12 精确一致,spirv-val全部通过。🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.