Commit Graph

280 Commits

Author SHA1 Message Date
c4db02a1c8 Merge pull request #1334 from ezwinxdlmao
# Conflicts:
#	docs/design.md
2026-11-22 05:37:46 -05:00
d5c0e16319 Tests: GPU test for the xy/xyz typed buffer loads and stores (TEST-185)
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>
2026-11-22 12:31:42 +02:00
1b88414e61 Tests: s_andn2_saveexec_b64 and s_andn2_wrexec_b64 on wave64, GPU and CPU
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>
2026-11-22 11:22:13 +01:00
f85582e23d Merge pull request #1318 from Freem 2026-11-22 05:08:05 -05:00
5b5f82a409 Merge pull request #1296 from Flyander 2026-11-22 05:07:55 -05:00
f0aa5c9693 Merge pull request #1293 from cxchhh 2026-11-22 05:07:54 -05:00
5f9ed5f458 Skip ps_bitmask_perm when fragment shaders run narrower than 32 lanes 2026-11-22 11:00:52 +01:00
311c37d059 Close remaining files in GPU test runner 2026-11-22 10:55:15 +01:00
220fa73744 GPU tests: cover non-mov DPP with bound_ctrl
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.
2026-11-22 09:51:36 +00:00
ea0fbf4486 Close GPU readback files after reading 2026-11-22 10:45:43 +01:00
8c4e3832d9 GPU fixtures for the CPU-only nlg, cvt_off, output-modifier and constant-modifier rules (TEST-175)
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>
2026-11-22 09:41:50 +00:00
bafbdc87b7 Merge pull request #1269 from bobcatchris 2026-11-22 04:37:57 -05:00
18670d9aea Merge pull request #1249 from Felix Croasdale 2026-11-22 04:37:52 -05:00
5f6603cc01 Merge pull request #238 from Mokbul Miah 2026-11-22 04:37:47 -05:00
418dcd6223 audit_shader4_regs: a bad path is one ERROR line, and --json keeps its folder
os.listdir on a missing path or a file traced back with FileNotFoundError, and
--json into a folder that does not exist raised after the whole corpus audit had
already printed its report, losing the run. An explicit --fssm/--dxbc that does
not exist was counted as "(missing fssm)" instead, so the report looked valid
while every CS shader's RSRC2 was skipped. Validate the three paths, create the
report's folder, and report an unwritable report path as one line.
2026-11-22 03:24:37 -06:00
aa41f3d500 mc_command: name --llvm-mc only for the tool that has it; one import in crosslane_fuzz
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>
2026-11-22 03:15:13 -06:00
8c20dd093d Translator: implement DPP16/DPP8 source selection
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.
2026-11-22 09:15:01 +00:00
40bd14777a Merge pull request #1249 from Felix Croasdale 2026-11-22 04:07:53 -05:00
4ee52cab78 Merge pull request #1238 from Felix Croasdale 2026-11-22 04:07:49 -05:00
cac87b289d Merge pull request #1233 from Nostyxx 2026-11-22 04:07:47 -05:00
e63bf6bdef mc_command.run: a missing llvm-mc is one line, not a FileNotFoundError traceback
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>
2026-11-22 03:02:20 -06:00
f4ee349968 build_runtime.ps1: the cl.exe fallback builds the GPU test harnesses the tools need
Without VS's "C++ CMake tools" component, build_runtime.ps1 compiles
with cl.exe directly, and that list never built vk_compute_test,
vk_store_test or vk_harness (the programs check.py and run_gpu_tests.py
require and valu_fuzz.py/lds_fuzz.py run), nor vk_image_fuzz
(image_fuzz.py's harness). TEST-71 on that path stopped at
"vk_compute_test not found". Build them the way the fallback builds
vk_texture_test. tests/test_build_runtime_fallback.py checks that the
fallback builds every harness those tools name and that each source it
compiles exists.

Found by @derekhearst.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 02:46:54 -06:00
342028959a build_llvm_mc: install llvm-mc outside AppData, where the install manager's python can see it
python from the Python install manager (the WindowsApps alias) doesn't see folders other programs create under %LOCALAPPDATA% or %APPDATA%, so the old default made make_game.py report llvm-mc missing and the fuzzers stop with WinError 2 although LLVM_MC named the file. The default -Dest is now %USERPROFILE%\.leonida\llvm-mc, and the preflight explains an LLVM_MC that points into AppData.
2026-11-22 15:39:48 +07:00
4f2b8877f0 Merge pull request #1226 from Vonsek 2026-11-22 03:37:57 -05:00
e7d204c6dc Merge pull request #1214 from quackottu 2026-11-22 03:37:52 -05:00
445be4daa7 test(shader): check every D16 texture sample across the frame
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.
2026-11-22 09:36:10 +01:00
98f485f492 Translator: read the high f16 half in v_interp_p1ll_f16 / v_interp_p2_f16 (high) 2026-11-22 13:57:08 +05:30
caad84c32b Translator: --mesh-compute runs mesh shaders without VK_EXT_mesh_shader
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
2026-11-22 00:21:36 -08:00
e0343157d8 Merge pull request #1143 from Rayhan Robin 2026-11-22 02:47:54 -05:00
fcdf2b391d Merge pull request #1136 from quackottu 2026-11-22 02:47:52 -05:00
b4db783bb7 Merge pull request #1127 from Jess-Doit 2026-11-22 02:47:49 -05:00
9b524e5774 Merge pull request #1122 from whattheflop 2026-11-22 02:47:47 -05:00
9307b32b3f Merge pull request #1111 from quackottu 2026-11-22 02:47:44 -05:00
f7679b4909 Merge pull request #1104 from AlxcBTW 2026-11-22 02:47:41 -05:00
1bc8459361 Merge pull request #930 from BACONMANXDGOD 2026-11-22 02:47:39 -05:00
059e6afd86 BUILD: use canonical game path prefix in carve_all.ps1 2026-11-22 01:34:55 -06:00
1979b944f5 rdna2spirv: d16 image_load reads integer images through their uint/sint views
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.
2026-11-22 12:57:13 +05:30
a0a6d2f07c Translator: --texel-offset-fallback for image_sample*_o without VK_KHR_maintenance8
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
2026-11-21 23:18:38 -08:00
43b5b3ecc0 Use literal paths in meta_to_xml.ps1 2026-11-22 17:14:28 +10:00
2b7621997a Merge remote-tracking branch 'origin/main' into oob-select-v2
# Conflicts:
#	tests/semantic/regen_fixtures.py
2026-11-22 08:11:31 +01:00
c774f25f09 rdna2spirv: barrier rounds for wave32 compute shaders whose s_barrier isn't in uniform control flow (SHADER-91)
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>
2026-11-22 01:09:17 -06:00
70ed36c765 Merge pull request #1100 from quackottu 2026-11-22 02:09:06 -05:00
16608f2a53 Merge pull request #1064 from SHAURYASANYAL3 2026-11-22 02:08:57 -05:00
2a0de113b3 Merge pull request #988 from jdotcollins 2026-11-22 02:08:53 -05:00
9543f5d305 carve_all.ps1: -LiteralPath everywhere, so a folder with [ ] in its name works
-Game was resolved with -LiteralPath, but Get-ChildItem, Test-Path,
Get-Content and Set-Content then took it as a wildcard path. A game folder
like 'GTA VI [1.0.2.1]' matched no archives and the script exited 0 without
writing coverage.json; an -Out folder with brackets broke the index.json
skip.
2026-11-22 12:38:16 +05:30
662752cc57 run_gpu_tests: bary, gradient and WQM checks fail a NaN or short frame
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.
2026-11-22 12:25:11 +05:30
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
16e7591419 runtime: thunk deduplication, XGameRuntime shims, PE loader long paths, and drive-root packaging 2026-11-22 12:19:06 +05:30
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
dd6f55634b Merge pull request #1041 from sanuk369 2026-11-22 01:38:00 -05:00