Current main now preserves an odd load's leftover VGPR half. Apply the signed or unsigned range conversion before that shared half-word write so both behaviors survive the integration.
Nearest sampling an integer image through a float view violates Vulkan's numeric-type rule. For D16 the subsequent float-to-half conversion also destroys the sampled integers, including every texel in the synthetic signed/unsigned sum.
main is at c2967a5e, 120 commits past the branch's base. Two conflicts, both
sides kept:
- docs/design.md: main added a third "Typed image loads" row at the place
where this branch adds its "Image atomics, size and LOD queries" row. Main's
row first, then this branch's.
- tests/test_shader_checks.py: main counts one more check (cs_fmt_xy_xyz,
TEST-185: 2 -> 3) on the line next to this branch's comment change. Main's
count with this branch's comment; the STORE_WORDS and GET_LOD_TESTS terms
stay.
Nothing from main overlaps the new fixtures: TEST-185 and cs_w64x_andn2_exec
run through vk_compute_test's dump mode, and vk_store_test, vk_texture_test
and vk_compute_test are unchanged on main.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Corpus (scripts/vs_input_survey.py, all 2,236 VS): no exp prim, no s_sendmsg, no v_mbcnt, every
VS exports pos0/param, so the console runs them as legacy hardware VS. Their input VGPRs are
Mesa's GFX10 legacy layout (radv_shader_args.c, declare_vs_input_vgprs, not is_ngg): v0 vertex
id, v1 unused, v2 primitive id, v3 instance id; no VS reads v1/v2 on entry, 788 start with the
fetch call and read attributes from v4.
Those ids are zero-based on the hardware (ac_nir_lower_intrinsics_to_args.c: vertex_id is
load_vertex_id_zero_base, instance_id is load_instance_id; the bases come in SGPRs), while
Vulkan's VertexIndex/InstanceIndex include firstVertex|vertexOffset/firstInstance. The
translator now seeds v0 = VertexIndex - BaseVertex and v3 = InstanceIndex - BaseInstance
(DrawParameters; feature shaderDrawParameters in every VS's metadata).
GPU test vs_base_ids.asm, drawn with VKH_DRAW=16,7 (new vk_harness option): 0x101 on every
pixel, where before it was 0x7111. Run by check.py and run_gpu_tests.py. vk_harness,
vk_pipeline_check, vk_bindless_test, vk_texture_test and the runtime's Vulkan device enable
shaderDrawParameters. design.md's "Inputs and outputs" row replaces the "unverified" note.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use the final two readback words to make both packed view formats reproducible through the existing filtered test. Give the paired RGBA cases real identity selectors.
The translator handles the image atomics, image_get_resinfo, image_get_lod
and the 32-bit image_bvh_intersect_ray, but no test ran them. Six hand-written
fixtures now do, with the expected words derived in each header from the
RDNA2 ISA definition of the instruction:
- cs_imgatomic: add, sub, and, or, xor, smin, smax, umin, umax and cmpswap on
a 2D r32 uint image. 0xfffffff0 tells the signed min/max from the unsigned
ones, each with a case that goes the other way; cmpswap hits and misses; one
op runs without glc; 63 lanes are off; 64 threads add to one texel.
- cs_imgatomic3d: six cases on a 4x4x4 volume, the 3D path of the translator.
- cs_resinfo: a 16x4 image with five levels: levels 0, 1 and 3 in full, then
dmask 0x3, 0xa and 0x8.
- ps_get_lod, ps_get_lod_array: calculated LOD 1 and 3 on the two-mip
texture, the clamped LOD held by the last level and by the sampler's
MAX_LOD; 2 and -3 on the one-level 2D array.
- cs_bvh32: the scene of cs_bvh through the 11-dword address form.
vk_store_test gets a "words" mode for the compute ones: it also binds the
uint image and a small volume as r32ui storage images (bindings 4 and 7) and
a 16x4 five-level image behind its real T#, fills the images and prints them;
check.py holds the expected words. The other two run on vk_texture_test and
vk_compute_test as they are.
All pass on an RX 7900 XTX and a Ryzen 9 7950X3D integrated GPU (RADV, Mesa
26.3.1) and on llvmpipe, natively and with LEONIDA_W64_EMULATE=1, and are
clean under the validation layer. No translator change was needed.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Conflicts with main's DPP and TEST-175 entries in check.py,
run_gpu_tests.py and regen_fixtures.py: main's lists with
cs_w32_mask_imm / cs_w64_mask_imm added back.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v_cmpx_{eq,gt,le,lt,ngt,nle}_f32, v_cmpx_f_i32, v_cmpx_t_u32,
v_cmpx_{eq,gt,le}_i64 and v_cmpx_{ge,lt,ne}_u64 are translated but
appeared in no test, fixture or fuzzer table.
ps_vcmpx_forms runs each in the e32 encoding, and the f32 ones,
f_i32, t_u32, gt_i64 and ge_u64 in e64 too, on operands read from
memory: NaN on either side, signed zeros, -infinity, and 64-bit pairs
that only the low word, only the high word or the sign tells apart. It
also checks that an empty EXEC stays empty and that VCC is kept. The
four words are derived from the ISA in the .asm header.
test_vcmpx_forms.py re-derives those words, runs every form in both
encodings on a table of operands, and runs each on a 16-lane wave with
one lane switched off beforehand.
No translator change: all of them pass.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
662752cc made check_bary, check_grad and check_wqm fail a short or NaN
frame. The other pixel checks could still pass one:
- read_raw_rgba32f / read_raw_u32 dropped a trailing partial pixel, so a
readback ending mid-pixel still looked like a full frame; it now reads
as no frame.
- check_uniform_branch (ps_uniform_branch, ps_scc_mask32) took any frame
length and a NaN barycentric i passed both range tests.
- check_flat raised ValueError on an empty readback and could pass NaN UVs.
- check_bitmask_perm passed a frame of any length with one good pixel.
- check_clip_half let NaN through on the covered half.
All of them now go through frame_problem(). The UniformBranchCheck
fixtures repeat their rows over a full 64x64 frame instead of 3 pixels.
Tested on an RTX 4070 SUPER (Windows 11, NVIDIA 32.0.16.2101):
run_gpu_tests.py 105/133 passed, 28 skipped, 0 failed before and after
(same per-test results); with LEONIDA_W64_EMULATE=1 133/133 before and
after. tests/semantic 1178 OK; the new tests fail on the old runner.
AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gen.mask_src turned an immediate lane-mask operand into bit 0 of the
constant for every lane, so s_and_saveexec_b32 s7, 0xff00 with all lanes
on left none on and an inline 5 left all 32 on. Lane L now takes bit L:
of the 64-bit value for the 64-bit forms (inline constants sign-extended,
literals with a zero high word, as src64_data) and of the 32-bit value at
L mod 32 for s_*_saveexec_b32 and s_andn2_wrexec_b32. 0 and -1 stay
constants. s_bcnt0/1_i32_b64 of a constant now counts the constant's bits
(scalar data, like s_ff1_i32_b64) instead of this lane's mask copy.
SGPR operands are unchanged.
GPU tests cs_w32_mask_imm.asm and cs_w64_mask_imm.asm, words derived in
their headers, failed on main on an RTX 5080 and an RDNA2 iGPU and pass
now; LaneMaskConstants runs both across every lane in the semantic suite.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
buffer_load_format_xy/xyz, tbuffer_load_format_xy/xyz and
buffer_store_format_xy/xyz were checked only on the CPU. The new
cs_fmt_xy_xyz.asm runs 12 loads and 9 stores on one thread, and
check.py and run_gpu_tests.py compare 128 dumped words.
Every expected word was measured by running the same body natively on a
Radeon 680M (gfx1035, RDNA2), through tools/hw_oracle's kernel wrapper
with s[0:3] set to the V# vk_compute_test passes. Wave32 and wave64 gave
the same words. What the hardware does:
- Loads write only their 2 or 3 VGPRs. A missing channel repeats one the
format has (SHADER-86), and tbuffer loads take the instruction's format.
- Bounds: the whole element must end inside num_records, even when the
loaded components do. Such a load reads 0, and such a store writes
nothing.
- A store with fewer components than its format writes the whole
element, with 0 for the rest. Into a one-channel format only x is
written.
The translation already does all of this. The test catches a store that
fills the missing components with anything but 0, a bounds check on the
first dword only, and an xy/xyz load that writes four VGPRs: each of
these, made in a scratch copy of the translator, failed 6, 16 and 18
words.
check.py's dump comparison becomes dump_test, shared with
fmt_1010102_test, whose messages are unchanged. docs/design.md records
the measured rules in the typed-load, format-store and bounds rows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GLSL.std.450 Fma may be split into two roundings by a driver (Vulkan
environment: inherited from OpFMul followed by OpFAdd); RDNA2 v_fma_* round
once. --fma khr (default stays glsl) emits OpFmaKHR with capability FMAKHR and
SPV_KHR_fma and lists shaderFmaFloat32 in the index. Runtime device creation
and the vk_* test programs enable VK_KHR_shader_fma when present; cs_fma_fused
tests single rounding; the mini interpreter learns OpFmaKHR.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Native gfx1036 clamps out-of-range channels from signed and unsigned RGBA32 views before packing D16 results. Exercise both limits in the existing GPU readback fixture so wrapping at either boundary is observable.
Neither instruction had a test (the _b32 forms are in #1299). The translator
needs no change: both pass.
- runtime/test/shaders/cs_w64x_andn2_exec.asm: one 64-lane wave. Each result
has lanes in one half of the wave only, so an EXEC or an SCC taken from the
other half alone shows; D is checked to be the old EXEC for saveexec and the
new one for wrexec. In check.py and run_gpu_tests.py as a wave64 dump.
- tests/semantic/test_andn2_exec_b64.py: 12 pairs of S0 and EXEC for each
instruction on all 64 lanes, against the ISA's definition written as
integers; also runs the GPU test's fixture.
Run on an RX 9070 XT (AMD 26.11.2, Windows 11): passes natively 64-wide and
with LEONIDA_W64_EMULATE=1; the whole GPU suite is 127/127 both ways and the
semantic suite 1175 tests OK. Breaking either instruction in the translator
(D of wrexec = the old EXEC, D of saveexec = the new one, andn2 as and) fails
the GPU test and 13 CPU subtests.
AI-assisted (Claude Code).
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
main moved (c0ac5fd): vulkan_replay.h takes main's checked buffer copies (predicated copies, overlap and overflow
refusals). README's Xbox row is rebuilt from both sides (the previous merge commit had committed a zero-filled
README.md; this restores it).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts (both sides kept): runtime/CMakeLists.txt (stub list), d3d12_com.h, d3d12_vulkan_device.cpp (arena buffers
with main's ray-tracing buffers and deferred destruction, calibrated timestamps, instance extensions, sampler
registration next to the window presenter), command_list.h, vulkan_backend.h, vulkan_replay.h, vk_test_device.h,
d3d12_state_map_test.cpp, docs and README. vulkan_present.h takes main's resource and tracker locks.
CI (linux-gpu-tests): ps_m15 and vs_m15 belong to d3d12_translated_draw_test. run_gpu_tests.py still assembles and
translates them but reports them as skipped (OTHER_HARNESS) instead of "no checker defined".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lane 0 of cs_dpp_bound has an invalid row_shr source and bound_ctrl:1, so it writes op(0, 10)=10; this pins the zero-filled src0 path for a VOP2 op. out[0..7] is 10 10 11 12 13 14 15 16 on the RTX 3070.
Three hand-written fixtures for translator rules that no test exercised
(or that only the CPU interpreter checked), expected words derived from the
RDNA2 ISA definitions in each .asm header:
- ps_vcmp_f32_nan: f32 VOPC with a quiet NaN read from memory. v_cmp
ge/lg/neq/nge (VCC) and ngt/nle/nlt/tru (SGPR), v_cmpx
ge/lg/nge/nlt/neq/o/tru/f.
- ps_vcmp_64: v_cmp lt/le/gt/ge u64 and i64, ne_u64, eq/ne_i64, v_cmpx
lt/ge/ne_i64 and gt/le_u64, with pairs where equal high words leave the
decision to an unsigned low word (0x80000000 vs 1).
- cs_w32_andn2_exec: s_andn2_saveexec_b32 and s_andn2_wrexec_b32 in a
32-thread wave: the EXEC they leave, old/new EXEC in D, SCC.
Registered in check.py and run_gpu_tests.py, added to regen_fixtures.py,
and asserted in test_value_semantics.py with plain-Python references.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/design.md marked four translator rules "not GPU-verified": v_cmp(x)_nlg,
v_cvt_off_f32_i4, the VOP3 output modifiers on v_fmac_f16 and
v_interp_p2/mov_f32, and VOP3 FP modifiers on constants. This adds one pixel
fixture per rule group, each writing four constant mrt0 words derived in its
header: ps_cmp_nlg, ps_cvt_off, ps_fmac_f16_mods, ps_vop3_const_mods,
ps_interp_f32_mods and ps_interp_mov_mods. The two interp fixtures are drawn
with a new vertex shader, vs_interp_consts, whose params are constant over the
triangle.
Every word is a normal float or zero, so the R32G32B32A32_SFLOAT target can't
change it. All six are wired into check.py and run_gpu_tests.py.
tests/semantic/test_rule_gpu_fixtures.py checks that the interpreter, both
runners and the headers agree. run_gpu_tests.py now skips only
ps_interp_f16_high under --bary-fallback, as check.py does, rather than every
PIXEL_VERTEX fixture.
On a Tesla V100 (NVIDIA 580.95.05, Linux), all six write their words on 4096
of 4096 pixels, natively and with LEONIDA_W64_EMULATE=1
LEONIDA_BARY_FALLBACK=1. docs/design.md now cites them. The integer clamp row
stays with quackottu's part of TEST-175, and the denormal-flush row still
needs an RDNA1/2 part.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review on #1249: the message offered '(or --llvm-mc)' in every tool, but
only run_gpu_tests.py has that option. run()/not_found() take the tool's
option name, and run_gpu_tests.py passes it. crosslane_fuzz.py imports
mc_command once at module level instead of in two functions.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
base_op stripped the _dpp suffix and the op ran as a plain move, so v_mov_b32_dpp quad_perm:[1,0,3,2] exported its own lane and still passed spirv-val. Implement the DPP16 controls (quad_perm, row_shl/shr/ror/share/xmask/mirror/half_mirror), DPP8 (dpp8 + fi), row/bank masks and bound_ctrl. A source lane that is out of range or inactive reads zero under bound_ctrl:1, otherwise the destination keeps its old value. Under --wave64-emulate the exchange goes through the workgroup buffer, like the other cross-lane ops. GPU-checked with cs_dpp*.asm on an RTX 3070.
Without llvm-mc, run_gpu_tests.py, valu_fuzz.py, lds_fuzz.py,
image_fuzz.py, crosslane_fuzz.py and runtime/test/shaders/build.py
ended in 'FileNotFoundError: [WinError 2]' from subprocess.run: the first
step of TEST-71 on a Windows machine without one. Only shader_disasm.py
said what was missing. mc_command.run() starts an llvm-mc command and
turns a command that can't be started into shader_disasm.py's message
(set LLVM_MC or --llvm-mc, build_llvm_mc.ps1, the WSL form); the six
llvm-mc call sites use it. tests/test_mc_command.py covers run() and
each tool with a nonexistent LLVM_MC.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts in docs/d3d12_vulkan.md, runtime/CMakeLists.txt, check.py,
run_gpu_tests.py and test_shader_checks.py: main's versions with
vk_sampler_test, ps_ssharp and its checks added back (ps_ssharp is drawn
with vs_ids through DRAWN_WITH now).
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At the center of the test texture red and green have the same value. Exchanging the two packed halves passed that check on hardware while 3584 pixels contained the wrong colors.
9,282 of the 26,503 shaders are mesh shaders, and a device without
VK_EXT_mesh_shader (NVIDIA Pascal, for one) can't run any of them. With
--mesh-compute each becomes a GLCompute module with the same workgroup size
and code; only the epilogue changes. After the same barrier, lane 0 writes
the vertex and primitive counts, lane i its vertex and its primitive, into
this workgroup's slot of an output buffer whose address is in push-constant
dwords 36-37 (152 bytes). The slot layout is mesh_compute_layout() and the
index records it as mesh_compute.
- tools/mesh_compute_vs.py: the vertex shader that draws the slots with a
non-indexed draw of groups * max_primitives * 3 vertices; unused and
culled primitives are clipped away, params keep their locations.
- vk_harness: VKH_MESH_COMPUTE (+ VKH_MESH_SLOT, VKH_MESH_PRIMS) dispatches
the module, adds a compute->vertex barrier and draws.
- run_gpu_tests.py / check.py: LEONIDA_MESH_COMPUTE=1 (check.mesh_env).
- tests/test_mesh_compute.py; docs/design.md row "Mesh shaders as compute",
docs/testing.md section.
GTX 1060 (Pascal) with LEONIDA_MESH_COMPUTE=1 LEONIDA_W64_EMULATE=1: all five
ms_* tests pass (SKIP before), zero validation messages. Mesh corpus: 9,282 of
9,282 translate and pass spirv-val with --mesh-compute --wave64-emulate, and
all 9,282 generated vertex shaders validate.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SSJXX67xeoorUsLJ2f9zms
A d16 image_load skipped the T# FORMAT branch the 32-bit load uses and
always read the float sampled view, which integer images are never bound
to, so a min16uint/min16int Load returned garbage (sint texel 14774 for
129 on an RTX 5070). d16 loads now go through image_load_typed and pack the
dmask components two per VGPR: f16 from the float view, the 16-bit integer
(truncated) from the uint/sint views.
A run-time texel Offset outside gather needs VK_KHR_maintenance8, which NVIDIA
Pascal lacks, so ps_texoff skips there and 4 PS (31 image_sample_o) can't run.
With --texel-offset-fallback the offset is folded into the coordinate:
coordinate + offset / size of the sampled level (0 for _lz/_c_lz, the LOD for
_l, OpImageQueryLod's for implicit samples, plus the bias for _b; floored and
clamped). An integer offset commutes with wrapping and clamping, so this is
exact at that level for every address mode; only a trilinear blend differs
(the coarser level moves by offset / 2). Implicit samples become Grad samples
with the unshifted coordinate's derivatives, so the LOD doesn't change with a
per-pixel offset. Gathers keep their Offset (shaderImageGatherExtended).
- LEONIDA_TEXOFF_FALLBACK=1 for build.py, check.py and run_gpu_tests.py;
vk_texture_test then isn't asked for maintenance8, and texoff_problem also
judges the +16/-32 sample.
- runtime/test/shaders/ps_texoff_implicit.asm: ps_texoff's per-pixel sample
as image_sample_o, the corpus form.
- tests/test_texel_offsets.py: the fallback for every sample form, including
spirv-val without --allow-offset-texture-operand.
- docs/design.md "Texel offsets", docs/testing.md.
GTX 1060: ps_texoff and ps_texoff_implicit 4096/4096 exact (SKIP before).
Corpus: the 4 PS translate and validate; needs_maintenance8 4 -> 0.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SSJXX67xeoorUsLJ2f9zms
On RDNA every s_barrier counts against the same workgroup barrier and a wave that has ended no longer counts;
SPIR-V needs every OpControlBarrier reached by the whole workgroup in uniform control flow. A native wave32
compute shader whose s_barrier sits anywhere but a top-level block of the structured tree now runs in rounds,
the emulated wave64 loop without its cross-lane part: s_barrier ends a segment, each invocation runs until its
next s_barrier or the end, and the workgroup meets at one OpControlBarrier at the end of the round. A per-round
count of the invocations not done (three Workgroup words) ends the loop. Native wave64 cs and ms are unchanged.
Intel Arrow Lake Xe-LPG iGPU (32.0.101.8132): cs_barrier_divergent and the new cs_barrier_early_end and
cs_barrier_loop lose the device with the plain translation and pass with barrier rounds; all three pass on an
RTX 5070 Ti (617.42) either way. docs/design.md's Workgroup barriers row describes it.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>