Review of #2886: the probe needs subgroup operations in compute (supportedStages) with basic and ballot
(supportedOperations), or the size stays "not available". LocalSize is the one of the GLCompute entry point "main"
the pipeline is made from, not the last in the module. The width is checked from each subgroup's own lane numbers
and ballot (a wrong width fails the test); 32-lane subgroups that aren't in invocation order, which Vulkan doesn't
promise and the translator assumes, print "not available" and the runners skip.
MoltenVK reports subgroups 4..32 and requiredSubgroupSizeStages 0, so VKC_SUBGROUP_SIZE=32 printed "not available"
and the 32-lane compute tests skipped. The translator emits SPIR-V 1.5, where varying subgroup sizes are not allowed,
so Vulkan fixes SubgroupSize at the device's subgroupSize (32 there). vk_compute_test now runs a probe shader
(cs_wave_probe.comp, embedded) with the test's local size and flags first, checks every invocation's lane, subgroup
number and ballot width, and runs the test if they match. If they don't, the test fails (exit 1) instead of being
skipped. Full subgroups are requested where local size X is a multiple of maxSubgroupSize. Devices whose default
isn't the requested size keep printing "not available".
A compute program that reads its inputs from memory (a root table, descriptors,
data) needs them in the heap before it runs; VKC_SGPRS only reaches s4..s31.
VKC_HEAP_INIT=<file> copies the file to Xbox VA 0 after the default fill. A file
larger than the buffer, or one that can't be read, is refused (exit 2).
cs_heap_init.asm loads four words the file put at 0x100 and stores them at 0;
check.py and run_gpu_tests.py write the file and check the words and the
file's zeros past them. First part of TEST-594 (the BVH builder's programs read
their root table from the heap).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use the existing SPIR-V capability scan to request the feature before creating the Vulkan device, or report an unsupported-device skip. Add a synthetic compute case that checks both words of a binary64 result.
With LEONIDA_PC_TAIL_UBO=1, build.py and run_gpu_tests.py translate with --pc-tail-ubo, and the test
programs (vk_compute_test, vk_store_test, vk_harness, vk_texture_test, vk_sampler_test, vk_bindless_test)
declare and push 128 bytes and, when a stage declares set 1, bind the tail block there
(runtime/test/vk_pc_tail.h: a host-visible buffer with one slot per dispatch or draw, bound as a dynamic
uniform buffer). vk_harness refuses --mesh-compute with the flag (exit 77): mesh_compute_vs.py's vertex
shader still reads its address from push constants. Without the variable nothing changes.
Step 2 of the uniform-buffer tail claimed in #1902.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main is at 41f44826. Two conflicts, both sides kept:
- docs/design.md: both sides edited the one-line "Ray tracing" row. Main's
row (the triangle node types and their vertex slots), with this branch's
sentence about cs_bvh32 where it stood.
- tests/test_shader_checks.py: main counts ps_ssharp (9 -> 10) and patches
sampler_test on the lines next to this branch's STORE_WORDS / GET_LOD_TESTS
terms and its get_lod_test patch. All four lines.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
image_bvh(64)_intersect_ray followed RADV's software path on triangle nodes,
which always reads vertex slots 0, 1, 2 and returns (v, w): RADV builds one
triangle per node. The hardware format packs up to four triangles per node,
and the node type picks the slots: TRI0 (0,1,2), TRI1 (1,3,2), TRI2 (2,3,4),
TRI3 (2,4,0). The type's byte of the triangle-ID word at +60 picks which two
vertex weights come back (bits [1:0] and [3:2]; 0x09 is RADV's v, w). A BVH
with paired leaves therefore traversed TRI1 against the wrong triangle.
Both rules come from AMD GPURT (CalcTriangleCompressionVertexIndices,
SwizzleBarycentrics, TRIANGLE_ID_I/J_SRC_SHIFT), and the public XDXR software
path (Read3Verts, TestXboxBvh4Leaf) agrees with it.
- tests/semantic/test_image_bvh_tri.py: every node type on a hand-built node,
every remap selector pair, the byte per type, selector 3, a zero word
- spirv_mini_interp: OpVectorExtractDynamic and GLSL.std.450 FSign, from the
specifications
- vk_compute_test "bvh": its hand-built triangle nodes now carry the 0x09
triangle ID a builder writes; expected words unchanged
- docs/design.md Ray tracing row, docs/bvh.md 7a, translator docstring
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main is at bb2e1842. Three conflicts, both sides kept:
- runtime/test/vk_store_test.cpp: main added the "load-d16" mode (a row of
16-bit boundary values in the fill, for the saturating d16 loads) and
VK_KHR_shader_fma support; this branch added the "words" mode. Both modes
and both includes stay; main's boundary row applies to "load-d16" only, so
"words" keeps the plain fill its expected words are derived from.
- runtime/test/shaders/check.py: main lengthened CS_STORE on the line next to
this branch's cs_bvh32 entry. Both lines.
- tests/test_shader_checks.py: main counts cs_fma_fused (8 -> 9) on the line
after this branch's STORE_WORDS and GET_LOD_TESTS terms. Both.
The automatic merges were read as well: vk_compute_test.cpp keeps the larger
bvh heap next to main's shader_fma code, and check.py and run_gpu_tests.py
run cs_imgload_d16 in "load-d16" next to the "words" fixtures.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The "bvh" mode writes its nodes at heap offsets 0x100 to 0x264, but with one
group the heap buffer is 64 words, 256 bytes. The host wrote past the mapped
range and the shader read the nodes through the buffer device address outside
the buffer. It worked because the memory allocation is larger than the buffer.
GPU-assisted validation reports it for cs_bvh on current main:
VUID-RuntimeSpirv-PhysicalStorageBuffer64-11819, "trying to read 4 bytes at
[..220, ..223) but this range does not belong to any buffer", the buffer being
256 bytes. The heap is now at least 0x280 bytes in this mode. The eight result
words are unchanged, and both BVH fixtures are clean under core and
GPU-assisted validation on RADV (RDNA2 integrated GPU) and llvmpipe.
Co-Authored-By: Claude Fable 5.2 <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>
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 GPU tools picked a device with the shared ranker but never applied the
name filter the D3D12 tests have used since #861. Filter candidates through
vulkan_device_wanted in vk_device_pick.h, report a filter that matches nothing
instead of dereferencing a null device, and cover the filter cases in the
picker test. docs/testing.md no longer says the tools ignore it.
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
With the Compatibility Pack installed, Windows enumerates Mesa's D3D12
translation layer next to the real GPU, and Dozen reports DISCRETE_GPU. Every
harness used "the last discrete device wins", so it selected the wrapper and
the resulting failures looked like translator bugs (#915). One shared rank now
treats Microsoft's vendor as a translation layer, then prefers discrete over
integrated over virtual over CPU, keeping the first device on a tie. A CPU-only
test covers the reported enumeration without needing the Compatibility Pack.
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
vk_compute_test always put the output V# in s[0:3] and zero in every
other user SGPR, so a compute test shader could not be given an input
word: #300's cs_cvt_f32_sat reads its float from s4 and could only be
checked on a GPU by building one shader variant per input by hand.
- VKC_SGPRS=w4,w5,... sets s4, s5, ... up to s31 (s[0:3] stay the output
V#), with the same syntax and checks as vk_harness's VKH_SGPRS: decimal
or 0x hex, no sign, nothing above 32 bits, no trailing comma, at most
28 words; anything else exits 2 with a message.
- cs_user_sgprs.asm declares eight user SGPRs (RSRC2 0x8090) and stores
s4..s7 back. Both runners seed it with 0x4f000000,0xdeadbeef,7,
0xffffffff (check.USER_SGPRS) and expect those words, then the
0xEEEEEEEE fill.
- check.compute_test() takes an env for vk_compute_test.
- tests/test_shader_checks.py: the fake harness only answers
cs_user_sgprs with the seeded words when VKC_SGPRS was passed, and no
other test may get VKC_SGPRS.
AI-assisted (Claude Code). Tested on NVIDIA GeForce RTX 4060 Ti (Ada,
subgroup 32), driver 32.0.16.2124, Windows 11, on main d937b7f:
- run_gpu_tests.py cs_user_sgprs PASS natively and with
LEONIDA_W64_EMULATE=1; check.py cs_user_sgprs ok
- vk_compute_test directly: unset -> s4..s7 read 0; "5" sets s4 only;
28 words accepted; "1,2,", "-1", "0x1ffffffff", "abc" and 29 words
exit 2
- test_shader_checks.py fails (7) if check.py stops passing VKC_SGPRS
- full suite: see the PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/lds_fuzz.py generates seeded 64-thread compute programs (wave64 or wave32, 4 KiB LDS) over the ds_*
instructions the translator accepts: every read width (also u16 d16/d16_hi), byte/short writes (also d16_hi),
read2/write2 (+st64), the add/sub/min/max/and/or/xor atomics with and without return, wrxchg, cmpst, ds_swizzle
and ds_bpermute, under random EXEC masks. It translates them, runs them with vk_compute_test and compares every
thread's 16 result VGPRs and the whole LDS bit for bit with a model written from the ISA, naming the op that last
wrote a wrong register. vk_compute_test gets VKC_OUT_WORDS / VKC_DUMP to read the whole buffer back.
On an RX 6700 XT the only mismatch is the wave32 ds_bpermute inactive-source case #253 fixes. docs/design.md no
longer claims the 8-bit d16 reads, which the translator rejects.
A whole-mask read of a register value already exchanged in the block reuses
the exchange; a block ending in a voted branch runs its successor in the
round that reads the vote. Adds scripts/bench_wave64.py, cs_bench_mix,
VKC_BENCH timing in vk_compute_test and the cs_w64x_mask_reuse test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Preserve whole-wave mask operations, saved EXEC values and flat
pixel inputs when generating SPIR-V. Keep a dispatch-loop fallback
alongside structured control flow and share the descriptor probe.
Add reproducible GPU fixtures for these cases and exercise the
control-flow and mask analyses in CI.
The BVH step is emulated over buffer reads in AMD's node format (box16/box32/triangle), with RADV's
watertight triangle test and sorted box children. GPU-checked with a synthetic BVH (vk_compute_test bvh).
All 64 ray-tracing compute shaders translate.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- wave64 detected per shader; v_mbcnt and EXEC writes use the hardware lane (LocalInvocationIndex in CS/MS).
- s_mov_b32 exec_lo/exec_hi with a constant now sets each lane from its own bit (any non-zero constant
used to enable every lane). GPU-checked (cs_exec64).
- spirv/index.json: stage, wave size, capabilities/extensions, Vulkan features, bindings, local size, LDS,
mesh/GS limits and IO locations per shader, so pipelines can be created up front.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Compute: FSSM word 0x138 is COMPUTE_PGM_RSRC2 (user SGPRs, workgroup-id enables, thread-id VGPRs,
LDS size), 0x13C..0x144 the group size; checked against 2,689 CS. GPU-checked with vk_compute_test.
- LDS as a Workgroup array (reads/writes/read2/write2/st64/sub-dword/atomics/cmpst), ds_bpermute,
s_barrier as a workgroup control barrier.
- s_cbranch_vccz/vccnz/execz/execnz decided wave-wide (OpGroupNonUniformAny); v_cmp writes 0 for
inactive lanes. GPU-checked.
- image_store for 2D/2D array/3D with float/uint/sint views picked from the T# FORMAT at run time.
- Raw barycentric reads via BaryCoordKHR (321 PS), POPS via fragment-shader interlock, image_sample_o
offsets, fma_f16 op_sel, 64-bit v_cmpx, vcc_lo scalar loads, s_addk to specials, undeclared vertex
components, normalized-encoding re-anchoring, array image_get_lod/gather4_lz, image_sample_l LOD on
arrays (was reading the layer).
- Duplicate vector/pointer type declarations merged; vk_harness enables barycentrics/interlock/maintenance8.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>