Commit Graph

345 Commits

Author SHA1 Message Date
ae21dddaa6 Merge pull request #2290 from 1TrickOmen 2026-11-22 11:43:51 -05:00
72758b9c5b Merge pull request #2270 from Tim Elery
# Conflicts:
#	docs/design.md
2026-11-22 11:43:39 -05:00
693b8c63af Merge pull request #2209 from Vonsek 2026-11-22 11:42:51 -05:00
94d7bfddae Merge pull request #2184 from AvantBras 2026-11-22 11:42:34 -05:00
1180c0b4a4 Merge pull request #2136 from Vonsek 2026-11-22 11:42:07 -05:00
3d1a9889df Merge pull request #2049 from Shrey Ratna 2026-11-22 11:41:12 -05:00
5cf0a1743d Merge pull request #1880 from Vonsek 2026-11-22 11:40:43 -05:00
ea00498d3f Merge pull request #664 from WHOISJARDAS 2026-11-22 11:40:30 -05:00
72d7e52dfa Translator: a mask copied to a VGPR respects EXEC (SHADER-21 part 2, #210) 2026-11-22 16:33:52 +00:00
fbe50b23fd rdna2spirv: align swizzled buffer addressing with native RDNA2 hardware (SHADER-343)
Measure MUBUF/MTBUF swizzled buffer addressing (V# SWIZZLE_ENABLE,
ADD_TID_ENABLE, INDEX_STRIDE, OOB_SELECT, multi-dword and typed
accesses, atomics, 32-bit offset wrap) natively on RDNA2 (gfx1036,
wave32 and wave64) via tools/buffer_swizzle_probe.py, and fix all six
observed silicon divergences in tools/rdna2spirv.py:

- idxen=1 ignores ADD_TID_ENABLE (both address and bounds).
- SWIZZLE_ENABLE=1 with idxen=0 and ADD_TID_ENABLE=0 stays linear and
  OOB_SELECT 3 remains RAW.
- Multi-dword raw accesses step by +4*IS only in scratch-swizzle mode
  (SWIZZLE_ENABLE=1, idxen=0, ADD_TID_ENABLE=1); indexed swizzle
  (idxen=1) steps linearly by +4 bytes even across IS boundaries.
- Scratch-swizzle mode suppresses typed formats > 4 bytes (MUBUF/MTBUF)
  and 8-byte buffer_atomic_*_x2 even under OOB_SELECT 2 (formats <= 4B
  execute normally); indexed swizzle executes them linearly.
- OOB_SELECT 3 with active swizzle and stride != 0 checks
  (index + soffset) >= num_records or off + payload > stride.
- off = uint32(voff + inst_offset) wraps at 32 bits before bounds
  checking, while RAW mode 3 uint64(off) + uint64(soffset) does not.

Update semantic tests, cs_buf_swizzle fixture expectation (word 4:
0x5eed0028 -> 0x5eed000c), unit tests, and docs/design.md /
docs/shader_validation.md.
2026-11-22 08:32:34 -08:00
9f03fc31e1 run_gpu_tests: ps_m3_query belongs to d3d12_m3_frame_test (OTHER_HARNESS)
#1825's single-output M3 occlusion shader is drawn by the ctest d3d12_m3_frame_test; run_gpu_tests picked it up
and failed it with "no checker defined".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:22:00 -05:00
d78546fc92 rdna2spirv: apply the SDWA src_sel to an f16 inline float constant
In an f16 SDWA op, Gen.src_h returned a float inline constant as its f16
bits without the operand's src_sel. On RDNA2 the constant is the f16 value
over a zero high half and src_sel then narrows it like a register:
v_add_f16_sdwa d, 1.0, v src0_sel:WORD_1 reads +0.0 (measured on gfx1036).
The translator added 1.0.

GPU test ps_sdwa_f16_const (hand-derived words, measured on gfx1036) with a
semantic fixture; it also covers an SGPR source and the integer path
(v_cvt_f16_u16_sdwa of 1.0), which were already right. docs/design.md row.

AI-assisted.
2026-11-22 17:17:54 +01:00
fc52e96723 Tests: let focused GPU runs require a pass (TEST-364) 2026-11-22 17:13:19 +01:00
21d01a9570 fix(tests): enforce the GPU timeout for texture cases
The texture harness needs a shader working directory, so two branches launched it directly and bypassed the configured deadline. Pass the working directory through the shared launcher so those cases time out and the suite can continue.
2026-11-22 17:04:37 +01:00
91b53e294b GPU test cs_fmt_int_narrow: 8/16-bit UINT/SINT typed buffers, words from gfx1036
A compute fixture loads through the nine narrow integer formats (DST_SEL
XYZW, X011 and d16) and stores edge values through each with the
runtime's selectors. check.py's 136 expected words are the same program's
output run natively on gfx1036 (tools/hw_oracle, wave32 and wave64), and
the interpreter test runs the fixture against them too.

Depends on #1871.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:58:11 +01:00
a47749b8de Merge pull request #1996 from Joao vitor alves
# Conflicts:
#	docs/d3d12_vulkan.md
2026-11-22 10:40:16 -05:00
e403590204 Merge pull request #718 from fearkov 2026-11-22 10:38:40 -05:00
81e520c327 Merge pull request #409 from JustDown 2026-11-22 10:38:36 -05:00
a0e8229a55 Tests: don't judge cs_signed_zero_nan's 0 * inf check on llvmpipe
Mesa llvmpipe returns 0 for out[5], the NaN check of 0 * inf with an
inline-constant 0, with or without SignedZeroInfNanPreserve, while its
other NaN checks give 1 (a run on #664, Mesa with LLVM 21.1.8). The CI
runs scripts/run_gpu_tests.py on llvmpipe, so the test would fail there.

APPLE_UNJUDGED_WORDS becomes UNJUDGED_WORDS, keyed by the first word of
the device name on vk_compute_test's "device:" line. Apple keeps words
0, 2 and 3, and llvmpipe gets word 5. Every other device still judges
all eight words.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:38:11 +00:00
e45c973ff0 Tests: don't judge cs_signed_zero_nan's -0 products on Apple GPUs (#1203)
MoltenVK returns +0 for -0 products with or without SignedZeroInfNanPreserve,
in out[0] (v_mul_f32), out[2] (v_pk_mul_f16) and out[3] (v_mul_f16). The mode
still fixes the three NaN checks on Apple. Seen on an Apple A18 Pro and an Apple
Paravirtual device in #664, tracked as #1203 / SHADER-182.

- check.py: judged_words() leaves those three words of cs_signed_zero_nan
  unjudged when vk_compute_test's device line names an Apple GPU, and
  words_match() compares the rest. The other five words still have to match,
  and every other device judges all eight.
- run_gpu_tests.py: uses the same two functions and says which words weren't
  judged.
- tests/test_shader_checks.py: tests for the Apple and non-Apple cases, the
  NaN checks still judged on Apple, and run_gpu_tests' judge_cs_dump.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:36:20 +00:00
bd8fb7c9f5 Translator: declare SignedZeroInfNanPreserve so drivers keep NaN, inf and -0
RDNA2 float ops return NaN, +-inf and -0 as computed. Without float controls,
Vulkan lets the driver assume none of them occur, and AMD's compiler does. On
an RX 9070 XT (26.11.2), x != x NaN checks fold to false and -0 products come
back +0. With integer f16 narrowing (#575), NaN results are never stored.

- rdna2spirv.py: every module declares the SignedZeroInfNanPreserve capability
  and OpExecutionMode SignedZeroInfNanPreserve 32. The index entry lists the
  property it needs (float_controls). --no-float-controls leaves both out.
- vk_pipeline_check: reads float_controls and skips a shader on a device
  without shaderSignedZeroInfNanPreserveFloat32.
- GPU test cs_signed_zero_nan (check.py, run_gpu_tests.py): without the mode,
  out[4..7] are 0 on AMD; with it, all eight words match.
- tests/test_translate.py: covers the mode, the index entry and the opt-out.
- docs/design.md: a "Float controls" contract row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:35:13 +00:00
e3cfc7f010 GPU runners: run the f16 interpolation tests under the bary fallback when the f16 fallback is on
run_gpu_tests.py skipped ps_interp_f16_high and ms_f16_pack whenever
LEONIDA_BARY_FALLBACK was set, and check.py skipped ps_interp_f16_high the
same way. The skip predates --f16-interp-fallback: --bary-fallback alone has
no PerVertexKHR inputs, so the f16 halves can't be interpolated. With
--f16-interp-fallback as well, which run_gpu_tests.py turns on by itself on a
device without fragmentShaderBarycentric (the usual reason for the bary
fallback), the pixel shader reads the decoded halves its producer exports,
and both tests run. Skip only when the bary fallback is on without it.

On llvmpipe (Mesa 26.0.8, no VK_KHR_fragment_shader_barycentric) with
LEONIDA_BARY_FALLBACK=1, both tests went from SKIP to PASS. Under the bary
fallback alone they would still fail (f16 halves off by 0.984), so that skip
stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:34:55 +00:00
502c1ce513 Runtime: M2 formats test (BC1/BC7 mip chains and a 2D array through a PSO)
Closes M2's open item "texture formats other than R8G8B8A8_UNORM, mips and arrays
through a PSO". d3d12_m2_formats_test samples, through the M2 descriptor path
(heap slots 9/10, CreateShaderResourceView, CreateSampler, two root tables,
translated vs_m2/ps_m2): an 8x8 BC1 and an 8x8 BC7 texture with 4 mips each and
an R8G8B8A8 2D array of 3 slices (new ps_m2_array.asm). Every subresource is
uploaded at its GetCopyableFootprints layout; POINT samplers with MinLOD = MaxLOD
pin each level; a view from mip 1 and two array views check that level and slice
are relative to the view. Blocks use endpoint colours only, so all 12 cases are
compared with the CPU byte for byte (error 0). Validation clean on RTX 4070 Ti
SUPER; no layer change was needed. Synthetic data only, no game files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01PiKMETzszqwfnV8QQyzocY
2026-11-22 12:26:05 -03:00
c53024be39 Merge pull request #1858 from AlxcBTW
# Conflicts:
#	docs/d3d12_vulkan.md
2026-11-22 09:48:50 -05:00
3b7cd5e4bf Merge pull request #1791 from AlxcBTW 2026-11-22 09:48:16 -05:00
9df596963a Translator: v_cvt_pk_u8_f32 NaN gives 0, with RDNA2-measured GPU test (SHADER-48)
Measured natively on an RDNA2 iGPU (gfx1036): v_cvt_pk_u8_f32 rounds to
nearest even, clamps to [0, 255] and gives 0 for NaN. The RoundEven rule
was right; NaN reached FClamp, which is undefined for a NaN operand, so it
is now replaced by +0 first.

cs_cvt_pk_u8.asm holds eight hardware words (four byte selects), checked
by check.py and run_gpu_tests.py, and bit-for-bit on the CPU by
tests/semantic/test_cvt_pk_u8.py. Contract-table row added.

Fixes #358
2026-11-22 15:48:12 +01:00
f8ef313033 Merge pull request #1627 from nonverifiedperson 2026-11-22 09:48:05 -05:00
00452cfaa3 Merge pull request #1615 from Ewann 2026-11-22 09:48:04 -05:00
b83f74f6d2 Merge pull request #1612 from mokkymiah 2026-11-22 09:48:03 -05:00
b9e91c2af8 Merge pull request #1398 from ezwinxdlmao 2026-11-22 09:48:00 -05:00
f2ba7831ae Tests: v_cvt_f16_f32 output modifiers, in the interpreter and on a GPU
ps_outmods_f16 has six results; each changes a word when its modifier is dropped, and two change when the omod is applied before the rounding.
2026-11-22 10:40:54 -04:00
537486c875 Merge remote-tracking branch 'fork/m4-synthetic-gate' into buffer-uav-typed-counter
# Conflicts:
#	docs/d3d12_vulkan.md
#	runtime/shims/d3d12_vulkan_device.cpp
2026-11-22 15:34:07 +01:00
f209d86b8f D3D12 layer: typed buffer UAVs and UAV counters (V# FORMAT, counter V# in the slot), d3d12_buffer_uav_test
CreateUnorderedAccessView on a buffer with a typed Format writes a typed V# (GFX10_FORMAT code, element size as
stride, element count, OOB_SELECT structured, the format's own DST_SEL), and a structured view with pCounterResource +
CounterOffsetInBytes writes a second raw 4-byte V# in the upper 16 bytes of the slot (a hypothesis for the console
contract, documented in section 3.4). The combinations D3D12 documents as invalid leave a null slot.

d3d12_buffer_uav_test runs two hand-written RDNA2 compute shaders through the translator (typed store/load/atomic on
five formats with NUM_RECORDS as the bound; append by 256 lanes and consume by 128 on a counter at offset 4096, read
back with CopyBufferRegion) against a CPU reference, then compares typed-buffer and counter clears with the host D3D12
runtime on the same adapter (LUID).

Depends on: #1791

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:33:50 +01:00
cd6e21be84 Translator: tbuffer_store_format_* with the instruction's format
tbuffer_store_format_* and its d16 forms were Unsupported, though every
tbuffer_load_format_* form translates. They now go through buffer_store
with the instruction's format, as the loads go through
buffer_load_format:
- only that format is encoded, with no branch on the V#'s FORMAT;
- the bounds check uses its element size;
- a V# whose FORMAT is 0 (INVALID) still disables the store, as measured.
  (@Vonsek covers the MTBUF loads and @opit80 the raw MUBUF accesses
  through such a V#.)

The format parsing the loads did inline becomes mtbuf_format(), shared by
both: no modifier is GFX10's default BUF_FMT_8_UNORM, and a format
FORMATS has no encoder for stays Unsupported. read_before_write_vgprs
now counts a tbuffer store's data VGPRs as reads, as for buffer_store.

cs_tbuffer_store.asm stores into 13 sentinel-filled regions through V#s
whose format differs from the instruction's or is 0, and reads them
back. Every
expected word was measured by running the same body natively on a
Radeon 680M (gfx1035, RDNA2); wave32 and wave64 gave the same 52 words:
- the instruction's format decides the encoding, the element and the
  bounds;
- components the format has but the store doesn't give are 0, and extra
  ones are dropped;
- the default format is one byte, and its neighbours are kept;
- a FORMAT-0 V# leaves the region untouched.

check.py and run_gpu_tests.py compare the dump. The semantic fixture
runs through the interpreter in tests/semantic/test_tbuffer_store.py,
which fails on the old translator (Unsupported). It also fails on
versions that take the bounds from the V#'s element (5 words differ),
take the format from the V#, fill missing components with anything
but 0 (1 word), or drop the FORMAT-0 guard (2 words).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:33:18 +02:00
c5edaf72f7 Add ps_mandelbrot: a divergent backward loop with EXEC masking
A pixel shader that iterates z = z^2 + c per lane until it escapes or 64
rounds pass. Escaped lanes drop out of EXEC, s_cbranch_execz leaves the loop
once all lanes are out, and EXEC is restored before the export. check.py and
run_gpu_tests.py compare every pixel's iteration count with a pure-Python
float32 model (mul/add/sub only, no FMA, so the model is exact).

Tested on main 003e7812: run_gpu_tests.py 131/171 on RTX 5070 Ti (40
skipped) and 162/171 on AMD Radeon integrated graphics (9 skipped, run by
the d3d12 draw tests). AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:30:42 +01:00
ab55405c2c Tests: GPU coverage for ds_cmpst_b32 and the b64 LDS 2-address forms 2026-11-22 14:24:28 +00:00
ec9b6cf22b tools: text reports are written with LF line ends on every platform (BUILD-468)
open(path, "w") without newline= turns each \n into \r\n on Windows, so the same JSON report, manifest or assembly
listing was CRLF there and LF elsewhere. 91 text-mode writes (open, os.fdopen, Path.write_text) under tools/, scripts/,
make_game.py and runtime/test/shaders/ now pass newline="\n". tests/test_text_write_line_endings.py reads the source
with ast and fails for a writer that forgets it; CONTRIBUTING.md names the convention.

AI-assisted (Claude), on behalf of dev-ewann.
2026-11-22 14:20:30 +00:00
1c80759bca Merge pull request #1768 from AlxcBTW 2026-11-22 09:15:12 -05:00
f0cddb90f8 Merge pull request #1578 from Dominik 2026-11-22 09:14:47 -05:00
c2f39447b6 Merge origin/main into m4-synthetic-gate 2026-11-22 15:13:40 +01:00
967564a20c M4 (synthetic): d3d12_m4_compute_test, UAV table, indirect dispatch, copy queues; buffer UAV views and indirect dispatch state
d3d12_m4_compute_test, through the proxy with D3D12 API only and two
translator-output compute shaders (cs_m4_fill.asm, cs_m4_indirect.asm):
a COPY queue streams an input buffer in, a COMPUTE queue waits on it and runs a
compute PSO over a UAV table (structured buffer, raw buffers, an R32_UINT
RWTexture2D), then ExecuteIndirect of a second PSO from arguments the first
wrote (with a transition to INDIRECT_ARGUMENT and UAV barriers), and a COPY
queue behind a cross-queue fence reads the results back. 1,924 words match the
CPU reference with error 0.

Layer gaps the test found, fixed:
- CreateUnorderedAccessView of a buffer was a stub: structured and raw views are
  now a V# in the slot.
- ExecuteIndirect of a dispatch ran whatever pipeline and root arguments the
  command buffer had bound; the command now carries the list's, as Dispatch does.
- An image created in UNORDERED_ACCESS and first used by a shader was
  zero-filled by the first barrier or copy that named it, losing the shader's
  writes; images with a UAV view are now moved to GENERAL (zeroed) at the next
  submission.
- COMPUTE and COPY command lists no longer log "unimplemented".

Test infrastructure: vk_test_device.h can create more than one VkQueue;
build.py gives a compute shader's FSSM program extra words (fssm-at/fssm-data
from 0x148) so two compute shaders with the same group size get distinct hashes,
and honours LEONIDA_SPIRV_TOOLS (as #1679) so the target builds under the Visual
Studio generator. docs/d3d12_vulkan.md section 6: M4 synthetic part met; M3 row
credits @whattheflop's #1584 measurement of fences in flight.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:09:58 +01:00
a178a06b34 salu_diff: s_nand/s_nor/s_xnor_b64 in the generator; hardware-checked nand/nor/xnor
The translator already handles s_nand/nor/xnor_b32 and _b64 (rdna2spirv.py,
tests/semantic), so no translator change. What was missing: the _b64 forms in
salu_diff's generator, a GPU test of the translated output, and a hardware
comparison. Adds the three _b64 ops to salu_diff (and LANE_MASK_OPS),
ps_scc_logic32/64.asm (values and SCC by hand) registered in check.py and
run_gpu_tests.py, and a docs/design.md row with the hardware counts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:00:17 +01:00
52c3a88947 GPU test: image atomics in a pixel shader (ps_imgatomic)
1,018 of the corpus's 1,038 image-atomic shaders are pixel shaders, but every GPU test of image atomics ran in a
compute shader (found by @aslan2142). ps_imgatomic does the corpus's forms in a pixel shader: image_atomic_umax,
umin and or on three 8x8 2D r32ui images (64 pixels contend for each texel) and umax on a 4x4x4 3D image, each
found through its own T# in the descriptor table and the set-0 r32ui storage arrays. Odd pixels are discarded
after their atomics, which must still count.

vk_bindless_test runs it when given ps_imgatomic.spv: it enables fragmentStoresAndAtomics (exit 77 without it),
clears the images (umin to all ones), draws, and checks all 256 texels against a model of the 4096 pixels and the
render target's discarded columns. run_gpu_tests.py and check.py run it next to ps_tex.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:42:22 +00:00
5f76cc2b27 Merge pull request #1680 from abilliontokens 2026-11-22 08:38:21 -05:00
a9c0d3bfb9 Merge pull request #1659 from Anira
# Conflicts:
#	docs/design.md
2026-11-22 08:38:17 -05:00
42512eec28 Merge pull request #1549 from tylerstraub 2026-11-22 08:38:03 -05:00
bb0ecfc089 Merge pull request #906 from AlxcBTW 2026-11-22 08:37:59 -05:00
b7201d7147 Merge pull request #616 from SirAmong
# Conflicts:
#	docs/design.md
2026-11-22 08:37:58 -05:00
64d41a89a6 Translator: v_sin/v_cos reduce with x - RoundEven(x), contract row and GPU test (SHADER-88 follow-up to #1283)
#1283 reduced the angle in turns with Fract. For a negative argument Fract is
1 - |x|, which rounds in binary32: sin(-2**-26 turns) became +0 and the
absolute error was up to ~1.7e-7 at -0.1 turns. x - RoundEven(x) is exact in
binary32 for every finite x and keeps the angle in [-pi, pi]. The change is
inside turn_angle (shared by the f32 and f16 forms), with the variable names
of the line that test_mutations.py anchors on kept.

- tests/semantic/test_alu_sincos.py: f32/f16 against sin/cos(2*pi*x) in
  double, tiny arguments (fails on main), whole turns of either sign (+0, as
  measured on an RX 6800 by shelbykb2), +-0, inf/NaN, modifiers.
- runtime/test/shaders/cs_w32_sincos.asm: wave32 GPU regression guard
  (tolerance 1e-3, the driver Sin is only good to 2^-11), registered in
  check.py and run_gpu_tests.py.
- docs/design.md: contract row with the RX 6800 measurement and what is not
  matched (half/quarter turns, the small-x constant, inf/NaN words).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 08:34:03 -05:00
1062df5154 Shader: accept abs on v_pack_b32_f16 (a sign clear of the packed half)
Follow-up to #1570, which took the `neg` half of SHADER-260 and left `abs`
refused. `abs` is the ISA's absolute value of the operand: a clear of the
sign bit, on the 16-bit half the operand contributes and applied before
`neg` (which #1570 emits as a bit 15 flip). The instruction already moved
each half unchanged, so the translator emitted nothing for `abs` and threw
`Unsupported("v_pack_b32_f16 abs modifier")` for any shader that used it.

Emit the clear instead: OpBitwiseAnd 0x7FFF on the selected half, before
the `neg` xor. No hardware run of this instruction with `abs` exists, so
the docs row says the rule is ISA-derived and unmeasured rather than
quoting a measurement.

Tests: exact-bit CPU cases in tests/semantic/test_pack_b32_f16_mods.py and
tests/test_values.py (both halves, op_sel, an sNaN payload, neg+abs order),
the interpreter-run GPU fixture ps_f16_pack_mods with its words derived
from the rule, and the row in docs/design.md.

SHADER-260, Depends on: #1570
2026-11-22 15:23:17 +02:00