#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>
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
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
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>
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>
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>
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.
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>
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>
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>
#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>
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
d3d12_compute, d3d12_draw, d3d12_r9g9b9e5_uav, d3d12_descriptor and d3d12_indirect_rt open their GLSL test
shaders through absolute paths compiled into them (LEONIDA_TEST_*_SPV, D:/a/Leonida/Leonida/runtime/build/
generated/*.spv). The runtime-windows artifact didn't carry generated/*.spv and Wine has no such D: drive, so
they failed under Wine (copy_file threw, exit 3, or the shader read failed).
The artifact now includes runtime/build/generated/*.spv, and run_wine_tests.py points the drive of
--windows-root at --root in the Wine prefix for the run (a dosdevices link to a scratch folder), leaving a
drive the prefix already has untouched and removing both links afterwards.
Follow-up to #1545 (SHADER-177). Under --bary-fallback and --f16-interp-fallback the translator refuses a
computed I/J pair, so ps_ij_computed has no .spv, and both runners reported "missing .spv" instead of SKIP:
9018411c's bary skip in run_gpu_tests sits inside the PIXEL_VERTEX branch (ps_ij_computed is not in it) and
after the missing-.spv check, check.py's skip came after its .spv check too, and neither knew the f16
fallback, which run_gpu_tests turns on by default where PerVertexKHR doesn't compile (MoltenVK). Both runners
now skip it first, under either fallback; a missing .spv without a fallback is still a failure.
tests/test_run_gpu_tests.py covers both runners.
Co-authored-by: crastinator <qvaras@proton.me>
cs_w64x_saveexec_b64 checks the new EXEC per lane, D (old or new EXEC) and SCC, with old EXEC and S0
different in each 32-lane half. test_saveexec_b64.py runs the four ops on all 64 lanes for both sources
against the ISA lines, and the fixture.
AI-assisted.
#1545 added ps_ij_computed and its check to check.py only, so run_gpu_tests.py failed it with "no checker defined".
The check is now check.ij_computed_problem, used by both runners; run_gpu_tests also skips it under
--bary-fallback like check.py. Passes in both GPU runs on an RTX 4060 Ti.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sampling an integer image through a float view makes D16 convert the wrong numeric values. Compute the quad derivatives before branching to the matching view so implicit minification still chooses the correct level.