[PR #1778] [MERGED] rdna2spirv: apply src0 float modifiers after bound_ctrl zero selection (SHADER-DPP-NEG-BOUND-CTRL) #1793

Closed
opened 2026-11-26 21:18:58 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1778
Author: @abnalstlll-byte
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: feat/shader-dpp-neg-bound-ctrl


📝 Commits (3)

  • fb3552f rdna2spirv: apply src0 float modifiers after bound_ctrl zero selection (SHADER-DPP-NEG-BOUND-CTRL)
  • 3e729e8 docs/design.md: escape pipes in DPP table row and note gfx1101 measurement (SHADER-DPP-NEG-BOUND-CTRL)
  • 31e8ba5 docs/design.md: note RDNA2 not measured for DPP invalid-lane modifier rule (SHADER-DPP-NEG-BOUND-CTRL)

📊 Changes

3 files changed (+93 additions, -2 deletions)

View changed files

📝 docs/design.md (+1 -1)
➕ tests/semantic/test_dpp_bound_ctrl_modifiers.py (+87 -0)
📝 tools/rdna2spirv.py (+5 -1)

📄 Description

Claimed in the coordination issue as: SHADER-DPP-NEG-BOUND-CTRL (claim)

What and why

Implements the hardware measurement by @mcpeacebir-lang on AMD RDNA3 (RX 7800 XT, HW-DPP-NEG-INVALID-LANE, addressing @OreoFR's finding in Issue #1608):

"Result: on RDNA3 the hardware applies src0's neg after the bound_ctrl zero. An invalid source lane reads -0, not the +0 Gen.dpp_insn gives it on main. abs gives +0, as expected."

Previously, Gen.dpp_insn (tools/rdna2spirv.py:7353) evaluated src_val = self.src_u(src) before the shuffle and bound check under the assumption that "neg/abs are lane-uniform, so before or after the shuffle is the same". Then at line 7523, src0 = OpSelect %uint %src_ok %shuffled %zero selected %zero (0x00000000 / +0.0f) for invalid lanes (bound_ctrl:1 or DPP8 fi:0), which wiped out the float negation on invalid lanes and caused them to read +0.0f instead of -0.0f.

This fixes the ordering:

  1. Strips neg and abs from raw_src before evaluating src_val = self.src_u(raw_src) so the raw register bits are shuffled across lanes.
  2. Selects src0 = OpSelect %uint %src_ok %shuffled %zero.
  3. Calls src0 = self.modify(src0, src) after the zero selection, applying FAbs / OpFNegate to the selected result. An invalid lane reading 0.0f with neg becomes -0.0f (0x80000000), with abs becomes +0.0f (0x00000000), and with -|src0| becomes -0.0f.
  4. Documents the confirmed hardware behavior in docs/design.md.
  5. Adds semantic test fixture tests/semantic/test_dpp_bound_ctrl_modifiers.py verifying wave execution and SPIR-V instruction structure.

Tested

  • python -m unittest tests/semantic/test_dpp_bound_ctrl_modifiers.py: 2/2 tests pass (0.03s).
  • python -m unittest discover -s tests/semantic -p "*dpp*.py": 19/19 tests pass.
  • python -I tests/test_text_write_line_endings.py: 3/3 pass (clean line endings).
  • python -I scripts/check_no_game_data.py: clean (0 violations, no game data).

AI-assisted (Claude Code)


🔄 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/1778 **Author:** [@abnalstlll-byte](https://github.com/abnalstlll-byte) **Created:** 11/25/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `feat/shader-dpp-neg-bound-ctrl` --- ### 📝 Commits (3) - [`fb3552f`](https://github.com/ubiquitarianism/leonida/commit/fb3552fdde8d8e7a79fafa6a1d10eb9bf9746455) rdna2spirv: apply src0 float modifiers after bound_ctrl zero selection (SHADER-DPP-NEG-BOUND-CTRL) - [`3e729e8`](https://github.com/ubiquitarianism/leonida/commit/3e729e84c283eb26f8fcedec6219ad4f38b4b400) docs/design.md: escape pipes in DPP table row and note gfx1101 measurement (SHADER-DPP-NEG-BOUND-CTRL) - [`31e8ba5`](https://github.com/ubiquitarianism/leonida/commit/31e8ba5fbe0150eff6874a1db2c15deb0f140797) docs/design.md: note RDNA2 not measured for DPP invalid-lane modifier rule (SHADER-DPP-NEG-BOUND-CTRL) ### 📊 Changes **3 files changed** (+93 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) ➕ `tests/semantic/test_dpp_bound_ctrl_modifiers.py` (+87 -0) 📝 `tools/rdna2spirv.py` (+5 -1) </details> ### 📄 Description Claimed in the coordination issue as: SHADER-DPP-NEG-BOUND-CTRL ([claim](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161557331)) ### What and why Implements the hardware measurement by @mcpeacebir-lang on AMD RDNA3 (RX 7800 XT, `HW-DPP-NEG-INVALID-LANE`, addressing @OreoFR's finding in Issue #1608): > "Result: on RDNA3 the hardware applies src0's `neg` after the bound_ctrl zero. An invalid source lane reads -0, not the +0 `Gen.dpp_insn` gives it on `main`. `abs` gives +0, as expected." Previously, `Gen.dpp_insn` (`tools/rdna2spirv.py:7353`) evaluated `src_val = self.src_u(src)` before the shuffle and bound check under the assumption that *"neg/abs are lane-uniform, so before or after the shuffle is the same"*. Then at line 7523, `src0 = OpSelect %uint %src_ok %shuffled %zero` selected `%zero` (`0x00000000` / `+0.0f`) for invalid lanes (`bound_ctrl:1` or DPP8 `fi:0`), which wiped out the float negation on invalid lanes and caused them to read `+0.0f` instead of `-0.0f`. This fixes the ordering: 1. Strips `neg` and `abs` from `raw_src` before evaluating `src_val = self.src_u(raw_src)` so the raw register bits are shuffled across lanes. 2. Selects `src0 = OpSelect %uint %src_ok %shuffled %zero`. 3. Calls `src0 = self.modify(src0, src)` after the zero selection, applying `FAbs` / `OpFNegate` to the selected result. An invalid lane reading `0.0f` with `neg` becomes `-0.0f` (`0x80000000`), with `abs` becomes `+0.0f` (`0x00000000`), and with `-|src0|` becomes `-0.0f`. 4. Documents the confirmed hardware behavior in `docs/design.md`. 5. Adds semantic test fixture `tests/semantic/test_dpp_bound_ctrl_modifiers.py` verifying wave execution and SPIR-V instruction structure. ### Tested - `python -m unittest tests/semantic/test_dpp_bound_ctrl_modifiers.py`: 2/2 tests pass (0.03s). - `python -m unittest discover -s tests/semantic -p "*dpp*.py"`: 19/19 tests pass. - `python -I tests/test_text_write_line_endings.py`: 3/3 pass (clean line endings). - `python -I scripts/check_no_game_data.py`: clean (0 violations, no game data). AI-assisted (Claude Code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 21:18:58 +01:00
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#1793
No description provided.