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.
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>
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>
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>
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>
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>
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>
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.
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.
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>
- 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.
- 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.