feat(webgpu-rt): add intersection stage, procedural hit group, AABB BLAS API

Extends the cross-backend RT type surface for procedural geometry +
any-hit on the WebGPU path:

- RTShaderGroupType::ProceduralHitGroup + RTShaderGroup::intersectionShader
  (mirror VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR).
- WebGPURTStage::Intersection for AABB intersection shaders.
- Mesh::BuildProcedural(span<RTAabb>, opaque) — the WebGPU analog of a
  VK_GEOMETRY_TYPE_AABBS_KHR geometry.
- wgpuRegisterMeshBLAS gains geomType / opaqueFlag / primCount.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
catbot 2026-06-02 22:09:14 +00:00
commit 321fe596a7
4 changed files with 66 additions and 15 deletions

View file

@ -167,6 +167,12 @@ namespace Crafter::WebGPU {
// that gets appended to a global attribs heap and exposed to RT
// closest-hit shaders as `vertexAttribs : array<u32>` at
// @group(1) @binding(7). Pass (nullptr, 0) for positions-only meshes.
// `geomType` selects the primitive kind: 0 = triangles (the
// verticesPtr/indicesPtr streams), 1 = AABBs (VK_GEOMETRY_TYPE_AABBS) —
// then verticesPtr holds 2 vec3 per primitive [min, max], indexCount is
// 0, and an intersection shader supplies the hit. `opaqueFlag` is the
// geometry's opaque bit (0 lets any-hit run). `primCount` is the
// triangle / AABB primitive count.
__attribute__((import_module("env"), import_name("wgpuRegisterMeshBLAS")))
extern "C" std::uint32_t wgpuRegisterMeshBLAS(
float minX, float minY, float minZ,
@ -175,7 +181,8 @@ namespace Crafter::WebGPU {
const void* indicesPtr, std::int32_t indexCount,
const void* bvhNodesPtr, std::int32_t bvhNodeCount,
const void* primRemapPtr, std::int32_t primRemapCount,
const void* attribsPtr, std::int32_t attribsByteCount);
const void* attribsPtr, std::int32_t attribsByteCount,
std::int32_t geomType, std::int32_t opaqueFlag, std::int32_t primCount);
// RT pipeline build. The library composes WGSL by concatenating the
// traversal library, generated hit-group switches, and the user-