Go to the documentation of this file.
33 #include <unordered_map>
57 using BLASNameToIndex = std::unordered_map<HashMapStringKey, BLASGeomIndex, HashMapStringKey::Hasher>;
73 template <
typename EngineImplTraits>
78 using BaseInterface =
typename EngineImplTraits::BottomLevelASInterface;
93 bool bIsDeviceInternal =
false) :
98 if (Desc.CompactedSize > 0)
103 CopyGeometryDescriptionUnsafe(Desc,
nullptr);
118 DEV_CHECK_ERR(Name !=
nullptr && Name[0] !=
'\0',
"Geometry name must not be empty");
124 ActualIndex = iter->second.ActualIndex;
126 iter->second.ActualIndex = ActualIndex;
127 return iter->second.IndexInDesc;
130 return INVALID_INDEX;
136 DEV_CHECK_ERR(Name !=
nullptr && Name[0] !=
'\0',
"Geometry name must not be empty");
140 return iter->second.IndexInDesc;
143 return INVALID_INDEX;
149 DEV_CHECK_ERR(Name !=
nullptr && Name[0] !=
'\0',
"Geometry name must not be emtpy");
154 VERIFY(iter->second.ActualIndex != INVALID_INDEX,
"Geometry with name '", Name,
"', exists, but was not enabled in the last build");
155 return iter->second.ActualIndex;
158 return INVALID_INDEX;
165 "Unsupported state for a bottom-level acceleration structure");
188 DEV_CHECK_ERR((State & (State - 1)) == 0,
"Single state is expected");
190 return (this->
m_State & State) == State;
193 #ifdef DILIGENT_DEVELOPMENT
196 this->m_DvpVersion.fetch_add(1);
201 return this->m_DvpVersion.load();
203 #endif // DILIGENT_DEVELOPMENT
211 CopyGeometryDescriptionUnsafe(SrcBLAS.GetDesc(), &SrcBLAS.m_NameToIndex);
237 void ClearGeometry() noexcept
261 #ifdef DILIGENT_DEVELOPMENT
262 std::atomic<Uint32> m_DvpVersion{0};
Implementation of a linear allocator on a fixed-size memory page.
Definition: FixedLinearAllocator.hpp:45
RESOURCE_STATE m_State
Definition: BottomLevelASBase.hpp:255
Uint32 UpdateGeometryIndex(const char *Name, Uint32 &ActualIndex, bool OnUpdate)
Definition: BottomLevelASBase.hpp:116
Base interface for a reference counter object that stores the number of strong and weak references an...
Definition: ReferenceCounters.h:44
#define LOG_ERROR_MESSAGE(...)
Definition: Errors.hpp:122
BLASGeomIndex()
Definition: BottomLevelASBase.hpp:50
Uint32 ActualIndex
Definition: BottomLevelASBase.hpp:48
Uint32 m_GeometryCount
Definition: BottomLevelASBase.hpp:258
const BLASBoundingBoxDesc * pBoxes
Array of AABB geometry descriptions.
Definition: BottomLevelAS.h:154
void SetActualGeometryCount(Uint32 Count)
Definition: BottomLevelASBase.hpp:219
Defines the scratch buffer info for acceleration structure.
Definition: BottomLevelAS.h:177
BottomLevelASDesc m_Desc
Object description.
Definition: DeviceObjectBase.hpp:182
virtual void SetState(RESOURCE_STATE State) override final
Implementation of IBottomLevelAS::SetState()
Definition: BottomLevelASBase.hpp:162
#define DEV_CHECK_ERR(...)
Definition: DebugUtilities.hpp:90
BottomLevelASBase(IReferenceCounters *pRefCounters, RenderDeviceImplType *pDevice, const BottomLevelASDesc &Desc, bool bIsDeviceInternal=false)
Definition: BottomLevelASBase.hpp:90
void CopyGeometryDescription(const BottomLevelASBase &SrcBLAS) noexcept
Definition: BottomLevelASBase.hpp:205
~BottomLevelASBase()
Definition: BottomLevelASBase.hpp:107
bool CheckState(RESOURCE_STATE State) const
Definition: BottomLevelASBase.hpp:186
virtual Uint32 GetGeometryDescIndex(const char *Name) const override final
Implementation of IBottomLevelAS::GetGeometryDescIndex()
Definition: BottomLevelASBase.hpp:134
IMemoryAllocator & GetRawAllocator()
Returns raw memory allocator.
Definition: EngineMemory.cpp:51
std::unordered_map< HashMapStringKey, BLASGeomIndex, HashMapStringKey::Hasher > BLASNameToIndex
Definition: BottomLevelASBase.hpp:57
void ValidateBottomLevelASDesc(const BottomLevelASDesc &Desc) noexcept(false)
Validates bottom-level AS description and throws an exception in case of an error.
Definition: BottomLevelASBase.cpp:33
#define IMPLEMENT_QUERY_INTERFACE_IN_PLACE(InterfaceID, ParentClassName)
Definition: ObjectBase.hpp:59
typename EngineD3D12ImplTraits ::BottomLevelASInterface BaseInterface
Definition: BottomLevelASBase.hpp:78
#define DILIGENT_CALL_TYPE
Definition: CommonDefinitions.h:45
const BLASTriangleDesc * pTriangles
Array of triangle geometry descriptions.
Definition: BottomLevelAS.h:148
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
void * m_pRawPtr
Definition: BottomLevelASBase.hpp:257
@ RESOURCE_STATE_UNKNOWN
The resource state is not known to the engine and is managed by the application.
Definition: GraphicsTypes.h:2817
@ RESOURCE_STATE_BUILD_AS_WRITE
The resource is used as the target for AS building or AS copy operations.
Definition: GraphicsTypes.h:2875
virtual RESOURCE_STATE GetState() const override final
Implementation of IBottomLevelAS::GetState()
Definition: BottomLevelASBase.hpp:170
Template class implementing base functionality of the bottom-level acceleration structure object.
Definition: BottomLevelASBase.hpp:74
Uint32 TriangleCount
The number of triangle geometries in pTriangles array.
Definition: BottomLevelAS.h:151
DeviceObjectBase< BaseInterface, RenderDeviceImplType, BottomLevelASDesc > TDeviceObjectBase
Definition: BottomLevelASBase.hpp:83
virtual Uint32 GetGeometryIndex(const char *Name) const override final
Implementation of IBottomLevelAS::GetGeometryIndex()
Definition: BottomLevelASBase.hpp:147
virtual Uint32 GetActualGeometryCount() const override final
Definition: BottomLevelASBase.hpp:224
@ RESOURCE_STATE_BUILD_AS_READ
The resource is used as vertex/index/instance buffer in an AS building operation or as an acceleratio...
Definition: GraphicsTypes.h:2872
#define VERIFY(...)
Definition: DebugUtilities.hpp:76
BLASNameToIndex m_NameToIndex
Definition: BottomLevelASBase.hpp:256
bool IsInKnownState() const
Definition: BottomLevelASBase.hpp:181
RESOURCE_STATE
Resource usage state.
Definition: GraphicsTypes.h:2814
Uint32 BoxCount
The number of AABB geometries in pBoxes array.
Definition: BottomLevelAS.h:157
typename EngineD3D12ImplTraits ::RenderDeviceImplType RenderDeviceImplType
Definition: BottomLevelASBase.hpp:81
virtual ScratchBufferSizes GetScratchBufferSizes() const override final
Implementation of IBottomLevelAS::GetScratchBufferSizes()
Definition: BottomLevelASBase.hpp:176
BLASGeomIndex(Uint32 _IndexInDesc, Uint32 _ActualIndex)
Definition: BottomLevelASBase.hpp:51
Bottom-level AS description.
Definition: BottomLevelAS.h:145
virtual void Free(void *Ptr)=0
Releases memory.
Uint32 IndexInDesc
Definition: BottomLevelASBase.hpp:47
Definition: BottomLevelASBase.hpp:45
void CopyBLASGeometryDesc(const BottomLevelASDesc &SrcDesc, BottomLevelASDesc &DstDesc, FixedLinearAllocator &MemPool, const BLASNameToIndex *pSrcNameToIndex, BLASNameToIndex &DstNameToIndex) noexcept(false)
Copies bottom-level AS geometry description using MemPool to allocate required space.
Definition: BottomLevelASBase.cpp:108
Template class implementing base functionality of the device object.
Definition: DeviceObjectBase.hpp:45
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
ScratchBufferSizes m_ScratchSize
Definition: BottomLevelASBase.hpp:259