RDNA2 771/779: s_bfe and v_cvt_(pk)norm references confirmed on RDNA2 hardware #78

Closed
github-bot wants to merge 1 commit from gh-pr/78/head into gh-pr/78/base
Owner

@⁠SchmashinPrunes on GitHub · 2026-11-22 00:40 UTC · original
SchmashinPrunes:rdna2-hw-refs → main · +956 −28 · 12 files · 96 commits · closed without merging

@⁠omonkeyz, this closes the two "RDNA2 instructions held at yellow" entries in BLOCKERS with measurements from real RDNA2 hardware. It also explains why the RDNA2 map can't honestly reach 100%.

Library / area: tombox-xshader tests (ISA sweep) and the progress data. No translator change.

Exports changed (exports.txt rows): none

Source of the behaviour: results recorded on RDNA2 silicon, the gfx1036 iGPU of a Ryzen 5 9600X (Linux Mint, ROCm/HIP 5.7.1). They came from the sbfe and norm probes of tools/rdna2-hwprobe/valu_probe.py (#72 by @⁠QuentinDanblon), posted in #41. No game or console files are involved.

Scope: gfx1036 is RDNA2 but not the console's GPU (gfx1013), so "confirmed on silicon" here means RDNA2 hardware (gfx1036), not a console measurement.

Dependency: the Rust test is self-contained and runs on main as is. Only the generator tools/rdna2-hwprobe/sweep_vectors.py needs valu_probe.py, which arrives with #72 (stacked on #41), so it can't run until those land.

Why these were held

BLOCKERS held s_bfe_* (the width ≥ 32 rule) and v_cvt_norm / v_cvt_pknorm (the rounding) because neither rule had been confirmed on silicon. The sweep already passes all 10 mnemonics on WARP against its reference models ops_s::bfe64 and ops_v::norm16. What was missing was evidence that those models match hardware. This PR adds it.

What RDNA2 does

  • s_bfe_{u,i}{32,64}: the width is the full 7-bit field. A signed field that reaches the top bit sign-fills. Junk in the unused S1 bits is ignored. SCC = result != 0. All 152 measured cases match bfe64, which is the translator's behaviour since 8491769.
  • v_cvt_norm_* / v_cvt_pknorm_*: the exact value rounded to nearest, and NaN gives 0. The only exact ties are ±0.5, where ties-to-even and ties-away agree. v_cvt_norm_* keeps the upper half of D. This matches norm16 (and so tb_nrm) everywhere.

Change

  • tests/isa_sweep/rdna2_hw.rs: the hardware record, generated by tools/rdna2-hwprobe/sweep_vectors.py:
    • all 152 s_bfe cases as literals;
    • for the four f16 conversions, an FNV-1a digest over all 65,536 f16 inputs, whose inputs the test regenerates, plus 54 literal edge inputs;
    • for the f32 pknorm forms, a digest over the sweep's 26×26 NRM_F32 edge grid plus 512 literal random pairs.
  • tests/isa_sweep.rs: a new CPU-only test, sweep_references_match_rdna2, checks bfe64 / norm16 against the record. bfe64 and NRM_F32 become pub for it.
  • progress.json: s_bfe_i32 / s_bfe_u32 join rdna2_verified (the other 8 held mnemonics were already listed there), and rdna2_pending is empty. The two BLOCKERS entries are marked DONE.
  • gen.py: RDNA2 769/779 → 771/779. No other generated value changes.

Tests (Windows 11, WARP, on 9ab754c; rebased onto 4cb7a54, generated files regenerated)

cargo test -p tombox-xshader --release --test isa_sweep -- --nocapture
sweep references vs RDNA2: 152 s_bfe cases, 4 f16 digests (54 literal inputs), 2 f32 grid digests, 512 f32 literal inputs; 0 mismatches
isa_sweep on WARP: 541 mnemonics, 531 pass, 0 fail, 10 known WARP deviations, 28 skipped
test result: ok. 3 passed; 0 failed

Mutation check: each of these planted model changes makes the new test fail:

  • zero-fill past the top bit: 26 mismatches;
  • width taken modulo the operand size: 52;
  • truncate: 590;
  • round half up: 6;
  • NaN → 1: 18;
  • u16 not clamped at 0: 432.

Why 100% isn't reachable

After this PR, 8 of 779 squares are left, and none of them can honestly turn green:

  • ds_gws_* (6): a wave blocks until other thread groups release a semaphore or reach a barrier. D3D12 has no cross-group blocking primitive and no forward-progress guarantee for spin waits, so any lowering could hang or would only appear to work.
  • ds_ordered_count: counts in wave-launch order, which D3D12 doesn't expose. Atomics give unique slots, not ordered ones.
  • s_sendmsghalt: halts the wave until a debugger or trap handler resumes it, which is a GPU hang on a console. Translating it as "end the wave" would be fake success.

No title shader uses any of them, and these are the refusals you already documented in BLOCKERS. Hardware measurements can't change that, because the gap is what D3D12 can express, not a missing description of RDNA2. Unless you count a documented refusal as "done", 771/779 is the honest ceiling. If you'd like the map to show that, for example a separate "unsupported by design" state, I'm happy to send it as a follow-up.

  • #70 (@⁠QuentinDanblon) fixes the stale s_bfe expected values in vop::basic::salu_basic / scalar_sop2, which still fail on main. It's independent of this PR, so no file overlap.

  • #38 touches the same instructions in other files. Its translator change is already on main.

  • cargo test -p tombox-xshader --release --test isa_sweep passes (the 10 known WARP deviations are the existing WARP_KNOWN list)

  • No game or console files and no binaries included

  • No fake success: the 8 refusals stay refused

🤖 Generated with Claude Code

**@⁠SchmashinPrunes** on GitHub · 2026-11-22 00:40 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/78) `SchmashinPrunes:rdna2-hw-refs` → `main` · +956 −28 · 12 files · 96 commits · closed without merging @⁠omonkeyz, this closes the two "RDNA2 instructions held at yellow" entries in BLOCKERS with measurements from real RDNA2 hardware. It also explains why the RDNA2 map can't honestly reach 100%. **Library / area:** tombox-xshader tests (ISA sweep) and the progress data. No translator change. **Exports changed (exports.txt rows):** none **Source of the behaviour:** results recorded on RDNA2 silicon, the gfx1036 iGPU of a Ryzen 5 9600X (Linux Mint, ROCm/HIP 5.7.1). They came from the `sbfe` and `norm` probes of `tools/rdna2-hwprobe/valu_probe.py` (#72 by @⁠QuentinDanblon), posted in https://git.gtahub.st/github/omonkeyz--xbox-emulator/pulls/41. No game or console files are involved. **Scope:** gfx1036 is RDNA2 but not the console's GPU (gfx1013), so "confirmed on silicon" here means RDNA2 hardware (gfx1036), not a console measurement. **Dependency:** the Rust test is self-contained and runs on main as is. Only the generator `tools/rdna2-hwprobe/sweep_vectors.py` needs `valu_probe.py`, which arrives with #72 (stacked on #41), so it can't run until those land. ### Why these were held BLOCKERS held `s_bfe_*` (the width ≥ 32 rule) and `v_cvt_norm` / `v_cvt_pknorm` (the rounding) because neither rule had been confirmed on silicon. The sweep already passes all 10 mnemonics on WARP against its reference models `ops_s::bfe64` and `ops_v::norm16`. What was missing was evidence that those models match hardware. This PR adds it. ### What RDNA2 does - **`s_bfe_{u,i}{32,64}`:** the width is the full 7-bit field. A signed field that reaches the top bit sign-fills. Junk in the unused S1 bits is ignored. SCC = result != 0. All 152 measured cases match `bfe64`, which is the translator's behaviour since 8491769. - **`v_cvt_norm_*` / `v_cvt_pknorm_*`:** the exact value rounded to nearest, and NaN gives 0. The only exact ties are ±0.5, where ties-to-even and ties-away agree. `v_cvt_norm_*` keeps the upper half of D. This matches `norm16` (and so `tb_nrm`) everywhere. ### Change - `tests/isa_sweep/rdna2_hw.rs`: the hardware record, generated by `tools/rdna2-hwprobe/sweep_vectors.py`: - all 152 `s_bfe` cases as literals; - for the four f16 conversions, an FNV-1a digest over **all 65,536 f16 inputs**, whose inputs the test regenerates, plus 54 literal edge inputs; - for the f32 pknorm forms, a digest over the sweep's 26×26 `NRM_F32` edge grid plus 512 literal random pairs. - `tests/isa_sweep.rs`: a new CPU-only test, `sweep_references_match_rdna2`, checks `bfe64` / `norm16` against the record. `bfe64` and `NRM_F32` become `pub` for it. - `progress.json`: `s_bfe_i32` / `s_bfe_u32` join `rdna2_verified` (the other 8 held mnemonics were already listed there), and `rdna2_pending` is empty. The two BLOCKERS entries are marked DONE. - `gen.py`: **RDNA2 769/779 → 771/779**. No other generated value changes. ### Tests (Windows 11, WARP, on 9ab754c; rebased onto 4cb7a54, generated files regenerated) ``` cargo test -p tombox-xshader --release --test isa_sweep -- --nocapture sweep references vs RDNA2: 152 s_bfe cases, 4 f16 digests (54 literal inputs), 2 f32 grid digests, 512 f32 literal inputs; 0 mismatches isa_sweep on WARP: 541 mnemonics, 531 pass, 0 fail, 10 known WARP deviations, 28 skipped test result: ok. 3 passed; 0 failed ``` **Mutation check:** each of these planted model changes makes the new test fail: - zero-fill past the top bit: 26 mismatches; - width taken modulo the operand size: 52; - truncate: 590; - round half up: 6; - NaN → 1: 18; - u16 not clamped at 0: 432. ### Why 100% isn't reachable After this PR, 8 of 779 squares are left, and none of them can honestly turn green: - **`ds_gws_*` (6):** a wave blocks until other thread groups release a semaphore or reach a barrier. D3D12 has no cross-group blocking primitive and no forward-progress guarantee for spin waits, so any lowering could hang or would only appear to work. - **`ds_ordered_count`:** counts in wave-launch order, which D3D12 doesn't expose. Atomics give unique slots, not ordered ones. - **`s_sendmsghalt`:** halts the wave until a debugger or trap handler resumes it, which is a GPU hang on a console. Translating it as "end the wave" would be fake success. No title shader uses any of them, and these are the refusals you already documented in BLOCKERS. Hardware measurements can't change that, because the gap is what D3D12 can express, not a missing description of RDNA2. Unless you count a documented refusal as "done", 771/779 is the honest ceiling. If you'd like the map to show that, for example a separate "unsupported by design" state, I'm happy to send it as a follow-up. ### Related - #70 (@⁠QuentinDanblon) fixes the stale `s_bfe` expected values in `vop::basic::salu_basic` / `scalar_sop2`, which still fail on main. It's independent of this PR, so no file overlap. - #38 touches the same instructions in other files. Its translator change is already on main. - [x] `cargo test -p tombox-xshader --release --test isa_sweep` passes (the 10 known WARP deviations are the existing `WARP_KNOWN` list) - [x] No game or console files and no binaries included - [x] No fake success: the 8 refusals stay refused 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The ISA sweep held s_bfe_* and v_cvt_norm / v_cvt_pknorm at yellow
because their rules (s_bfe width >= 32, norm rounding) were not confirmed
against silicon. The sweep already passes them on WARP against
ops_s::bfe64 and ops_v::norm16; this adds the missing link from those
models to hardware.

tests/isa_sweep/rdna2_hw.rs records what an RDNA2 GPU (gfx1036 iGPU of a
Ryzen 5 9600X, ROCm/HIP 5.7.1) returned for the sbfe and norm probes of
tools/rdna2-hwprobe/valu_probe.py (community PR #72):
- all 152 s_bfe cases, literal;
- every f16 input of the four f16 conversions, as an FNV-1a digest over
  the 65536 inputs (regenerated in Rust) plus 54 literal edge inputs;
- the 26x26 f32 edge grid (the sweep's NRM_F32) as a digest, plus 512
  literal random f32 pairs.

sweep_references_match_rdna2 (CPU only) checks the sweep models against
it: 0 mismatches. Planted model changes (zero-fill, width modulo the
operand size, truncate, half-up, NaN -> 1, unclamped u16) each fail it
with 6 to 590 mismatches. tools/rdna2-hwprobe/sweep_vectors.py
regenerates the record from a probe directory.

s_bfe_i32 / s_bfe_u32 move to rdna2_verified (the other 8 were already
listed), rdna2_pending is empty, and the two BLOCKERS entries are
closed. gen.py: RDNA2 769/779 -> 771/779. The remaining 8 (ds_gws_* x6,
ds_ordered_count, s_sendmsghalt) are the deliberate refusals in
BLOCKERS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xsrj8HzdWhzzYYavNNpHjk
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:09:38 +00:00
github-bot closed this pull request 2026-11-26 06:09:38 +00:00
Author
Owner

@⁠QuentinDanblon on GitHub · 2026-11-22 00:57 UTC · original

Tested and cross-checked against the probe this builds on (#72). Short version: the test passes on today's main and the record is consistent with the probe in every way I could check from here.

Run (Windows 11, WARP, this PR merged into main 285a165, the merge is clean):

cargo test -p tombox-xshader --release --test isa_sweep -- --nocapture
sweep references vs RDNA2: 152 s_bfe cases, 4 f16 digests (54 literal inputs), 2 f32 grid digests, 512 f32 literal inputs; 0 mismatches
isa_sweep on WARP: 541 mnemonics, 531 pass, 0 fail, 10 known WARP deviations, 28 skipped
test result: ok. 3 passed; 0 failed

Cross-check of rdna2_hw.rs with a separate script that uses only valu_probe.py from #72 (its case list, its input generators and its Fraction models, which share no code with the Rust bfe64 / norm16):

check result
BFE inputs equal the probe's case list, in order 152 / 152
BFE results: 7-bit width with sign-fill 152 / 152
BFE results: literal ISA formula / width modulo the operand size 114 / 100, the same counts as in the #41 comment
BFE SCC = (result != 0) 152 / 152
four f16 digests, recomputed over all 65,536 inputs from the Python model all four equal
54 literal f16 rows (216 values) 0 differ
two f32 grid digests (26 x 26) both equal
512 literal f32 pairs: inputs equal rows 676 + 126k of norm32_input() 512 / 512
512 literal f32 pairs: results vs the Python model 0 differ

So the record matches what the probe would have fed the GPU, and two independent models (Rust and Python) agree with it. What I cannot check from here is that the numbers are what the GPU returned: that rests on your run. If you still have the probe directory, attaching the raw sbfe_*.out, norm16.out and norm32.out as a zip in a comment (not in the tree) would let anyone regenerate rdna2_hw.rs byte for byte.

Three notes:

  1. Dependency. tools/rdna2-hwprobe/sweep_vectors.py imports valu_probe.py, which only exists in #72, itself stacked on #41, and tools/rdna2-hwprobe/ is not on main yet. The Rust test is self-contained and works without them, but the generator cannot run on main until #41 and #72 land. Worth one line in the description.
  2. Generated docs. BLOCKERS.md, progress.json, LIBRARY_MAP.md, MILESTONES.md and the SVGs are rewritten by @⁠omonkeyz in each sync commit (285a165 touched all of them except the instructions badge). They merge cleanly today and will conflict at the next sync. The two files that carry the result are tests/isa_sweep.rs and tests/isa_sweep/rdna2_hw.rs; those can be taken on their own.
  3. Scope of the claim. gfx1036 is RDNA2 but not the console's gfx1013. The header of rdna2_hw.rs says gfx1036, which is right. I would keep "RDNA2 hardware (gfx1036)" wherever the docs say "confirmed on silicon", so nobody reads it as a console measurement.

On the tie argument: I agree. valu_probe.py makes the same point for its nearest rule (the only exact tie a float can produce is ±0.5, at 16383.5 and 32767.5, where ties-to-even and ties-away give the same result), so the measurement cannot separate the two and does not need to.

#70 is still needed on main for the two stale s_bfe exec oracles (scalar_sop2, vop::basic::salu_basic), as you say. No overlap with this PR.

**@⁠QuentinDanblon** on GitHub · 2026-11-22 00:57 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/78#issuecomment-7071893940) Tested and cross-checked against the probe this builds on (#72). Short version: the test passes on today's main and the record is consistent with the probe in every way I could check from here. **Run** (Windows 11, WARP, this PR merged into main 285a165, the merge is clean): ``` cargo test -p tombox-xshader --release --test isa_sweep -- --nocapture sweep references vs RDNA2: 152 s_bfe cases, 4 f16 digests (54 literal inputs), 2 f32 grid digests, 512 f32 literal inputs; 0 mismatches isa_sweep on WARP: 541 mnemonics, 531 pass, 0 fail, 10 known WARP deviations, 28 skipped test result: ok. 3 passed; 0 failed ``` **Cross-check of `rdna2_hw.rs`** with a separate script that uses only `valu_probe.py` from #72 (its case list, its input generators and its `Fraction` models, which share no code with the Rust `bfe64` / `norm16`): | check | result | |---|---| | `BFE` inputs equal the probe's case list, in order | 152 / 152 | | `BFE` results: 7-bit width with sign-fill | 152 / 152 | | `BFE` results: literal ISA formula / width modulo the operand size | 114 / 100, the same counts as in the #41 comment | | `BFE` SCC = (result != 0) | 152 / 152 | | four f16 digests, recomputed over all 65,536 inputs from the Python model | all four equal | | 54 literal f16 rows (216 values) | 0 differ | | two f32 grid digests (26 x 26) | both equal | | 512 literal f32 pairs: inputs equal rows 676 + 126k of `norm32_input()` | 512 / 512 | | 512 literal f32 pairs: results vs the Python model | 0 differ | So the record matches what the probe would have fed the GPU, and two independent models (Rust and Python) agree with it. What I cannot check from here is that the numbers are what the GPU returned: that rests on your run. If you still have the probe directory, attaching the raw `sbfe_*.out`, `norm16.out` and `norm32.out` as a zip in a comment (not in the tree) would let anyone regenerate `rdna2_hw.rs` byte for byte. Three notes: 1. **Dependency.** `tools/rdna2-hwprobe/sweep_vectors.py` imports `valu_probe.py`, which only exists in #72, itself stacked on #41, and `tools/rdna2-hwprobe/` is not on main yet. The Rust test is self-contained and works without them, but the generator cannot run on main until #41 and #72 land. Worth one line in the description. 2. **Generated docs.** `BLOCKERS.md`, `progress.json`, `LIBRARY_MAP.md`, `MILESTONES.md` and the SVGs are rewritten by @⁠omonkeyz in each sync commit (285a165 touched all of them except the instructions badge). They merge cleanly today and will conflict at the next sync. The two files that carry the result are `tests/isa_sweep.rs` and `tests/isa_sweep/rdna2_hw.rs`; those can be taken on their own. 3. **Scope of the claim.** gfx1036 is RDNA2 but not the console's gfx1013. The header of `rdna2_hw.rs` says gfx1036, which is right. I would keep "RDNA2 hardware (gfx1036)" wherever the docs say "confirmed on silicon", so nobody reads it as a console measurement. On the tie argument: I agree. `valu_probe.py` makes the same point for its `nearest` rule (the only exact tie a float can produce is ±0.5, at 16383.5 and 32767.5, where ties-to-even and ties-away give the same result), so the measurement cannot separate the two and does not need to. #70 is still needed on main for the two stale `s_bfe` exec oracles (`scalar_sop2`, `vop::basic::salu_basic`), as you say. No overlap with this PR.
Author
Owner

@⁠SchmashinPrunes on GitHub · 2026-11-22 02:52 UTC · original

Thanks for the independent cross-check, that's exactly the second pair of eyes this needed.

  1. Added the dependency line to the description.
  2. Rebased onto 4cb7a54 (the sync did conflict, as you predicted). The code files are unchanged and the generated files were regenerated with gen.py, still 771/779. @⁠omonkeyz, if the generated files keep getting in the way, tests/isa_sweep.rs and tests/isa_sweep/rdna2_hw.rs carry the result on their own, plus the two progress.json entries.
  3. Agreed. The description now says "RDNA2 hardware (gfx1036)" explicitly and states it isn't a console (gfx1013) measurement. The record header and the BLOCKERS lines already name gfx1036.

I'll attach the raw sbfe_*.out, norm16.out and norm32.out as a zip below so anyone can regenerate rdna2_hw.rs byte for byte.

**@⁠SchmashinPrunes** on GitHub · 2026-11-22 02:52 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/78#issuecomment-7073180532) Thanks for the independent cross-check, that's exactly the second pair of eyes this needed. 1. Added the dependency line to the description. 2. Rebased onto 4cb7a54 (the sync did conflict, as you predicted). The code files are unchanged and the generated files were regenerated with gen.py, still 771/779. @⁠omonkeyz, if the generated files keep getting in the way, `tests/isa_sweep.rs` and `tests/isa_sweep/rdna2_hw.rs` carry the result on their own, plus the two `progress.json` entries. 3. Agreed. The description now says "RDNA2 hardware (gfx1036)" explicitly and states it isn't a console (gfx1013) measurement. The record header and the BLOCKERS lines already name gfx1036. I'll attach the raw `sbfe_*.out`, `norm16.out` and `norm32.out` as a zip below so anyone can regenerate `rdna2_hw.rs` byte for byte.
Author
Owner

@⁠SchmashinPrunes on GitHub · 2026-11-22 03:02 UTC · original

rdna2-hw-gfx1036-sbfe-norm.zip

Raw results as promised. README.txt has the regenerate command; the output is byte-identical to rdna2_hw.rs at d94424d

**@⁠SchmashinPrunes** on GitHub · 2026-11-22 03:02 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/78#issuecomment-7073286032) [rdna2-hw-gfx1036-sbfe-norm.zip](https://github.com/user-attachments/files/35224564/rdna2-hw-gfx1036-sbfe-norm.zip) Raw results as promised. README.txt has the regenerate command; the output is byte-identical to rdna2_hw.rs at d94424d
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 13:12 UTC · original

Main's history was rewritten, which auto-closed this PR (sorry for the noise). Please drop the edits to the generated docs/ and tools/progress files and strip the comment lines. The RDNA2 silicon evidence is very welcome. Resubmit after #41/#72, since sweep_vectors.py depends on #72. To resubmit: git fetch this repo, branch from the current main, cherry-pick only your own commits (the old branch is based on the previous history and cannot be merged), and open a new PR.

**@⁠omonkeyz** on GitHub · 2026-11-22 13:12 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/78#issuecomment-7079646137) Main's history was rewritten, which auto-closed this PR (sorry for the noise). Please drop the edits to the generated docs/ and tools/progress files and strip the comment lines. The RDNA2 silicon evidence is very welcome. Resubmit after #41/#72, since sweep_vectors.py depends on #72. To resubmit: `git fetch` this repo, branch from the current `main`, cherry-pick only your own commits (the old branch is based on the previous history and cannot be merged), and open a new PR.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.