Commit Graph

29 Commits

Author SHA1 Message Date
b9ed33b241 Merge pull request #3263 from Dominik 2026-11-22 15:16:18 -05:00
61a9adc2a8 vk_compute_test: VKC_HEAP_INIT seeds the heap from a file before the dispatch
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>
2026-11-22 19:56:18 +00:00
151c372ee1 Merge pull request #2395 from Matheus Gomes 2026-11-22 13:14:40 -05:00
33456ca4e7 fix(test): enable shaderFloat64 for compute SPIR-V that declares it
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.
2026-11-22 13:53:56 -03:00
0ec464b0e1 GPU tests: bind the --pc-tail-ubo block, so 128-byte push-constant devices run the tests
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>
2026-11-22 18:48:05 +02:00
f3977cac42 Merge main into test-184-image-ops
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>
2026-11-22 07:33:23 -05:00
d55fa3d4d1 Translator: image_bvh triangle nodes read their type's vertex slots and the barycentric remap byte
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>
2026-11-22 12:56:07 +01:00
5e91fb9af2 Merge main into test-184-image-ops
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>
2026-11-22 06:31:49 -05:00
b9864d274a vk_compute_test: the heap of the bvh mode holds its BVH
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>
2026-11-22 05:43:32 -05:00
e256a2547c Translator: --fma khr emits OpFmaKHR for fused multiply-adds
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>
2026-11-22 11:25:37 +01:00
f7679b4909 Merge pull request #1104 from AlxcBTW 2026-11-22 02:47:41 -05:00
d1a7bb96d2 check.py: request 32 lanes for the wave32 lane-mask dumps, as run_gpu_tests.py does (#774)
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.
2026-11-21 23:53:02 -07:00
14887e6828 Translator: honour V# OOB_SELECT in MUBUF/MTBUF bounds checks
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>
2026-11-22 07:40:20 +01:00
6d7bb1755a Tests: shader tools honor LEONIDA_VK_DEVICE
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>
2026-11-22 00:02:29 -06:00
9806be2999 Tests: prefer the native Vulkan ICD over Mesa's Dozen on Windows
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>
2026-11-21 22:58:59 -06:00
95ab84432d vk_compute_test: seed s4.. from VKC_SGPRS, so a compute test can take an input word
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>
2026-11-21 19:22:03 -06:00
ed742a6b0b lds_fuzz: count skips and harness errors apart from matches, never compare a stale dump or SPIR-V, --show keeps --no-exec; vk_compute_test checks the dump after close 2026-11-22 01:18:38 +02:00
4fe8cdf38d Tools: LDS / ds_* differential fuzzer on the GPU (FUZZ-6)
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.
2026-11-22 01:13:21 +02:00
cdaef79a7d Wave64 emulation: fewer rounds (reuse mask exchanges, chain voted branches), benchmark
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>
2026-11-21 22:52:35 +01:00
5b3bbad6e6 Test compute workgroup Y/Z registers on a 3D Vulkan dispatch 2026-11-21 22:00:38 +01:00
6582fa2dcb Make Vulkan shader checks aware of wave64 support 2026-11-21 19:46:32 +02:00
4b251d1cb6 Merge pull request #15 from Mulkku
# Conflicts:
#	runtime/test/vk_store_test.cpp
#	runtime/test/vk_texture_test.cpp
#	runtime/test/vulkan_loader.h
#	tools/rdna2spirv.py
2026-11-21 11:47:52 -05:00
6f486f75d3 Merge pull request #13 from eIBart0 2026-11-21 11:46:54 -05:00
987e8471ee Fix RDNA2 wave masks and flat inputs
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.
2026-11-21 16:56:54 +02:00
e72e13ecfe Vulkan tests: fix AMD vk_store_test bindings, add subgroupSizeControl, add GPU test runner 2026-11-21 10:55:05 -03:00
4146672f58 Vulkan tools: fix builds on Linux 2026-11-21 02:35:54 -03:00
cef55f04ae Translator: ray tracing (image_bvh(64)_intersect_ray emulated per RADV's software path), backward far branches
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>
2026-11-20 22:18:47 -05:00
21c8ae0ab6 Translator: exact wave64 lanes in CS/MS, per-lane constant EXEC halves, exec_hi writes; shader metadata index
- 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>
2026-11-20 22:04:21 -05:00
bd2dd1c874 Translator: compute shaders, LDS, wave-uniform branches, typed image stores; all VS/PS failure groups
- 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>
2026-11-20 18:59:41 -05:00