upleb.uk

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

summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJolymmiles <75259437+Jolymmiles@users.noreply.github.com>2026-11-22 20:55:49 +0400
committerJolymmiles <75259437+Jolymmiles@users.noreply.github.com>2026-11-22 22:09:22 +0400
commitad88c19e971f3e8c5d54d0c9d0ea4c8ec1587330 (patch)
tree1939250f093a608b8ae65858d76824a5a21072b9 /docs
parentec8ec4c9a46c6623f1a9c125afd3566da97f1e0c (diff)
xdxr_build: radix scan writes offsets apart from the counts, correct on MoltenVK 1.4.2
The scan read each digit count and stored its prefix sum over it. MoltenVK 1.4.2's SPIRV-Cross (6c09849f; MoltenVK main pins aa217aeb, also affected) moves a load through a pointer bitcast from a uvec2 past a later store to the same address, so the MSL read back the sum it had just written. The radix path (more than 1,024 elements) then lost and duplicated elements: blas_three_sort_tiles and blas_refit_in_place failed xdxr_build_check in 10 runs out of 10. SPIRV-Cross 38abe362 fixes it upstream. The prefix sums now go to their own scratch array (XdxrLayout::scratch grows by 64 bytes per tile), so no invocation stores to a word whose loaded value it still uses. xdxr_build.inc regenerated with glslc (shaderc 2026.4) --target-env=vulkan1.2 -O -mfmt=c. Tested on an Apple M3 Max, macOS 27.3: xdxr_build_check passes 10 runs out of 10 on Homebrew MoltenVK 1.4.2 (0/10 before), MoltenVK 5189f8de with SPIRV-Cross 57e4efcc, KosmicKrisp and llvmpipe. The full native ctest passes 36/36 on each driver, with the same two skips as before. AI-assisted.
Diffstat (limited to 'docs')
-rw-r--r--docs/bvh.md13
1 files changed, 13 insertions, 0 deletions
diff --git a/docs/bvh.md b/docs/bvh.md
index 313d3f3a2..395cf925c 100644
--- a/docs/bvh.md
+++ b/docs/bvh.md
@@ -439,6 +439,19 @@ the destination buffer:
439 instance's `ParentNode`; 439 instance's `ParentNode`;
4404. the header. 4404. the header.
441 441
442The radix sort's scan writes the prefix sums of the digit counts to their own scratch array, not over the counts.
443No invocation of the builder stores to a word and then uses a value it loaded from that word earlier. SPIRV-Cross
444`6c09849f`, in MoltenVK 1.4.2, breaks that pattern for a pointer made by `OpBitcast` from a `uvec2`
445(`GL_EXT_buffer_reference_uvec2`): it moves the load to where the value is used, after the store, and the load
446returns the new value. MoltenVK `main` at `5189f8de` pins SPIRV-Cross `aa217aeb`, which has the same bug.
447SPIRV-Cross [`38abe362`](https://github.com/KhronosGroup/SPIRV-Cross/commit/38abe362c57311a77808b7ec4d1d0d9ceb8d9370)
448fixes it. With the old in-place scan, the radix path (more than 1,024 elements) lost and duplicated elements on
449MoltenVK: `xdxr_build_check` found about 130 of 200 rays wrong in `blas_three_sort_tiles` and 210 of 300 in
450`blas_refit_in_place`, which refits a radix-sorted tree. Measured on an Apple M3 Max, the separate arrays pass
45110 runs out of 10 on Homebrew MoltenVK 1.4.2, on MoltenVK `5189f8de` built with SPIRV-Cross `57e4efcc`, on
452KosmicKrisp and on llvmpipe. A pointer from `OpConvertUToPtr`, which the translator uses, kept its load before the
453store in the same test.
454
442The tree's shape depends only on the element count. `XdxrLayout` therefore computes the result and scratch sizes 455The tree's shape depends only on the element count. `XdxrLayout` therefore computes the result and scratch sizes
443exactly when the build is recorded, and the same numbers can answer `GetRaytracingAccelerationStructurePrebuildInfo`. 456exactly when the build is recorded, and the same numbers can answer `GetRaytracingAccelerationStructurePrebuildInfo`.
444A triangle with a NaN vertex gets an empty box (D3D12 treats it as inactive). So do an instance with mask 0, one with 457A triangle with a NaN vertex gets an empty box (D3D12 treats it as inactive). So do an instance with mask 0, one with