Match RDNA2 mode-0 denormal semantics and legacy zero override; flush product before output scaling and normalize modifier zeros. Add synthetic semantic/GPU fixtures and documentation. AI-assisted (GPT-6).
RADV returns VK_KHR_pipeline_binary data as one binary per stage
(radv_shader_serialize), not the AMD Windows driver's single PAL ELF, so
ps_oracle exited 77 on every Linux AMD GPU. Find the pixel stage, its
code, sizes, num_vgprs/num_sgprs and rsrc1 by values that must agree
(radv_shader_info's size changes between Mesa versions), replace the
code and raise the VGPR counts. GFX10 only (GFX11+ is refused with
"unsupported architecture"); --set stays PAL-only.
Checked on gfx1036 (RADV RAPHAEL_MENDOCINO, Mesa 26.3.1); an RX 9070 XT
(RADV GFX1201) is refused with exit 77.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hw_oracle launches compute kernels only. vk_harness can now write a
pipeline's VK_KHR_pipeline_binary data and build a pipeline from it
(VKH_BINARY_OUT / VKH_BINARY_IN). ps_oracle.py puts assembled ISA in
place of _amdgpu_ps_main in the driver's PAL ELF, raises the pixel
stage's register counts in the msgpack metadata, optionally changes
other metadata entries, and draws with it, reading every pixel's mrt0
words back.
Checked on gfx1036 (driver 26.10.1): v_interp of a varying and the
parameter words P0 / P10 come back as expected. Tests in
tests/test_ps_oracle.py, docs in docs/shader_validation.md.
AI-assisted.
The translated image_load fetches a UNORM texel through a float view, so the 8-bit -> float conversion is
the driver's. RDNA2 returns the correctly rounded c / 255; llvmpipe multiplies by an f32 1/255, one ulp
above it for 126 of the 256 byte values (27: 0x3dd8d8da, not 0x3dd8d8d9). The comparison was bit exact
and a run stops at its first mismatch, so on llvmpipe every run ended at its first R8G8B8A8_UNORM case
and the other formats never ran.
The translator oracle now accepts one ulp on a UNORM8 texel component, never on another format or on the
sentinels of registers dmask leaves unwritten, and the summary counts how many components needed it.
--oracle hw stays bit exact.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Seven opcodes (v_sad_u8, v_sad_hi_u8, v_sad_u16, v_sad_u32, v_msad_u8,
v_qsad_pk_u16_u8, v_mqsad_pk_u16_u8) against an ISA-written reference and
the translated SPIR-V in spirv_mini_interp, four exported words, bit for
bit. A 785-program sweep covers every source-kind combination (the 64-bit
constant rule pinned both ways), random seeded programs widen the values.
12,810 programs across six seeds match with zero mismatches and zero
skips; two translator mutations make 36/60 and 17/60 programs fail.
clamp, op_sel/neg/abs, v_mqsad_u32_u8 (#1926/#2163) and null as a 64-bit
quad source (#2650) are out of scope, on purpose.
tools/interp_hw_probe.py runs v_interp_* in a compute wave through tools/hw_oracle (the ops read the
attribute words from LDS at M0) and checks them against exact models: p1/p2_f32 and p1ll_f16 are single
fmas rounded to f32, p2_f16 rounds once straight to f16 (30 discriminating ties), and a 32-bit read of a
packed channel takes the raw words as f32. f32 denormal words follow MODE. All 292,474 checks match per
mode on a Radeon gfx1036 iGPU.
v_interp_p2_f16 keeps the high 16 bits of vdst on hardware; the translator zeroed them. It now writes
the low half only (write_lo16), with a semantic test that fails on the old code.
The SPI half (what a real draw writes into LDS for a packed channel) stays unverified; it needs a
pixel-shader harness.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A separate exact-rational ISA model for v_fract_f32, v_frexp_mant/exp_f32, v_ldexp_f32, v_cvt_u32/i32_f32, v_cvt_off_f32_i4, v_fmamk_f32, the 16 v_cmp_*_f32 conditions and v_cmp_class_f32, with neg/abs, omod and clamp and every source kind within the constant-bus rules, compared one lane at a time with rdna2spirv run in tests/semantic/spirv_mini_interp.py, optionally with the hardware through tools/hw_oracle (run under IEEE off, f32 denormals flushed). Denormals, NaN payloads read as integers, clamp of a NaN and omod giving a zero are counted skips. v_cmp_class_f32 with neg/abs on a signalling NaN only with --known.
AI-assisted.
A separate ISA model for the v_pk_* integer ops (op_sel, op_sel_hi, clamp) and the 16-bit VOP3 integer ops (op_sel on sources and the destination half, the kept other half, clamp), with VGPR, SGPR, inline-constant and literal sources within the constant-bus rules, compared one lane at a time with rdna2spirv run in tests/semantic/spirv_mini_interp.py, optionally with the hardware through tools/hw_oracle. A constant whose high half a packed op reads (#2224) only with --known.
AI-assisted.
The f32 OpFMul of the clamped value and 32767 (or 65535) can land exactly on k + 0.5 while the exact product is just
below or above it; RoundEven then picked the even neighbour, one off from the hardware on 28 of 28 such inputs on an
RDNA2 iGPU (gfx1036, SHADER-339). The product's error Fma(c, s, -p) is exact, so on such a tie the translator now
takes floor(p) + 1 when it is positive, floor(p) when negative, and RoundEven when it is 0. Away from a tie both
roundings agree.
tools/pknorm_probe.py --oracle hw on the same iGPU now exits 0: all 134 words equal the translator's in wave32 and
wave64 under five MODEs. tests/semantic/test_alu_cvt_pknorm_f32.py's reference rounds the exact product once and
checks the twelve measured near-tie words (they fail on the old translation); tests/test_pknorm_probe.py expects
single rounding. docs/design.md: the three copies of the pknorm row become one, with both RDNA2 measurements.
A separate ISA model for 55 integer opcodes (VOP1/VOP2 as e32 and e64, VOP3-only ops, VOPC e64 + v_cndmask) with VGPR, SGPR, inline, float-inline and literal sources within the encoding and constant-bus rules, compared one lane at a time with rdna2spirv run in tests/semantic/spirv_mini_interp.py, optionally with the hardware through tools/hw_oracle. A mask read as data (#293) only with --known.
AI-assisted.
Seeded integer VALU programs run on every lane of a wave32 or wave64 wave with EXEC rewritten between instructions: compares into SGPR masks and VCC, v_cmpx, v_cndmask on the masks, carry-out/carry-in forms, v_mad_u64/i64 with a mask carry-out, 16-bit op_sel half writes and 32-bit ops. A per-lane ISA model is compared with rdna2spirv run in tests/semantic/spirv_wave_interp.py, optionally with the hardware through tools/hw_oracle. Known divergences (VCC data read as a mask, #2206; a mask read as data, #293) only with --known.
AI-assisted.
Measure MUBUF/MTBUF swizzled buffer addressing (V# SWIZZLE_ENABLE,
ADD_TID_ENABLE, INDEX_STRIDE, OOB_SELECT, multi-dword and typed
accesses, atomics, 32-bit offset wrap) natively on RDNA2 (gfx1036,
wave32 and wave64) via tools/buffer_swizzle_probe.py, and fix all six
observed silicon divergences in tools/rdna2spirv.py:
- idxen=1 ignores ADD_TID_ENABLE (both address and bounds).
- SWIZZLE_ENABLE=1 with idxen=0 and ADD_TID_ENABLE=0 stays linear and
OOB_SELECT 3 remains RAW.
- Multi-dword raw accesses step by +4*IS only in scratch-swizzle mode
(SWIZZLE_ENABLE=1, idxen=0, ADD_TID_ENABLE=1); indexed swizzle
(idxen=1) steps linearly by +4 bytes even across IS boundaries.
- Scratch-swizzle mode suppresses typed formats > 4 bytes (MUBUF/MTBUF)
and 8-byte buffer_atomic_*_x2 even under OOB_SELECT 2 (formats <= 4B
execute normally); indexed swizzle executes them linearly.
- OOB_SELECT 3 with active swizzle and stride != 0 checks
(index + soffset) >= num_records or off + payload > stride.
- off = uint32(voff + inst_offset) wraps at 32 bits before bounds
checking, while RAW mode 3 uint64(off) + uint64(soffset) does not.
Update semantic tests, cs_buf_swizzle fixture expectation (word 4:
0x5eed0028 -> 0x5eed000c), unit tests, and docs/design.md /
docs/shader_validation.md.
A hardware-oracle probe that reads 32-bit UINT/SINT texels (one and two channels) with d16 image_load and
image_load_mip on SQ_RSRC_IMG_1D, 2D, 2D_ARRAY and 3D, and compares each result with truncation and with
unsigned/signed saturation. Native gfx1036 saturates on every dimension and form, as the translator does;
docs/design.md and docs/shader_validation.md record it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/design.md left resinfo's 2D depth word, the clamped LOD under a linear
mip filter and the u/v order of the LOD query unverified. The new probe runs
both instructions natively through tools/hw_oracle on hand-built GFX10
descriptors and compares every word with written rules. On gfx1036 all 614
results (wave32 and wave64) follow them:
- resinfo's 2D depth word is 0 (any WORD4 DEPTH); a 2D array's layer count
is minified, max(1, layers >> (BASE_LEVEL + level)); past the last level
width, height and depth are 0.
- get_lod's raw LOD includes LOD_BIAS; the clamped LOD is the clamp under a
linear mip filter, the level read (half up) under point, 0 with none.
- u scales by the width, v by the height.
The translator still differs on the resinfo points; design.md says so.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lds_fuzz --oracle hw: default and --extended, seeds 1-3, 0 mismatches; the
masked ds_swizzle_b32 reads 0 from an off source lane on RDNA2 too
(SHADER-207). image_fuzz --oracle hw: 7,200 cases on the GFX10 T# layout,
0 mismatches. Negative controls caught every wrong model.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A separate reference for 92 _sdwa VOP1/VOP2/VOPC opcodes (integer and f16
families: source selects, sext(), dst_sel with dst_unused PAD/SEXT/PRESERVE,
SGPR and inline-constant sources, clamp, f16 neg/abs) compared with
rdna2spirv + spirv_mini_interp on seeded one-lane programs, in the style of
salu_diff.py. --oracle hw runs the programs on an RDNA1/RDNA2 GPU; every rule
of the reference was checked on gfx1036. Forms where the translator is known
to differ are left out unless --known.
AI-assisted.
tools/f32_fuzz.py --oracle hw, seeds 1 to 6, on an RX 6700 XT (gfx1031,
AMD Windows driver 26.11.2): 39,101 programs, 0 mismatch, 66 omod -0 -> +0
deviations. mul:2/mul:4/div:2 behave as measured on gfx1150: applied with
IEEE off and f32 denormals flushed (a -0 result becomes +0), ignored by the
ALU ops with denormals kept (the transcendental and cube ops still apply
them), ignored with MODE.IEEE = 1.
- docs/design.md: merge the two duplicated "Output modifiers on hardware"
rows (one said RDNA2 was unmeasured, the other cited gfx1036) and add the
gfx1031 numbers.
- docs/shader_validation.md: the gfx1031 run and its omod table.
- tools/f32_fuzz.py: omod_label no longer counts a -0 result that the omod
cannot change as "applied" (65 such programs showed up as "applied" in
the ieee column); widen the table's label column; drop "RDNA2 unmeasured".
- tests/test_f32_fuzz.py: the omod_label labels, the -0 case included.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/pknorm_probe.py runs v_cvt_pknorm_i16_f32 / v_cvt_pknorm_u16_f32 through the translator on the CPU interpreter
and, with --oracle hw, natively through tools/hw_oracle in wave32 and wave64 under five MODEs. On an RDNA2 iGPU
(gfx1036) every NaN half (74 of 74: quiet, signalling, both signs, payloads, in S0 and S1) gives 0, as the translator
assumes, whatever IEEE, DX10_CLAMP and the f32 denormal mode are.
The rounding does not match: the hardware rounds the exact product x * 32767 (or 65535) once, while the translator
rounds the f32 OpFMul product and then RoundEven, one off on 28 of 28 near-tie inputs in both directions. Recorded in
docs/design.md and docs/shader_validation.md; the translator is not changed here. tests/test_pknorm_probe.py checks
four near-tie words against a hand derivation and the translator side's double rounding and NaN zero.