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

Shader Binding Table base class, providing functions to manage custom generic shader group data and SBT building, aswell as buffer management. More...

#include <foray_basesbt.hpp>

Inheritance diagram for foray::rtpipe::ShaderBindingTableBase:
foray::rtpipe::GeneralShaderBindingTable foray::rtpipe::HitShaderBindingTable

Classes

struct  VectorRange
 

Public Member Functions

 ShaderBindingTableBase (VkDeviceSize entryDataSize=0)
 
virtual void Build (core::Context *context, const VkPhysicalDeviceRayTracingPipelinePropertiesKHR &pipelineProperties, const std::vector< const uint8_t * > &handles)
 Rebuilds the SBT buffer according to the pipeline properties and matching indices.
 
std::vector< uint8_t > & GroupDataAt (GroupIndex groupIndex)
 Access the custom data entry for a group.
 
const std::vector< uint8_t > & GroupDataAt (GroupIndex groupIndex) const
 Access the custom data entry for a group.
 
template<typename TData >
TData * GroupDataAt (GroupIndex groupIndex)
 Access the custom data entry for a group. May return nullptr!
 
template<typename TData >
const TData * GroupDataAt (GroupIndex groupIndex) const
 Access the custom data entry for a group. May return nullptr!
 
void SetData (GroupIndex groupIndex, const void *data)
 Set the custom data entry for a group.
 
template<typename TData >
void SetData (GroupIndex groupIndex, const TData &data)
 Set the custom data entry for a group.
 
virtual ShaderBindingTableBaseSetEntryDataSize (VkDeviceSize newSize)
 Set the custom entry data size. Any non-zero custom data is resized according to std::vector<uint8_t>::resize(newSize)!
 
virtual void WriteToShaderCollection (RtShaderCollection &collection) const =0
 For any shader group defined, register it with the collection.
 
virtual VectorRange WriteToShaderGroupCiVector (std::vector< VkRayTracingShaderGroupCreateInfoKHR > &groupCis, const RtShaderCollection &shaderCollection) const =0
 Write the shader groups to groupCis vector.
 
virtual void Destroy ()
 
virtual ~ShaderBindingTableBase ()
 

Protected Member Functions

virtual size_t GetGroupArrayCount () const =0
 
void ArrayResized (size_t newSize)
 

Protected Attributes

core::ManagedBuffer mBuffer
 
VkStridedDeviceAddressRegionKHR mAddressRegion {}
 
VkDeviceSize mEntryDataSize {}
 
std::vector< std::vector< uint8_t > > mGroupData {}
 

Detailed Description

Shader Binding Table base class, providing functions to manage custom generic shader group data and SBT building, aswell as buffer management.

A shader binding table stores entries in the following layout

| Entry0 | Entry1 | ...
|-----------------------------|-----------------------------|-------
| GroupHandle | Custom Data | GroupHandle | Custom Data | ...

Where the GroupHandle is a vulkan driver specific memory block (all currently known drivers use 32 bit values here), as defined by VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleSize It is essentially a reference to a ShaderGroup as defined in the CreateInfo passed to 'createRayTracingPipelinesKHR'

Custom Data is an optional memory area of user defined size. It allows pairing shaders with different configuration parameters.

ShaderBindingTable classes Usage:

  1. If you use custom data, best use SetEntryDataSize(...) first
  2. Define all shader groups. Make sure that all indices from 0 to the highest used are defined!
  3. If you didn't already when defining the shader groups, set custom data now
  4. Use Build(...) to build the SBT. If you use the RtPipeline class, use RtPipeline::Build(...) instead!

Constructor & Destructor Documentation

◆ ShaderBindingTableBase()

foray::rtpipe::ShaderBindingTableBase::ShaderBindingTableBase ( VkDeviceSize  entryDataSize = 0)
explicit

◆ ~ShaderBindingTableBase()

virtual foray::rtpipe::ShaderBindingTableBase::~ShaderBindingTableBase ( )
inlinevirtual

Member Function Documentation

◆ ArrayResized()

void foray::rtpipe::ShaderBindingTableBase::ArrayResized ( size_t  newSize)
protected

◆ Build()

virtual void foray::rtpipe::ShaderBindingTableBase::Build ( core::Context context,
const VkPhysicalDeviceRayTracingPipelinePropertiesKHR &  pipelineProperties,
const std::vector< const uint8_t * > &  handles 
)
virtual

Rebuilds the SBT buffer according to the pipeline properties and matching indices.

Parameters
contextContext
pipelinePropertiesPipeline Properties for alignment information
handlesVector of pointers to handles. Indices in this vector have to match shadergroup indices of the SBT. The caller must guarantee that any memory area pointed to is of pipelineProperties.shaderGroupHandleSize size (bytes)

◆ Destroy()

virtual void foray::rtpipe::ShaderBindingTableBase::Destroy ( )
virtual

◆ GetGroupArrayCount()

virtual size_t foray::rtpipe::ShaderBindingTableBase::GetGroupArrayCount ( ) const
protectedpure virtual

◆ GroupDataAt() [1/4]

std::vector< uint8_t > & foray::rtpipe::ShaderBindingTableBase::GroupDataAt ( GroupIndex  groupIndex)

Access the custom data entry for a group.

◆ GroupDataAt() [2/4]

template<typename TData >
TData * foray::rtpipe::ShaderBindingTableBase::GroupDataAt ( GroupIndex  groupIndex)
inline

Access the custom data entry for a group. May return nullptr!

◆ GroupDataAt() [3/4]

const std::vector< uint8_t > & foray::rtpipe::ShaderBindingTableBase::GroupDataAt ( GroupIndex  groupIndex) const

Access the custom data entry for a group.

◆ GroupDataAt() [4/4]

template<typename TData >
const TData * foray::rtpipe::ShaderBindingTableBase::GroupDataAt ( GroupIndex  groupIndex) const
inline

Access the custom data entry for a group. May return nullptr!

◆ SetData() [1/2]

template<typename TData >
void foray::rtpipe::ShaderBindingTableBase::SetData ( GroupIndex  groupIndex,
const TData &  data 
)
inline

Set the custom data entry for a group.

◆ SetData() [2/2]

void foray::rtpipe::ShaderBindingTableBase::SetData ( GroupIndex  groupIndex,
const void *  data 
)

Set the custom data entry for a group.

◆ SetEntryDataSize()

virtual ShaderBindingTableBase & foray::rtpipe::ShaderBindingTableBase::SetEntryDataSize ( VkDeviceSize  newSize)
virtual

Set the custom entry data size. Any non-zero custom data is resized according to std::vector<uint8_t>::resize(newSize)!

◆ WriteToShaderCollection()

virtual void foray::rtpipe::ShaderBindingTableBase::WriteToShaderCollection ( RtShaderCollection collection) const
pure virtual

For any shader group defined, register it with the collection.

Implemented in foray::rtpipe::GeneralShaderBindingTable, and foray::rtpipe::HitShaderBindingTable.

◆ WriteToShaderGroupCiVector()

virtual VectorRange foray::rtpipe::ShaderBindingTableBase::WriteToShaderGroupCiVector ( std::vector< VkRayTracingShaderGroupCreateInfoKHR > &  groupCis,
const RtShaderCollection shaderCollection 
) const
pure virtual

Write the shader groups to groupCis vector.

Parameters
shaderCollectionCollection used to look up the index of shaders
Returns
the range in the groupCis vector used by this Sbts' ShaderGroups

Implemented in foray::rtpipe::GeneralShaderBindingTable, and foray::rtpipe::HitShaderBindingTable.

Member Data Documentation

◆ mAddressRegion

VkStridedDeviceAddressRegionKHR foray::rtpipe::ShaderBindingTableBase::mAddressRegion {}
protected

◆ mBuffer

core::ManagedBuffer foray::rtpipe::ShaderBindingTableBase::mBuffer
protected

◆ mEntryDataSize

VkDeviceSize foray::rtpipe::ShaderBindingTableBase::mEntryDataSize {}
protected

◆ mGroupData

std::vector<std::vector<uint8_t> > foray::rtpipe::ShaderBindingTableBase::mGroupData {}
protected

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