Diligent Engine  v.2.4.g
TopLevelASBase.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2019-2021 Diligent Graphics LLC
3  * Copyright 2015-2019 Egor Yusov
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * In no event and under no legal theory, whether in tort (including negligence),
18  * contract, or otherwise, unless required by applicable law (such as deliberate
19  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
20  * liable for any damages, including any direct, indirect, special, incidental,
21  * or consequential damages of any character arising as a result of this License or
22  * out of the use or inability to use the software (including but not limited to damages
23  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
24  * all other commercial damages or losses), even if such Contributor has been advised
25  * of the possibility of such damages.
26  */
27 
28 #pragma once
29 
32 
33 #include <unordered_map>
34 #include <atomic>
35 
36 #include "TopLevelAS.h"
37 #include "BottomLevelASBase.hpp"
38 #include "DeviceObjectBase.hpp"
39 #include "RenderDeviceBase.hpp"
40 #include "StringPool.hpp"
41 #include "HashUtils.hpp"
42 
43 namespace Diligent
44 {
45 
47 void ValidateTopLevelASDesc(const TopLevelASDesc& Desc) noexcept(false);
48 
50 
52 template <typename EngineImplTraits>
53 class TopLevelASBase : public DeviceObjectBase<typename EngineImplTraits::TopLevelASInterface, typename EngineImplTraits::RenderDeviceImplType, TopLevelASDesc>
54 {
55 private:
56  // Base interface that this class inherits (ITopLevelASD3D12, ITopLevelASVk, etc.).
57  using BaseInterface = typename EngineImplTraits::TopLevelASInterface;
58 
59  // Render device implementation type (RenderDeviceD3D12Impl, RenderDeviceVkImpl, etc.).
60  using RenderDeviceImplType = typename EngineImplTraits::RenderDeviceImplType;
61 
62  // Bottom-level AS implementation type (BottomLevelASD3D12Impl, BottomLevelASVkImpl, etc.).
63  using BottomLevelASImplType = typename EngineImplTraits::BottomLevelASImplType;
64 
65  struct InstanceDesc
66  {
67  Uint32 ContributionToHitGroupIndex = 0;
68  Uint32 InstanceIndex = 0;
70 #ifdef DILIGENT_DEVELOPMENT
71  Uint32 Version = 0;
72 #endif
73  };
74 
75 public:
77 
84  RenderDeviceImplType* pDevice,
85  const TopLevelASDesc& Desc,
86  bool bIsDeviceInternal = false) :
87  TDeviceObjectBase{pRefCounters, pDevice, Desc, bIsDeviceInternal}
88  {
90  }
91 
93  {
94  }
95 
97 
98  bool SetInstanceData(const TLASBuildInstanceData* pInstances,
99  const Uint32 InstanceCount,
100  const Uint32 BaseContributionToHitGroupIndex,
101  const Uint32 HitGroupStride,
102  const HIT_GROUP_BINDING_MODE BindingMode) noexcept
103  {
104  try
105  {
106  ClearInstanceData();
107 
108  size_t StringPoolSize = 0;
109  for (Uint32 i = 0; i < InstanceCount; ++i)
110  {
111  VERIFY_EXPR(pInstances[i].InstanceName != nullptr);
112  StringPoolSize += StringPool::GetRequiredReserveSize(pInstances[i].InstanceName);
113  }
114 
115  this->m_StringPool.Reserve(StringPoolSize, GetRawAllocator());
116 
117  Uint32 InstanceOffset = BaseContributionToHitGroupIndex;
118 
119  for (Uint32 i = 0; i < InstanceCount; ++i)
120  {
121  const auto& Inst = pInstances[i];
122  const char* NameCopy = this->m_StringPool.CopyString(Inst.InstanceName);
123  InstanceDesc Desc = {};
124 
125  Desc.pBLAS = ValidatedCast<BottomLevelASImplType>(Inst.pBLAS);
126  Desc.ContributionToHitGroupIndex = Inst.ContributionToHitGroupIndex;
127  Desc.InstanceIndex = i;
128  CalculateHitGroupIndex(Desc, InstanceOffset, HitGroupStride, BindingMode);
129 
130 #ifdef DILIGENT_DEVELOPMENT
131  Desc.Version = Desc.pBLAS->GetVersion();
132 #endif
133  bool IsUniqueName = this->m_Instances.emplace(NameCopy, Desc).second;
134  if (!IsUniqueName)
135  LOG_ERROR_AND_THROW("Instance name must be unique!");
136  }
137 
139 
140  InstanceOffset = InstanceOffset + (BindingMode == HIT_GROUP_BINDING_MODE_PER_TLAS ? HitGroupStride : 0) - 1;
141 
142  this->m_BuildInfo.HitGroupStride = HitGroupStride;
143  this->m_BuildInfo.FirstContributionToHitGroupIndex = BaseContributionToHitGroupIndex;
144  this->m_BuildInfo.LastContributionToHitGroupIndex = InstanceOffset;
145  this->m_BuildInfo.BindingMode = BindingMode;
146  this->m_BuildInfo.InstanceCount = InstanceCount;
147 
148 #ifdef DILIGENT_DEVELOPMENT
149  this->m_DvpVersion.fetch_add(1);
150 #endif
151  return true;
152  }
153  catch (...)
154  {
155 #ifdef DILIGENT_DEVELOPMENT
156  this->m_DvpVersion.fetch_add(1);
157 #endif
158  ClearInstanceData();
159  return false;
160  }
161  }
162 
163  bool UpdateInstances(const TLASBuildInstanceData* pInstances,
164  const Uint32 InstanceCount,
165  const Uint32 BaseContributionToHitGroupIndex,
166  const Uint32 HitGroupStride,
167  const HIT_GROUP_BINDING_MODE BindingMode) noexcept
168  {
169  VERIFY_EXPR(this->m_BuildInfo.InstanceCount == InstanceCount);
170 #ifdef DILIGENT_DEVELOPMENT
171  bool Changed = false;
172 #endif
173  Uint32 InstanceOffset = BaseContributionToHitGroupIndex;
174 
175  for (Uint32 i = 0; i < InstanceCount; ++i)
176  {
177  const auto& Inst = pInstances[i];
178  auto Iter = this->m_Instances.find(Inst.InstanceName);
179 
180  if (Iter == this->m_Instances.end())
181  {
182  UNEXPECTED("Failed to find instance with name '", Inst.InstanceName, "' in instances from the previous build");
183  return false;
184  }
185 
186  auto& Desc = Iter->second;
187  const auto PrevIndex = Desc.ContributionToHitGroupIndex;
188  const auto pPrevBLAS = Desc.pBLAS;
189 
190  Desc.pBLAS = ValidatedCast<BottomLevelASImplType>(Inst.pBLAS);
191  Desc.ContributionToHitGroupIndex = Inst.ContributionToHitGroupIndex;
192  //Desc.InstanceIndex = i; // keep Desc.InstanceIndex unmodified
193  CalculateHitGroupIndex(Desc, InstanceOffset, HitGroupStride, BindingMode);
194 
195 #ifdef DILIGENT_DEVELOPMENT
196  Changed = Changed || (pPrevBLAS != Desc.pBLAS);
197  Changed = Changed || (PrevIndex != Desc.ContributionToHitGroupIndex);
198  Desc.Version = Desc.pBLAS->GetVersion();
199 #endif
200  }
201 
202  InstanceOffset = InstanceOffset + (BindingMode == HIT_GROUP_BINDING_MODE_PER_TLAS ? HitGroupStride : 0) - 1;
203 
204 #ifdef DILIGENT_DEVELOPMENT
205  Changed = Changed || (this->m_BuildInfo.HitGroupStride != HitGroupStride);
206  Changed = Changed || (this->m_BuildInfo.FirstContributionToHitGroupIndex != BaseContributionToHitGroupIndex);
207  Changed = Changed || (this->m_BuildInfo.LastContributionToHitGroupIndex != InstanceOffset);
208  Changed = Changed || (this->m_BuildInfo.BindingMode != BindingMode);
209  if (Changed)
210  this->m_DvpVersion.fetch_add(1);
211 #endif
212  this->m_BuildInfo.HitGroupStride = HitGroupStride;
213  this->m_BuildInfo.FirstContributionToHitGroupIndex = BaseContributionToHitGroupIndex;
214  this->m_BuildInfo.LastContributionToHitGroupIndex = InstanceOffset;
215  this->m_BuildInfo.BindingMode = BindingMode;
216 
217  return true;
218  }
219 
220  void CopyInstancceData(const TopLevelASBase& Src) noexcept
221  {
222  ClearInstanceData();
223 
224  this->m_StringPool.Reserve(Src.m_StringPool.GetReservedSize(), GetRawAllocator());
225  this->m_BuildInfo = Src.m_BuildInfo;
226 
227  for (auto& SrcInst : Src.m_Instances)
228  {
229  const char* NameCopy = this->m_StringPool.CopyString(SrcInst.first.GetStr());
230  this->m_Instances.emplace(NameCopy, SrcInst.second);
231  }
232 
234 
235 #ifdef DILIGENT_DEVELOPMENT
236  this->m_DvpVersion.fetch_add(1);
237 #endif
238  }
239 
241  virtual TLASInstanceDesc DILIGENT_CALL_TYPE GetInstanceDesc(const char* Name) const override final
242  {
243  VERIFY_EXPR(Name != nullptr && Name[0] != '\0');
244 
245  TLASInstanceDesc Result = {};
246 
247  auto Iter = this->m_Instances.find(Name);
248  if (Iter != this->m_Instances.end())
249  {
250  const auto& Inst = Iter->second;
251  Result.ContributionToHitGroupIndex = Inst.ContributionToHitGroupIndex;
252  Result.InstanceIndex = Inst.InstanceIndex;
253  Result.pBLAS = Inst.pBLAS.template RawPtr<IBottomLevelAS>();
254  }
255  else
256  {
257  Result.ContributionToHitGroupIndex = INVALID_INDEX;
258  Result.InstanceIndex = INVALID_INDEX;
259  LOG_ERROR_MESSAGE("Can't find instance with the specified name ('", Name, "')");
260  }
261 
262  return Result;
263  }
264 
266  virtual TLASBuildInfo DILIGENT_CALL_TYPE GetBuildInfo() const override final
267  {
268  return m_BuildInfo;
269  }
270 
272  virtual void DILIGENT_CALL_TYPE SetState(RESOURCE_STATE State) override final
273  {
275  "Unsupported state for top-level acceleration structure");
276  this->m_State = State;
277  }
278 
280  virtual RESOURCE_STATE DILIGENT_CALL_TYPE GetState() const override final
281  {
282  return this->m_State;
283  }
284 
287  {
288  return this->m_ScratchSize;
289  }
290 
291  bool IsInKnownState() const
292  {
293  return this->m_State != RESOURCE_STATE_UNKNOWN;
294  }
295 
296  bool CheckState(RESOURCE_STATE State) const
297  {
298  VERIFY((State & (State - 1)) == 0, "Single state is expected");
299  VERIFY(IsInKnownState(), "TLAS state is unknown");
300  return (this->m_State & State) == State;
301  }
302 
303 #ifdef DILIGENT_DEVELOPMENT
304  bool ValidateContent() const
305  {
306  bool result = true;
307 
308  if (this->m_Instances.empty())
309  {
310  LOG_ERROR_MESSAGE("TLAS with name ('", this->m_Desc.Name, "') doesn't have instances, use IDeviceContext::BuildTLAS() or IDeviceContext::CopyTLAS() to initialize TLAS content");
311  result = false;
312  }
313 
314  // Validate instances
315  for (const auto& NameAndInst : this->m_Instances)
316  {
317  const InstanceDesc& Inst = NameAndInst.second;
318 
319  if (Inst.Version != Inst.pBLAS->GetVersion())
320  {
321  LOG_ERROR_MESSAGE("Instance with name '", NameAndInst.first.GetStr(), "' contains BLAS with name '", Inst.pBLAS->GetDesc().Name,
322  "' that was changed after TLAS build, you must rebuild TLAS");
323  result = false;
324  }
325 
326  if (Inst.pBLAS->IsInKnownState() && Inst.pBLAS->GetState() != RESOURCE_STATE_BUILD_AS_READ)
327  {
328  LOG_ERROR_MESSAGE("Instance with name '", NameAndInst.first.GetStr(), "' contains BLAS with name '", Inst.pBLAS->GetDesc().Name,
329  "' that must be in BUILD_AS_READ state, but current state is ",
330  GetResourceStateFlagString(Inst.pBLAS->GetState()));
331  result = false;
332  }
333  }
334  return result;
335  }
336 
337  Uint32 GetVersion() const
338  {
339  return this->m_DvpVersion.load();
340  }
341 #endif // DILIGENT_DEVELOPMENT
342 
343 private:
344  void ClearInstanceData()
345  {
346  this->m_Instances.clear();
347  this->m_StringPool.Clear();
348 
350  this->m_BuildInfo.HitGroupStride = 0;
351  this->m_BuildInfo.FirstContributionToHitGroupIndex = INVALID_INDEX;
352  this->m_BuildInfo.LastContributionToHitGroupIndex = INVALID_INDEX;
353  }
354 
355  static void CalculateHitGroupIndex(InstanceDesc& Desc, Uint32& InstanceOffset, const Uint32 HitGroupStride, const HIT_GROUP_BINDING_MODE BindingMode)
356  {
357  static_assert(HIT_GROUP_BINDING_MODE_LAST == HIT_GROUP_BINDING_MODE_USER_DEFINED, "Please update the switch below to handle the new shader binding mode");
358 
359  if (Desc.ContributionToHitGroupIndex == TLAS_INSTANCE_OFFSET_AUTO)
360  {
361  Desc.ContributionToHitGroupIndex = InstanceOffset;
362  switch (BindingMode)
363  {
364  // clang-format off
365  case HIT_GROUP_BINDING_MODE_PER_GEOMETRY: InstanceOffset += Desc.pBLAS->GetActualGeometryCount() * HitGroupStride; break;
366  case HIT_GROUP_BINDING_MODE_PER_INSTANCE: InstanceOffset += HitGroupStride; break;
367  case HIT_GROUP_BINDING_MODE_PER_TLAS: /* InstanceOffset is constant */ break;
368  case HIT_GROUP_BINDING_MODE_USER_DEFINED: UNEXPECTED("TLAS_INSTANCE_OFFSET_AUTO is not compatible with HIT_GROUP_BINDING_MODE_USER_DEFINED"); break;
369  default: UNEXPECTED("Unknown ray tracing shader binding mode");
370  // clang-format on
371  }
372  }
373  else
374  {
375  VERIFY(BindingMode == HIT_GROUP_BINDING_MODE_USER_DEFINED, "BindingMode must be HIT_GROUP_BINDING_MODE_USER_DEFINED");
376  }
377 
378  constexpr Uint32 MaxIndex = (1u << 24);
379  VERIFY(Desc.ContributionToHitGroupIndex < MaxIndex, "ContributionToHitGroupIndex must be less than ", MaxIndex);
380  }
381 
382 protected:
386 
387  std::unordered_map<HashMapStringKey, InstanceDesc, HashMapStringKey::Hasher> m_Instances;
388 
390 
391 #ifdef DILIGENT_DEVELOPMENT
392  std::atomic<Uint32> m_DvpVersion{0};
393 #endif
394 };
395 
396 } // namespace Diligent
Diligent::TopLevelASBase::CheckState
bool CheckState(RESOURCE_STATE State) const
Definition: TopLevelASBase.hpp:296
TopLevelAS.h
Diligent::IReferenceCounters
Base interface for a reference counter object that stores the number of strong and weak references an...
Definition: ReferenceCounters.h:44
LOG_ERROR_MESSAGE
#define LOG_ERROR_MESSAGE(...)
Definition: Errors.hpp:122
Diligent::TopLevelASBase::GetBuildInfo
virtual TLASBuildInfo GetBuildInfo() const override final
Implementation of ITopLevelAS::GetBuildInfo().
Definition: TopLevelASBase.hpp:266
Diligent::StringPool::Clear
void Clear()
Definition: StringPool.hpp:85
Diligent::TopLevelASBase::SetState
virtual void SetState(RESOURCE_STATE State) override final
Implementation of ITopLevelAS::SetState().
Definition: TopLevelASBase.hpp:272
Diligent::TopLevelASBase::GetState
virtual RESOURCE_STATE GetState() const override final
Implementation of ITopLevelAS::GetState().
Definition: TopLevelASBase.hpp:280
Diligent::TopLevelASBase::GetInstanceDesc
virtual TLASInstanceDesc GetInstanceDesc(const char *Name) const override final
Implementation of ITopLevelAS::GetInstanceDesc().
Definition: TopLevelASBase.hpp:241
Diligent::TopLevelASBase::m_ScratchSize
ScratchBufferSizes m_ScratchSize
Definition: TopLevelASBase.hpp:385
LOG_ERROR_AND_THROW
#define LOG_ERROR_AND_THROW(...)
Definition: Errors.hpp:101
DeviceObjectBase.hpp
Diligent::TLASBuildInfo::InstanceCount
Uint32 InstanceCount
The number of instances, same as BuildTLASAttribs::InstanceCount.
Definition: TopLevelAS.h:104
Diligent::TopLevelASDesc
Top-level AS description.
Definition: TopLevelAS.h:49
Diligent::TLASBuildInfo
Defines TLAS state that was used in the last build.
Definition: TopLevelAS.h:101
Diligent::HIT_GROUP_BINDING_MODE_PER_GEOMETRY
@ HIT_GROUP_BINDING_MODE_PER_GEOMETRY
Each geometry in every instance may use a unique hit shader group. In this mode, the SBT reserves spa...
Definition: TopLevelAS.h:78
Diligent::StringPool::GetRemainingSize
size_t GetRemainingSize() const
Definition: StringPool.hpp:154
Diligent::HIT_GROUP_BINDING_MODE_USER_DEFINED
@ HIT_GROUP_BINDING_MODE_USER_DEFINED
The user must specify TLASBuildInstanceData::ContributionToHitGroupIndex and only use IShaderBindingT...
Definition: TopLevelAS.h:94
Diligent::TopLevelASBase::m_State
RESOURCE_STATE m_State
Definition: TopLevelASBase.hpp:383
Diligent::TLASInstanceDesc::pBLAS
IBottomLevelAS * pBLAS
Bottom-level AS that is specified in TLASBuildInstanceData::pBLAS.
Definition: TopLevelAS.h:132
Diligent::TopLevelASBase::m_BuildInfo
TLASBuildInfo m_BuildInfo
Definition: TopLevelASBase.hpp:384
UNEXPECTED
#define UNEXPECTED(...)
Definition: DebugUtilities.hpp:77
Diligent::TopLevelASDesc
struct TopLevelASDesc TopLevelASDesc
Definition: TopLevelAS.h:68
Diligent::ScratchBufferSizes
Defines the scratch buffer info for acceleration structure.
Definition: BottomLevelAS.h:177
Diligent::DeviceObjectBase< EngineImplTraits::TopLevelASInterface, EngineImplTraits::RenderDeviceImplType, TopLevelASDesc >::m_Desc
TopLevelASDesc m_Desc
Object description.
Definition: DeviceObjectBase.hpp:182
Diligent::StringPool::CopyString
Char * CopyString(const String &Str)
Definition: StringPool.hpp:124
Diligent::HIT_GROUP_BINDING_MODE_LAST
@ HIT_GROUP_BINDING_MODE_LAST
Definition: TopLevelAS.h:96
Diligent::TopLevelASBase::GetScratchBufferSizes
virtual ScratchBufferSizes GetScratchBufferSizes() const override final
Implementation of ITopLevelAS::GetScratchBufferSizes().
Definition: TopLevelASBase.hpp:286
Diligent::TopLevelASBase::~TopLevelASBase
~TopLevelASBase()
Definition: TopLevelASBase.hpp:92
RenderDeviceBase.hpp
Diligent::TLASBuildInstanceData
This structure is used by BuildTLASAttribs.
Definition: DeviceContext.h:1040
Diligent::TLASInstanceDesc
Top-level AS instance description.
Definition: TopLevelAS.h:122
Diligent::GetRawAllocator
IMemoryAllocator & GetRawAllocator()
Returns raw memory allocator.
Definition: EngineMemory.cpp:51
Diligent::GetResourceStateFlagString
const Char * GetResourceStateFlagString(RESOURCE_STATE State)
Returns the string containing the buffer mode description.
Definition: GraphicsAccessories.cpp:1045
IMPLEMENT_QUERY_INTERFACE_IN_PLACE
#define IMPLEMENT_QUERY_INTERFACE_IN_PLACE(InterfaceID, ParentClassName)
Definition: ObjectBase.hpp:59
Diligent::RESOURCE_STATE_RAY_TRACING
@ RESOURCE_STATE_RAY_TRACING
The resource is used as a top-level AS shader resource in a trace rays operation.
Definition: GraphicsTypes.h:2878
Diligent::RefCntAutoPtr< BottomLevelASImplType >
DILIGENT_CALL_TYPE
#define DILIGENT_CALL_TYPE
Definition: CommonDefinitions.h:45
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
Diligent::TLASBuildInfo::FirstContributionToHitGroupIndex
Uint32 FirstContributionToHitGroupIndex
First hit group location, same as BuildTLASAttribs::BaseContributionToHitGroupIndex.
Definition: TopLevelAS.h:113
Diligent::TLASBuildInfo::HitGroupStride
Uint32 HitGroupStride
The number of hit shader groups, same as BuildTLASAttribs::HitGroupStride.
Definition: TopLevelAS.h:107
Diligent::RESOURCE_STATE_UNKNOWN
@ RESOURCE_STATE_UNKNOWN
The resource state is not known to the engine and is managed by the application.
Definition: GraphicsTypes.h:2817
Diligent::TopLevelASBase::m_Instances
std::unordered_map< HashMapStringKey, InstanceDesc, HashMapStringKey::Hasher > m_Instances
Definition: TopLevelASBase.hpp:387
Diligent::RESOURCE_STATE_BUILD_AS_WRITE
@ RESOURCE_STATE_BUILD_AS_WRITE
The resource is used as the target for AS building or AS copy operations.
Definition: GraphicsTypes.h:2875
Diligent::TopLevelASBase::m_StringPool
StringPool m_StringPool
Definition: TopLevelASBase.hpp:389
Diligent::TopLevelASBase::TDeviceObjectBase
DeviceObjectBase< BaseInterface, RenderDeviceImplType, TopLevelASDesc > TDeviceObjectBase
Definition: TopLevelASBase.hpp:76
Diligent::ValidateTopLevelASDesc
void ValidateTopLevelASDesc(const TopLevelASDesc &Desc) noexcept(false)
Validates top-level AS description and throws an exception in case of an error.
Definition: TopLevelASBase.cpp:33
Diligent::TopLevelASBase::SetInstanceData
bool SetInstanceData(const TLASBuildInstanceData *pInstances, const Uint32 InstanceCount, const Uint32 BaseContributionToHitGroupIndex, const Uint32 HitGroupStride, const HIT_GROUP_BINDING_MODE BindingMode) noexcept
Definition: TopLevelASBase.hpp:98
HashUtils.hpp
Diligent::HIT_GROUP_BINDING_MODE_PER_TLAS
@ HIT_GROUP_BINDING_MODE_PER_TLAS
All instances in each TLAS will use the same hit group. In this mode, the SBT reserves a single slot ...
Definition: TopLevelAS.h:90
Diligent::HIT_GROUP_BINDING_MODE
HIT_GROUP_BINDING_MODE
Defines hit group binding mode used by the top-level AS.
Definition: TopLevelAS.h:72
Diligent::StringPool::Reserve
void Reserve(size_t Size, IMemoryAllocator &Allocator)
Definition: StringPool.hpp:71
Diligent::TopLevelASBase::TopLevelASBase
TopLevelASBase(IReferenceCounters *pRefCounters, RenderDeviceImplType *pDevice, const TopLevelASDesc &Desc, bool bIsDeviceInternal=false)
Definition: TopLevelASBase.hpp:83
Diligent::TLASInstanceDesc::InstanceIndex
Uint32 InstanceIndex
The autogenerated index of the instance. Same as InstanceIndex() in HLSL and gl_InstanceID in GLSL.
Definition: TopLevelAS.h:129
VERIFY_EXPR
#define VERIFY_EXPR(...)
Definition: DebugUtilities.hpp:79
StringPool.hpp
Diligent::RESOURCE_STATE_BUILD_AS_READ
@ 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
VERIFY
#define VERIFY(...)
Definition: DebugUtilities.hpp:76
BottomLevelASBase.hpp
Diligent::StringPool
Implementation of a simple fixed-size string pool.
Definition: StringPool.hpp:42
Diligent::TopLevelASBase::CopyInstancceData
void CopyInstancceData(const TopLevelASBase &Src) noexcept
Definition: TopLevelASBase.hpp:220
Diligent::TLASBuildInfo::LastContributionToHitGroupIndex
Uint32 LastContributionToHitGroupIndex
Last hit group location.
Definition: TopLevelAS.h:116
Diligent::TopLevelASBase::IsInKnownState
bool IsInKnownState() const
Definition: TopLevelASBase.hpp:291
Diligent::RESOURCE_STATE
RESOURCE_STATE
Resource usage state.
Definition: GraphicsTypes.h:2814
Diligent::HIT_GROUP_BINDING_MODE_PER_INSTANCE
@ HIT_GROUP_BINDING_MODE_PER_INSTANCE
Each instance may use a unique hit shader group. In this mode, the SBT reserves one slot for each ins...
Definition: TopLevelAS.h:84
Diligent::TopLevelASBase
Template class implementing base functionality of the top-level acceleration structure object.
Definition: TopLevelASBase.hpp:53
Diligent::TLASInstanceDesc::ContributionToHitGroupIndex
Uint32 ContributionToHitGroupIndex
Index that corresponds to the one specified in TLASBuildInstanceData::ContributionToHitGroupIndex.
Definition: TopLevelAS.h:125
Diligent::TLASBuildInfo::BindingMode
HIT_GROUP_BINDING_MODE BindingMode
Hit group binding mode, same as BuildTLASAttribs::BindingMode.
Definition: TopLevelAS.h:110
Diligent::DeviceObjectAttribs::Name
const Char * Name
Object name.
Definition: GraphicsTypes.h:1199
Diligent::DeviceObjectBase
Template class implementing base functionality of the device object.
Definition: DeviceObjectBase.hpp:45
Diligent::TopLevelASBase::UpdateInstances
bool UpdateInstances(const TLASBuildInstanceData *pInstances, const Uint32 InstanceCount, const Uint32 BaseContributionToHitGroupIndex, const Uint32 HitGroupStride, const HIT_GROUP_BINDING_MODE BindingMode) noexcept
Definition: TopLevelASBase.hpp:163
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
Diligent::StringPool::GetRequiredReserveSize
static size_t GetRequiredReserveSize(const char *str)
Definition: StringPool.hpp:98