Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
foray::as::GeometryMetaBuffer Class Reference

Device local buffer maintaining GeometryMeta structs for all primitives/geometries for multiple BLAS. More...

#include <foray_geometrymetabuffer.hpp>

Public Member Functions

const std::unordered_map< const Blas *, uint32_t > & CreateOrUpdate (core::Context *context, const std::unordered_set< const Blas * > &entries)
 (re)creates the meta buffer
 
VkDescriptorBufferInfo GetVkDescriptorInfo () const
 

Protected Attributes

core::ContextmContext = nullptr
 
std::unordered_map< const Blas *, uint32_t > mBufferOffsets
 Maps BLAS to their offsets into the BlasMetaBuffers GeometryMeta array.
 
core::ManagedBuffer mBuffer
 The device local buffer holding the array.
 

Detailed Description

Device local buffer maintaining GeometryMeta structs for all primitives/geometries for multiple BLAS.

DATA LAYOUT / USAGE

initialize with a set of BLAS. BLAS are assigned sections in the buffer consecutively:

| BLAS #0 | BLAS #1 | BLAS #2 | // Unique BLAS

The amount of space assigned per BLAS is GeometryCount * sizeof(GeometryMeta)

| BLAS #0 | BLAS #1 | BLAS #2 | // Unique BLAS
| G0 | G1 | G2 | G3 | G0 | G1 | G2 | G0 | G1 | G2 | G3 | G4 | G5 | // Geometry Meta structs (1x per Geometry per BLAS)

The buffer maintains the offsets into this buffer for each BLAS

| BLAS #0 | BLAS #1 | BLAS #2 | // Unique BLAS
| G0 | G1 | G2 | G3 | G0 | G1 | G2 | G0 | G1 | G2 | G3 | G4 | G5 | // Geometry Meta structs (1x per Geometry per BLAS)
^ ^ ^
| | |
0 4 7 // Offset per BLAS into the Geometry Meta Array

These offsets are the return value of GeometryMetaBuffer::CreateOrUpdate and can be later retrieved via GeometryMetaBuffer::GetBufferOffsets()

Intended use for these offsets is to set them as VkAccelerationStructureInstanceKHR::instanceCustomIndex in BLAS instances installed into a TLAS. In rt shaders the correct meta struct can be accessed by geoMetaindex = gl_InstanceCustomIndexEXT + gl_GeometryIndexEXT;

gl_InstanceCustomIndexEXT: The custom index returned by the GeometryMetaBuffer and set as part of the BLAS instance struct in the TLAS gl_GeometryIndexEXT: The index of the geometry within the current BLAS

Member Function Documentation

◆ CreateOrUpdate()

const std::unordered_map< const Blas *, uint32_t > & foray::as::GeometryMetaBuffer::CreateOrUpdate ( core::Context context,
const std::unordered_set< const Blas * > &  entries 
)

(re)creates the meta buffer

◆ GetVkDescriptorInfo()

VkDescriptorBufferInfo foray::as::GeometryMetaBuffer::GetVkDescriptorInfo ( ) const
inline

Member Data Documentation

◆ mBuffer

core::ManagedBuffer foray::as::GeometryMetaBuffer::mBuffer
protected

The device local buffer holding the array.

◆ mBufferOffsets

std::unordered_map<const Blas*, uint32_t> foray::as::GeometryMetaBuffer::mBufferOffsets
protected

Maps BLAS to their offsets into the BlasMetaBuffers GeometryMeta array.

◆ mContext

core::Context* foray::as::GeometryMetaBuffer::mContext = nullptr
protected

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