VGPR[D + M0[25:16]] = VGPR[S0 + M0[9:0]] (RDNA2 ISA VOP1 opcode 72; same
fields in the RDNA3 ISA). It raised Unsupported before (noted in #496).
- tools/rdna2spirv.py: masks M0 per side on the existing movrel path.
- tests/semantic/test_alu_movrelsd_2.py: 7 hand-computed cases through the
translator and the interpreter, including ignored M0 bits set, the _e32
spelling and a check that it differs from v_movrelsd_b32.
- runtime/test/shaders/cs_movrelsd_2.asm: GPU test (wave32 dump) with the
ISA's own example; registered in check.py and run_gpu_tests.py.
- docs/design.md: contract row for the v_movrel* forms.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
check_uniform_branch (ps_uniform_branch, ps_scc_mask32) only asked for some
s5 = 8 and some s5 = 7, so a translator that decides the branch per lane
passed too. Like check.py, it now also needs a pixel whose own bit is 0 but
got 8 (the wave-wide vote). Reported by @Vonsek in #477: the parent 4abd545
gave 0 such pixels and still passed the runner.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Covers the "16-bit results" contract row, which ended with "not yet GPU-verified".
Hardware evidence: AMD RX 6800 (gfx1030), the instructions run as a raw compute kernel in wave32 and
wave64, IEEE off, DX10 clamp on, denormals kept, round to nearest. The bytes assemble identically for
gfx1013 and gfx1030 (llvm-mc 21; the kernels themselves were assembled by the driver's comgr).
- v_med3_f16: all 16 op_sel patterns, neg/abs on a selected high half, clamp, destination also a source.
- v_add/sub/mul/max/min_f16 (_e32, _e64 with neg/abs/clamp), v_fmac_f16 (_e32, _e64), f16 unary
(rndne/floor/ceil/trunc/fract/sqrt/rcp/rsq, _e32 and _e64), v_cvt_f16_f32: low halves in, low half out,
high half of the destination kept; the v_fmac_f16 accumulator is the low half of the destination.
336 words per wave size, all as the rule says and as the translator computes.
- Not expressible: op_sel on the VOP2/VOP1 ops in VOP3 encoding (v_add/sub/mul/max/min_f16_e64,
v_fmac_f16_e64, unary _e64). llvm-mc rejects the modifier and its disassembler drops the bits, so
nothing was measured there and nothing was hand-encoded.
Translator fix (tools/rdna2spirv.py, new src_h): an inline float constant in an f16 operand is the f16
value in the low half over a zero high half. The translator unpacked the f32 pattern, whose low half is
zero, so v_add_f16 d, 1.0, v added 0.0 and v_cvt_f32_f16 d, 0.5 gave 0. Measured for v_add/mul/max_f16,
v_sub_f16_e64, v_fma_f16, v_fmac_f16, v_rcp_f16, v_med3_f16, v_cmp_lt_f16, v_cvt_f32_f16, v_cos_f16,
v_pk_add/mul_f16 and v_pack_b32_f16 (0.15915494 is 0x3118); the high half op_sel selects from a constant
reads +0.0. v_fma_mix* operands were not
measured and are unchanged.
Tests:
- runtime/test/shaders/ps_f16_{med3_opsel,med3_mods,vop2,vop2b,vop1,vop1b,const,const2,pack}.asm, wired into
check.py and scripts/run_gpu_tests.py. Their expected words are the ones the hardware gave for the same
instructions. Vulkan, AMD Radeon RX 6800, Windows, driver 26.11.2: 9/9 pass; with one expected word
flipped per test 0/9 pass; without the translator fix ps_f16_const, ps_f16_const2 and ps_f16_pack fail.
- tests/test_f16_hw_words.py: header, check.py and run_gpu_tests.py hold the hardware words; a
plain-Python reference of the rule and the translator (tests/spirv_interp.py) both give them. 12 of its
tests fail without the fix.
- tests/semantic: ps_f16_vop2 fixture and value test; the v_sin_f16 mutation anchor follows the edit.
- tests/spirv_interp.py: Floor/Ceil/Trunc/RoundEven keep the sign of a zero result (trunc(-0.75) is
0x8000 on the hardware and on Vulkan), Sin/Cos, component-wise vector arithmetic.
- python -m unittest discover -s tests/semantic: 388 -> 389, OK. pytest tests: 1467 -> 1514 passed.
scripts/run_gpu_tests.py (test tools rebuilt): 48/49 -> 57/58 passed, 1 skipped.
docs/design.md: the "16-bit results" row says what was verified and what is not expressible; new row
"f16 inline constants".
AI-assisted.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RDNA2 uses S1[4:0] in wave32 and S1[5:0] in wave64. Always ANDing with 63
left selects 32..63 pointing past a 32-wide subgroup. Fixture cs_w32_lane_wrap
checks lane 40 wraps to 8 on an RTX 5060.
tools/cf_diff.py generates seeded wave32/wave64 pixel shaders from the
control-flow shapes compilers emit (saveexec if/else, v_cmpx, VCC- and
SCC-voted branches, uniform and per-lane loops, two-entry cycles) and
compares every lane's export between:
* tools/cf_ref.py: cpu_ref's Machine plus branches, compares, v_cmpx,
saveexec and 64-bit masks (the ISA model, one wave)
* rdna2spirv + tests/semantic/spirv_wave_interp.py: every invocation of
one subgroup in lockstep, split at selections and rejoined at merges,
with the subgroup operations the translator emits
in both the structured and the dispatch-loop form; --spirv-val also
validates each module, --minimize reduces a mismatch.
Finding (fixed here): in a wave32 program s_and/or/xor/andn2/orn2/nand/
nor/xnor_b32 on lane masks set SCC from the lane's own bit instead of the
whole mask, so `s_and_b32 s0, vcc_lo, exec_lo; s_cbranch_scc0` and loops
closed by `s_andn2_b32 exec_lo, ...; s_cbranch_scc1` split the wave. SCC
is now the same subgroup vote as for the _b64 forms. GPU test
ps_scc_mask32 (not run on a GPU yet).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SHADER-14. runtime/test/shaders/ps_texoff.asm samples vk_texture_test's 8x8
texture (every texel different, point sampler, clamp to edge) through the
translated shader and exports the texel coordinates it read as integers:
- image_sample_lz_o with an offset computed per pixel: all 64 pairs of x, y
in -4..3 from the centre of texel (4, 4), each a different texel, none
clamped;
- image_sample_l_o with (-3, +2) and image_sample_lz_o with (+16, -32), the
offset dword loaded from an immediate. The second one tells 4-bit, 5-bit
and 6-bit fields apart; it is outside Vulkan's guaranteed -8..7 and is
judged only where the device's texel offset limits cover it;
- image_gather4_lz_o of red and of green with the per-pixel offset, at a
texel corner (shaderImageGatherExtended, not maintenance8).
Expected words are derived by hand from the docs/design.md rule (signed
6-bit fields, x [5:0], y [13:8]) and the texture contents, before any run;
the derivation is in the .asm header and check.py's texoff_words().
Harness: vk_texture_test enables VK_KHR_maintenance8 and
shaderImageGatherExtended when the device has them, prints the texel offset
limits, and with VKT_NEED_MAINTENANCE8=1 exits 77 without the extension
(SKIP in check.py and scripts/run_gpu_tests.py).
vk_harness.cpp is unchanged: its maintenance8 guard (#if defined() on the
structure-type enumerator, never true) was already fixed upstream, which now
uses #ifdef VK_KHR_MAINTENANCE_8_EXTENSION_NAME.
tests/conftest.py: the sample validator retries with
--allow-offset-texture-operand (what rdna2spirv.py validates with) when
spirv-val rejects a non-gather Offset, and skips on a spirv-val that does not
know the flag.
Tested on an AMD Radeon RX 6800, Windows, driver 26.11.2 (texel offset limits
-64..63, gather -32..31, maintenance8 enabled):
run_gpu_tests.py: 49/50 passed, 1 skipped (was 48/49, 1 skipped)
PASS ps_texoff 4096/4096 pixels exact (offsets +16/-32 judged)
check.py: 45 of 45 pass, 0 skipped (was 44 of 44)
No translator bug found: tools/rdna2spirv.py is unchanged.
Negative controls (translator sabotaged, test run, reverted). FAIL: sample
offset dropped, x/y swapped, y field at bit 6, 4-bit fields, 5-bit fields;
gather offset dropped, x/y swapped, y field at bit 6; three corrupted
expectations. PASS, so not detected on this GPU:
- fields read unsigned (sample and gather): Offset 60..63 sampled as -4..-1
and +32 as -32, so the sign extension cannot be seen through Vulkan here;
- 4-bit and 5-bit gather fields: the gather offsets stay in -4..3.
Both are pinned by the new structural test tests/test_texel_offsets.py
instead (signed, bit 8k, 6 bits; it fails with OpBitFieldUExtract).
The test shows that the translated SPIR-V implements the documented rule on
Vulkan; it does not measure the field layout on the hardware. Still not
GPU-tested: sign extension, gather field width, image_sample_o, _b_o,
_c_lz_o, image_gather4_l_o, the z field (3D), 1D/2D-array/cube targets, wrap
or mirror addressing, linear filtering, mips other than 0, other vendors'
drivers, devices without maintenance8.
unittest tests/semantic: 388 OK before and after.
pytest tests (LLVM_MC set): 1467 passed, 6 skipped, 1 xfailed before;
1478 passed, 6 skipped, 1 xfailed after.
AI-assisted.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
global_mem read the instruction offset with int(..., 0) and then did
"if inst & 0x800: inst -= 0x1000". llvm-mc prints the 12-bit field signed
(offset:-4 for 0xffc, range -2048..2047; it rejects offset:0xffc and
disassembles 0xffc back as offset:-4), so -4 & 0x800 was true and every
negative offset became base - 4096 + offset. Both repo paths (shader_disasm
--disassemble, build.py -show-encoding) deliver only the signed spelling. The
offset is now taken as written; a raw unsigned field (0x800..0xfff), which
llvm-mc never prints, still means the same negative offset, and anything
outside 12 bits raises Unsupported instead of being guessed.
Hardware (AMD Radeon RX 6800, gfx1030, raw compute kernel, wave32 = wave64):
dword at byte n = 0x10000000+n, pointer 0x1000: offset 0 reads 0x10001000,
-4 0x10000ffc, -2048 0x10000800, 2044 0x100017fc, -1024 0x10000c00.
Audit of the other offset / signed-immediate sites in rdna2spirv.py (widths
checked by assembling and disassembling with llvm-mc 21): MUBUF offset:
(12-bit unsigned; llvm-mc assembles a hand-written offset:4096 to field 0 while
echoing offset:4096, reachable only from hand-written sources, left alone),
DS offset: (16-bit unsigned), offset0/offset1 (8-bit
unsigned), ds_bpermute offset (16-bit unsigned), s_movk/s_addk/s_mulk and
s_cmpk_*_i32 (16-bit, masked then sign-extended, so 0xfffc and -4 agree),
s_cmpk_*_u32 (zero-extended), branch targets (16-bit signed, disassembled
unsigned as 65532, masked then sign-extended): all right. Not changed here:
scalar_load zero-extends a negative SMEM immediate (21-bit signed; -0x4 adds
0xfffffffc), which another branch is changing.
Tests: tests/semantic/test_global_mem_offset.py runs the emitted address
code (both addressing modes, dword/x2/x4, ubyte/sbyte/ushort/sshort, stores,
offsets -4, -2048, 2047 and 0, raw-field and out-of-range spellings): the negative-offset
cases fail on main's translator (0 and 2047 pass there too), all pass here. New GPU test
runtime/test/shaders/cs_global_neg_offset.asm (wired into check.py and
scripts/run_gpu_tests.py), expected words derived from its seeds. On AMD
Radeon RX 6800 / Windows / driver 26.11.2: run_gpu_tests 57/57, check.py
51 of 51; with main's translator the new test returns the 4096-lower seeds
and fails.
AI-assisted.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow-up to #337, from the review points there:
- resolve_build_dir, CONFIG_DIRS and the "not found" message move from
scripts/run_gpu_tests.py into runtime/test/shaders/check.py, which
run_gpu_tests.py already imports from. check.py main() now finds the
programs in build/RelWithDebInfo, Release, Debug or MinSizeRel as well,
so `check.py <out>` (docs/design.md, "Reproduce the shader tests") works
with the Visual Studio generator.
- When the programs come from a configuration subfolder, one line says
which: `test programs: <folder> (newest of A, B)`, so a #166 report can
name the build it ran and a stale pick is visible.
- The "Test programs not found" message says the configuration subfolders
were searched too (and gets a space after the colon in run_gpu_tests.py).
- tests/test_gpu_build_dir.py: the printed line, the message, and two
main()-level tests (run_gpu_tests.main hands the resolved folder to
run_suite, check.main hands it to the first test) with the programs faked.
No GPU used. AI-assisted.
- vs/gs/ms: no OpGroupNonUniformQuadSwap (only guaranteed in fragment and
compute); shuffle from the quad's four lanes there.
- 32-bit forms in wave64 write only their own half of EXEC/VCC and vote SCC
over that half; mask_src accepts exec_hi. New GPU test cs_wqm_w64_half.
- cs_wqm_w32: read SCC right after s_wqm.
- test_wqm_on_data checks the real constants and shifts; new vs and half tests.
- docs: narrowed claims (SCC vote needs 64-wide or emulation, lane
assumptions, partial quads, helper invocations untested).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the Visual Studio generator the test programs land in build/<Config>, and the runner only looked in the build
folder itself, so --build had to point at the subfolder (#166, RX 9070 XT entry). resolve_build_dir() looks in the
build folder first, then in RelWithDebInfo, Release, Debug and MinSizeRel, and takes the configuration that has all
three required programs and was built last. If none has them, the folder given is kept for the error message.
Keep the cube array at its original extent and allocate a separate upload range for the two-dimensional mip chain. Both shader registrations now run through the updated upstream runner.
s_wqm on EXEC/VCC/an SGPR mask is no longer the identity: the lane ORs its
bit with its quad's (two OpGroupNonUniformQuadSwap, or four x_buf reads under
--wave64-emulate), SCC is the wave-wide any. Data operands compute the quad
bits directly. GPU tests cs_wqm_w64, cs_wqm_w32, ps_wqm; design.md row.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ps_vcc_x2 reads two dwords through the V# in s[0:3], but vk_harness pushed zeros and bound no memory, so on the
GPU it read address 0 and lost the device; run_gpu_tests.py skipped it and check.py left it out. vk_harness now
takes VKH_SGPRS (user SGPRs, decimal or 0x hex) and VKH_HEAP (addr=word seeds in a 64 KiB device-address heap,
passed as the heap base). bufferDeviceAddress and shaderInt64 are enabled only then; a device without them gets
"unsupported: ..." and exit 77, which both runners report as SKIP. Both runners give ps_vcc_x2 the V# and words
tests/semantic uses and expect 0x11223344 0x55667788 0 0.