Commit Graph

22 Commits

Author SHA1 Message Date
74da6c8a4b conftest: install the piecewise finder before the translator is imported
test_support_installs_the_finder_only_where_the_tokenizer_is_slow is the one
test keeping the CI workflow red on 85ec1d33b, and it is red for a reason that
has nothing to do with the translator:

  AssertionError: <class '_frozen_importlib_external.SourceFileLoader'> is not
                  <class 'support.PiecewiseLoader'>

support.py installs ToolsFinder just before PathFinder and then imports
rdna2spirv through it, but tests/conftest.py imports rdna2spirv first, for its
own fixtures. A finder can only take an import it is in sys.meta_path for, so
under pytest the module is loaded by PathFinder and stays that way; run as
`python tests/test_piecewise_parse.py` there is no conftest and the test passes.
Green one way, red the other, for the same code.

So conftest now puts tests/semantic on the path and imports support first.
support.py imports rdna2spirv itself, so the line after it stays as it is and
becomes the import that already happened.

Measured, main 85ec1d33b, this machine (CPython 3.14, where needed() is true):

  python -m pytest tests/test_piecewise_parse.py     1 failed, 25 passed -> 26 passed
  python tests/test_piecewise_parse.py               OK, still
  the five files ci.yml runs for this area + test_cpu_ref
                                                     81 passed, 34 skipped

Written with an AI assistant.
2026-12-01 18:00:04 +01:00
dbdef2efd7 mesh-serial-waves: a GPU fixture whose two waves run loops of different length
ms_w64x_wave_loops: each wave loops while a wave-wide count is not 0, 5 iterations in wave 0 and 9 in
wave 1, so under --wave64-emulate the waves reach different numbers of workgroup barriers. Written after
stalls were reported with the serial form on an RTX 2070 SUPER (issue 1608). On an RTX 4080 (NVIDIA
621.24) it draws 4096/4096 pixels exact side by side and in series; that does not explain the stalls.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-27 17:29:50 +08:00
fbceecf042 mesh-serial-waves: unit tests, the design row, the GPU runner's switch
tests/test_mesh_serial_waves.py: the module shape of a program that
qualifies (64 invocations, the pass loop, the index from the built-in,
the exchange's own place, per-pass copies of the exports, one
OpSetMeshOutputsEXT), that every initialised Function variable is set
again per pass, and that ms_wave_info_s3 (LDS), a 32-thread program,
native wave64 and --mesh-compute are unchanged by the flag.

LEONIDA_MESH_SERIAL_WAVES=1 is read by scripts/run_gpu_tests.py, like the
other translation switches, and no longer by rdna2spirv.py itself.
docs/design.md and docs/testing.md say what the flag does and how it is
tested; conftest gives ms_w64x_wave_votes its 128-vertex PSV0.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-27 11:29:22 +08:00
8d29ffd26c tests: the pytest helper takes a text-only sample's lines as its listing, as run_gpu_tests.py does (TEST-TRANSLATE-TEXT-ONLY)
translator-tests fails on main since 6261ca916 (the merge of #957), which added runtime/test/shaders/cs_dpp_cmp.asm:
tests/test_translate.py::test_gpu_samples_translate_and_validate[cs_dpp_cmp.asm] and
::test_wave64_emulate_uses_no_subgroup_ops[cs_dpp_cmp.asm] stop at the llvm-mc assertion of conftest.Shader with
"dpp variant of this instruction is not supported" (2 failed, 1879 passed on a runner with llvm-mc 21; the same two
with 23.1.4).

llvm-mc has no gfx1013 encoding for a VOPC compare in DPP form, so the fixture carries the line
"; run_gpu_tests: text only, ..." and assemble_to_s in scripts/run_gpu_tests.py writes its listing from the text.
conftest.Shader assembled every sample with llvm-mc and did not know the line. It now does the same as the GPU
runner for a sample that carries it, so both tests translate and validate the fixture instead of failing before
they reach the translator.

Two new tests: the line is spelled in conftest as in run_gpu_tests.py, and only a sample that carries it skips
llvm-mc (the same lines without it still go to llvm-mc and fail there). Controls: with the line spelled
differently in conftest the spelling test and both cs_dpp_cmp tests fail; with every sample taking the text path
the second new test fails.

The translator-tests step with the workflow's file list (37 files, pytest 9.2.0, llvm-mc 23.1.4, without numpy
and Pillow, so 134 skipped): 2 failed, 1618 passed on main 89d7dfcf5; 1622 passed here.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 16:49:03 -06:00
b639b07aba Merge pull request #3837 from Maxime Mansiet
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:08:46 -05:00
02c19d105d tests: find Homebrew's keg-only llvm-mc in conftest
Signed-off-by: Maxime Mansiet <AirKyzzZ@users.noreply.github.com>
2026-11-22 22:59:10 +01:00
2124bc2907 conftest: synthetic DXBC for gs_w64_a_ring, gs_w64_c_lane_id and ms_f16_pack
test_translate.py skipped these three hand-written GPU samples (four cases with
the wave64-emulate test) because SAMPLE_DXBC had no entry for them, so they
were never translated or run through spirv-val. They use the signatures the
GPU runners give them: gs_tri's ISG1/OSG1 (build.py, every gs_*) and ms_tri's
PSV0 (scripts/run_gpu_tests.py). All three translate and validate with them.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 00:20:20 +03:00
898532131d tests: give ms_w64x_ballot its synthetic PSV0 so it is translated and validated
test_gpu_samples_translate_and_validate and test_wave64_emulate_uses_no_subgroup_ops
skipped runtime/test/shaders/ms_w64x_ballot.asm because conftest.SAMPLE_DXBC had no
entry for it. Its header asks for ms_tri's DXBC (PSV0, 128 threads, 64/64 outputs,
triangles), so it gets MS_TRI_DXBC, as ms_wave_info_s3 does.

Both tests now run for it and pass: the plain translation and the --wave64-emulate one
(no subgroup ops, %x_buf exchange) translate and pass spirv-val.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 22:25:09 -03:00
2da77d56e6 Merge pull request #269 from shelbykb2 2026-11-21 19:08:26 -05:00
e53b9e5450 Tests: add ms_wave_info_s3 mesh shader test for s3[27:24] wave ID 2026-11-21 21:05:43 -03:00
add0b5cfce GPU test for texel offsets (image_sample*_o, image_gather4_lz_o)
SHADER-14. runtime/test/shaders/ps_texoff.asm samples vk_texture_test's 8x8
texture (every texel different, point sampler, clamp to edge) through the
translated shader and exports the texel coordinates it read as integers:

- image_sample_lz_o with an offset computed per pixel: all 64 pairs of x, y
  in -4..3 from the centre of texel (4, 4), each a different texel, none
  clamped;
- image_sample_l_o with (-3, +2) and image_sample_lz_o with (+16, -32), the
  offset dword loaded from an immediate. The second one tells 4-bit, 5-bit
  and 6-bit fields apart; it is outside Vulkan's guaranteed -8..7 and is
  judged only where the device's texel offset limits cover it;
- image_gather4_lz_o of red and of green with the per-pixel offset, at a
  texel corner (shaderImageGatherExtended, not maintenance8).

Expected words are derived by hand from the docs/design.md rule (signed
6-bit fields, x [5:0], y [13:8]) and the texture contents, before any run;
the derivation is in the .asm header and check.py's texoff_words().

Harness: vk_texture_test enables VK_KHR_maintenance8 and
shaderImageGatherExtended when the device has them, prints the texel offset
limits, and with VKT_NEED_MAINTENANCE8=1 exits 77 without the extension
(SKIP in check.py and scripts/run_gpu_tests.py).

vk_harness.cpp is unchanged: its maintenance8 guard (#if defined() on the
structure-type enumerator, never true) was already fixed upstream, which now
uses #ifdef VK_KHR_MAINTENANCE_8_EXTENSION_NAME.

tests/conftest.py: the sample validator retries with
--allow-offset-texture-operand (what rdna2spirv.py validates with) when
spirv-val rejects a non-gather Offset, and skips on a spirv-val that does not
know the flag.

Tested on an AMD Radeon RX 6800, Windows, driver 26.11.2 (texel offset limits
-64..63, gather -32..31, maintenance8 enabled):
  run_gpu_tests.py: 49/50 passed, 1 skipped (was 48/49, 1 skipped)
    PASS  ps_texoff  4096/4096 pixels exact (offsets +16/-32 judged)
  check.py: 45 of 45 pass, 0 skipped (was 44 of 44)
No translator bug found: tools/rdna2spirv.py is unchanged.

Negative controls (translator sabotaged, test run, reverted). FAIL: sample
offset dropped, x/y swapped, y field at bit 6, 4-bit fields, 5-bit fields;
gather offset dropped, x/y swapped, y field at bit 6; three corrupted
expectations. PASS, so not detected on this GPU:
- fields read unsigned (sample and gather): Offset 60..63 sampled as -4..-1
  and +32 as -32, so the sign extension cannot be seen through Vulkan here;
- 4-bit and 5-bit gather fields: the gather offsets stay in -4..3.
Both are pinned by the new structural test tests/test_texel_offsets.py
instead (signed, bit 8k, 6 bits; it fails with OpBitFieldUExtract).

The test shows that the translated SPIR-V implements the documented rule on
Vulkan; it does not measure the field layout on the hardware. Still not
GPU-tested: sign extension, gather field width, image_sample_o, _b_o,
_c_lz_o, image_gather4_l_o, the z field (3D), 1D/2D-array/cube targets, wrap
or mirror addressing, linear filtering, mips other than 0, other vendors'
drivers, devices without maintenance8.

unittest tests/semantic: 388 OK before and after.
pytest tests (LLVM_MC set): 1467 passed, 6 skipped, 1 xfailed before;
1478 passed, 6 skipped, 1 xfailed after.

AI-assisted.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 16:55:18 -07:00
c56589c91b SHADER-30: emit CullPrimitiveEXT as Block+bool for old spirv-val
Array-of-bool is legal (VUID-07036) but SPIRV-Tools <=2025.1 rejects it (#5980).
The Block member form matches glslang and passes both old and new validators.
2026-11-21 19:14:58 -03:00
e8a0b11ada Test mesh v5 against all 24 coordinates of a 3D draw 2026-11-21 22:33:25 +01:00
5026d36f9c Merge pull request #184 from Mokbul Miah 2026-11-21 16:08:07 -05:00
0980b157b7 Merge pull request #173 from shelbykb2 2026-11-21 16:08:05 -05:00
66a410edf0 Accept LLVM_MC as a whole command in the tests and GPU tools
LLVM_MC may be one executable or a command line such as the WSL llvm-mc documented for Windows. shader_disasm.py already split it, but the tests, runtime/test/shaders/build.py and scripts/run_gpu_tests.py treated it as a single executable, so the documented setup skipped translator tests, and build.py passed a Windows path to WSL. Share the splitter in tools/mc_command.py and feed assembly on stdin.
2026-11-21 21:00:03 +00:00
8ea0e072dc tests: repair the stale stdin handle pytest's fd capture leaves on Windows; mutation test without cwd=HERE
On Windows `python -m pytest tests` fails at random places with
"OSError: [WinError 6] The handle is invalid" (subprocess.py, _make_inheritable).
pytest's default fd capture replaces fd 0 with os.dup2(), which closes the
handle fd 0 had, but the process's STD_INPUT_HANDLE keeps that number.
subprocess starts from GetStdHandle(), so a child that has its output captured
but is given no stdin=/input= (23 of the 25 call sites in tests/) gets a closed
handle, or, once the number has been reused, some unrelated file. Logged per
hook, the same number was a file, a pipe and invalid within one two-test
session. In conftest._has_amdgpu the OSError is caught, so a working llvm-mc
was reported as missing and all of test_translate.py skipped.

Fix in one place: when tests/conftest.py loads (before its llvm-mc probe) and
STD_INPUT_HANDLE is not fd 0's handle, point it at a NUL handle of our own.
Nothing happens on Linux, with -s or --capture=sys, or without pytest: there
the two handles are equal (checked for python -I <file>, python -m unittest
and unittest discover with console, NUL and pipe stdin), so the stdlib entry
points cannot hit this and need nothing. Per-call stdin=DEVNULL was the
alternative; the next new test would bring the failure back. A config file
forcing --capture=sys would change what is captured for everyone.
_has_amdgpu keeps catching OSError: a candidate that is not a program arrives
as a plain OSError (WinError 216), and it must be skipped, not crash collection.

Only stdin is repaired. STD_OUTPUT_HANDLE and STD_ERROR_HANDLE go stale the
same way, but fd 1 and fd 2 change handles for every test phase, and every
test that redirects a child's output redirects both streams, so subprocess
never reads those two. A test that redirects only one (stdout=PIPE alone,
check_output) would still fail under fd capture: use capture_output=True.

Separately, run_semantics() started its child with cwd=tests/semantic. Windows
refuses a working directory over 258 characters (WinError 267), so the mutation
tests failed in a checkout in a deep folder (measured with a 250-character
root, where tests/semantic is 265). The child now finds test_ps_semantics
through PYTHONPATH.

Tested on Windows 11, Python 3.14.7, pytest 9.2.0, main d51bddc:
- pytest tests, two runs each. Before: 6 and 44 failed without LLVM_MC, 94 and
  6 failed with it. After: 6 failed, 823 passed, 65 skipped without, and
  6 failed, 883 passed, 4 skipped, 1 xfailed with, both runs. The 6 are
  test_rtti_scan needing pefile, which is not installed here; the skip reasons
  are unchanged (ffmpeg, SCARAB_REF, llvm-mc).
- STD_INPUT_HANDLE forced to a number that is never valid, LLVM_MC set:
  44 failed and all 61 translator tests skipped before (the probe rejected
  llvm-mc), same as the clean run after. The unforced 94-failure run above has
  50 of them in conftest's Shader.validate (spirv-as).
- A copy with a 250-character root: test_mutations 14 failed before, passes after.
- Ubuntu (WSL), Python 3.14.4: unittest discover -s tests/semantic and the
  python -I tests/test_*.py loop print the same before and after.
No GPU involved. AI-assisted.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 13:27:44 -07:00
26727b5b81 tests: add VS and MS ClipDistance/CullDistance translation tests 2026-11-21 16:57:02 -03:00
957dfb24bd Fix: stop dropping first instruction in shader_ir.parse_file on LLVM 21+ and un-xfail vcc_half test
- shader_ir.parse_file() unconditionally skipped lines[0] as a comment header,
  while tests/conftest.py wrote raw llvm-mc stdout without a header line.
- On LLVM 14/18/19, llvm-mc emitted a leading '.text' directive on line 0 so
  lines[1:] skipped '.text'. On LLVM 21/22, llvm-mc stopped emitting '.text',
  causing parse_file() to drop the first instruction (s_mov_b64 exec, -1 in
  test_wave64_bfm64_and_half_cmp_emit_wave_ops's vcc_half shader), which left
  g.wave64 = False and made s_bcnt1_i32_b32 count both halves.
- Only skip lines[0] in parse_file() when it is not an instruction line, skip
  assembler '.' directives (like '.text'), prepend a synthetic header in
  tests/conftest.py, and restore the strict assert in tests/test_translate.py.
2026-11-21 16:17:58 -03:00
1a7ca71f97 Tests: add per-file mattr directive, restore wave64 cs_wave64_ballot, register in run_gpu_tests.py
- Support '; mattr: ...' header directives in runtime/test/shaders/build.py,
  scripts/run_gpu_tests.py, and tests/conftest.py.
- Restore runtime/test/shaders/cs_wave64_ballot.asm to wave64 v_cmp_*_e64
  s[4:5] / s[6:7] / s[10:11] form using '; mattr: +wavefrontsize64,-wavefrontsize32'.
- Register cs_wave64_ballot and cs_wm_* in scripts/run_gpu_tests.py.
2026-11-21 18:11:52 +00:00
1d3b9bfe4c tests: synthetic ISG1/OSG1 and PSV0 DXBC for the gs_tri and ms_tri samples 2026-11-21 10:00:24 +01:00
44021cb729 Add pytest regression tests for the RDNA2 -> SPIR-V translator 2026-11-21 09:17:32 +01:00