upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs/testing.md
diff options
context:
space:
mode:
authorJan Trencansky <jan.trencansky@protonmail.com>2026-11-24 20:26:00 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-24 20:26:00 -0500
commit154e4ec034902deffa4b89b2cbca9a949f38baec (patch)
tree1b2ef5656de42c172291bc6009efa4c510650815 /docs/testing.md
parenteb6a08cd359d98b5777e70d54d0ae8a75879495a (diff)
parent8a242efebf823aeb23c72d17c3d666daf0bbd3e2 (diff)
Merge the #984 result (main + RT-PROTON-STORY-LOAD) into #939
The base is 8a242efeb, the merge of main and #984. 68 files conflicted; they were resolved in seven groups by one rule: the same change in two forms keeps the base's form, everything only #939 has is kept, and where the two solve one problem in two ways the base's is the frame and #939's plugs into it. A, the Xbox proxy (d3d12_xs_device.cpp/.h, d3d12_xs.cpp, d3d12_xs_pso_stream.cpp/.h, d3d12_xs_alloc_size.h, d3d12_xs_desc_clean.h, device_proxy_test.cpp, queue_proxy_test.cpp): the base's files with #939's additions ported in. Device slot 57 asks #939's NativeGraphicsFactory first and falls back to the base's proxy_create_graphics_pipeline_from_native_code on E_NOTIMPL. Kept from #939: the providers (texture lease, raw texture view, resource by address, constant view, descriptor mapping, depth-stencil UAV, texture pages), the title-backed descriptor mirror, slot 13's feature answers, GPU labels on list slots 71/72. Dropped: #939's duplicates of the boot ladder routes, its fallback window, its slot 133 stand-in. A2 (xs_proxy_mock_test.cpp): the base's test with #939's slot 70 raw-buffer case; presentation cases follow #939's rule that a device which ever had a handler has no queue fallback. B1, the Vulkan device (d3d12_vulkan_device.cpp, d3d12_com.cpp/.h, shader_library.h, queue_families.h, pipeline_cache_file.h, startup_trace.h): one lazy-pipeline mechanism, the base's; #939's pending_base_compile and first_use_backend_pipelines dropped, prepare_on_bind and cold_graphics_compile kept. create_texture keeps the base's signature; #939's deferred backing is folded into the base's placed-memory binder. #939's quad lists as triangle indices. B2, the D3D12 tests (d3d12_existing_heap, a8_dimensions, pipeline_cache_seed, title_va, rect_list, shader_library, loader_tls_index0, draw, compute, xmem_placed, shader_library_corpus): the base's tests where both carry the same case, #939's cases added (rebound tables, linear texture map, large vertex batch, executable shaders, default A8 views). C, the backend (vulkan_replay.h, vulkan_backend.h, vulkan_bindless.h, vulkan_scratch.h, vulkan_present.h, rect_list_geometry.h, vk_test_device.h, vk_pipeline_check.cpp, vk_store_test.cpp, bindless_sizing_test.cpp, replay_texture_barrier_test.cpp): the base's prepare_draw and lazy compute, its #1055 release rule and its rectangle generator; #939's rectangle variants, GPU quad index expansion, 1D/3D and depth-stencil UAVs, the label fence on the base's submit. D, memory, services, presentation (xmem.cpp/.h, xg_xs.cpp, xg_xs_test.cpp, title_va_alias.h and its test, main.cpp, frame_pacer.h, xbox_present.cpp/.h; xgameruntime_offline.cpp for one comment): the base's xmem with #939's label hooks, file-backed sections and pin_mapped_data; both texture computers in xg_xs.cpp, the base's answering first; --first-run-ui kept without host speech in its profile. E, build, tools, docs (runtime/CMakeLists.txt, make_game.py, tools/rdna2spirv.py, tools/shader_disasm.py, scripts, tests, docs; docs/README.md and tests/test_exe_shaders_stage.py beyond the conflicts): the base's v_dot4 decode, #281's disassembler form and tests/semantic/test_fspx_dot4_op_sel_disasm.py dropped; the base's executable-shader step with #939's cache fix; 366 registered tests. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'docs/testing.md')
-rw-r--r--docs/testing.md161
1 files changed, 129 insertions, 32 deletions
diff --git a/docs/testing.md b/docs/testing.md
index 23a64516b..d8eb074e6 100644
--- a/docs/testing.md
+++ b/docs/testing.md
@@ -171,20 +171,7 @@ python -I runtime/test/shaders/build.py <out dir>
171python -I runtime/test/shaders/check.py <out dir> <folder with the test programs> 171python -I runtime/test/shaders/check.py <out dir> <folder with the test programs>
172``` 172```
173 173
174For the standalone `v_mullit_f32` readback, build the full-screen triangle and the 174For D3D12/runtime tests, `LEONIDA_VK_VALIDATION=1` enables `VK_LAYER_KHRONOS_validation`. When running with validation, set `DISABLE_RTSS_LAYER=1` and `DISABLE_VULKAN_OBS_CAPTURE=1` if MSI Afterburner (RivaTuner) or OBS is installed: their overlay layers can add unsupported swapchain usage, and in an elevated (administrator) terminal the loader ignores `VK_LOADER_LAYERS_DISABLE=~implicit~` (see "Known problems").
175hand-written semantic fixture, then run 120 draws with runtime SGPR inputs.
176The driver checks every pixel against an integer product rounded to 24 bits.
177It reports the input words, pixel and channel on the first mismatch.
178
179```sh
180python -I runtime/test/shaders/build.py <out-dir> vs_ids ps_mullit
181python -I runtime/test/shaders/mullit_readback.py <out-dir> <harness-directory>
182```
183
184For D3D12/runtime tests, `LEONIDA_VK_VALIDATION=1` enables `VK_LAYER_KHRONOS_validation`. When running with
185validation, set `DISABLE_RTSS_LAYER=1` and `DISABLE_VULKAN_OBS_CAPTURE=1` if MSI Afterburner (RivaTuner) or OBS is
186installed: their overlay layers can add unsupported swapchain usage, and in an elevated (administrator) terminal
187the loader ignores `VK_LOADER_LAYERS_DISABLE=~implicit~` (see "Known problems").
188 175
189On Windows, `run_gpu_tests.py` assembles and translates the D3D-78 fixture and runs the UAV readback and WARP 176On Windows, `run_gpu_tests.py` assembles and translates the D3D-78 fixture and runs the UAV readback and WARP
190comparison from the same build folder. Use `--filter cs_texture_uav` to run only this case: 177comparison from the same build folder. Use `--filter cs_texture_uav` to run only this case:
@@ -250,6 +237,49 @@ and `vk_presenter_sync`, `xbox_present` and `dxgi_swapchain` pass, while they fa
250compositor for those three. Six still failed with a real display: `device_proxy`, `d3d12_xs_root_signature`, 237compositor for those three. Six still failed with a real display: `device_proxy`, `d3d12_xs_root_signature`,
251`xdxr_build`, `d3d12_xdxr_rt`, `d3d12_present` and `d3d12_compute`. 238`xdxr_build`, `d3d12_xdxr_rt`, `d3d12_present` and `d3d12_compute`.
252 239
240Run one after another as above, the suite takes several seconds per test, although a test started by hand takes 0.1 to
2411 second. Four settings make a local run of the cross-build much faster:
242
243```sh
244export WINEPREFIX="$HOME/.local/share/leonida-wine" WINEDEBUG=-all \
245 WINEDLLOVERRIDES="winedbg.exe=d;winemenubuilder.exe=d"
246mkdir -p "$WINEPREFIX"
247xvfb-run -a sh -c 'wineserver -p; wine wineboot -u </dev/null >/dev/null 2>&1
248 ctest --test-dir runtime/build/windows -j 6 --timeout 120; wineserver -k'
249```
250
251Start the server before `wineboot`: `wineserver -p` does nothing while another server runs for the prefix. Run
252`wineboot` after it, with its output thrown away: the first Wine program a server runs starts the prefix's services,
253which keep that program's output open for as long as the server lives, so a first test that started them would wait
254for the end of its output until the timeout.
255
256- `wineserver -p` keeps one Wine server for the whole run; without it a new one starts for each test.
257- `winedbg.exe=d`: a test that crashes otherwise waits in Wine's debugger until its timeout.
258- `winemenubuilder.exe=d`: without it `wineboot` on a fresh prefix writes `wine-extension-*.desktop` files and the MIME
259 cache into `~/.local/share/applications`, pointing your file associations at the test prefix. Set it before the
260 prefix is first made.
261- `ctest -j 6` runs six tests at a time. The tests that share files under the temp directory (see "Known problems")
262 can then fail now and then; rerun such a failure on its own before you count it.
263
264Measured with Wine 11.22 on llvmpipe, 40 tests of a clang-cl build (`ctest -R '^(d3d12_[a-c]|vk_[a-d]|xg)'`), adding
265one setting at a time:
266
267| Settings | Seconds |
268|---|---|
269| As above: one test after another | 179 |
270| `wineserver -p` (and `wineboot` after it) | 35 |
271| and `WINEDEBUG=-all` | 35 |
272| and `winedbg.exe=d` | 35 |
273| and `ctest -j 6` | 5.6 |
274| `ctest -j 6` and the overrides, without `wineserver -p` | 18 |
275
276The kept server is most of it: a test that takes 0.05 seconds with it took about 3.4 without, the time of a server
277starting and stopping. `WINEDEBUG=-all` and `winedbg.exe=d` changed nothing here because no test crashed; with a crash,
278`winedbg.exe=d` saves the rest of that test's timeout. The full suite (about 310 tests) took about 28 minutes run one
279after another, and 67 seconds with all four settings for two devices (llvmpipe and an integrated GPU) run at the same
280time. `scripts/run_wine_tests.py` (below) does the same: 32 seconds for those 40 tests with `--jobs 1`, 6 with
281`--jobs 6`, and 19 seconds for all 312 tests with `--jobs 6`.
282
253The build type defaults to `RelWithDebInfo`: xwin leaves out the debug CRT, so `Debug` needs `--include-debug-libs`. 283The build type defaults to `RelWithDebInfo`: xwin leaves out the debug CRT, so `Debug` needs `--include-debug-libs`.
254`make_game.py`'s `runtime` stage makes this same build on Linux when the tools and the SDK are there (`--runtime-build 284`make_game.py`'s `runtime` stage makes this same build on Linux when the tools and the SDK are there (`--runtime-build
255runtime/build/windows` takes a folder made by hand like a Windows build). CMake packages are 285runtime/build/windows` takes a folder made by hand like a Windows build). CMake packages are
@@ -322,7 +352,12 @@ WINE=wine WINEPREFIX="$(mktemp -d)" WINEDLLOVERRIDES="mscoree,mshtml=" WINEDEBUG
322 352
323The session script initializes a dedicated prefix and stops its Wine processes at exit. On a headless host, 353The session script initializes a dedicated prefix and stops its Wine processes at exit. On a headless host,
324put `xvfb-run -a` before `bash` so prefix initialization and the tests share one virtual display. The test runner 354put `xvfb-run -a` before `bash` so prefix initialization and the tests share one virtual display. The test runner
325maps the recorded Windows drive to the Linux checkout for shaders referenced by absolute Windows paths. It prints 355maps the recorded Windows drive to the Linux checkout for shaders referenced by absolute Windows paths. It keeps one
356wineserver alive for the run and stops it at the end, and adds `winedbg.exe=d;winemenubuilder.exe=d` to each test's
357`WINEDLLOVERRIDES` (an entry of yours for the same program wins). `--jobs N` runs N tests at a time (default 1): tests
358marked `RUN_SERIAL` run alone, tests that share a `RESOURCE_LOCK` never overlap, and the verdicts are printed in the
359same order as with `--jobs 1`; the tests that share temp files can fail now and then in parallel (see "Known
360problems"). It prints
326every verdict and returns a failure status if any required test fails, skips or is missing. Check the printed 361every verdict and returns a failure status if any required test fails, skips or is missing. Check the printed
327verdicts for failures outside the required set. 362verdicts for failures outside the required set.
328 363
@@ -379,6 +414,85 @@ It needs shader Int64 support; a device that lacks it reports a skip. This is a
379independent of wave64 emulation. On RTX 3080 Ti (616.92, Windows 11), all 640 words matched; replacing the count 414independent of wave64 emulation. On RTX 3080 Ti (616.92, Windows 11), all 640 words matched; replacing the count
380mask with 31 or the arithmetic shift with a logical shift made the test fail at words 66 and 251 respectively. 415mask with 31 or the arithmetic shift with a logical shift made the test fail at words 66 and 251 respectively.
381 416
417`cs_w32_frexp_ldexp` checks `v_frexp_mant_f32`, `v_frexp_exp_i32_f32`, `v_ldexp_f32`, `v_frexp_mant_f64` and
418`v_frexp_exp_i32_f64`, which the translator computes with integer ops on the float's words. 64 records of a binary32
419value, an `ldexp` exponent and a binary64 value are loaded at run time: normals, the clamp of the exponent at ±512
420and beyond, results that overflow to an infinity and that fall below the smallest normal, binary32 denormals (read
421as zero), binary64 subnormals (normalized; single fraction bits on both sides of the dword boundary and patterns
422with several), zeros, infinities and NaNs. Each thread stores the five results, `v_frexp_mant_f32` with a `neg`
423source and `v_ldexp_f32` with an `abs` source run with the odd threads turned off, whose destination must keep the
424word it held. The expected words come from an oracle written from the rows of [design.md](design.md)
425(`frexp_mant_f32`, `frexp_exp_i32_f32`, `ldexp_f32` and `frexp_f64` in `check.py`), and
426`tests/test_gpu_frexp_ldexp.py` checks it against `math.frexp` and `math.ldexp` wherever those agree with the
427hardware. Both GPU runners compare all 768 heap words, the 256 unchanged input words included. Run it alone with
428`python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_frexp_ldexp --require-pass`.
429On an RTX 4070 Ti (NVIDIA 620.70.06, Linux) and on llvmpipe (Mesa 26.2.6, LLVM 23.1.4) all 768 words match. While
430the binary32 ops still applied `neg` and `abs` with `OpFNegate` and `FAbs`, six words differed on the 4070 Ti and none
431on llvmpipe: every NaN source under a modifier came back as `0x7fffffff`, the driver's default NaN (word 419 is the
432first: the mantissa of the negated `0x7fc00000`). Rules broken one at a time each failed the test on both devices:
433the mantissa given the exponent field 127 (word 0) or, for binary64, 1023 (word 5), the exponent subtracting 127
434(word 1), `v_ldexp_f32` without its clamp (word 258) or overflowing to the largest finite value (word 106), a
435binary32 denormal not read as zero (word 352), the binary64 subnormal exponent off by one in the low or in the high
436dword (words 134 and 150), and the fixture without its `v_cmpx` (word 15).
437
438`cs_w32_cmp_f64` checks the 32 binary64 vector compares, `v_cmp_*_f64` into VCC and `v_cmpx_*_f64` on EXEC, with
439256 memory-fed operand pairs: the product of 16 values (±inf, ±max, the 1-ULP neighbours of ±1, the smallest
440subnormals, ±0, the smallest normal, a NaN whose payload is only in the low dword and a negative quiet NaN). Each
441thread stores one bit per predicate for both forms, a bit for `tru` run with the odd threads turned off (an inactive
442lane gets VCC 0 from `v_cmp_` and stays off through `v_cmpx_`) and two bits for `lt` and `nge` with VOP3 `abs`/`neg`.
443The expected words come from Python floats (`cmp_f64_words` in `check.py`): IEEE-754 ordering, with every pair that
444has a NaN unordered. Both GPU runners compare all 1536 heap words (512 result words and 1024 unchanged input words);
445the operands are loaded at run time, so neither the translator nor the driver can fold a compare. Run it alone with
446`python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_cmp_f64 --require-pass`.
447It is a wave32 test and no step of it needs a particular subgroup width, so it also runs on llvmpipe; the SGPR-pair
448and constant operand forms are CPU-checked only (`tests/semantic/test_cmp_f64.py`). On an RTX 4070 Ti (NVIDIA
449620.70.06, Linux) all 1536 words matched, and seven translator rules broken one at a time each failed it: no `-0`
450canonicalization at word 206, a NaN test that ignores the low dword at word 28, an ordering key without the low
451dword at word 70, the raw result written to an inactive lane's VCC at word 2, `v_cmpx_` replacing EXEC at word 3,
452`abs` ignored and `nlt` lowered as the negation of `le` at word 0.
453
454`cs_w32_round_f64` checks `v_trunc_f64`, `v_ceil_f64`, `v_rndne_f64` and `v_floor_f64`, which the translator gives
455to the driver's double-precision `Trunc`, `Ceil`, `RoundEven` and `Floor` (`shaderFloat64`). 64 inputs are loaded at
456run time: signed zeros, the smallest subnormals and normals, values around 0.5 and 1 (the largest value below 0.5
457among them), ties from 0.5 to 5.5 and at 2^31 + 0.5, 2^51 + 0.5 and 2^52 - 0.5, integers from 2^52 to 2^63, 1e300,
458the largest finite value, the infinities, and quiet and signalling NaNs. Each thread stores the four roundings,
459`v_trunc_f64` with a `neg` source, `v_ceil_f64` with an `abs` source, a `v_floor_f64` whose destination pair overlaps
460its source pair, and a `v_rndne_f64` run with the odd threads turned off, whose destination must keep the pair it
461held. The expected words come from Python (`round_f64` in `check.py`: exact IEEE-754, the result keeping its
462source's sign), and `tests/test_gpu_round_f64.py` checks that oracle against exact rational rounding. All 1152 heap
463words are compared exactly, the 128 unchanged input words included: a NaN and a subnormal are rounded by the
464translated code with integer ops and not by the driver, as the row in [design.md](design.md) says. (llvmpipe gets
465one allowance, for what it does to `Trunc` and `RoundEven` on some CPUs; see below.) Run it alone with
466`python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_round_f64 --require-pass`.
467It needs `shaderFloat64`; a device without it reports a skip.
468
469Measured: on an RTX 4070 Ti (NVIDIA 620.70.06, Linux) and on llvmpipe (Mesa 26.2.6, LLVM 23.1.4) all 1152 words
470match. While those two kinds of input still went to the driver's function, 15 of the 512 results differed on the
4714070 Ti, those of the two signalling NaNs, which came back quiet with sign and payload kept (`0x7ff0000000000001`
472gave `0x7ff8000000000001`), and five more on llvmpipe, which read the two smallest subnormals as zero (`v_ceil_f64`
473of the positive one gave +0 instead of 1, `v_floor_f64` of the negative one -0 instead of -1). Rules broken one at a
474time each failed the test on both devices: a NaN left to the driver (word 784), the NaN and subnormal tests ignoring
475the low dword, `v_ceil_f64` or `v_floor_f64` lifting the subnormal of the wrong sign (words 34 and 38), a subnormal's
476result losing its sign (word 40), a NaN's low word dropped (word 784), `rndne` lowered as `floor(x + 0.5)` (word 20,
477the sign of -0), `trunc` or `ceil` lowered as `Floor`, the `neg` or the `abs` source modifier ignored (words 8 and
47826), the two result words swapped (word 8), and the fixture without its `v_cmpx` (word 30). Two changes are not
479caught everywhere: a subnormal left to the driver fails on llvmpipe (word 34) and passes on the 4070 Ti, which keeps
480binary64 denormals, and `RoundEven` replaced by GLSL `Round` changes nothing on either device, since both send a tie
481to the even integer.
482
483llvmpipe gave those results on a CPU with AVX-512. On one without it, `Trunc` and `RoundEven` of a double go through
484the code llvmpipe has for a float, because its double vectors are twice its native width (512 bits at the usual 256)
485and it only has the exact rounding for a width the CPU has an extension for. There a magnitude above 2^24 comes back
486unchanged (`v_trunc_f64` of 123456789.0625 is 123456789.0625) and `RoundEven` of a smaller one can give the other
487neighbouring integer (1 for 1.5, 0 for the value just above 0.5): 48 of the 512 results, the same 48 with Mesa
48825.2.8 (LLVM 20.1.2) on a CI runner and with Mesa 26.2.6 under `GALLIUM_OVERRIDE_CPU_CAPS=avx`, which is how to see
489it on a CPU that has AVX-512. `Floor` and `Ceil` are exact on that path. The CI's runners differ in this, so the
490unchanged fixture passed or failed there by the machine it got. On llvmpipe the judge therefore lets `v_trunc_f64`
491and `v_rndne_f64` return what that path can give, the source itself above 2^24 and either neighbouring integer
492from 0.5 up to it, and nothing else (`ROUND_F64_FLOAT_PATH` in `check.py`); `v_floor_f64`, `v_ceil_f64`, the kept
493pair and the inputs stay exact there, and no other device gets the allowance. `LP_NATIVE_VECTOR_WIDTH=128` makes
494llvmpipe exact on a CPU with AVX.
495
382## Wave64 pixel, vertex and geometry shaders (`w64_graphics.py`) 496## Wave64 pixel, vertex and geometry shaders (`w64_graphics.py`)
383 497
384Graphics stages have no emulation: on a 32-wide subgroup a wave64 VS, PS or GS runs as two 32-lane halves, and the 498Graphics stages have no emulation: on a 32-wide subgroup a wave64 VS, PS or GS runs as two 32-lane halves, and the
@@ -418,23 +532,6 @@ Each line prints `ok`, a `SKIP` with its reason, or what differed. To add a fixt
4183. Add it to `EXPECT` in `tests/test_wave64_halves_fixtures.py` with the tier, reasons and idioms the translator 5323. Add it to `EXPECT` in `tests/test_wave64_halves_fixtures.py` with the tier, reasons and idioms the translator
419 should give it, and run `python -m pytest tests/test_wave64_halves_fixtures.py`. 533 should give it, and run `python -m pytest tests/test_wave64_halves_fixtures.py`.
4204. Run `w64_graphics.py` on a RADV GPU and say which GPU and Mesa version in the pull request. 5344. Run `w64_graphics.py` on a RADV GPU and say which GPU and Mesa version in the pull request.
421## GPUs with 128 bytes of push constants (AMD RDNA2 iGPUs on Windows, some Intel Arc drivers)
422
423The translated shaders take 144 bytes of push constants: s0..s31, then the heap base and the code base. A device whose
424`maxPushConstantsSize` is 128, Vulkan's minimum, can't take that, so the texture tests and every test drawn through
425`vk_harness` skip there (`unsupported: need 144 push constant bytes, device has 128`); `vulkaninfo` shows the limit.
426AMD's older Windows drivers report 128 on RDNA2 iGPUs (Radeon 680M on 22.40.84.06, 610M on 24.10.16.14, the Ryzen 5
4277600's iGPU on 24.10.24); 26.11.2 reports 256 on a Radeon 610M, where these tests run without the variable below.
428RADV reports more on the same chips.
429
430To run them anyway, set `LEONIDA_PC_TAIL_UBO=1` **for both `build.py` and `check.py`** (or for
431`run_gpu_tests.py`). The shaders are then translated with `--pc-tail-ubo`: s0..s31 stay in 128 push-constant bytes,
432and the heap base and code base move to a uniform block at set 1 (`docs/design.md`, "Push-constant tail as a uniform
433block"), which `vk_compute_test`, `vk_store_test`, `vk_harness`, `vk_texture_test`, `vk_sampler_test` and
434`vk_bindless_test` bind (`runtime/test/vk_pc_tail.h`). If you set it
435only for `check.py`, the shaders read the tail from push constants the programs no longer declare. `--mesh-compute`
436(`LEONIDA_MESH_COMPUTE=1`) isn't combined with it yet: its vertex shader still reads the output address from push
437constants, so those tests skip.
438 535
439## GPUs with 128 bytes of push constants (AMD RDNA2 iGPUs on Windows, some Intel Arc drivers) 536## GPUs with 128 bytes of push constants (AMD RDNA2 iGPUs on Windows, some Intel Arc drivers)
440 537