GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
src/vk/rt_query.wgsl (858B)
1 // rt_query.wgsl — tier-2 intersect_scene: hardware ray queries against a
2 // driver-built TLAS (VK_KHR_ray_query), engaging RT cores where present.
3 // Concatenated after rt_common.wgsl at pipeline creation; compiled with
4 // naga's RAY_QUERY capability to SPIR-V 1.4.
5
6 @group(0) @binding(1) var tlas: acceleration_structure;
7
8 fn intersect_scene(ro: vec3<f32>, rd: vec3<f32>) -> HitInfo {
9 var rq: ray_query;
10 // Geometry is marked opaque at BLAS build, no cull flags: two-sided hits
11 // like the BVH tier. tmin matches the tier-1 epsilon.
12 rayQueryInitialize(&rq, tlas, RayDesc(0x0u, 0xFFu, 1e-4, 1e30, ro, rd));
13 while (rayQueryProceed(&rq)) {}
14 let hit = rayQueryGetCommittedIntersection(&rq);
15 if hit.kind == RAY_QUERY_INTERSECTION_TRIANGLE {
16 return HitInfo(hit.t, hit.primitive_index);
17 }
18 return HitInfo(1e30, 0u);
19 }