rdna2spirv: support VOP3 clamp on v_sad_* ops (SHADER-845) #275

Closed
kotekompotek wants to merge 1 commit from upstream-pr/275 into main
kotekompotek commented 2026-11-24 02:57:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kotekompotek on 2026-11-24T02:57:25Z.


Claimed in the coordination issue as: SHADER-845 (coordination issue #14)

What and why

  • Rebased onto current main and squashed into one clean commit.
  • Supported VOP3 clamp (unsigned 32-bit saturating addition via OpULessThan + OpSelect to 0xFFFFFFFF) across all five v_sad_* ops in tools/rdna2spirv.py.
  • Synced the v_sad_* row in docs/design.md (marking the VOP3 clamp rule as CPU-checked and hardware-unmeasured).

Tested

  • python -I tests/semantic/test_sad_clamp.py (2/2 OK), tests/semantic/test_alu_sad.py (5/5 OK), tests/semantic/test_alu_sad_u32.py (35/35 OK), tests/test_ci_registration.py (15/15 OK).

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5465225780 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/275). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-24T02:57:25Z. --- Claimed in the coordination issue as: SHADER-845 (coordination issue #14) ### What and why - Rebased onto current `main` and squashed into one clean commit. - Supported VOP3 `clamp` (unsigned 32-bit saturating addition via `OpULessThan` + `OpSelect` to `0xFFFFFFFF`) across all five `v_sad_*` ops in `tools/rdna2spirv.py`. - Synced the `v_sad_*` row in `docs/design.md` (marking the VOP3 clamp rule as CPU-checked and hardware-unmeasured). ### Tested - `python -I tests/semantic/test_sad_clamp.py` (`2/2 OK`), `tests/semantic/test_alu_sad.py` (`5/5 OK`), `tests/semantic/test_alu_sad_u32.py` (`35/35 OK`), `tests/test_ci_registration.py` (`15/15 OK`). GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
ubiquitarianism commented 2026-11-24 03:14:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ubiquitarianism on 2026-11-24T03:14:45Z.


Not merging. This changes a documented contract with no evidence of what the hardware does. The SAD row in docs/design.md says these ops wrap at 32 bits (hardware-verified on gfx1036), and that clamp raises Unsupported because the ISA pseudocode doesn't define it. The PR also rewrites the tests that pinned that rejection.

To change it, please measure clamp on RDNA2 with tools/int_hw_probe.py / hw_oracle, quote the result, and update the contract row. Please also drop the 'SHADER-845' reference, which doesn't exist in this repository. Until then, Unsupported is the correct behaviour.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7120908059 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/275#issuecomment-7120908059). Originally posted by [ubiquitarianism](https://github.com/ubiquitarianism) on 2026-11-24T03:14:45Z. --- Not merging. This changes a documented contract with no evidence of what the hardware does. The SAD row in `docs/design.md` says these ops wrap at 32 bits (hardware-verified on gfx1036), and that `clamp` raises `Unsupported` because the ISA pseudocode doesn't define it. The PR also rewrites the tests that pinned that rejection. To change it, please measure `clamp` on RDNA2 with `tools/int_hw_probe.py` / `hw_oracle`, quote the result, and update the contract row. Please also drop the 'SHADER-845' reference, which doesn't exist in this repository. Until then, `Unsupported` is the correct behaviour.
kotekompotek commented 2026-11-24 18:34:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kotekompotek on 2026-11-24T18:34:10Z.


@ubiquitarianism Thank you for the review and clear guidance. We do not have an RDNA2 (hw_oracle) GPU on our test host to measure sad clamp behavior empirically, so per the ruling that Unsupported remains the correct contract until measured (and dropping the SHADER-845 reference), closing this PR.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7140827725 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/275#issuecomment-7140827725). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-24T18:34:10Z. --- @ubiquitarianism Thank you for the review and clear guidance. We do not have an RDNA2 (`hw_oracle`) GPU on our test host to measure `sad` clamp behavior empirically, so per the ruling that `Unsupported` remains the correct contract until measured (and dropping the `SHADER-845` reference), closing this PR.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!275
No description provided.