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.
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.
The hardware takes a cube sample's s and t in [1, 2] and its third
coordinate as 8 * slice + face (Mesa ac_nir_lower_tex_coords.c, LLPC
ImageBuilder.cpp). Samples and gathers passed them unchanged to the
6-layer 2D-array view; they now use s - 1, t - 1 and layer
6 * slice + face.
ps_cube_sample checks every pixel on a GPU (vk_texture_test cube), and
test_cube_sample checks the coordinates without one.
vk_texture_test runs with its working directory in <work>/spirv, so a relative --build (runtime/build) made the
tool path point there and the test failed with "missing runtime/build/vk_texture_test". --build and --work are
now made absolute after parsing. A filtered run also builds vs_ids.spv for ps_texture_sample, which
vk_texture_test loads, as #192 did for ps_flat (one table, DRAWN_WITH).
On Windows 11, Smart App Control blocks freshly built unsigned programs it
has no reputation for (WinError 4551, "An Application Control policy has
blocked this file"), and which ones it blocks changes with each rebuild.
run_gpu_tests.py then stopped the whole run with an OSError traceback, and
check.py did the same from mesh_w64x_test.
- check.start_failure() turns the OSError into one result line naming the
program and, for the Windows refusals (4551 Application Control, 1260
software restriction policy, 225 Defender), who refused it and how to
allow it.
- check.run(), mesh_w64x_test(), run_gpu_tests.run_cmd() and the
ps_texture_sample launch report it as a FAIL of that test and go on with
the rest. It is a failure, not a SKIP: a blocked run must not look green.
pixel_test() passes the reason on instead of "vk_harness failed".
- A missing program still stops check.py with the build instructions.
tests/test_gpu_blocked_program.py fakes the error, so it runs on any OS.
AI-assisted (Claude Code). Tested on Windows 11 Home, NVIDIA GeForce RTX
4060 Ti (driver 32.0.16.2124), on main 36ace71:
- the new tests: 7/7 on Windows and on Linux (WSL Ubuntu 26.04); 5 of
them fail without the fix
- end to end, with test programs Windows really refuses (WinError 216):
run_gpu_tests.py and check.py print one FAIL line per test and exit 1,
no traceback
- run_gpu_tests.py: every PASS/SKIP identical to main, natively (29/49,
20 skipped) and with LEONIDA_W64_EMULATE=1 (47/49, 2 skipped); ctest
12/12; tests/test_*.py all pass; tests/semantic 388 OK
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
check.py drops --require-wave64 for cs_wavemask when wave64 is emulated; run_gpu_tests.py always passed it,
so on a 32-wide GPU the emulated suite skipped cs_wavemask. The check moves into wavemask_check(), which
asks for a 64-wide subgroup (and confirms it) only for the native build. test_run_gpu_wavemask covers both
paths with a fake vk_compute_test.
NVIDIA GeForce RTX 4070 SUPER (subgroup 32), driver 610.88, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8 in WSL:
LEONIDA_W64_EMULATE=1 run_gpu_tests.py 48/49 (was 47/49; ps_vcc_x2 skips), cs_wavemask 0 mismatches.
Native: 29/49, cs_wavemask still skips. AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>