Commit Graph

231 Commits

Author SHA1 Message Date
dd6f55634b Merge pull request #1041 from sanuk369 2026-11-22 01:38:00 -05:00
d1d23d842d Merge pull request #804 from Jess-Doit 2026-11-22 01:37:54 -05:00
4030a386fb Translator: --bary-fallback for raw barycentrics without VK_KHR_fragment_shader_barycentric (SHADER-98)
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
2026-11-21 22:28:25 -08:00
3d15db456b Merge pull request #1017 from Vonsek 2026-11-22 01:08:23 -05:00
94aaa2b799 Merge pull request #1011 from nicolas 2026-11-22 01:08:20 -05:00
926b03eb22 Merge pull request #1003 from bobcatchris 2026-11-22 01:08:17 -05:00
63bb76f079 Merge pull request #820 from kapitche 2026-11-22 01:08:06 -05:00
66c07cc858 carve_all.ps1: archive names from the resolved -Game, so a relative or trailing-backslash path works
The archive name was FullName.Substring($Game.Length + 1), which assumes
-Game is absolute and has no trailing separator. With -Game .\game (what
tab completion gives) or game, the name kept part of the absolute path;
with a trailing backslash it lost its first letter ("carving ommon.rpf").
Either way every existing carve was missed and everything was carved
again into misnamed folders, and coverage.json named the wrong archives.

-Game is now resolved, and names are cut after it plus one separator.
tests/test_carve_all_paths.py runs the three forms against two carves
that are already there.
2026-11-22 11:37:41 +05:30
87d7bf7c43 Translator: SMEM alignment, s_buffer_load NUM_RECORDS bound, signed s_load imm, raw MUBUF per-dword tail
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>
2026-11-21 22:49:26 -07:00
773891bdff fix: pack D16 explicit-LOD gather results
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.
2026-11-22 06:48:05 +01:00
502462e1c7 rdna2spirv: set constant EXEC lane bits with shift and mask, not OpBitFieldUExtract
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.
2026-11-22 00:46:32 -05:00
f966fc159b Tests: cover the Wine test runner, and stop it crashing on bad input
scripts/run_wine_tests.py is what runtime.yml's wine job runs, and it was the
only script in the tree with no test. tests/test_run_wine_tests.py drives it
with the Python interpreter as the "wine" command and tiny exit-code scripts
as build artifacts, so every status and exit code is checked without Wine.

That exposed three real defects, fixed here: a --tests file that is not JSON
(and JSON that is not ctest --show-only=json-v1 output) ended in a
JSONDecodeError/AttributeError before any test ran; a wine command that cannot
be started ended in FileNotFoundError out of subprocess.run, losing every
result; and WILL_FAIL/ctest booleans were read with Python truthiness, so the
JSON string "0" inverted the check. --timeout now refuses 0 and negatives,
which previously raised ValueError inside subprocess.run.

Negative control on main: 1 failure and 17 errors. With the change: 24/24.
Standard library only, no Wine, no game data.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-21 23:36:48 -06:00
07402f3828 Merge pull request #973 from Vonsek 2026-11-22 00:33:21 -05:00
81647000cc Merge pull request #950 from Bushyon 2026-11-22 00:33:14 -05:00
738870a92b Merge pull request #793 from DANISBR1 2026-11-22 00:32:53 -05:00
acbb574bca Fail a GPU test filter that selects only inputs 2026-11-21 22:30:27 -07:00
5826a60187 fix: apply sampler LOD bounds to emulated gathers
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.
2026-11-22 06:25:26 +01:00
1293cc2656 Translator: hardware NaN rules for float min/max/med3, v_fract below 1.0
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>
2026-11-21 22:25:05 -07:00
f61720d877 Translator: s_cmp of a lane mask with -1 compares the real mask word
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>
2026-11-22 02:04:46 -03:00
e13c9ceb77 Merge pull request #870 from nicolas 2026-11-21 23:15:38 -05:00
524bb1fb7b Merge pull request #862 from sanuk369 2026-11-21 23:15:35 -05:00
d627754795 Merge pull request #849 from stayjuced 2026-11-21 23:15:33 -05:00
0e191881e2 Merge pull request #846 from Ayoze Torres 2026-11-21 23:15:32 -05:00
b7e24a0869 run_gpu_tests: run cs_wavemask once and report it once
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>
2026-11-21 22:09:09 -06:00
9e9138829a CI: run the Wine job on WineHQ stable as well as Ubuntu's Wine
A matrix entry installs winehq-stable from WineHQ's repository next to
Ubuntu's Wine 9.0, closer to what Proton users run. The job summary
names the Wine version (run_wine_tests.py --label).
2026-11-22 03:55:52 +00:00
f674a125d9 CI: pe_loader_bounds off the default EXE base; host-tool tests skip under Wine
test_pe_loader_bounds maps images at 0x140000000 like loader_test, so it
links with GTA6RT_HOST_BASE too (under Wine every case was rejected with
"preferred base is taken").

run_wine_tests.py: a test whose command is a tool of the Windows runner
(gameinput's cmake -P, d3d12_trace's python) is reported as skipped with
that reason instead of failing as missing from the artifact.
2026-11-22 03:55:50 +00:00
8987269414 Report available shader statistics across drivers 2026-11-21 20:55:26 -07:00
0c84bff89a GPU tests: a device with too few push constant bytes skips the texture tests
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.
2026-11-22 09:25:03 +05:30
ddb1faf9b7 Reject llvm-mc install paths inside the cleanup directory 2026-11-21 22:50:24 -05:00
48e086cc39 Merge pull request #835 from kapitche 2026-11-21 22:48:36 -05:00
2867a3b545 Merge pull request #253 from AlxcBTW 2026-11-21 22:48:27 -05:00
1552ae7278 Merge remote-tracking branch 'origin/main' into bpw32-main
# Conflicts:
#	docs/design.md
#	runtime/test/shaders/check.py
#	scripts/run_gpu_tests.py
2026-11-22 04:42:52 +01:00
ff07b0b6e3 Merge pull request #821 from stayjuced 2026-11-21 22:37:49 -05:00
6c5550d456 GPU tests: give each test program a time limit, so a GPU hang fails one test instead of stalling the suite
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.
2026-11-21 22:37:45 -05:00
78c5b429bc Merge pull request #795 from DANISBR1 2026-11-21 22:37:44 -05:00
b07409135d Merge pull request #677 from nicolas 2026-11-21 22:37:39 -05:00
52a357c604 Merge pull request #341 from AlxcBTW 2026-11-21 22:37:36 -05:00
c2df6ab458 Warn when post-install llvm-mc cleanup fails 2026-11-21 22:31:40 -05:00
710c5e724b Merge remote-tracking branch 'origin/main' into shader-36-gather-wrap
# Conflicts:
#	scripts/run_gpu_tests.py
#	tests/test_shader_checks.py
2026-11-22 04:27:11 +01:00
ebbce72855 Merge remote-tracking branch 'origin/main' into bpw32-main
# Conflicts:
#	docs/design.md
#	runtime/test/shaders/check.py
#	scripts/run_gpu_tests.py
2026-11-22 04:22:25 +01:00
84e1d2ebe9 Merge pull request #769 from mohamedsaad.lahlou 2026-11-21 22:08:46 -05:00
b288ad9638 Merge pull request #680 from kotorvr 2026-11-21 22:08:12 -05:00
10f5b63a26 Merge updated GPU runner checks while preserving packed-format coverage 2026-11-21 20:07:25 -07:00
f577bf0318 vk_pipeline_check --stats: the driver's statistics for each translated shader
vk_pipeline_check <spirv dir> --stats FILE enables VK_KHR_pipeline_executable_properties, creates the
pipelines with CAPTURE_STATISTICS and writes, for the executable that runs each translated shader (not
the partner stub's), every statistic the driver reports as CSV rows name,stage,statistic,value. On RADV:
instructions, VGPRs, SGPRs, spills, scratch size, waves per SIMD, and more.

scripts/shader_stats.py <stats.csv> <disasm dir> [--details] compares them with the original RDNA
listings: code growth, VGPRs against the highest VGPR the original uses, and which shaders use scratch or
spill (a register file that went to memory, e.g. through v_movrels with an unbounded index). Over the
corpus it says how many shaders compile badly.

RX 5700 XT (RADV), the repository's test shaders: 47 pipelines, no scratch or spills in any.
New tests/test_shader_stats.py (standard library only).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 21:06:49 -06:00
1b6cc3f2c2 Translator: ds_read_u8/i8_d16[_hi] 8-bit LDS reads into a 16-bit half (SHADER-85)
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>
2026-11-21 22:02:47 -05:00
71812aac05 GameInput shim: download SDL3 only when asked (LEONIDA_SDL3_FETCH)
The shim is built with an installed SDL3 (find_package) or with
-DLEONIDA_SDL3_FETCH=ON / FETCHCONTENT_SOURCE_DIR_SDL3; otherwise configure
prints a message, gta6rt builds without it, and CTest lists gameinput as
disabled. build_runtime.ps1 gains -FetchSdl3 and warns that its cl.exe
fallback never builds the shim. Review nits: delivering_thread is atomic,
and SDL's own GameInput joystick driver is pinned off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 02:58:46 +00:00
9f8cac64f5 Tests: isolate shader inputs when reusing GPU test work 2026-11-22 03:46:04 +01:00
5879d22055 Merge remote-tracking branch 'origin/main' into shader-36-gather-wrap
# Conflicts:
#	scripts/run_gpu_tests.py
#	tests/test_shader_checks.py
2026-11-22 03:41:57 +01:00
875aecb46e Merge remote-tracking branch 'origin/main' into bpw32-main
# Conflicts:
#	docs/design.md
#	runtime/test/shaders/check.py
#	scripts/run_gpu_tests.py
#	tests/test_run_gpu_tests.py
2026-11-22 03:38:09 +01:00
1511d2bff2 Merge pull request #747 from Ayoze Torres 2026-11-21 21:37:57 -05:00