abs(nan - want) > tol is False, so an all-NaN frame counted as exact, and
none of the three counted pixels, so an empty .raw passed. check.py rejects
both; these now do too, as check_pixel_const already counts pixels.
check.py ran cs_wqm_w32, cs_w32_lane_wrap, cs_w32_permute and cs_bpermute32
without VKC_SUBGROUP_SIZE, so on a device whose range is 8..32 (Intel ANV) the
driver could pick a narrower size and the two runners judged different words.
check.py now requests 32 for them; run_gpu_tests.py requests it even without
index.json.
vk_compute_test prints whether a VKC_SUBGROUP_SIZE request is honoured
("compute subgroup size: N" or "... N not available"), and both runners skip
these dumps when 32 can't be pinned instead of reporting wrong words. Output
from an older vk_compute_test is judged as before.
buffer_address() picked the bounds check from the stride alone and never read
word3. It now reads OOB_SELECT (bits 29:28) and applies the rule measured
natively on RDNA2 (gfx1036, docs/buffer_bounds.md; Mesa's GFX11 column): a
dword is out of range in mode 0 at idx >= NR or off + 4 > stride, mode 1 at
idx >= NR, mode 2 at NR == 0, mode 3 (RAW) at offs + 4 > NR, where off is
inst_offset + vaddr and offs adds soffset. A literal word3 folds the mode, a
run-time one selects with OpSelect.
Builds on the raw tail rule of #443 (per-dword loads): x2..x4 loads AND stores
are per dword in modes 0 and 3 (a store that straddled the edge used to write
past it), modes 1 and 2 take the whole access, a typed element
(buffer_load/store_format) is all or nothing at its format's size, an atomic
checks its dword's end. Measured on a Radeon 880M (gfx1150), a valid proxy for
RDNA2: 504 buffer_load_dword cases over idxen/offen/inst_offset/soffset at the
stride and record edges agree with the rules, plus the x2/x4, typed and atomic
edges.
Swizzle (V# word1 bit 31 SWIZZLE_ENABLE, word3 bit 23 ADD_TID_ENABLE; Mesa
gfx10-rsrc.json lines 326 and 337): a literal V# with either is Unsupported in
every mode; a run-time one is translated unswizzled (documented known gap).
A V# with word3 = 0 is mode 0 / stride 0 and so always out of range, as on
hardware: the harness output V# (vk_compute_test, interpreter push constants),
cs_bounds, cs_fmt_1010102, cs_store, mem_diff and the format tests now say
OOB_SELECT 3 (or 1 with a stride) explicitly.
Tests: tests/semantic/test_buffer_oob_select.py (33 hand-tabulated cases plus
multi-dword stores, typed elements and the swizzle gate, literal and run-time
V#), GPU tests cs_oob_select.asm and cs_oob_tail.asm (the second tells the end
check from Mesa's GFX10 start check). docs/design.md, Buffer bounds checking,
has the per-mode rule; docs/buffer_bounds.md notes the translator reads it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 321 pixel shaders that read the raw barycentric pair are translated to
BuiltIn BaryCoordKHR, so they can't run on a device without the extension
(NVIDIA Pascal, for one). With --bary-fallback the pair comes from an
ordinary vec3 input one location past the shader's attributes; the module
needs neither the capability nor the extension, and the index records the
location as bary_fallback_input. tools/bary_fallback_gs.py writes the
pass-through geometry shader that fills it: Position and the PS's inputs
copied unchanged, plus (1,0,0), (0,1,0), (0,0,1) at the three vertices,
whose perspective interpolation is the BaryCoordKHR value.
- LEONIDA_BARY_FALLBACK=1 for build.py, check.py and run_gpu_tests.py
(like LEONIDA_W64_EMULATE): translate with the flag, build
<name>.bary_gs.spv, draw those shaders through it.
- vk_harness: VKH_GS_HELPER=1 keeps VKH_SUBGROUP_SIZE on the fragment
stage when the GS only feeds the pixel shader under test.
- tests/semantic/test_bary_fallback.py and the ps_bary fixture.
- docs/design.md contract row and index key, docs/testing.md section.
GTX 1060 (Pascal): ps_bary 4096/4096 exact, ps_uniform_branch and
ps_scc_mask32 pass with the fallback (SKIP without it). Pixel-shader corpus:
12,101/12,101 translate and pass spirv-val with and without the flag.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SSJXX67xeoorUsLJ2f9zms
What was wrong (tools/rdna2spirv.py):
- s_load* / s_buffer_load* added base + soffset + imm unaligned; hardware truncates each of the three to a
multiple of 4 before adding them.
- s_buffer_load* had no bound at all and read past NUM_RECORDS.
- s_load* zero-extended a negative immediate from 32 bits (soffset 8 + imm -4 read ptr + 4 GiB + 4).
- raw buffer_load_dword* checked only the start (offset < num_records), so a dword at NR-1..NR-3 and the tail
of a multi-dword load returned data where hardware returns 0.
Hardware evidence: AMD Radeon RX 6800 (gfx1030, driver 32.0.21045.29003), raw compute kernels, wave32 and
wave64, 155 runs, every result 0 or the stored data, wave32 = wave64 in every dword. Decisive rows:
s_buffer_load imm 0x10 with NR 18 -> 0; imm 0x13 with NR 21 -> data@0x10; soffset 0xe + imm 2 with NR 16 ->
data@0xc; x4 at 0xc with NR 21 -> data, data, 0, 0; stride 4 with NR 5: 0x10 data, 0x14 0; stride 1 with NR 17:
0x10 -> 0; base & 3 = 1 with imm 3 -> data@0. s_load soffset 8 + imm -4 -> @4, soffset 0xb + imm -1 -> @4.
buffer_load_dword at 0xf with NR 18 -> 0; x4 at 3 with NR 18 -> d0..d2 data, d3 0.
Now: off = (soff & ~3) + (imm & ~3), dword i at (base & ~3) + off + 4i. s_buffer_load dword i is 0 and not
loaded (its own selection construct + OpPhi) when off + 4i + 4 > limit, limit = NR * stride or NR (stride 0).
s_load: imm sign-extended from 21 bits, 64-bit sum, no bound. Raw (stride 0, no idxen) buffer_load: dword i
loaded iff O + 4i + 4 <= NR. Structured, idxen, stores, atomics and format loads keep their old first-byte
check (not measured).
Inferred, not measured: s_load with soffset + imm < 0 (64-bit signed sum), s_buffer_load x16 and buffer_load
x3 (same rule), an s_buffer_load immediate with bit 20 set or negative. OOB_SELECT (V# word3[29:28]) changes
vector-load results on hardware (2 probes) and is recorded in docs/design.md, not modelled.
Tests: tests/semantic SmemHardwareRuleTests (evaluator follows branches/phis), RawBufferTailBounds and
MeasuredBoundsShaders assert values and the exact addresses read; 19 fail with main's translator. New GPU
tests cs_smem_bounds, cs_smem_stride_align, cs_smem_sload_neg, cs_buf_tail (expected words derived by hand
from the model) in check.py and scripts/run_gpu_tests.py. test_heap_base_is_added_once now gives its V# a
NUM_RECORDS (it had 0, which the measured bound turns into a load of nothing).
Tested on AMD Radeon RX 6800 / Windows / driver 26.11.2 (Vulkan), on main d937b7f: run_gpu_tests 62/62 passed;
check.py 56 of 56; unittest tests/semantic 460 OK; pytest 1796 passed, 7 skipped, 1 xfailed. The three new tests
that are safe to run with main's translator fail with it on the GPU; cs_smem_sload_neg was not run with it (it
would read 4 GiB past the heap). Indexed (idxen) buffer loads keep their single selection construct.
AI-assisted.
Rebased onto main 8df277f: since 2e8101b the semantic mini interpreter raises on a PhysicalStorageBuffer access that
is not 4-byte aligned, so RawBufferTailBounds rows that load at an unaligned O now set base_low so that base + O is
aligned (the bound sees only O, so the measured O / NR pairs are kept); the base & 3 = 3 row uses offset 5 as a
stand-in for the measured offset 3. Byte-exact data at an unaligned address is no longer asserted there.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Route both four-tap gather paths through the existing binary16 conversion so explicit LOD and offsets keep the two-word result and the following register intact.
Intel's Windows driver (UHD 770 / Xe-LP, 32.0.101.6129) evaluates OpBitFieldUExtract
of a constant that fits in 16 bits with the offset taken mod 16, so s_mov_b32
exec_lo, 0xffff ran all 32 lanes and lanes 16-31 copied the EXEC bits of lanes 0-15.
That is what broke cs_w32_permute case C and lds_fuzz w32 programs 24 and 26 there.
(K >> lane) & 1 gives the same bit on every driver. cs_exec_const.asm checks four
constant masks, three of them 16-bit, in both GPU runners.
Explicit-LOD gathers use four texel fetches that bypass the Vulkan sampler. Decode its 4.8 LOD bounds before selecting the mip so clamped gathers agree with a sampler-backed draw.
Measured on an AMD Radeon RX 6800 (gfx1030) with the hw-oracle tool from the
AnyPS5 project, all four IEEE/DX10_CLAMP combinations, wave32 and wave64:
- v_min/v_max f32/f16, each half of v_pk_min/max_f16, and v_min3/v_max3 now
emit NMin/NMax (one NaN operand gives the other) instead of FMin/FMax.
- v_med3_f32/_f16: FClamp(z, NMin(x,y), NMax(x,y)), and with OpIsNan of each
operand that can be a NaN, select NMin(NMin(x,y), z) (hardware: min3 when
any operand is NaN). Non-NaN constants get no check; no select when none.
- v_fract_f32: Fract, then 1.0 -> 0x3f7fffff by compare and select (the NaN
of fract(+-inf) is kept). v_fract_f16: the same, then a packed 0x3c00 ->
0x3bff (not after an output multiplier).
Other FMin/FMax/FClamp uses (clamp bit, LOD and conversion clamps) are
unchanged. GPU fixtures ps_fnan_med3 and ps_fnan_fract read their inputs
from memory; on the RX 6800 the two med3 words differed before this change.
tests/semantic/test_float_nan_fract.py runs the measured rows; both
interpreters gain NMin/NMax, and spirv_mini_interp OpIsNan and exact Fract.
tests/semantic/test_alu_med3.py (merged after this branch was cut): its float
reference used Python min/max, which return the first argument for equal
zeros. Hardware orders -0 below +0 (RX 6800: med3(-0, +0, 1.0) = +0,
med3(+0, -0, -1.0) = -0 in every operand order), so the reference now sorts
with that order, and spirv_mini_interp's FMin/FMax/FClamp order zeros the same
way as its NMin/NMax.
Rebased onto 8df277f. Two upstream tests were written against the old
behaviour and are updated: tests/semantic/test_valu_f32_min3_max3_mad.py
(its min3/max3 reference used first-operand order for mixed zeros, and its
negative control replaced FMin/FMax; now -0 < +0, as measured on the RX 6800,
and the control swaps NMin/NMax) and tests/semantic/test_valu_f16_round.py
(it asserted that the interpreter rejects Fract; it now asserts the value).
Upstream had added an OpIsNan/OpIsInf branch to spirv_mini_interp, so this
commit's own OpIsNan branch is dropped (it shadowed upstream's). docs/design.md
notes that an output modifier on v_fract_f16 is applied before narrowing to
f16, an order not measured on hardware.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In a partial wave, lanes that were never launched don't vote but their
bits are 0 in the mask, so the vote called vcc_hi = 0xff "all ones".
Keep the vote for 0 only; -1 goes through wave_mask(). GPU tests for a
40-thread wave64 and a 20-thread wave32.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cs_wavemask branch kept two older inline copies of the test next to the wavemask_check() call that
replaced them (merge leftovers): vk_compute_test ran three times and the result was appended twice, so
every run reported cs_wavemask twice (seen in a #166 report: RX 5700 XT on Windows, "83/94" for 90
tests). The branch is now the wavemask_check() call alone, with w64_emulated() for LEONIDA_W64_EMULATE
(it also accepts the trailing space cmd.exe leaves).
New test: run_suite with a fake translator and vk_compute_test runs cs_wavemask once and prints one row
(fails before: 3 runs).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vk_texture_test returned 1 instead of the unsupported code 77 when
maxPushConstantsSize is below the 144 bytes it needs (only --two-mip got 77),
and run_gpu_tests.py treated any non-zero exit of the bindless texture tests and
ps_gather_wrap as a failure. On a 128-byte device that reported 8 FAILs instead
of SKIPs. Both now skip with the device's own reason; check.py already mapped 77
to a skip.
run_gpu_tests.py (run_cmd) and check.py (run, the mesh harness) start each GPU program with
LEONIDA_GPU_TEST_TIMEOUT seconds (default 120, 0 = no limit). A program that runs longer is
killed and its test fails with 'timed out after N s'. The translator step over the whole suite
keeps no limit. Seen on an Intel UHD 770, where cs_barrier_divergent can hang vk_compute_test.
ds_read_u8_d16, ds_read_u8_d16_hi, ds_read_i8_d16 and ds_read_i8_d16_hi
(RDNA2 DS opcodes 162-165) were rejected. They reuse the u8/i8/u16_d16
path: the byte is zero- or sign-extended 8->16 into one half of the
destination and the other half is kept.
Tests: CPU value test on the new cs_w32_lds_u8_d16 fixture (mini
interpreter now accepts Workgroup variables for one invocation), GPU
dump cs_w32_lds_u8_d16.asm registered in check.py and run_gpu_tests.py,
lds_fuzz generates the four reads. Contract row in docs/design.md and
shader_validation.md updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cs_barrier_divergent: wave32, 128 threads. Wave 0 and waves 1-3 take different branches, each with its own s_barrier; on RDNA they count against the same workgroup barrier, so wave 0 reads what wave 3 wrote to LDS (out[i] = 127 - i). Registered in check.py and scripts/run_gpu_tests.py as a wave32 dump that doesn't need 32-lane subgroups.
Passes on an RTX 4070 Ti with the current translator; it guards the behaviour for any change to barrier handling.
AI-assisted.
A shader that declares MinLod (image_sample_d_cl) needs the feature, and without it the validation layer reports VUID-VkShaderModuleCreateInfo-pCode-08740. A device without it is now a skip (exit 77), as in the other texture tests.
The follow-up to #349 that the #374 coordination note asked for. #349
fixed s_ff0_i32_b32 reading an inline constant or literal as a lane mask;
this adds a hardware and interpreter check for it.
ps_sff_imm runs s_ff1_i32_b32 on the inline constant 4 and the literal
0x00100000, and s_ff0_i32_b32 on the inline constant 61 and the literal
0x0000ffff: 2, 1, 20, 16. Read as a lane mask (all ones or zero from bit
0) the two s_ff0 words are -1; the s_ff1 words guard the path that was
already right.
- runtime/test/shaders/ps_sff_imm.asm, with its expected words in
check.py and run_gpu_tests.py
- the fixture (regen_fixtures.py) and a value test in
tests/semantic/test_value_semantics.py that runs it through the
interpreter, with an independent reference
AI-assisted (Claude Code). Tested on NVIDIA GeForce RTX 4060 Ti (subgroup
32), driver 32.0.16.2124, Windows 11: see the PR for the run on main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>