feat(vulkan-rt): Mesh::BuildProcedural — AABB (procedural) BLAS build path (#33) #35

Merged
catbot merged 2 commits from claude/issue-33 into master 2026-06-13 02:18:31 +02:00
Member

Resolves #33

Adds the one missing piece for procedural geometry on the native Vulkan backend: an AABB BLAS build path, API-symmetric with the WebGPU Mesh::BuildProcedural.

Changes

  • Mesh::BuildProcedural(std::span<const RTAabb>, bool opaque, VkCommandBuffer) (Vulkan): uploads the boxes as a 24-byte-stride VkAabbPositionsKHR-compatible device buffer (ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY | SHADER_DEVICE_ADDRESS) and builds the BLAS from one VkAccelerationStructureGeometryAabbsDataKHR geometry (VK_GEOMETRY_TYPE_AABBS_KHR). opaque maps to VK_GEOMETRY_OPAQUE_BIT_KHR (false = any-hit runs, matching the WebGPU path's default semantics).
  • RTAabb now also defined on the native branch of the :Mesh partition, static_assert'd layout-compatible with VkAabbPositionsKHR — portable user code compiles unchanged on both backends.
  • The BLAS sizing/create/build tail of the triangle path is factored into a geometry-type-agnostic RecordBLASBuildFromGeometry helper shared by both paths; same scratch/lifetime handling, no TLAS/instance changes.

Regression test: RTVolume ported to native Vulkan

The WebGPU procedural example now runs on both backends from the same scene code: a 3×3×3 grid of unit-box AABBs bound to a PROCEDURAL_HIT_GROUP_KHR group — intersection.glsl (reportIntersectionEXT) marches each box into a radius-1 sphere, anyhit.glsl punches the spherical-checkerboard cut-out (visible proof the non-opaque path invokes any-hit), closesthit.glsl shades per-instance tints. Runs clean under core + GPU-assisted validation.

crafter-build test (PushConstantRewrite) · native + wasm32-wasip1 builds

Screenshots

RTVolume on native Vulkan — procedural spheres with any-hit checkerboard cut-outs

Resolves #33 Adds the one missing piece for procedural geometry on the native Vulkan backend: an AABB BLAS build path, API-symmetric with the WebGPU `Mesh::BuildProcedural`. ## Changes - **`Mesh::BuildProcedural(std::span<const RTAabb>, bool opaque, VkCommandBuffer)`** (Vulkan): uploads the boxes as a 24-byte-stride `VkAabbPositionsKHR`-compatible device buffer (`ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY | SHADER_DEVICE_ADDRESS`) and builds the BLAS from one `VkAccelerationStructureGeometryAabbsDataKHR` geometry (`VK_GEOMETRY_TYPE_AABBS_KHR`). `opaque` maps to `VK_GEOMETRY_OPAQUE_BIT_KHR` (false = any-hit runs, matching the WebGPU path's default semantics). - **`RTAabb`** now also defined on the native branch of the `:Mesh` partition, `static_assert`'d layout-compatible with `VkAabbPositionsKHR` — portable user code compiles unchanged on both backends. - The BLAS sizing/create/build tail of the triangle path is factored into a geometry-type-agnostic `RecordBLASBuildFromGeometry` helper shared by both paths; same scratch/lifetime handling, no TLAS/instance changes. ## Regression test: RTVolume ported to native Vulkan The WebGPU procedural example now runs on both backends from the same scene code: a 3×3×3 grid of unit-box AABBs bound to a `PROCEDURAL_HIT_GROUP_KHR` group — `intersection.glsl` (`reportIntersectionEXT`) marches each box into a radius-1 sphere, `anyhit.glsl` punches the spherical-checkerboard cut-out (visible proof the non-opaque path invokes any-hit), `closesthit.glsl` shades per-instance tints. Runs clean under core + GPU-assisted validation. `crafter-build test` ✅ (PushConstantRewrite) · native + wasm32-wasip1 builds ✅ ## Screenshots ![RTVolume on native Vulkan — procedural spheres with any-hit checkerboard cut-outs](https://forgejo.catcrafts.net/attachments/a808dc8f-c735-4238-9041-270a34a7590d)
230 KiB
Adds the native counterpart of the WebGPU Mesh::BuildProcedural: uploads
the boxes as a 24-byte-stride VkAabbPositionsKHR-compatible device buffer
(AS-build-input read-only + device address) and builds the BLAS from one
VK_GEOMETRY_TYPE_AABBS_KHR geometry. opaque maps to
VK_GEOMETRY_OPAQUE_BIT_KHR, default-false semantics matching the WebGPU
path so any-hit shaders run. The BLAS sizing/create/build tail is factored
into a geometry-type-agnostic helper shared with the triangle path; no
TLAS/instance changes needed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Regression test for the procedural BLAS path: the same 3x3x3 grid of
unit-box AABBs runs through a PROCEDURAL_HIT_GROUP_KHR group whose GLSL
intersection shader (reportIntersectionEXT) turns each box into a
radius-1 sphere, the any-hit shader punches the spherical-checkerboard
cut-out (visible proof non-opaque geometry runs any-hit), and the
closest-hit shades per-instance tints — the WebGPU example behavior
reproduced natively. Fixed camera in raygen.glsl; the WebGPU/DOM path is
unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
catbot merged commit 27bfb36e60 into master 2026-06-13 02:18:31 +02:00
catbot deleted branch claude/issue-33 2026-06-13 02:18:31 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Catcrafts/Crafter.Graphics!35
No description provided.