[PR #422] rdna2spirv: accept VOP3P clamp as hardware no-op on packed 16-bit shifts (SHADER-PK-SHIFT-CLAMP) #473

Open
opened 2026-11-26 20:18:00 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/422
Author: @tahffo68hk-hash
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: fix/shader-pk-shift-clamp


📝 Commits (1)

  • 990e26b rdna2spirv: accept VOP3P clamp as hardware no-op on packed 16-bit shifts (SHADER-PK-SHIFT-CLAMP)

📊 Changes

3 files changed (+15 additions, -7 deletions)

View changed files

📝 docs/design.md (+1 -1)
📝 tests/semantic/test_valu_pk_shift_b16.py (+11 -3)
📝 tools/rdna2spirv.py (+3 -3)

📄 Description

Claimed in the coordination issue as: SHADER-PK-SHIFT-CLAMP

Problem

tools/rdna2spirv.py rejected v_pk_lshlrev_b16, v_pk_lshrrev_b16, and v_pk_ashrrev_i16 with Unsupported whenever VOP3P clamp was set.

Measured natively on AMD RDNA2 (gfx1036 via tools/hw_oracle): VOP3P clamp is a valid encoding and a hardware no-op on all three packed 16-bit shift instructions (each 16-bit half wraps without saturating, matching v_pk_mul_lo_u16 / v_pk_max_*16 / v_pk_min_*16).

Fix

  • Accept clamp as a hardware no-op on v_pk_lshlrev_b16, v_pk_lshrrev_b16, and v_pk_ashrrev_i16 in tools/rdna2spirv.py.
  • Update tests/semantic/test_valu_pk_shift_b16.py with test_clamp_is_hardware_noop covering all three opcodes.
  • Document the hardware-confirmed rule in docs/design.md.

Verification

  • CPU semantic tests: python -I tests/semantic/test_valu_pk_shift_b16.py -> OK.
  • Hardware differential verification (Native AMD RDNA2 vs. Translated Vulkan + spirv-val):
    • Native reference: AMD GFX1036 (RDNA2) via tools/hw_oracle -> 4 dwords across all 3 opcodes + op_sel/op_sel_hi with clamp.
    • Translated execution: NVIDIA GeForce RTX 5060 Ti (driver 617.42, Windows 11) via vk_compute_test.exe:
      • Wave32: 4/4 exact dwords (spirv-val PASS)
      • Wave64 (--wave64-emulate): 4/4 exact dwords (spirv-val PASS)
  • No game files used (synthetic assembly only).
  • AI-assisted: Yes (Antigravity).
中文翻译

在协调帖 #14 中认领的 ID:SHADER-PK-SHIFT-CLAMP

问题描述

tools/rdna2spirv.py 此前对携带 VOP3P clamp 的 v_pk_lshlrev_b16、v_pk_lshrrev_b16、v_pk_ashrrev_i16 抛出 Unsupported。

经原生 AMD RDNA2(gfx1036)实测确认,VOP3P clamp 在这三条打包 16 位移位指令上为合法编码且属于硬件空操作(各 16 位通道正常回绕不饱和)。

修复方案

  • 在 tools/rdna2spirv.py 中允许上述三条指令携带 clamp(按硬件空操作处理)。
  • 在 tests/semantic/test_valu_pk_shift_b16.py 中补充 test_clamp_is_hardware_noop 回归测试并更新 docs/design.md。

验证结果

  • CPU 语义测试:tests/semantic/test_valu_pk_shift_b16.py 全部通过。
  • 跨架构硬件差分验证(原生 AMD GFX1036 vs 翻译后 NVIDIA RTX 5060 Ti,驱动 617.42):Wave32 4/4 精确一致,Wave64 模拟(--wave64-emulate)4/4 精确一致,spirv-val 全部通过。
  • 仅使用手写合成汇编,无游戏文件。
  • AI 辅助:是(Antigravity)。

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/422 **Author:** [@tahffo68hk-hash](https://github.com/tahffo68hk-hash) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/shader-pk-shift-clamp` --- ### 📝 Commits (1) - [`990e26b`](https://github.com/ubiquitarianism/leonida/commit/990e26babda904a533312820d0953c3a84c4c643) rdna2spirv: accept VOP3P clamp as hardware no-op on packed 16-bit shifts (SHADER-PK-SHIFT-CLAMP) ### 📊 Changes **3 files changed** (+15 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) 📝 `tests/semantic/test_valu_pk_shift_b16.py` (+11 -3) 📝 `tools/rdna2spirv.py` (+3 -3) </details> ### 📄 Description Claimed in the coordination issue as: `SHADER-PK-SHIFT-CLAMP` ## Problem `tools/rdna2spirv.py` rejected `v_pk_lshlrev_b16`, `v_pk_lshrrev_b16`, and `v_pk_ashrrev_i16` with `Unsupported` whenever VOP3P `clamp` was set. Measured natively on AMD RDNA2 (`gfx1036` via `tools/hw_oracle`): VOP3P `clamp` is a valid encoding and a **hardware no-op** on all three packed 16-bit shift instructions (each 16-bit half wraps without saturating, matching `v_pk_mul_lo_u16` / `v_pk_max_*16` / `v_pk_min_*16`). ## Fix - Accept `clamp` as a hardware no-op on `v_pk_lshlrev_b16`, `v_pk_lshrrev_b16`, and `v_pk_ashrrev_i16` in `tools/rdna2spirv.py`. - Update `tests/semantic/test_valu_pk_shift_b16.py` with `test_clamp_is_hardware_noop` covering all three opcodes. - Document the hardware-confirmed rule in `docs/design.md`. ## Verification - **CPU semantic tests**: `python -I tests/semantic/test_valu_pk_shift_b16.py` -> OK. - **Hardware differential verification (Native AMD RDNA2 vs. Translated Vulkan + `spirv-val`)**: - Native reference: AMD GFX1036 (RDNA2) via `tools/hw_oracle` -> 4 dwords across all 3 opcodes + `op_sel`/`op_sel_hi` with `clamp`. - Translated execution: NVIDIA GeForce RTX 5060 Ti (driver 617.42, Windows 11) via `vk_compute_test.exe`: - Wave32: **4/4 exact dwords** (`spirv-val` PASS) - Wave64 (`--wave64-emulate`): **4/4 exact dwords** (`spirv-val` PASS) - No game files used (synthetic assembly only). - AI-assisted: Yes (Antigravity). <details> <summary>中文翻译</summary> 在协调帖 #14 中认领的 ID:`SHADER-PK-SHIFT-CLAMP` ## 问题描述 `tools/rdna2spirv.py` 此前对携带 VOP3P `clamp` 的 `v_pk_lshlrev_b16`、`v_pk_lshrrev_b16`、`v_pk_ashrrev_i16` 抛出 `Unsupported`。 经原生 AMD RDNA2(`gfx1036`)实测确认,VOP3P `clamp` 在这三条打包 16 位移位指令上为合法编码且属于硬件空操作(各 16 位通道正常回绕不饱和)。 ## 修复方案 - 在 `tools/rdna2spirv.py` 中允许上述三条指令携带 `clamp`(按硬件空操作处理)。 - 在 `tests/semantic/test_valu_pk_shift_b16.py` 中补充 `test_clamp_is_hardware_noop` 回归测试并更新 `docs/design.md`。 ## 验证结果 - CPU 语义测试:`tests/semantic/test_valu_pk_shift_b16.py` 全部通过。 - 跨架构硬件差分验证(原生 AMD GFX1036 vs 翻译后 NVIDIA RTX 5060 Ti,驱动 617.42):Wave32 **4/4 精确一致**,Wave64 模拟(`--wave64-emulate`)**4/4 精确一致**,`spirv-val` 全部通过。 - 仅使用手写合成汇编,无游戏文件。 - AI 辅助:是(Antigravity)。 </details> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#473
No description provided.