diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 21:44:23 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 21:44:23 -0500 |
| commit | b8563e949ed389fff20be91c73687a70b5213469 (patch) | |
| tree | d69c6817854ce0a14a67ff1fd0f1c39dec68a91f /docs/testing.md | |
| parent | 00fc23b9a9eeb1a75f1fec2b58024bea15c26663 (diff) | |
| parent | 7ae1dd3de34f1542242bc8ccfc80d9b97d20cc01 (diff) | |
Merge main into D3D-448-GRAPHICS (#974)
main already lays graphics root arguments out in the console layout (from s8, one dword per table: #939's
graphics-root-layout patch in #984's form, pack_stage(Stage::Pixel), RootArgumentLayout::graphics_console,
graphics_arguments_end, LEONIDA_GRAPHICS_STAGE_LAYOUT=0 for pack()). That form stays. What this pull request adds
beyond it is carried onto it: the mesh-shader root window (translator, index "root_window", mesh_ok, the two
refusals) and its tests. Its own graphics spill handling (Spill::block) and LEONIDA_GRAPHICS_ROOT_LAYOUT=pc are not
carried: main keeps pack()'s s0 layout for a graphics signature past s31, and its switch does what =pc did.
Conflicts:
- runtime/src/root_signature.h, root_signature.cpp: main's pack_stage (compute spill array, spill_dword); the
Spill enum, first_spilled and spilled_dwords dropped. The header keeps the PR's evidence note, with Stage::Pixel.
- runtime/shims/d3d12_com.h: main's comment and members, with the mesh window described; mesh_ok added (false by
default, set only for a console-layout signature that Stage::Mesh also places); the PR's second graphics_console
dropped.
- runtime/shims/d3d12_vulkan_device.cpp (CreateRootSignature): main's pixel/packed form; the PR's Stage::Mesh pack
and its log line added, mesh_ok = pixel.ok && mesh.ok. The mesh-shader refusal without "root_window" (no
conflict) stays.
- runtime/shims/d3d12_com.cpp: DispatchMesh keeps main's any_nonempty_viewport() and graphics_user_data() after the
PR's mesh_ok check; address() keeps main's comment. The PR's kNoSgpr guard in constants()/address() stays,
reworded: in main a spilled compute parameter has first_sgpr kNoSgpr, and kNoSgpr + offset wrapped round to s0.
- runtime/src/shader_library.h: both (main's wave64_graphics, the PR's root_window).
- runtime/test/d3d12_mesh_test.cpp: main's mesh shader-kind byte on both containers (also the PR's ms_old); the
PR's two-parameter signature replaces main's 25-dword padding onto the s0 layout; both test blocks kept (the
PR's window refusals, main's DISPATCH_MESH command signature), each in its own scope. The =pc case is dropped
(main's switch is read once per process).
- runtime/CMakeLists.txt (no conflict): the mesh test uses ps_draw.spv again; the ps_draw_s0.spv rule is gone.
- runtime/test/glsl/ps_draw.frag, vs_depth.vert, vs_draw.vert, vs_draw_int.vert, ps_depth_write.frag and
runtime/test/shaders/ps_m15, ps_m2, ps_m2_array, ps_m2_literal, ps_m2_uoff, ps_m3, ps_m3_post, ps_m3_query,
vs_m15, vs_m3 (.asm): main's (the same s8 rewrite done twice); ps_draw.frag's mesh-test note updated.
- runtime/test/root_signature_test.cpp (no conflict): the Spill::block cases dropped, the window cases kept.
- docs/design.md: main's rows (loop guard, direct resource heap) and the PR's user-data row.
- docs/d3d12_vulkan.md (no conflict): section 3.5 and the CreateRootSignature bullet rewritten for main's form.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'docs/testing.md')
| -rw-r--r-- | docs/testing.md | 199 |
1 files changed, 170 insertions, 29 deletions
diff --git a/docs/testing.md b/docs/testing.md index 04a5af180..ffe729d24 100644 --- a/docs/testing.md +++ b/docs/testing.md | |||
| @@ -56,9 +56,9 @@ This page collects the setup steps and the problems testers have run into so far | |||
| 56 | 56 | ||
| 57 | ## Build the test programs | 57 | ## Build the test programs |
| 58 | 58 | ||
| 59 | On a Windows runtime build with Vulkan enabled, CMake only registers `d3d12_translated_draw`, `d3d12_m2_textured`, | 59 | On a Windows runtime build with Vulkan enabled, CMake only registers `d3d12_translated_draw`, `d3d12_rect_list`, |
| 60 | `d3d12_m2_formats`, `d3d12_m3_frame`, `d3d12_m4_compute` and `d3d12_buffer_uav` when it finds `llvm-mc`, | 60 | `d3d12_quad_index`, `d3d12_m2_textured`, `d3d12_m2_formats`, `d3d12_m3_frame`, `d3d12_m4_compute` and |
| 61 | `spirv-as` and `spirv-val`. It registers `d3d12_subgroup` only when it finds `llvm-mc` and `glslangValidator`. | 61 | `d3d12_buffer_uav` when it finds `llvm-mc`, `spirv-as` and `spirv-val`. It registers `d3d12_subgroup` only when it finds `llvm-mc` and `glslangValidator`. |
| 62 | Without `glslangValidator`, other tests are also omitted, including `d3d12_compute`, `d3d12_draw`, | 62 | Without `glslangValidator`, other tests are also omitted, including `d3d12_compute`, `d3d12_draw`, |
| 63 | `d3d12_set0_compute` and `d3d12_mesh`; some registered tests run only part of their checks. These tests can be | 63 | `d3d12_set0_compute` and `d3d12_mesh`; some registered tests run only part of their checks. These tests can be |
| 64 | **absent**, not reported as skipped, when their build prerequisites are missing, so a passing `ctest` percentage | 64 | **absent**, not reported as skipped, when their build prerequisites are missing, so a passing `ctest` percentage |
| @@ -171,17 +171,26 @@ python -I runtime/test/shaders/build.py <out dir> | |||
| 171 | python -I runtime/test/shaders/check.py <out dir> <folder with the test programs> | 171 | python -I runtime/test/shaders/check.py <out dir> <folder with the test programs> |
| 172 | ``` | 172 | ``` |
| 173 | 173 | ||
| 174 | For the standalone `v_mullit_f32` readback, build the full-screen triangle and the | 174 | For 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"). |
| 175 | hand-written semantic fixture, then run 120 draws with runtime SGPR inputs. | ||
| 176 | The driver checks every pixel against an integer product rounded to 24 bits. | ||
| 177 | It reports the input words, pixel and channel on the first mismatch. | ||
| 178 | 175 | ||
| 179 | ```sh | 176 | On Windows, `run_gpu_tests.py` assembles and translates the D3D-78 fixture and runs the UAV readback and WARP |
| 180 | python -I runtime/test/shaders/build.py <out-dir> vs_ids ps_mullit | 177 | comparison from the same build folder. Use `--filter cs_texture_uav` to run only this case: |
| 181 | python -I runtime/test/shaders/mullit_readback.py <out-dir> <harness-directory> | 178 | |
| 179 | ```powershell | ||
| 180 | $env:LEONIDA_VK_VALIDATION = "1" | ||
| 181 | python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_texture_uav | ||
| 182 | ``` | 182 | ``` |
| 183 | 183 | ||
| 184 | For 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"). | 184 | Use the actual configuration subfolder for the executables with a multi-config generator. The native Windows |
| 185 | case reports SKIP without WARP or a sufficiently capable Vulkan device; failed translation, a missing test | ||
| 186 | executable on Windows, and readback mismatches fail the runner. Devices without sliced 3D views still run the 1D, | ||
| 187 | array and whole-mip cases and check that partial views are refused. | ||
| 188 | |||
| 189 | CTest runs the same D3D-78 descriptor creation, copy, range/refusal and clear checks with `--descriptors-only`. | ||
| 190 | That mode requires Vulkan, but not a translated shader or WARP. The GPU runner still exercises dispatch and readback. | ||
| 191 | |||
| 192 | Use `--filter cs_imgload_mip` to check 2D `image_load_mip` on FLOAT (UNORM), UINT and SINT sampled views with | ||
| 193 | both full-width and D16 loads; mip 0 contains decoy data and mip 1 holds the expected texels. | ||
| 185 | 194 | ||
| 186 | `vk_compute_test`, `vk_bindless_test` and `vk_image_fuzz` read `LEONIDA_VK_VALIDATION` too (`vk_compute_test` | 195 | `vk_compute_test`, `vk_bindless_test` and `vk_image_fuzz` read `LEONIDA_VK_VALIDATION` too (`vk_compute_test` |
| 187 | through `runtime/test/vk_validation.h`): each validation message goes to stderr and a validation error makes the | 196 | through `runtime/test/vk_validation.h`): each validation message goes to stderr and a validation error makes the |
| @@ -228,6 +237,49 @@ and `vk_presenter_sync`, `xbox_present` and `dxgi_swapchain` pass, while they fa | |||
| 228 | compositor for those three. Six still failed with a real display: `device_proxy`, `d3d12_xs_root_signature`, | 237 | compositor for those three. Six still failed with a real display: `device_proxy`, `d3d12_xs_root_signature`, |
| 229 | `xdxr_build`, `d3d12_xdxr_rt`, `d3d12_present` and `d3d12_compute`. | 238 | `xdxr_build`, `d3d12_xdxr_rt`, `d3d12_present` and `d3d12_compute`. |
| 230 | 239 | ||
| 240 | Run one after another as above, the suite takes several seconds per test, although a test started by hand takes 0.1 to | ||
| 241 | 1 second. Four settings make a local run of the cross-build much faster: | ||
| 242 | |||
| 243 | ```sh | ||
| 244 | export WINEPREFIX="$HOME/.local/share/leonida-wine" WINEDEBUG=-all \ | ||
| 245 | WINEDLLOVERRIDES="winedbg.exe=d;winemenubuilder.exe=d" | ||
| 246 | mkdir -p "$WINEPREFIX" | ||
| 247 | xvfb-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 | |||
| 251 | Start 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, | ||
| 253 | which keep that program's output open for as long as the server lives, so a first test that started them would wait | ||
| 254 | for 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 | |||
| 264 | Measured with Wine 11.22 on llvmpipe, 40 tests of a clang-cl build (`ctest -R '^(d3d12_[a-c]|vk_[a-d]|xg)'`), adding | ||
| 265 | one 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 | |||
| 276 | The 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 | ||
| 277 | starting 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 | ||
| 279 | after another, and 67 seconds with all four settings for two devices (llvmpipe and an integrated GPU) run at the same | ||
| 280 | time. `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 | |||
| 231 | The build type defaults to `RelWithDebInfo`: xwin leaves out the debug CRT, so `Debug` needs `--include-debug-libs`. | 283 | The build type defaults to `RelWithDebInfo`: xwin leaves out the debug CRT, so `Debug` needs `--include-debug-libs`. |
| 232 | `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 |
| 233 | runtime/build/windows` takes a folder made by hand like a Windows build). CMake packages are | 285 | runtime/build/windows` takes a folder made by hand like a Windows build). CMake packages are |
| @@ -300,7 +352,12 @@ WINE=wine WINEPREFIX="$(mktemp -d)" WINEDLLOVERRIDES="mscoree,mshtml=" WINEDEBUG | |||
| 300 | 352 | ||
| 301 | The session script initializes a dedicated prefix and stops its Wine processes at exit. On a headless host, | 353 | The session script initializes a dedicated prefix and stops its Wine processes at exit. On a headless host, |
| 302 | put `xvfb-run -a` before `bash` so prefix initialization and the tests share one virtual display. The test runner | 354 | put `xvfb-run -a` before `bash` so prefix initialization and the tests share one virtual display. The test runner |
| 303 | maps the recorded Windows drive to the Linux checkout for shaders referenced by absolute Windows paths. It prints | 355 | maps the recorded Windows drive to the Linux checkout for shaders referenced by absolute Windows paths. It keeps one |
| 356 | wineserver 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 | ||
| 358 | marked `RUN_SERIAL` run alone, tests that share a `RESOURCE_LOCK` never overlap, and the verdicts are printed in the | ||
| 359 | same order as with `--jobs 1`; the tests that share temp files can fail now and then in parallel (see "Known | ||
| 360 | problems"). It prints | ||
| 304 | every verdict and returns a failure status if any required test fails, skips or is missing. Check the printed | 361 | every verdict and returns a failure status if any required test fails, skips or is missing. Check the printed |
| 305 | verdicts for failures outside the required set. | 362 | verdicts for failures outside the required set. |
| 306 | 363 | ||
| @@ -346,6 +403,28 @@ on an Apple M3 Max (MoltenVK 1.4.2 and 1.4.3): 17 workgroup shapes from 1 to 102 | |||
| 346 | subgroups, with and without full subgroups and register pressure, all 32 lanes in order. A device whose default | 403 | subgroups, with and without full subgroups and register pressure, all 32 lanes in order. A device whose default |
| 347 | isn't the requested size still prints `not available`, and those tests skip. | 404 | isn't the requested size still prints `not available`, and those tests skip. |
| 348 | 405 | ||
| 406 | `cs_w32_salu_ext` runs 38 scalar ALU ops that no other fixture runs: `s_sub_i32`, `s_andn2_b32`, `s_orn2_b32`, | ||
| 407 | `s_xor_b32`, `s_ashr_i32`, `s_mul_hi_u32`, `s_lshl3_add_u32`, `s_lshl4_add_u32`, `s_pack_ll_b32_b16`, | ||
| 408 | `s_pack_hh_b32_b16`, `s_abs_i32`, `s_bcnt0_i32_b32`, `s_bitset0_b32`, `s_bitset1_b32`, `s_brev_b32`, `s_flbit_i32`, | ||
| 409 | `s_flbit_i32_b32`, `s_sext_i32_i8`, the six `s_cmp_*_i32`, `s_cmp_gt_u32`, `s_cmp_le_u32`, `s_bitcmp0_b32`, | ||
| 410 | `s_bitcmp1_b32`, `s_addk_i32`, `s_mulk_i32`, `s_cmovk_i32`, `s_ashr_i64`, `s_lshl_b64`, `s_lshr_b64`, | ||
| 411 | `s_bcnt0_i32_b64`, `s_bitset0_b64`, `s_cmov_b64` and `s_ff0_i32_b64`. Its sixteen operand words arrive in `s4..s19` | ||
| 412 | through `VKC_SGPRS`, so each op reaches the driver as SPIR-V: a scalar op on literals is folded by the translator | ||
| 413 | (the "Chained scalar constant folding" row of [design.md](design.md)) and only its result is stored. One thread stores | ||
| 414 | every destination and four words of SCC bits: SCC after each op that writes it, each run on operands that set it | ||
| 415 | and on operands that clear it; each compare and bit test both ways, the signed and the unsigned ones on words that | ||
| 416 | tell the two apart; and SCC after each op that must keep it, set to 1 and to 0 in turn before them. The 73 expected | ||
| 417 | words are literals in `check.py`, derived in the fixture's header, and `tests/test_gpu_salu_ext.py` recomputes them | ||
| 418 | from the fixture's own instruction lines with the reference of `tools/salu_diff.py`, the model that was compared | ||
| 419 | with hardware. Both GPU runners compare the whole 80-word heap, the untouched fill after the results included. Run | ||
| 420 | it alone with `python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_salu_ext --require-pass`. | ||
| 421 | On an RTX 4070 Ti (NVIDIA 620.70.06, Linux) and on llvmpipe (Mesa 26.2.6, LLVM 23.1.4) all 80 words match. Nine | ||
| 422 | translator rules broken one at a time each failed it on both: `s_ashr_i32` shifting in zeros (word 8), | ||
| 423 | `s_lshlN_add_u32` taking SCC from the add's carry alone (word 69), `s_abs_i32` negating (word 17), `s_mulk_i32` and | ||
| 424 | `s_addk_i32` zero-extending their immediate (words 37 and 21), `s_cmovk_i32` ignoring SCC (word 38), the 64-bit | ||
| 425 | shifts taking their count modulo 32 and `s_ashr_i64` shifting in zeros (word 51), and the 64-bit shifts taking SCC | ||
| 426 | from the low dword alone (word 72). | ||
| 427 | |||
| 349 | `cs_w32_shift64` checks `v_lshlrev_b64`, `v_lshrrev_b64` and `v_ashrrev_i64` with 64 memory-fed cases: | 428 | `cs_w32_shift64` checks `v_lshlrev_b64`, `v_lshrrev_b64` and `v_ashrrev_i64` with 64 memory-fed cases: |
| 350 | eight boundary values crossed with counts 0, 1, 31, 32, 33, 63, 64 and 65. The expected values come from Python | 429 | eight boundary values crossed with counts 0, 1, 31, 32, 33, 63, 64 and 65. The expected values come from Python |
| 351 | integers using the low six count bits, as specified by the [RDNA2 ISA, VOP3 opcodes 767–769](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content). | 430 | integers using the low six count bits, as specified by the [RDNA2 ISA, VOP3 opcodes 767–769](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content). |
| @@ -357,6 +436,85 @@ It needs shader Int64 support; a device that lacks it reports a skip. This is a | |||
| 357 | independent of wave64 emulation. On RTX 3080 Ti (616.92, Windows 11), all 640 words matched; replacing the count | 436 | independent of wave64 emulation. On RTX 3080 Ti (616.92, Windows 11), all 640 words matched; replacing the count |
| 358 | mask with 31 or the arithmetic shift with a logical shift made the test fail at words 66 and 251 respectively. | 437 | mask with 31 or the arithmetic shift with a logical shift made the test fail at words 66 and 251 respectively. |
| 359 | 438 | ||
| 439 | `cs_w32_frexp_ldexp` checks `v_frexp_mant_f32`, `v_frexp_exp_i32_f32`, `v_ldexp_f32`, `v_frexp_mant_f64` and | ||
| 440 | `v_frexp_exp_i32_f64`, which the translator computes with integer ops on the float's words. 64 records of a binary32 | ||
| 441 | value, an `ldexp` exponent and a binary64 value are loaded at run time: normals, the clamp of the exponent at ±512 | ||
| 442 | and beyond, results that overflow to an infinity and that fall below the smallest normal, binary32 denormals (read | ||
| 443 | as zero), binary64 subnormals (normalized; single fraction bits on both sides of the dword boundary and patterns | ||
| 444 | with several), zeros, infinities and NaNs. Each thread stores the five results, `v_frexp_mant_f32` with a `neg` | ||
| 445 | source and `v_ldexp_f32` with an `abs` source run with the odd threads turned off, whose destination must keep the | ||
| 446 | word it held. The expected words come from an oracle written from the rows of [design.md](design.md) | ||
| 447 | (`frexp_mant_f32`, `frexp_exp_i32_f32`, `ldexp_f32` and `frexp_f64` in `check.py`), and | ||
| 448 | `tests/test_gpu_frexp_ldexp.py` checks it against `math.frexp` and `math.ldexp` wherever those agree with the | ||
| 449 | hardware. Both GPU runners compare all 768 heap words, the 256 unchanged input words included. Run it alone with | ||
| 450 | `python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_frexp_ldexp --require-pass`. | ||
| 451 | On 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 | ||
| 452 | the binary32 ops still applied `neg` and `abs` with `OpFNegate` and `FAbs`, six words differed on the 4070 Ti and none | ||
| 453 | on llvmpipe: every NaN source under a modifier came back as `0x7fffffff`, the driver's default NaN (word 419 is the | ||
| 454 | first: the mantissa of the negated `0x7fc00000`). Rules broken one at a time each failed the test on both devices: | ||
| 455 | the mantissa given the exponent field 127 (word 0) or, for binary64, 1023 (word 5), the exponent subtracting 127 | ||
| 456 | (word 1), `v_ldexp_f32` without its clamp (word 258) or overflowing to the largest finite value (word 106), a | ||
| 457 | binary32 denormal not read as zero (word 352), the binary64 subnormal exponent off by one in the low or in the high | ||
| 458 | dword (words 134 and 150), and the fixture without its `v_cmpx` (word 15). | ||
| 459 | |||
| 460 | `cs_w32_cmp_f64` checks the 32 binary64 vector compares, `v_cmp_*_f64` into VCC and `v_cmpx_*_f64` on EXEC, with | ||
| 461 | 256 memory-fed operand pairs: the product of 16 values (±inf, ±max, the 1-ULP neighbours of ±1, the smallest | ||
| 462 | subnormals, ±0, the smallest normal, a NaN whose payload is only in the low dword and a negative quiet NaN). Each | ||
| 463 | thread stores one bit per predicate for both forms, a bit for `tru` run with the odd threads turned off (an inactive | ||
| 464 | lane gets VCC 0 from `v_cmp_` and stays off through `v_cmpx_`) and two bits for `lt` and `nge` with VOP3 `abs`/`neg`. | ||
| 465 | The expected words come from Python floats (`cmp_f64_words` in `check.py`): IEEE-754 ordering, with every pair that | ||
| 466 | has a NaN unordered. Both GPU runners compare all 1536 heap words (512 result words and 1024 unchanged input words); | ||
| 467 | the operands are loaded at run time, so neither the translator nor the driver can fold a compare. Run it alone with | ||
| 468 | `python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_cmp_f64 --require-pass`. | ||
| 469 | It is a wave32 test and no step of it needs a particular subgroup width, so it also runs on llvmpipe; the SGPR-pair | ||
| 470 | and constant operand forms are CPU-checked only (`tests/semantic/test_cmp_f64.py`). On an RTX 4070 Ti (NVIDIA | ||
| 471 | 620.70.06, Linux) all 1536 words matched, and seven translator rules broken one at a time each failed it: no `-0` | ||
| 472 | canonicalization at word 206, a NaN test that ignores the low dword at word 28, an ordering key without the low | ||
| 473 | dword at word 70, the raw result written to an inactive lane's VCC at word 2, `v_cmpx_` replacing EXEC at word 3, | ||
| 474 | `abs` ignored and `nlt` lowered as the negation of `le` at word 0. | ||
| 475 | |||
| 476 | `cs_w32_round_f64` checks `v_trunc_f64`, `v_ceil_f64`, `v_rndne_f64` and `v_floor_f64`, which the translator gives | ||
| 477 | to the driver's double-precision `Trunc`, `Ceil`, `RoundEven` and `Floor` (`shaderFloat64`). 64 inputs are loaded at | ||
| 478 | run time: signed zeros, the smallest subnormals and normals, values around 0.5 and 1 (the largest value below 0.5 | ||
| 479 | among 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, | ||
| 480 | the largest finite value, the infinities, and quiet and signalling NaNs. Each thread stores the four roundings, | ||
| 481 | `v_trunc_f64` with a `neg` source, `v_ceil_f64` with an `abs` source, a `v_floor_f64` whose destination pair overlaps | ||
| 482 | its source pair, and a `v_rndne_f64` run with the odd threads turned off, whose destination must keep the pair it | ||
| 483 | held. The expected words come from Python (`round_f64` in `check.py`: exact IEEE-754, the result keeping its | ||
| 484 | source's sign), and `tests/test_gpu_round_f64.py` checks that oracle against exact rational rounding. All 1152 heap | ||
| 485 | words are compared exactly, the 128 unchanged input words included: a NaN and a subnormal are rounded by the | ||
| 486 | translated code with integer ops and not by the driver, as the row in [design.md](design.md) says. (llvmpipe gets | ||
| 487 | one allowance, for what it does to `Trunc` and `RoundEven` on some CPUs; see below.) Run it alone with | ||
| 488 | `python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_round_f64 --require-pass`. | ||
| 489 | It needs `shaderFloat64`; a device without it reports a skip. | ||
| 490 | |||
| 491 | Measured: on an RTX 4070 Ti (NVIDIA 620.70.06, Linux) and on llvmpipe (Mesa 26.2.6, LLVM 23.1.4) all 1152 words | ||
| 492 | match. While those two kinds of input still went to the driver's function, 15 of the 512 results differed on the | ||
| 493 | 4070 Ti, those of the two signalling NaNs, which came back quiet with sign and payload kept (`0x7ff0000000000001` | ||
| 494 | gave `0x7ff8000000000001`), and five more on llvmpipe, which read the two smallest subnormals as zero (`v_ceil_f64` | ||
| 495 | of the positive one gave +0 instead of 1, `v_floor_f64` of the negative one -0 instead of -1). Rules broken one at a | ||
| 496 | time each failed the test on both devices: a NaN left to the driver (word 784), the NaN and subnormal tests ignoring | ||
| 497 | the low dword, `v_ceil_f64` or `v_floor_f64` lifting the subnormal of the wrong sign (words 34 and 38), a subnormal's | ||
| 498 | result losing its sign (word 40), a NaN's low word dropped (word 784), `rndne` lowered as `floor(x + 0.5)` (word 20, | ||
| 499 | the sign of -0), `trunc` or `ceil` lowered as `Floor`, the `neg` or the `abs` source modifier ignored (words 8 and | ||
| 500 | 26), the two result words swapped (word 8), and the fixture without its `v_cmpx` (word 30). Two changes are not | ||
| 501 | caught everywhere: a subnormal left to the driver fails on llvmpipe (word 34) and passes on the 4070 Ti, which keeps | ||
| 502 | binary64 denormals, and `RoundEven` replaced by GLSL `Round` changes nothing on either device, since both send a tie | ||
| 503 | to the even integer. | ||
| 504 | |||
| 505 | llvmpipe gave those results on a CPU with AVX-512. On one without it, `Trunc` and `RoundEven` of a double go through | ||
| 506 | the code llvmpipe has for a float, because its double vectors are twice its native width (512 bits at the usual 256) | ||
| 507 | and it only has the exact rounding for a width the CPU has an extension for. There a magnitude above 2^24 comes back | ||
| 508 | unchanged (`v_trunc_f64` of 123456789.0625 is 123456789.0625) and `RoundEven` of a smaller one can give the other | ||
| 509 | neighbouring integer (1 for 1.5, 0 for the value just above 0.5): 48 of the 512 results, the same 48 with Mesa | ||
| 510 | 25.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 | ||
| 511 | it on a CPU that has AVX-512. `Floor` and `Ceil` are exact on that path. The CI's runners differ in this, so the | ||
| 512 | unchanged fixture passed or failed there by the machine it got. On llvmpipe the judge therefore lets `v_trunc_f64` | ||
| 513 | and `v_rndne_f64` return what that path can give, the source itself above 2^24 and either neighbouring integer | ||
| 514 | from 0.5 up to it, and nothing else (`ROUND_F64_FLOAT_PATH` in `check.py`); `v_floor_f64`, `v_ceil_f64`, the kept | ||
| 515 | pair and the inputs stay exact there, and no other device gets the allowance. `LP_NATIVE_VECTOR_WIDTH=128` makes | ||
| 516 | llvmpipe exact on a CPU with AVX. | ||
| 517 | |||
| 360 | ## Wave64 pixel, vertex and geometry shaders (`w64_graphics.py`) | 518 | ## Wave64 pixel, vertex and geometry shaders (`w64_graphics.py`) |
| 361 | 519 | ||
| 362 | Graphics stages have no emulation: on a 32-wide subgroup a wave64 VS, PS or GS runs as two 32-lane halves, and the | 520 | Graphics stages have no emulation: on a 32-wide subgroup a wave64 VS, PS or GS runs as two 32-lane halves, and the |
| @@ -396,23 +554,6 @@ Each line prints `ok`, a `SKIP` with its reason, or what differed. To add a fixt | |||
| 396 | 3. Add it to `EXPECT` in `tests/test_wave64_halves_fixtures.py` with the tier, reasons and idioms the translator | 554 | 3. Add it to `EXPECT` in `tests/test_wave64_halves_fixtures.py` with the tier, reasons and idioms the translator |
| 397 | should give it, and run `python -m pytest tests/test_wave64_halves_fixtures.py`. | 555 | should give it, and run `python -m pytest tests/test_wave64_halves_fixtures.py`. |
| 398 | 4. Run `w64_graphics.py` on a RADV GPU and say which GPU and Mesa version in the pull request. | 556 | 4. Run `w64_graphics.py` on a RADV GPU and say which GPU and Mesa version in the pull request. |
| 399 | ## GPUs with 128 bytes of push constants (AMD RDNA2 iGPUs on Windows, some Intel Arc drivers) | ||
| 400 | |||
| 401 | The translated shaders take 144 bytes of push constants: s0..s31, then the heap base and the code base. A device whose | ||
| 402 | `maxPushConstantsSize` is 128, Vulkan's minimum, can't take that, so the texture tests and every test drawn through | ||
| 403 | `vk_harness` skip there (`unsupported: need 144 push constant bytes, device has 128`); `vulkaninfo` shows the limit. | ||
| 404 | AMD'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 | ||
| 405 | 7600's iGPU on 24.10.24); 26.11.2 reports 256 on a Radeon 610M, where these tests run without the variable below. | ||
| 406 | RADV reports more on the same chips. | ||
| 407 | |||
| 408 | To run them anyway, set `LEONIDA_PC_TAIL_UBO=1` **for both `build.py` and `check.py`** (or for | ||
| 409 | `run_gpu_tests.py`). The shaders are then translated with `--pc-tail-ubo`: s0..s31 stay in 128 push-constant bytes, | ||
| 410 | and the heap base and code base move to a uniform block at set 1 (`docs/design.md`, "Push-constant tail as a uniform | ||
| 411 | block"), which `vk_compute_test`, `vk_store_test`, `vk_harness`, `vk_texture_test`, `vk_sampler_test` and | ||
| 412 | `vk_bindless_test` bind (`runtime/test/vk_pc_tail.h`). If you set it | ||
| 413 | only for `check.py`, the shaders read the tail from push constants the programs no longer declare. `--mesh-compute` | ||
| 414 | (`LEONIDA_MESH_COMPUTE=1`) isn't combined with it yet: its vertex shader still reads the output address from push | ||
| 415 | constants, so those tests skip. | ||
| 416 | 557 | ||
| 417 | ## GPUs with 128 bytes of push constants (AMD RDNA2 iGPUs on Windows, some Intel Arc drivers) | 558 | ## GPUs with 128 bytes of push constants (AMD RDNA2 iGPUs on Windows, some Intel Arc drivers) |
| 418 | 559 | ||