SpiecsEngine
 
Loading...
Searching...
No Matches
Spices::VulkanRayTracing Class Reference

Wrapper of Scene RayTracing (KHR/VK) Features and Data. More...

#include <VulkanRayTracing.h>

Inheritance diagram for Spices::VulkanRayTracing:
Spices::VulkanObject

Classes

struct  BlasInput
 Blas Input data. More...
 
struct  BuildAccelerationStructure
 AccelerationStructure Build Info and result. More...
 

Public Member Functions

 VulkanRayTracing (VulkanState &vulkanState)
 Constructor Function.
 
virtual ~VulkanRayTracing () override=default
 Destructor Function.
 
const VkAccelerationStructureKHR GetAccelerationStructure () const
 Get AccelerationStructure.
 
void BuildBLAS (const std::vector< BlasInput > &input, VkBuildAccelerationStructureFlagsKHR flags=VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR)
 Create all the BLAS from the vector of BlasInput. There will be one BLAS per input-vector entry. There will be as many BLAS as input.size(). The resulting BLAS (along with the inputs used to build) are stored in m_blas, and can be referenced by index. if flag has the 'Compact' flag, the BLAS will be compacted.
 
void UpdateBlas (uint32_t blasIdx, const BlasInput &blas, VkBuildAccelerationStructureFlagsKHR flags) const
 Update part of BLAS.
 
void BuildTLAS (const std::vector< VkAccelerationStructureInstanceKHR > &instances, VkBuildAccelerationStructureFlagsKHR flags=VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR, bool update=false)
 Creating the top-level acceleration structure from the vector of Instance. The resulting TLAS will be stored in m_tlas. update is to rebuild the Tlas with updated matrices.
 
template<class T >
void BuildTLAS (const std::vector< T > &instances, VkBuildAccelerationStructureFlagsKHR flags=VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR, bool update=false, bool motion=false)
 Build TLAS from an array of VkAccelerationStructureInstanceKHR. The resulting TLAS will be stored in m_tlas. update is to rebuild the Tlas with updated matrices, flag must have the 'allow_update'.
 
void CmdCreateTLAS (VkCommandBuffer cmdBuf, uint32_t countInstance, VkDeviceAddress instBufferAddr, std::unique_ptr< VulkanBuffer > &scratchBuffer, VkBuildAccelerationStructureFlagsKHR flags, bool update, bool motion)
 Low level of Tlas creation. Creating the TLAS, called by buildTlas.
 
void SetHitGroups (std::shared_ptr< std::unordered_map< std::string, uint32_t > > groups)
 Set Scene hit groups.
 
std::shared_ptr< std::unordered_map< std::string, uint32_t > > GetHitGroups ()
 Get Scene hit groups.
 
void CreateRTShaderBindingTable (uint32_t rgenCount, uint32_t missCount, VkPipeline pipeline)
 Create Shader Binding Table.
 
VkStridedDeviceAddressRegionKHR & GetRgenRegion ()
 Get SBT RgenRegion.
 
VkStridedDeviceAddressRegionKHR & GetMissRegion ()
 Get SBT MissRegion.
 
VkStridedDeviceAddressRegionKHR & GetHitRegion ()
 Get SBT HitRegion.
 
VkStridedDeviceAddressRegionKHR & GetCallRegion ()
 Get SBT CallRegion.
 
Attribute< uint64_t > & GetMeshDesc ()
 Get Mesh Description.
 

Protected Attributes

VulkanStatem_VulkanState
 The global VulkanState Referenced from VulkanRenderBackend.
 

Private Member Functions

void CmdCreateBLAS (VkCommandBuffer cmdBuf, const std::vector< uint32_t > &indices, std::vector< BuildAccelerationStructure > &buildAs, VkDeviceAddress scratchAddress, std::shared_ptr< VulkanQueryPool > queryPool) const
 Creating the bottom level acceleration structure for all indices of buildAs vector. The array of BuildAccelerationStructure was created in buildBlas and the vector of indices limits the number of BLAS to create at once. This limits the amount of memory needed when compacting the BLAS.
 
void CmdCompactBLAS (VkCommandBuffer cmdBuf, const std::vector< uint32_t > &indices, std::vector< BuildAccelerationStructure > &buildAs, std::shared_ptr< VulkanQueryPool > queryPool) const
 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.
 
bool hasFlag (VkFlags item, VkFlags flag)
 Is item in flags.
 
AccelKHR CreateAcceleration (VkAccelerationStructureCreateInfoKHR &accel) const
 Create Acceleration.
 

Private Attributes

AccelKHR m_tlas
 Top-level acceleration structure.
 
std::shared_ptr< std::unordered_map< std::string, uint32_t > > m_HitGroups
 Scene ray hit shader groups.
 
std::unique_ptr< VulkanBufferm_RTSBTBuffer
 Shader Binding Table Buffer.
 
VkStridedDeviceAddressRegionKHR m_RgenRegion {}
 Ray Generation Region.
 
VkStridedDeviceAddressRegionKHR m_MissRegion {}
 Ray Missing Region.
 
VkStridedDeviceAddressRegionKHR m_HitRegion {}
 Ray Hit Region.
 
VkStridedDeviceAddressRegionKHR m_CallRegion {}
 Ray Callable Region.
 
Attribute< uint64_t > m_MeshDesc
 Scene Mesh Description Buffer.
 

Detailed Description

Wrapper of Scene RayTracing (KHR/VK) Features and Data.

Definition at line 30 of file VulkanRayTracing.h.


The documentation for this class was generated from the following files: