Create and replace a new acceleration structure and buffer based on the size retrieved by the Query. We have to wait until all BLAS are built, to make a copy in the more suitable memory space. This is the reason why we used m_cmdPool.submitAndWait(cmdBuf) before calling this function.
Get the compacted size result back.
Get Query Pool results.
Creating a compact version of the AS.
Copy the original BLAS to a compact version.
Get the compacted size result back.
Get Query Pool results.
Creating a compact version of the AS.
Copy the original BLAS to a compact version.
564 {
566
567 uint32_t queryCtn = 0;
568
572 std::vector<VkDeviceSize> compactSizes(static_cast<uint32_t>(indices.size()));
573
577 queryPool->QueryResults(compactSizes.data());
578
579 for (const auto idx : indices)
580 {
581 buildAs[idx].cleanupAS = *buildAs[idx].as;
582 buildAs[idx].sizeInfo.accelerationStructureSize = compactSizes[queryCtn++];
583
587 VkAccelerationStructureCreateInfoKHR asCreateInfo{};
588 asCreateInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CREATE_INFO_KHR;
589 asCreateInfo.size = buildAs[idx].sizeInfo.accelerationStructureSize;
590 asCreateInfo.type = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR;
592
596 VkCopyAccelerationStructureInfoKHR copyInfo{};
597 copyInfo.sType = VK_STRUCTURE_TYPE_COPY_ACCELERATION_STRUCTURE_INFO_KHR;
598 copyInfo.src = buildAs[idx].buildInfo.dstAccelerationStructure;
599 copyInfo.dst = buildAs[idx].as->accel->Get();
600 copyInfo.mode = VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR;
601
603 }
604 }
#define SPICES_PROFILE_ZONE
VulkanState & m_VulkanState
The global VulkanState Referenced from VulkanRenderBackend.
AccelKHR CreateAcceleration(VkAccelerationStructureCreateInfoKHR &accel) const
Create Acceleration.