Commit Graph

189 Commits

Author SHA1 Message Date
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
63bb76f079 Merge pull request #820 from kapitche 2026-11-22 01:08:06 -05:00
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
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
524bb1fb7b Merge pull request #862 from sanuk369 2026-11-21 23:15:35 -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
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
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
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
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
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
10f5b63a26 Merge updated GPU runner checks while preserving packed-format coverage 2026-11-21 20:07:25 -07: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
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
b0476248e8 Merge pull request #720 from fearkov 2026-11-21 21:37:52 -05:00
fcd51e74ba Merge pull request #708 from Spaghetih 2026-11-21 21:37:50 -05:00
1df0045b5c Merge pull request #500 from troythedecoyx 2026-11-21 21:37:44 -05:00
fcea57d5d9 Merge pull request #455 from fearkov 2026-11-21 21:37:44 -05:00
48f2164427 Merge pull request #399 from fearkov 2026-11-21 21:37:44 -05:00
f4fcbdc2bb Tests: run_gpu_tests.py reports a pixel test the device can't run once
A vk_harness exit 77 appended the SKIP row twice, so the shader was listed twice and the summary counted it twice (n/total and skipped).
2026-11-21 22:16:26 -04:00
ce87bf7ede Merge upstream GPU runner coverage into the packed format fixture branch 2026-11-21 19:14:27 -07:00
54d3ea1a88 GPU test: s_barrier sites in different wave-uniform branches meet (SHADER-91)
cs_barrier_divergent: wave32, 128 threads. Wave 0 and waves 1-3 take different branches, each with its own s_barrier; on RDNA they count against the same workgroup barrier, so wave 0 reads what wave 3 wrote to LDS (out[i] = 127 - i). Registered in check.py and scripts/run_gpu_tests.py as a wave32 dump that doesn't need 32-lane subgroups.

Passes on an RTX 4070 Ti with the current translator; it guards the behaviour for any change to barrier handling.

AI-assisted.
2026-11-22 03:12:48 +01:00
b707035ca0 Tests: vk_texture_test enables shaderResourceMinLod for a MinLod clamp
A shader that declares MinLod (image_sample_d_cl) needs the feature, and without it the validation layer reports VUID-VkShaderModuleCreateInfo-pCode-08740. A device without it is now a skip (exit 77), as in the other texture tests.
2026-11-21 22:11:02 -04:00
bd880b85cc Tests: a16 bias, d_cl and depth compare samples on a GPU 2026-11-21 22:10:52 -04:00
8de6eb2875 Tests: vk_texture_test dref checks depth compare samples on a GPU 2026-11-21 22:10:21 -04:00
ad6bb01d06 GPU and value test for SHADER-46: s_ff0/s_ff1_i32_b32 of an immediate
The follow-up to #349 that the #374 coordination note asked for. #349
fixed s_ff0_i32_b32 reading an inline constant or literal as a lane mask;
this adds a hardware and interpreter check for it.

ps_sff_imm runs s_ff1_i32_b32 on the inline constant 4 and the literal
0x00100000, and s_ff0_i32_b32 on the inline constant 61 and the literal
0x0000ffff: 2, 1, 20, 16. Read as a lane mask (all ones or zero from bit
0) the two s_ff0 words are -1; the s_ff1 words guard the path that was
already right.

- runtime/test/shaders/ps_sff_imm.asm, with its expected words in
  check.py and run_gpu_tests.py
- the fixture (regen_fixtures.py) and a value test in
  tests/semantic/test_value_semantics.py that runs it through the
  interpreter, with an independent reference

AI-assisted (Claude Code). Tested on NVIDIA GeForce RTX 4060 Ti (subgroup
32), driver 32.0.16.2124, Windows 11: see the PR for the run on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 20:10:09 -06:00
2736407127 Merge pull request #665 from mohamedsaad.lahlou 2026-11-21 21:08:36 -05:00
6d2303e0a7 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:02:50 +01:00
a71caa846f Merge remote-tracking branch 'origin/main' into bpw32-main
# Conflicts:
#	runtime/test/shaders/check.py
2026-11-22 03:02:48 +01:00
8cf0a8f6fc Run the packed 10:10:10:2 fixture in both GPU test suites 2026-11-21 18:46:06 -07:00
a412225fcc Tests: reject unmatched GPU test filters 2026-11-22 02:43:37 +01:00
c0a93d29f0 Merge pull request #628 from SirAmong 2026-11-21 20:39:01 -05:00