buffered TLAS

This commit is contained in:
Jorijn van der Graaf 2026-01-29 19:46:53 +01:00
commit 642cef78b1
4 changed files with 23 additions and 64 deletions

View file

@ -3,6 +3,7 @@
import Crafter.Graphics;
using namespace Crafter;
import std;
import Crafter.Event;
typedef VulkanShader<"raygen.spv", "main", VK_SHADER_STAGE_RAYGEN_BIT_KHR, 2, {{{VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, 0}, {VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1}}}> Raygenspv;
typedef VulkanShader<"closesthit.spv", "main", VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR, 0, {{}}> Closesthitspv;
@ -39,7 +40,8 @@ int main() {
std::array<std::uint32_t, 3> index {{2,1,0}};
triangleMesh.Build(verts, index, cmd);
RenderingElement3DVulkan::elements.emplace_back(triangleMesh);
RenderingElement3DVulkan::BuildTLAS(cmd);
RenderingElement3DVulkan::tlases.resize(1);
RenderingElement3DVulkan::BuildTLAS(cmd, 0);
VkDescriptorImageInfo imageInfo = {
.imageView = window.imageViews[0],
@ -49,7 +51,7 @@ int main() {
VkWriteDescriptorSetAccelerationStructureKHR writeDescriptorSetAccelerationStructure {
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR,
.accelerationStructureCount = 1,
.pAccelerationStructures = &RenderingElement3DVulkan::accelerationStructure
.pAccelerationStructures = &RenderingElement3DVulkan::tlases[0].accelerationStructure
};
VkWriteDescriptorSet write[2] = {
@ -84,7 +86,7 @@ int main() {
window.SetPipelineRT<Raygenspv, Closesthitspv, Misspv, Raygenspv, Closesthitspv, Misspv>();
window.descriptorsRt = pool.sets;
window.Render();
window.StartSync();
}