upleb.uk

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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 23:08:56 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 23:08:56 -0500
commite2ecb50cf149afb035c2d5fd2f3f2da509e8c2f9 (patch)
treef0642f5dc0223ad48771460d903237dfe82acb42
parentf02cf94d516591b05fe4553cd10e9136599e1a48 (diff)
parentaec744e39d54e5e33701198334df5dbf7e4d754a (diff)
Merge pull request #3855 from Oleg Makarov
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-rw-r--r--docs/testing.md1
-rw-r--r--runtime/test/shaders/check.py18
-rw-r--r--runtime/test/shaders/ps_nan_payload.asm10
-rw-r--r--runtime/test/vk_harness.cpp3
-rw-r--r--scripts/run_gpu_tests.py4
-rw-r--r--tests/test_shader_checks.py22
6 files changed, 57 insertions, 1 deletions
diff --git a/docs/testing.md b/docs/testing.md
index 8c3fd5ae6..d327e1803 100644
--- a/docs/testing.md
+++ b/docs/testing.md
@@ -479,6 +479,7 @@ The GPU tools of `runtime/test/shaders` (`vk_compute_test`, `vk_harness`, ...) r
479| `gs_tri` and `ms_tri` fail on a Mac | MoltenVK has no geometry stage and no `VK_EXT_mesh_shader` | Current `main` reports them as skipped | 479| `gs_tri` and `ms_tri` fail on a Mac | MoltenVK has no geometry stage and no `VK_EXT_mesh_shader` | Current `main` reports them as skipped |
480| With `LEONIDA_W64_EMULATE=1` on llvmpipe, the `ms_*` tests fail. Measured with Mesa 26.3.1: on x86_64 at 256-bit vectors (the default there) all six abort with "LLVM ERROR: Cannot emit physreg copy instruction"; on arm64 (128-bit) `ms_tri` draws nothing (the frame stays at the clear color); on x86_64 at 128 bits (`LP_NATIVE_VECTOR_WIDTH=128`) `ms_tri` happened to draw correctly, but with Mesa 26.0.3 `ms_wave_info_s3` and `ms_v5_workgroup` draw nothing there (4 of 6 pass, [measured by @TreXito](https://github.com/ItsNotRexed/Leonida/pull/3838#issuecomment-7086696759)) ([measured runs](https://github.com/ItsNotRexed/Leonida/issues/3127#issuecomment-7086469679)) | An llvmpipe bug: a mesh shader's runtime `CullPrimitiveEXT` is stored through an invalid `bitcast <N x i1> to <N x float>` (TEST-782, #3127; see "Without a GPU: Mesa llvmpipe") | Run the mesh tests on llvmpipe without `LEONIDA_W64_EMULATE`, or add `LEONIDA_MESH_COMPUTE=1` (the compute fallback): with it all 6 `ms_*` pass emulated on llvmpipe (x86_64, 256-bit) | 480| With `LEONIDA_W64_EMULATE=1` on llvmpipe, the `ms_*` tests fail. Measured with Mesa 26.3.1: on x86_64 at 256-bit vectors (the default there) all six abort with "LLVM ERROR: Cannot emit physreg copy instruction"; on arm64 (128-bit) `ms_tri` draws nothing (the frame stays at the clear color); on x86_64 at 128 bits (`LP_NATIVE_VECTOR_WIDTH=128`) `ms_tri` happened to draw correctly, but with Mesa 26.0.3 `ms_wave_info_s3` and `ms_v5_workgroup` draw nothing there (4 of 6 pass, [measured by @TreXito](https://github.com/ItsNotRexed/Leonida/pull/3838#issuecomment-7086696759)) ([measured runs](https://github.com/ItsNotRexed/Leonida/issues/3127#issuecomment-7086469679)) | An llvmpipe bug: a mesh shader's runtime `CullPrimitiveEXT` is stored through an invalid `bitcast <N x i1> to <N x float>` (TEST-782, #3127; see "Without a GPU: Mesa llvmpipe") | Run the mesh tests on llvmpipe without `LEONIDA_W64_EMULATE`, or add `LEONIDA_MESH_COMPUTE=1` (the compute fallback): with it all 6 `ms_*` pass emulated on llvmpipe (x86_64, 256-bit) |
481| On a Mac, `valu_fuzz.py --family f16` reads `+0` where the model wants `-0`, from a multiply whose exact product is -0 (`v_mul_f16`, `v_pk_mul_f16`) or from an FMA whose product and addend are both -0 (`v_fma_f16`, `v_fmac_f16`, `v_pk_fma_f16`) | MoltenVK computes a `NoContraction` multiply as `fma(l, r, +0)`, which drops the sign. MoltenVK 1.4.2 and `main` up to at least `5189f8de` are affected (SHADER-182, [design notes](design.md#translator-status-and-runtime-contract)) | Expected with these MoltenVK versions. To run the rest of the fuzzer clean, add `--skip-op` for each of the five ops. To see them match, install Homebrew's `mesa` and use its KosmicKrisp driver: `LEONIDA_VULKAN_LOADER=/opt/homebrew/opt/vulkan-loader/lib/libvulkan.1.dylib VK_DRIVER_FILES=/opt/homebrew/share/vulkan/icd.d/kosmickrisp_mesa_icd.aarch64.json python3 -I tools/valu_fuzz.py --family f16 --build runtime/build/linux`. Or build MoltenVK with SPIRV-Cross `300681bb` or newer in `ExternalRevisions/SPIRV-Cross_repo_revision`, and point `LEONIDA_VULKAN_LOADER` at its `libMoltenVK.dylib` | 481| On a Mac, `valu_fuzz.py --family f16` reads `+0` where the model wants `-0`, from a multiply whose exact product is -0 (`v_mul_f16`, `v_pk_mul_f16`) or from an FMA whose product and addend are both -0 (`v_fma_f16`, `v_fmac_f16`, `v_pk_fma_f16`) | MoltenVK computes a `NoContraction` multiply as `fma(l, r, +0)`, which drops the sign. MoltenVK 1.4.2 and `main` up to at least `5189f8de` are affected (SHADER-182, [design notes](design.md#translator-status-and-runtime-contract)) | Expected with these MoltenVK versions. To run the rest of the fuzzer clean, add `--skip-op` for each of the five ops. To see them match, install Homebrew's `mesa` and use its KosmicKrisp driver: `LEONIDA_VULKAN_LOADER=/opt/homebrew/opt/vulkan-loader/lib/libvulkan.1.dylib VK_DRIVER_FILES=/opt/homebrew/share/vulkan/icd.d/kosmickrisp_mesa_icd.aarch64.json python3 -I tools/valu_fuzz.py --family f16 --build runtime/build/linux`. Or build MoltenVK with SPIRV-Cross `300681bb` or newer in `ExternalRevisions/SPIRV-Cross_repo_revision`, and point `LEONIDA_VULKAN_LOADER` at its `libMoltenVK.dylib` |
482| A pixel shader exporting non-canonical f32 NaNs reads back `0x7fc00000` from an RGBA32F color attachment | KosmicKrisp (Mesa 26.3.1), reproduced on Apple M3 Max and M1 Pro ([#3125](https://github.com/ItsNotRexed/Leonida/issues/3125)); MoltenVK 1.4.2 preserved both tested payloads on the same M1 Pro | `ps_nan_payload` allows the measured canonical word only for the NaN channels and only when `vk_harness` reports `driver: KosmicKrisp`. Finite channels and other drivers still require exact words. Use integer or storage-buffer readback for comparisons that require the raw payload on KosmicKrisp. |
482| CMake stops with "needs the Windows SDK 10.0.26100 or newer", or MSVC reports `'Desc_1_2': is not a member of 'D3D12_VERSIONED_ROOT_SIGNATURE_DESC'` | A Windows SDK older than 10.0.26100 (10.0.22621 is the common one), which has no version 1.2 root signatures | `winget install Microsoft.WindowsSDK.10.0.26100`, or add it in the Visual Studio Installer, then delete `runtime/build` and configure again | 483| CMake stops with "needs the Windows SDK 10.0.26100 or newer", or MSVC reports `'Desc_1_2': is not a member of 'D3D12_VERSIONED_ROOT_SIGNATURE_DESC'` | A Windows SDK older than 10.0.26100 (10.0.22621 is the common one), which has no version 1.2 root signatures | `winget install Microsoft.WindowsSDK.10.0.26100`, or add it in the Visual Studio Installer, then delete `runtime/build` and configure again |
483| `ctest` lists `fsr_dispatch` and `bvh_builder` as failed (`Not Run`) after clang-cl hits an internal compiler error in `fsr_dispatch_test.cpp` and `bvh_builder_test.cpp` | clang-cl 22.1.8 on Fedora (Linux cross-build) and Windows, plus 22.1.7 on Windows | Use clang-cl 23.1.6 (both files compile on Windows) | 484| `ctest` lists `fsr_dispatch` and `bvh_builder` as failed (`Not Run`) after clang-cl hits an internal compiler error in `fsr_dispatch_test.cpp` and `bvh_builder_test.cpp` | clang-cl 22.1.8 on Fedora (Linux cross-build) and Windows, plus 22.1.7 on Windows | Use clang-cl 23.1.6 (both files compile on Windows) |
484| `d3d12_compute`, `d3d12_draw` or another test that writes a shader library under the temp directory fails now and then (a PSO creation `line N: SUCCEEDED(...)`, or exit 3 with no message) but passes when run alone | Two copies running at once (`ctest -j`, or two suites sharing one Wine prefix or `TMPDIR`) used the same `leonida_<test>` folder under the temp directory, and one copy deleted the shader modules the other was loading: 6 of 40 runs failed with four copies of `d3d12_compute` at once on a Mac under Wine | Current `main` gives each process its own folder (`<temp>/leonida_<test>_<pid>`) | 485| `d3d12_compute`, `d3d12_draw` or another test that writes a shader library under the temp directory fails now and then (a PSO creation `line N: SUCCEEDED(...)`, or exit 3 with no message) but passes when run alone | Two copies running at once (`ctest -j`, or two suites sharing one Wine prefix or `TMPDIR`) used the same `leonida_<test>` folder under the temp directory, and one copy deleted the shader modules the other was loading: 6 of 40 runs failed with four copies of `d3d12_compute` at once on a Mac under Wine | Current `main` gives each process its own folder (`<temp>/leonida_<test>_<pid>`) |
diff --git a/runtime/test/shaders/check.py b/runtime/test/shaders/check.py
index 0d748c2e3..e5d46e9fb 100644
--- a/runtime/test/shaders/check.py
+++ b/runtime/test/shaders/check.py
@@ -504,12 +504,13 @@ TEXTURE_CONSTANTS = {
504 "ps_array_resinfo": (8.0, 8.0, 12.0, 1.0), # binding 3, index 1: two 6-face cubes, one mip 504 "ps_array_resinfo": (8.0, 8.0, 12.0, 1.0), # binding 3, index 1: two 6-face cubes, one mip
505} 505}
506CLIP_TESTS = ("vs_clip", "vs_clip_param4", "vs_clip_undeclared") 506CLIP_TESTS = ("vs_clip", "vs_clip_param4", "vs_clip_undeclared")
507NAN_PAYLOAD_TEST = "ps_nan_payload"
507# One definition: a later assignment used to drop ps_texoff (and any entry added by an earlier assignment) from 508# One definition: a later assignment used to drop ps_texoff (and any entry added by an earlier assignment) from
508# the standalone run. Keep every pixel fixture in this tuple. 509# the standalone run. Keep every pixel fixture in this tuple.
509PIXEL_TESTS = sorted((*PIXEL_BITS, "ps_bary", "ps_persp_bary", "ps_flat", "ps_bitmask_perm", "ps_texoff", 510PIXEL_TESTS = sorted((*PIXEL_BITS, "ps_bary", "ps_persp_bary", "ps_flat", "ps_bitmask_perm", "ps_texoff",
510 "ps_texoff_implicit", "ps_texoff_forms", 511 "ps_texoff_implicit", "ps_texoff_forms",
511 "ps_uniform_branch", "ps_wqm", "ps_scc_mask32", "ps_interp_f16_high", "ps_ij_computed", 512 "ps_uniform_branch", "ps_wqm", "ps_scc_mask32", "ps_interp_f16_high", "ps_ij_computed",
512 "ps_mandelbrot")) 513 "ps_mandelbrot", NAN_PAYLOAD_TEST))
513# Pixel fixtures drawn with another vertex shader than vs_ids. 514# Pixel fixtures drawn with another vertex shader than vs_ids.
514PIXEL_VERTEX = {"ps_interp_f16_high": "vs_f16_pack", "ps_persp_bary": "vs_persp", 515PIXEL_VERTEX = {"ps_interp_f16_high": "vs_f16_pack", "ps_persp_bary": "vs_persp",
515 "ps_interp_f32_mods": "vs_interp_consts", "ps_interp_mov_mods": "vs_interp_consts"} 516 "ps_interp_f32_mods": "vs_interp_consts", "ps_interp_mov_mods": "vs_interp_consts"}
@@ -1559,6 +1560,19 @@ def barycentric_problem(px: list[tuple[float, float, float, float]], abs_tol: fl
1559 return "" 1560 return ""
1560 1561
1561 1562
1563def nan_payload_problem(px, out):
1564 """Check the exact words, except for the measured KosmicKrisp RGBA32F canonicalization (#3125)."""
1565 if len(px) != 64 * 64:
1566 return f"expected 4096 pixels, got {len(px)}"
1567 want = (0x7fc12345, 0xffc54321, 0x3f800000, 0x3f000000)
1568 canonicalizes = "driver: KosmicKrisp" in out.splitlines()
1569 for i, p in enumerate(px):
1570 if any(actual != expected and not (canonicalizes and c < 2 and actual == 0x7fc00000)
1571 for c, (actual, expected) in enumerate(zip(p, want))):
1572 return f"pixel ({i % 64},{i // 64}) has unexpected words: {[hex(x) for x in p]}"
1573 return ""
1574
1575
1562def pixel_test(tools, spirv, name): 1576def pixel_test(tools, spirv, name):
1563 path = os.path.join(spirv, name + ".spv") 1577 path = os.path.join(spirv, name + ".spv")
1564 if name == "ps_ij_computed" and (BARY_FALLBACK or F16_HALVES): 1578 if name == "ps_ij_computed" and (BARY_FALLBACK or F16_HALVES):
@@ -1591,6 +1605,8 @@ def pixel_test(tools, spirv, name):
1591 if not px: 1605 if not px:
1592 return out if out.startswith("could not start") else "vk_harness failed or returned no pixels" 1606 return out if out.startswith("could not start") else "vk_harness failed or returned no pixels"
1593 n = len(px) 1607 n = len(px)
1608 if name == NAN_PAYLOAD_TEST:
1609 return nan_payload_problem(px, out)
1594 if name in PIXEL_BITS: 1610 if name in PIXEL_BITS:
1595 wrong = sum(p != PIXEL_BITS[name] for p in px) 1611 wrong = sum(p != PIXEL_BITS[name] for p in px)
1596 return "" if not wrong else f"{wrong} of {n} pixels differ, e.g. {[hex(x) for x in next(p for p in px if p != PIXEL_BITS[name])]}" 1612 return "" if not wrong else f"{wrong} of {n} pixels differ, e.g. {[hex(x) for x in next(p for p in px if p != PIXEL_BITS[name])]}"
diff --git a/runtime/test/shaders/ps_nan_payload.asm b/runtime/test/shaders/ps_nan_payload.asm
new file mode 100644
index 000000000..67e5f6f8d
--- /dev/null
+++ b/runtime/test/shaders/ps_nan_payload.asm
@@ -0,0 +1,10 @@
1; Export two non-canonical f32 quiet NaNs and two finite controls to RGBA32F.
2; Expected mrt0 words: 0x7fc12345, 0xffc54321, 0x3f800000, 0x3f000000.
3; Only KosmicKrisp may return the canonical 0x7fc00000 for the NaNs (#3125).
4
5v_mov_b32 v0, 0x7fc12345
6v_mov_b32 v1, 0xffc54321
7v_mov_b32 v2, 0x3f800000
8v_mov_b32 v3, 0x3f000000
9exp mrt0 v0, v1, v2, v3 done vm
10s_endpgm
diff --git a/runtime/test/vk_harness.cpp b/runtime/test/vk_harness.cpp
index 7bd679f10..c9968a1c2 100644
--- a/runtime/test/vk_harness.cpp
+++ b/runtime/test/vk_harness.cpp
@@ -267,10 +267,13 @@ int main(int argc, char** argv) {
267 } 267 }
268 VkPhysicalDeviceProperties props; vkGetPhysicalDeviceProperties(pd, &props); 268 VkPhysicalDeviceProperties props; vkGetPhysicalDeviceProperties(pd, &props);
269 VkPhysicalDeviceSubgroupSizeControlProperties sgProps{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES}; 269 VkPhysicalDeviceSubgroupSizeControlProperties sgProps{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES};
270 VkPhysicalDeviceDriverProperties driver{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES};
271 if (props.apiVersion >= VK_API_VERSION_1_2) sgProps.pNext = &driver;
270 VkPhysicalDeviceProperties2 props2{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2}; 272 VkPhysicalDeviceProperties2 props2{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2};
271 props2.pNext = &sgProps; 273 props2.pNext = &sgProps;
272 vkGetPhysicalDeviceProperties2(pd, &props2); 274 vkGetPhysicalDeviceProperties2(pd, &props2);
273 std::fprintf(stderr, "device: %s (subgroup %u..%u)\n", props.deviceName, sgProps.minSubgroupSize, sgProps.maxSubgroupSize); 275 std::fprintf(stderr, "device: %s (subgroup %u..%u)\n", props.deviceName, sgProps.minSubgroupSize, sgProps.maxSubgroupSize);
276 if (driver.driverName[0]) std::fprintf(stderr, "driver: %s\n", driver.driverName);
274 uint32_t qn = 0; 277 uint32_t qn = 0;
275 vkGetPhysicalDeviceQueueFamilyProperties(pd, &qn, nullptr); 278 vkGetPhysicalDeviceQueueFamilyProperties(pd, &qn, nullptr);
276 std::vector<VkQueueFamilyProperties> qf(qn); 279 std::vector<VkQueueFamilyProperties> qf(qn);
diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py
index 4a9a79b64..8df85307f 100644
--- a/scripts/run_gpu_tests.py
+++ b/scripts/run_gpu_tests.py
@@ -45,6 +45,7 @@ from check import (WAVE32_LANE_DUMPS, WAVE32_LANE_ENV, bitmask_perm_narrow_skip,
45 unpinned_subgroup_skip, vcmpx_forms_narrow_skip, wave32_lane_skip) # as in check.py 45 unpinned_subgroup_skip, vcmpx_forms_narrow_skip, wave32_lane_skip) # as in check.py
46from check import PIXEL_VERTEX, VINT_ENV, interp_f16_high_problem, ij_computed_problem, mandelbrot_problem # pixel producers and checks 46from check import PIXEL_VERTEX, VINT_ENV, interp_f16_high_problem, ij_computed_problem, mandelbrot_problem # pixel producers and checks
47from check import barycentric_problem 47from check import barycentric_problem
48from check import NAN_PAYLOAD_TEST, nan_payload_problem
48from check import GET_LOD_TESTS, STORE_WORDS, get_lod_test, store_words_problem # TEST-184: image atomics and queries 49from check import GET_LOD_TESTS, STORE_WORDS, get_lod_test, store_words_problem # TEST-184: image atomics and queries
49from check import wide_pixel_skip # ps_w64x_readlane: judged only where the fragment stage was required 64-wide 50from check import wide_pixel_skip # ps_w64x_readlane: judged only where the fragment stage was required 64-wide
50from check import FMA_FUSED_ENV, judge_fma_fused # cs_fma_fused: strict under LEONIDA_FMA=khr, fused/split under glsl 51from check import FMA_FUSED_ENV, judge_fma_fused # cs_fma_fused: strict under LEONIDA_FMA=khr, fused/split under glsl
@@ -1336,6 +1337,9 @@ def run_suite(a, work: str) -> int:
1336 ok, detail = None, str(skip) 1337 ok, detail = None, str(skip)
1337 else: 1338 else:
1338 ok, detail = check_pixel_const(raw, const_wants[name]) 1339 ok, detail = check_pixel_const(raw, const_wants[name])
1340 elif name == NAN_PAYLOAD_TEST:
1341 problem = nan_payload_problem(read_raw_u32(raw), msg)
1342 ok, detail = not problem, problem or "4096/4096 pixels match the driver-aware NaN payload check"
1339 elif name == "ps_bary": 1343 elif name == "ps_bary":
1340 ok, detail = check_bary(raw) 1344 ok, detail = check_bary(raw)
1341 elif name == "ps_persp_bary": 1345 elif name == "ps_persp_bary":
diff --git a/tests/test_shader_checks.py b/tests/test_shader_checks.py
index 51b087d43..04a7108c6 100644
--- a/tests/test_shader_checks.py
+++ b/tests/test_shader_checks.py
@@ -373,6 +373,28 @@ class PixelDeviceLimits(unittest.TestCase):
373 self.assertNotIsInstance(problem, check.Skip) 373 self.assertNotIsInstance(problem, check.Skip)
374 self.assertIn("vk_harness failed", problem) 374 self.assertIn("vk_harness failed", problem)
375 375
376 def test_nan_payload_exception_is_limited_to_kosmickrisp(self):
377 payloads = self.readlane_pixels((0x7fc12345, 0xffc54321, 0x3f800000, 0x3f000000))
378 canonical = self.readlane_pixels((0x7fc00000, 0x7fc00000, 0x3f800000, 0x3f000000))
379 for driver in ("driver: KosmicKrisp\n", "driver: MoltenVK\n", ""):
380 with self.subTest(driver=driver):
381 out = f"device: Apple M1 Pro (subgroup 32..32)\n{driver}ok 64x64\n"
382 self.assertEqual(self.run_pixel("ps_nan_payload", 0, out, payloads), "")
383 problem = self.run_pixel("ps_nan_payload", 0, out, canonical)
384 if driver == "driver: KosmicKrisp\n":
385 self.assertEqual(problem, "")
386 else:
387 self.assertIn("unexpected words", problem)
388
389 def test_kosmickrisp_still_rejects_bad_nan_and_finite_words(self):
390 out = "driver: KosmicKrisp\nok 64x64\n"
391 for words in ((0x7fc00001, 0x7fc00000, 0x3f800000, 0x3f000000),
392 (0x7f800000, 0x7fc00000, 0x3f800000, 0x3f000000),
393 (0x7fc00000, 0x7fc00000, 0x7fc00000, 0x3f000000)):
394 with self.subTest(words=words):
395 problem = self.run_pixel("ps_nan_payload", 0, out, self.readlane_pixels(words))
396 self.assertIn("unexpected words", problem)
397
376 def test_bitmask_perm_skips_below_32_lanes(self): 398 def test_bitmask_perm_skips_below_32_lanes(self):
377 out = "device: fake (subgroup 8..8)\nok 64x64\n" 399 out = "device: fake (subgroup 8..8)\nok 64x64\n"
378 problem = self.run_pixel("ps_bitmask_perm", 0, out, data=self.bitmask_pixels(8)) 400 problem = self.run_pixel("ps_bitmask_perm", 0, out, data=self.bitmask_pixels(8))