Vulkan: Mesh::BuildProcedural — AABB (procedural) BLAS build path to match WebGPU #33
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics#33
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
3DForts grass (3DForts/3DForts#161) is switching from any-hit alpha cards to per-patch procedural AABBs with intersection-shader-marched volumetric blades. The WebGPU backend already ships everything this needs; the native Vulkan backend is missing exactly one piece: an AABB BLAS build path.
Current state
RTShaderGroupType::ProceduralHitGroupexists and mirrorsVK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, withRTShaderGroup::intersectionShaderdocumented as "only consulted for ProceduralHitGroup" (interfaces/Crafter.Graphics-RT.cppm).VkRayTracingShaderGroupCreateInfoKHRspans toPipelineRT::Init(interfaces/Crafter.Graphics-PipelineRTVulkan.cppm:57), so a procedural group + intersection shader stage already flows through today.Mesh::BuildProcedural(std::span<const RTAabb>, bool opaque, cmd)(interfaces/Crafter.Graphics-Mesh.cppm:143-146, impl inCrafter.Graphics-Mesh-WebGPU.cpp), theWebGPURTStage::Intersectionstage with contractfn(ray: RayDesc, aabbMin: vec3<f32>, aabbMax: vec3<f32>, primitiveId: u32) -> IntersectionResult(interfaces/Crafter.Graphics-ShaderBindingTableWebGPU.cppm:26-33), and the traversal'sgeomType==1AABB-leaf branch inadditional/dom-webgpu.js(~1830).Mesh::BuildhardcodesVK_GEOMETRY_TYPE_TRIANGLES_KHR(implementations/Crafter.Graphics-Mesh.cpp:62) and there is no AABB overload — a procedural BLAS cannot be built natively.Requested
A Vulkan
Mesh::BuildProcedural, API-symmetric with the WebGPU declaration:VkAabbPositionsKHR-compatible —RTAabbalready matches) device buffer withVK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR | SHADER_DEVICE_ADDRESS.VkAccelerationStructureGeometryAabbsDataKHRgeometry (VK_GEOMETRY_TYPE_AABBS_KHR);opaquemaps toVK_GEOMETRY_OPAQUE_BIT_KHR(default false so any-hit/non-opaque semantics match the WebGPU path).VkAccelerationStructureInstanceKHRis geometry-type-agnostic).Acceptance
An instance of a procedural mesh bound to a
PROCEDURAL_HIT_GROUP_KHRgroup invokes its GLSL intersection shader (reportIntersectionEXT+hitAttributeEXT) once per entered box, and the committed hit shades through the group's closest-hit — i.e. the WebGPU procedural example behavior reproduced natively. Porting that example to the Vulkan backend would make a good regression test.jorijnvdgraaf referenced this issue2026-06-16 15:31:40 +02:00