Merge pull request 'feat(vulkan-rt): Mesh::BuildProcedural — AABB (procedural) BLAS build path (#33)' (#35) from claude/issue-33 into master
This commit is contained in:
commit
27bfb36e60
10 changed files with 445 additions and 44 deletions
|
|
@ -31,12 +31,27 @@ import Crafter.Asset;
|
|||
import :VulkanBuffer;
|
||||
|
||||
export namespace Crafter {
|
||||
// One procedural primitive's axis-aligned bounding box, in object
|
||||
// space. Layout-compatible with VkAabbPositionsKHR (24-byte stride),
|
||||
// so a span of these uploads directly as a
|
||||
// VK_GEOMETRY_TYPE_AABBS_KHR build input. Mirrors the DOM-side
|
||||
// definition below so portable user code compiles unchanged.
|
||||
struct RTAabb {
|
||||
float min[3];
|
||||
float max[3];
|
||||
};
|
||||
static_assert(sizeof(RTAabb) == sizeof(VkAabbPositionsKHR));
|
||||
|
||||
class Mesh {
|
||||
public:
|
||||
VulkanBuffer<char, false> scratchBuffer;
|
||||
VulkanBuffer<char, false> blasBuffer;
|
||||
VulkanBuffer<Vector<float, 3, 3>, true> vertexBuffer;
|
||||
VulkanBuffer<std::uint32_t, true> indexBuffer;
|
||||
// AABB build input for the procedural path (BuildProcedural).
|
||||
// Lifetime contract matches vertexBuffer/indexBuffer: must stay
|
||||
// alive until the build submitted on `cmd` completes.
|
||||
VulkanBuffer<RTAabb, true> aabbBuffer;
|
||||
// Lives until the cmd buffer issued by the compressed Build path
|
||||
// completes execution. Kept as a member so the recorded
|
||||
// vkCmdDecompressMemoryEXT references valid memory until the queue
|
||||
|
|
@ -57,6 +72,18 @@ export namespace Crafter {
|
|||
// Region 2 (data) is not consumed here — the caller decompresses it
|
||||
// into their own buffer if needed (or uses Compression::DecompressCPU).
|
||||
void Build(const ::Crafter::CompressedMeshAsset& asset, VkCommandBuffer cmd);
|
||||
// Build an AABB (procedural) BLAS from a list of object-space
|
||||
// boxes (VK_GEOMETRY_TYPE_AABBS_KHR). The hit group bound to
|
||||
// instances of this mesh must be a
|
||||
// VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR group
|
||||
// carrying an intersection shader; that shader is invoked for
|
||||
// each box the ray enters and reports the surface hit via
|
||||
// reportIntersectionEXT. `opaque` maps to
|
||||
// VK_GEOMETRY_OPAQUE_BIT_KHR: pass false (the WebGPU-path
|
||||
// default) to let any-hit shaders run. Same scratch/lifetime
|
||||
// handling as the triangle Build; instances reference blasAddr
|
||||
// exactly like a triangle BLAS.
|
||||
void BuildProcedural(std::span<const RTAabb> aabbs, bool opaque, VkCommandBuffer cmd);
|
||||
};
|
||||
}
|
||||
#endif // !CRAFTER_GRAPHICS_WINDOW_DOM
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue