Diligent Engine
 
Loading...
Searching...
No Matches
Diligent::BuildTLASAttribs Struct Reference

This structure is used by IDeviceContext::BuildTLAS(). More...

#include <DeviceContext.h>

Public Attributes

ITopLevelASpTLAS = nullptr
 Target top-level AS.
 
RESOURCE_STATE_TRANSITION_MODE TLASTransitionMode = RESOURCE_STATE_TRANSITION_MODE_NONE
 Top-level AS state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
 
RESOURCE_STATE_TRANSITION_MODE BLASTransitionMode = RESOURCE_STATE_TRANSITION_MODE_NONE
 Bottom-level AS (in TLASBuildInstanceData::pBLAS) state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
 
TLASBuildInstanceData const * pInstances = nullptr
 A pointer to an array of InstanceCount TLASBuildInstanceData structures that contain instance data.
 
Uint32 InstanceCount = 0
 The number of instances.
 
IBufferpInstanceBuffer = nullptr
 The buffer that will be used to store instance data during AS building.
 
Uint64 InstanceBufferOffset = 0
 
RESOURCE_STATE_TRANSITION_MODE InstanceBufferTransitionMode = RESOURCE_STATE_TRANSITION_MODE_NONE
 Instance buffer state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
 
Uint32 HitGroupStride = 1
 The number of hit shaders that can be bound for a single geometry or an instance (depends on BindingMode).
 
Uint32 BaseContributionToHitGroupIndex = 0
 Base offset for the hit group location.
 
HIT_GROUP_BINDING_MODE BindingMode = HIT_GROUP_BINDING_MODE_PER_GEOMETRY
 Hit shader binding mode, see Diligent::SHADER_BINDING_MODE.
 
IBufferpScratchBuffer = nullptr
 Buffer that is used for acceleration structure building.
 
Uint64 ScratchBufferOffset = 0
 Offset from the beginning of the buffer.
 
RESOURCE_STATE_TRANSITION_MODE ScratchBufferTransitionMode = RESOURCE_STATE_TRANSITION_MODE_NONE
 Scratch buffer state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
 
Bool Update = False
 Whether to build the acceleration structure from scratch or update it.
 

Detailed Description

This structure is used by IDeviceContext::BuildTLAS().

Member Data Documentation

◆ BaseContributionToHitGroupIndex

Uint32 Diligent::BuildTLASAttribs::BaseContributionToHitGroupIndex = 0

Base offset for the hit group location.

Can be used to bind hit shaders for multiple acceleration structures, see IShaderBindingTable::BindHitGroupForGeometry().

◆ BindingMode

HIT_GROUP_BINDING_MODE Diligent::BuildTLASAttribs::BindingMode = HIT_GROUP_BINDING_MODE_PER_GEOMETRY

Hit shader binding mode, see Diligent::SHADER_BINDING_MODE.

Used to calculate TLASBuildInstanceData::ContributionToHitGroupIndex.

◆ HitGroupStride

Uint32 Diligent::BuildTLASAttribs::HitGroupStride = 1

The number of hit shaders that can be bound for a single geometry or an instance (depends on BindingMode).

You should use the same value in a shader:

  • MultiplierForGeometryContributionToHitGroupIndex argument in TraceRay() in HLSL
  • sbtRecordStride argument in traceRay() in GLSL.

◆ InstanceBufferOffset

Uint64 Diligent::BuildTLASAttribs::InstanceBufferOffset = 0

Offset from the beginning of the buffer to the location of instance data. Offset must be aligned by RayTracingProperties::InstanceBufferAlignment.

◆ InstanceCount

Uint32 Diligent::BuildTLASAttribs::InstanceCount = 0

The number of instances.

Must be less than or equal to TopLevelASDesc::MaxInstanceCount. If Update is true then count must be the same as used to build TLAS.

◆ pInstanceBuffer

IBuffer* Diligent::BuildTLASAttribs::pInstanceBuffer = nullptr

The buffer that will be used to store instance data during AS building.

The buffer size must be at least TLAS_INSTANCE_DATA_SIZE * InstanceCount. The buffer must be created with Diligent::BIND_RAY_TRACING flag.

◆ pInstances

TLASBuildInstanceData const* Diligent::BuildTLASAttribs::pInstances = nullptr

A pointer to an array of InstanceCount TLASBuildInstanceData structures that contain instance data.

If Update is true:

  • Any instance data can be changed.
  • To disable an instance set TLASBuildInstanceData::Mask to zero or set empty TLASBuildInstanceData::BLAS to pBLAS.

◆ pScratchBuffer

IBuffer* Diligent::BuildTLASAttribs::pScratchBuffer = nullptr

Buffer that is used for acceleration structure building.

Must be created with Diligent::BIND_RAY_TRACING.

Call ITopLevelAS::GetScratchBufferSizes().Build to get the minimal size for the scratch buffer.

Note
Access to the TLAS must be externally synchronized.

◆ pTLAS

ITopLevelAS* Diligent::BuildTLASAttribs::pTLAS = nullptr

Target top-level AS.

Access to the TLAS must be externally synchronized.

◆ ScratchBufferOffset

Uint64 Diligent::BuildTLASAttribs::ScratchBufferOffset = 0

Offset from the beginning of the buffer.

Offset must be aligned by RayTracingProperties::ScratchBufferAlignment.

◆ Update

Bool Diligent::BuildTLASAttribs::Update = False

Whether to build the acceleration structure from scratch or update it.

  • if false, then TLAS will be built from scratch.
  • If true, then previous content of TLAS will be updated.

pTLAS must be created with Diligent::RAYTRACING_BUILD_AS_ALLOW_UPDATE flag.

Note
An update will be faster than building an acceleration structure from scratch.