diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-10-04 23:59:33 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-10-04 23:59:33 +0000 |
| commit | 73fd82a29d3175e156754010f5de261d6f561f16 (patch) | |
| tree | f04b71a06b71addb56d2a79885e53d253caa417e /Graphics/GraphicsEngine | |
| parent | Added KHR extension emulation via NV extension (diff) | |
| download | DiligentCore-73fd82a29d3175e156754010f5de261d6f561f16.tar.gz DiligentCore-73fd82a29d3175e156754010f5de261d6f561f16.zip | |
A few random fixes to ray tracing API and implementation
Diffstat (limited to 'Graphics/GraphicsEngine')
10 files changed, 137 insertions, 94 deletions
diff --git a/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp b/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp index e0fcde4f..7f1e402f 100644 --- a/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp +++ b/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp @@ -30,12 +30,14 @@ /// \file /// Implementation of the Diligent::BottomLevelASBase template class +#include <map> +#include <memory> + #include "BottomLevelAS.h" #include "DeviceObjectBase.hpp" #include "RenderDeviceBase.hpp" #include "StringPool.hpp" #include "StringView.hpp" -#include <map> namespace Diligent { @@ -52,27 +54,24 @@ class BottomLevelASBase : public DeviceObjectBase<BaseInterface, RenderDeviceImp public: using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, BottomLevelASDesc>; - /// \param pRefCounters - reference counters object that controls the lifetime of this BLAS. - /// \param pDevice - pointer to the device. - /// \param Desc - BLAS description. + /// \param pRefCounters - reference counters object that controls the lifetime of this BLAS. + /// \param pDevice - pointer to the device. + /// \param Desc - BLAS description. /// \param bIsDeviceInternal - flag indicating if the BLAS is an internal device object and /// must not keep a strong reference to the device. - BottomLevelASBase(IReferenceCounters* pRefCounters, RenderDeviceImplType* pDevice, const BottomLevelASDesc& Desc, bool bIsDeviceInternal = false) : + BottomLevelASBase(IReferenceCounters* pRefCounters, + RenderDeviceImplType* pDevice, + const BottomLevelASDesc& Desc, + bool bIsDeviceInternal = false) : TDeviceObjectBase{pRefCounters, pDevice, Desc, bIsDeviceInternal} { ValidateBottomLevelASDesc(Desc); - // Memory must be released even if exception was thrown. - struct MemOwner - { - void* ptr = nullptr; - - ~MemOwner() - { - if (ptr != nullptr) - GetRawAllocator().Free(ptr); - } - } memOwner; + // Memory must be released if an exception is thrown. + auto RawMemDeleter = [](void* ptr) { + if (ptr != nullptr) + GetRawAllocator().Free(ptr); + }; if (Desc.pTriangles != nullptr) { @@ -87,12 +86,12 @@ public: m_StringPool.Reserve(StringPoolSize, GetRawAllocator()); - auto* pTriangles = ALLOCATE(GetRawAllocator(), "Memory for BLASTriangleDesc array", BLASTriangleDesc, Desc.TriangleCount); - memOwner.ptr = pTriangles; + std::unique_ptr<BLASTriangleDesc[], decltype(RawMemDeleter)> pTriangles{ + ALLOCATE(GetRawAllocator(), "Memory for BLASTriangleDesc array", BLASTriangleDesc, Desc.TriangleCount), + RawMemDeleter}; - std::memcpy(pTriangles, Desc.pTriangles, sizeof(*Desc.pTriangles) * Desc.TriangleCount); - this->m_Desc.pTriangles = pTriangles; - this->m_Desc.pBoxes = nullptr; + std::memcpy(pTriangles.get(), Desc.pTriangles, sizeof(*Desc.pTriangles) * Desc.TriangleCount); + this->m_Desc.pBoxes = nullptr; // copy strings for (Uint32 i = 0; i < Desc.TriangleCount; ++i) @@ -102,6 +101,7 @@ public: if (!IsUniqueName) LOG_ERROR_AND_THROW("Geometry name must be unique!"); } + this->m_Desc.pTriangles = pTriangles.release(); } else if (Desc.pBoxes != nullptr) { @@ -116,11 +116,11 @@ public: m_StringPool.Reserve(StringPoolSize, GetRawAllocator()); - auto* pBoxes = ALLOCATE(GetRawAllocator(), "Memory for BLASBoundingBoxDesc array", BLASBoundingBoxDesc, Desc.BoxCount); - memOwner.ptr = pBoxes; + std::unique_ptr<BLASBoundingBoxDesc[], decltype(RawMemDeleter)> pBoxes{ + ALLOCATE(GetRawAllocator(), "Memory for BLASBoundingBoxDesc array", BLASBoundingBoxDesc, Desc.BoxCount), + RawMemDeleter}; - std::memcpy(pBoxes, Desc.pBoxes, sizeof(*Desc.pBoxes) * Desc.BoxCount); - this->m_Desc.pBoxes = pBoxes; + std::memcpy(pBoxes.get(), Desc.pBoxes, sizeof(*Desc.pBoxes) * Desc.BoxCount); this->m_Desc.pTriangles = nullptr; // copy strings @@ -131,10 +131,8 @@ public: if (!IsUniqueName) LOG_ERROR_AND_THROW("Geometry name must be unique!"); } + this->m_Desc.pBoxes = pBoxes.release(); } - - // Constructor completed successfully and memory will be released in destructor. - memOwner.ptr = nullptr; } ~BottomLevelASBase() @@ -168,7 +166,7 @@ protected: if (!((Desc.pBoxes != nullptr) ^ (Desc.pTriangles != nullptr))) { - LOG_BLAS_ERROR_AND_THROW("Only one of pTriangles and pBoxes must be defined"); + LOG_BLAS_ERROR_AND_THROW("Exactly one of pTriangles and pBoxes must be defined"); } if (Desc.pBoxes == nullptr && Desc.BoxCount > 0) @@ -187,7 +185,7 @@ protected: IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_BottomLevelAS, TDeviceObjectBase) protected: - std::map<StringView, Uint32> m_NameToIndex; + std::map<StringView, Uint32> m_NameToIndex; // TODO (AZ): use unordered_map? StringPool m_StringPool; }; diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp index 57c2ba16..dd8851c7 100644 --- a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp +++ b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp @@ -1909,7 +1909,7 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::BuildBLAS(const BLA if ((Attribs.pTriangleData != nullptr) ^ (Attribs.pBoxData != nullptr)) { - LOG_ERROR_MESSAGE("IDeviceContext::BuildBLAS: only one of pTriangles and pBoxes must be defined"); + LOG_ERROR_MESSAGE("IDeviceContext::BuildBLAS: exactly one of pTriangles and pBoxes must be defined"); return false; } @@ -2164,14 +2164,16 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::CopyBLAS(const Copy auto& SrcTri = SrcDesc.pTriangles[i]; auto& DstTri = DstDesc.pTriangles[i]; - if (SrcTri.MaxVertexCount != DstTri.MaxVertexCount || - SrcTri.VertexValueType != DstTri.VertexValueType || + // clang-format off + if (SrcTri.MaxVertexCount != DstTri.MaxVertexCount || + SrcTri.VertexValueType != DstTri.VertexValueType || SrcTri.VertexComponentCount != DstTri.VertexComponentCount || - SrcTri.MaxIndexCount != DstTri.MaxIndexCount || - SrcTri.IndexType != DstTri.IndexType || - SrcTri.AllowsTransforms != DstTri.AllowsTransforms) + SrcTri.MaxIndexCount != DstTri.MaxIndexCount || + SrcTri.IndexType != DstTri.IndexType || + SrcTri.AllowsTransforms != DstTri.AllowsTransforms) + // clang-format on { - LOG_ERROR_MESSAGE("IDeviceContext::CopyBLAS: different triangles description at index: ", i, ", pDst must have been created with the same parameters as pSrc"); + LOG_ERROR_MESSAGE("IDeviceContext::CopyBLAS: different triangle descriptions at index: ", i, ", pDst must have been created with the same parameters as pSrc"); return false; } } @@ -2180,7 +2182,7 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::CopyBLAS(const Copy { if (SrcDesc.pBoxes[i].MaxBoxCount != DstDesc.pBoxes[i].MaxBoxCount) { - LOG_ERROR_MESSAGE("IDeviceContext::CopyBLAS: different boxes description at index: ", i, ", pDst must have been created with the same parameters as pSrc"); + LOG_ERROR_MESSAGE("IDeviceContext::CopyBLAS: different box descriptions at index: ", i, ", pDst must have been created with the same parameters as pSrc"); return false; } } diff --git a/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp b/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp index d615450a..44c99c7c 100644 --- a/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp +++ b/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp @@ -30,12 +30,13 @@ /// \file /// Implementation of the Diligent::ShaderBindingTableBase template class +#include <map> + #include "ShaderBindingTable.h" #include "DeviceObjectBase.hpp" #include "RenderDeviceBase.hpp" #include "StringPool.hpp" #include "StringView.hpp" -#include <map> namespace Diligent { @@ -52,12 +53,15 @@ class ShaderBindingTableBase : public DeviceObjectBase<BaseInterface, RenderDevi public: using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, ShaderBindingTableDesc>; - /// \param pRefCounters - reference counters object that controls the lifetime of this SBT. - /// \param pDevice - pointer to the device. - /// \param Desc - SBT description. + /// \param pRefCounters - reference counters object that controls the lifetime of this SBT. + /// \param pDevice - pointer to the device. + /// \param Desc - SBT description. /// \param bIsDeviceInternal - flag indicating if the BLAS is an internal device object and /// must not keep a strong reference to the device. - ShaderBindingTableBase(IReferenceCounters* pRefCounters, RenderDeviceImplType* pDevice, const ShaderBindingTableDesc& Desc, bool bIsDeviceInternal = false) : + ShaderBindingTableBase(IReferenceCounters* pRefCounters, + RenderDeviceImplType* pDevice, + const ShaderBindingTableDesc& Desc, + bool bIsDeviceInternal = false) : TDeviceObjectBase{pRefCounters, pDevice, Desc, bIsDeviceInternal} { ValidateShaderBindingTableDesc(Desc); @@ -74,12 +78,12 @@ protected: if (Desc.pPSO == nullptr) { - LOG_SBT_ERROR_AND_THROW("PipelineState must not be null"); + LOG_SBT_ERROR_AND_THROW("pPSO must not be null"); } if (Desc.pPSO->GetDesc().PipelineType != PIPELINE_TYPE_RAY_TRACING) { - LOG_SBT_ERROR_AND_THROW("PipelineState must be ray tracing pipeline"); + LOG_SBT_ERROR_AND_THROW("pPSO must be ray tracing pipeline"); } #undef LOG_SBT_ERROR_AND_THROW @@ -88,9 +92,9 @@ protected: IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_ShaderBindingTable, TDeviceObjectBase) protected: - std::map<StringView, Uint32> m_NameToIndex; + std::map<StringView, Uint32> m_NameToIndex; // TODO (AZ): use unordered_map? StringPool m_StringPool; - std::map<StringView, TLASInstanceDesc> m_Instances; + std::map<StringView, TLASInstanceDesc> m_Instances; // TODO (AZ): use unordered_map? }; } // namespace Diligent diff --git a/Graphics/GraphicsEngine/include/TopLevelASBase.hpp b/Graphics/GraphicsEngine/include/TopLevelASBase.hpp index 143cf54f..7c207a9d 100644 --- a/Graphics/GraphicsEngine/include/TopLevelASBase.hpp +++ b/Graphics/GraphicsEngine/include/TopLevelASBase.hpp @@ -52,12 +52,15 @@ class TopLevelASBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplTy public: using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, TopLevelASDesc>; - /// \param pRefCounters - reference counters object that controls the lifetime of this BLAS. - /// \param pDevice - pointer to the device. - /// \param Desc - TLAS description. + /// \param pRefCounters - reference counters object that controls the lifetime of this BLAS. + /// \param pDevice - pointer to the device. + /// \param Desc - TLAS description. /// \param bIsDeviceInternal - flag indicating if the BLAS is an internal device object and /// must not keep a strong reference to the device. - TopLevelASBase(IReferenceCounters* pRefCounters, RenderDeviceImplType* pDevice, const TopLevelASDesc& Desc, bool bIsDeviceInternal = false) : + TopLevelASBase(IReferenceCounters* pRefCounters, + RenderDeviceImplType* pDevice, + const TopLevelASDesc& Desc, + bool bIsDeviceInternal = false) : TDeviceObjectBase{pRefCounters, pDevice, Desc, bIsDeviceInternal} { ValidateTopLevelASDesc(Desc); @@ -89,7 +92,7 @@ public: Desc.contributionToHitGroupIndex = inst.contributionToHitGroupIndex; Desc.pBLAS = inst.pBLAS; - bool IsUniqueName = m_Instances.insert_or_assign(StringView{NameCopy}, Desc).second; + bool IsUniqueName = m_Instances.emplace(StringView{NameCopy}, Desc).second; if (!IsUniqueName) LOG_ERROR_AND_THROW("Instance name must be unique!"); } @@ -104,12 +107,14 @@ public: auto iter = m_Instances.find(StringView{Name}); if (iter != m_Instances.end()) { - Result.contributionToHitGroupIndex = iter->second.contributionToHitGroupIndex; + Result.ContributionToHitGroupIndex = iter->second.contributionToHitGroupIndex; Result.pBLAS = iter->second.pBLAS; - return Result; + } + else + { + UNEXPECTED("Can't find instance with the specified name ('", Name, "')"); } - UNEXPECTED("Can't find instance with specified name"); return Result; } @@ -123,9 +128,10 @@ protected: LOG_TLAS_ERROR_AND_THROW("MaxInstanceCount must not be zero"); } - if (!!(Desc.Flags & RAYTRACING_BUILD_AS_PREFER_FAST_TRACE) + !!(Desc.Flags & RAYTRACING_BUILD_AS_PREFER_FAST_BUILD)) + if ((Desc.Flags & RAYTRACING_BUILD_AS_PREFER_FAST_TRACE) != 0 || + (Desc.Flags & RAYTRACING_BUILD_AS_PREFER_FAST_BUILD) != 0) { - LOG_TLAS_ERROR_AND_THROW("Used incompatible flags: RAYTRACING_BUILD_AS_PREFER_FAST_TRACE and RAYTRACING_BUILD_AS_PREFER_FAST_BUILD"); + LOG_TLAS_ERROR_AND_THROW("RAYTRACING_BUILD_AS_PREFER_FAST_TRACE and RAYTRACING_BUILD_AS_PREFER_FAST_BUILD are invalid"); } #undef LOG_TLAS_ERROR_AND_THROW @@ -141,7 +147,7 @@ protected: }; StringPool m_StringPool; - std::map<StringView, InstanceDesc> m_Instances; + std::map<StringView, InstanceDesc> m_Instances; // TODO(AZ): use unordered_map? }; } // namespace Diligent diff --git a/Graphics/GraphicsEngine/interface/BottomLevelAS.h b/Graphics/GraphicsEngine/interface/BottomLevelAS.h index 507f461c..cc8c4aec 100644 --- a/Graphics/GraphicsEngine/interface/BottomLevelAS.h +++ b/Graphics/GraphicsEngine/interface/BottomLevelAS.h @@ -49,15 +49,15 @@ static const INTERFACE_ID IID_BottomLevelAS = /// AZ TODO struct BLASTriangleDesc { - /// The geometry name. - /// Name used only to map BLASBuildTriangleData to this geometry. + /// Geometry name. + /// The name is used to map BLASBuildTriangleData to this geometry. const char* GeometryName DEFAULT_INITIALIZER(nullptr); /// The maximum vertex count for this geometry. - /// Current number of vertices defined in BLASBuildTriangleData::VertexCount. + /// Current number of vertices is defined in BLASBuildTriangleData::VertexCount. Uint32 MaxVertexCount DEFAULT_INITIALIZER(0); - /// The vertices value type of this geometry. + /// The type of vertices in this geometry. /// Float, Int16 are supported. VALUE_TYPE VertexValueType DEFAULT_INITIALIZER(VT_UNDEFINED); @@ -66,11 +66,11 @@ struct BLASTriangleDesc Uint8 VertexComponentCount DEFAULT_INITIALIZER(0); /// The maximum index count for this geometry. - /// Current number of indices defined in BLASBuildTriangleData::IndexCount. - /// Must be 0 if IndexType is VT_UNDEFINED and greater than zero otherwise. + /// The current number of indices is defined in BLASBuildTriangleData::IndexCount. + /// It must be 0 if IndexType is VT_UNDEFINED and greater than zero otherwise. Uint32 MaxIndexCount DEFAULT_INITIALIZER(0); - /// The indices type of this geometry. + /// Index type of this geometry. /// Must be VT_UINT16, VT_UINT32 or VT_UNDEFINED. VALUE_TYPE IndexType DEFAULT_INITIALIZER(VT_UNDEFINED); @@ -90,8 +90,8 @@ typedef struct BLASTriangleDesc BLASTriangleDesc; /// AZ TODO struct BLASBoundingBoxDesc { - /// The geometry name. - /// Name used only to map BLASBuildBoundingBoxData to this geometry. + /// Geometry name. + /// The name is used to map BLASBuildBoundingBoxData to this geometry. const char* GeometryName DEFAULT_INITIALIZER(nullptr); /// The maximum AABBs count. @@ -127,7 +127,8 @@ DILIGENT_TYPED_ENUM(RAYTRACING_BUILD_AS_FLAGS, Uint8) /// Indicates that the given acceleration structure build should prioritize build time over trace performance. RAYTRACING_BUILD_AS_PREFER_FAST_BUILD = 0x08, - /// Indicates that this acceleration structure should minimize the size of the scratch memory and the final result build, potentially at the expense of build time or trace performance. + /// Indicates that this acceleration structure should minimize the size of the scratch memory and the final + /// result build, potentially at the expense of build time or trace performance. RAYTRACING_BUILD_AS_LOW_MEMORY = 0x10, RAYTRACING_BUILD_AS_FLAGS_LAST = 0x10 @@ -144,16 +145,16 @@ struct BottomLevelASDesc DILIGENT_DERIVE(DeviceObjectAttribs) /// Array of triangle geometry descriptions. const BLASTriangleDesc* pTriangles DEFAULT_INITIALIZER(nullptr); - /// Number of triangle geometries. + /// The number of triangle geometries in pTriangles array. Uint32 TriangleCount DEFAULT_INITIALIZER(0); /// Array of AABB geometry descriptions. const BLASBoundingBoxDesc* pBoxes DEFAULT_INITIALIZER(nullptr); - /// Number of AABB geometries; + /// The number of AABB geometries in pBoxes array. Uint32 BoxCount DEFAULT_INITIALIZER(0); - /// AZ TODO + /// Ray tracing build flags, see Diligent::RAYTRACING_BUILD_AS_FLAGS. RAYTRACING_BUILD_AS_FLAGS Flags DEFAULT_INITIALIZER(RAYTRACING_BUILD_AS_NONE); /// Defines which command queues this BLAS can be used with diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h index 7491a14f..a294b066 100644 --- a/Graphics/GraphicsEngine/interface/DeviceContext.h +++ b/Graphics/GraphicsEngine/interface/DeviceContext.h @@ -725,19 +725,20 @@ DILIGENT_TYPED_ENUM(RAYTRACING_INSTANCE_FLAGS, Uint8) /// AZ TODO RAYTRACING_INSTANCE_NONE = 0, - // Disables face culling for this instance. + /// Disables face culling for this instance. RAYTRACING_INSTANCE_TRIANGLE_FACING_CULL_DISABLE = 0x01, - // Indicates that the front face of the triangle for culling purposes is the face that is counter clockwise in object space relative to the ray origin. - // Because the facing is determined in object space, an instance transform matrix does not change the winding, but a geometry transform does. + /// Indicates that the front face of the triangle for culling purposes is the face that is counter + /// clockwise in object space relative to the ray origin. Because the facing is determined in object + /// space, an instance transform matrix does not change the winding, but a geometry transform does. RAYTRACING_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE = 0x02, - // Causes this instance to act as though RAYTRACING_GEOMETRY_FLAGS_OPAQUE were specified on all geometries referenced by this instance. - // This behavior can be overridden by the SPIR-V NoOpaqueKHR ray flag. + /// Causes this instance to act as though RAYTRACING_GEOMETRY_FLAGS_OPAQUE were specified on all + /// geometries referenced by this instance. This behavior can be overridden by the SPIR-V NoOpaqueKHR ray flag. RAYTRACING_INSTANCE_FORCE_OPAQUE = 0x04, - // causes this instance to act as though RAYTRACING_GEOMETRY_FLAGS_OPAQUE were not specified on all geometries referenced by this instance. - // This behavior can be overridden by the SPIR-V OpaqueKHR ray flag. + /// causes this instance to act as though RAYTRACING_GEOMETRY_FLAGS_OPAQUE were not specified on all + /// geometries referenced by this instance. This behavior can be overridden by the SPIR-V OpaqueKHR ray flag. RAYTRACING_INSTANCE_FORCE_NO_OPAQUE = 0x08, RAYTRACING_INSTANCE_FLAGS_LAST = 0x08 @@ -746,8 +747,8 @@ DILIGENT_TYPED_ENUM(RAYTRACING_INSTANCE_FLAGS, Uint8) /// AZ TODO DILIGENT_TYPED_ENUM(COPY_AS_MODE, Uint8) { - // creates a direct copy of the acceleration structure specified in src into the one specified by dst. - // The dst acceleration structure must have been created with the same parameters as src. + /// Creates a direct copy of the acceleration structure specified in src into the one specified by dst. + /// The dst acceleration structure must have been created with the same parameters as src. COPY_AS_MODE_CLONE = 0, // creates a more compact version of an acceleration structure src into dst. @@ -766,11 +767,11 @@ DILIGENT_TYPED_ENUM(RAYTRACING_GEOMETRY_FLAGS, Uint8) /// AZ TODO RAYTRACING_GEOMETRY_NONE = 0, - // Indicates that this geometry does not invoke the any-hit shaders even if present in a hit group. + /// Indicates that this geometry does not invoke the any-hit shaders even if present in a hit group. RAYTRACING_GEOMETRY_OPAQUE = 0x01, - // Indicates that the implementation must only call the any-hit shader a single time for each primitive in this geometry. - // If this bit is absent an implementation may invoke the any-hit shader more than once for this geometry. + /// Indicates that the implementation must only call the any-hit shader a single time for each primitive in this geometry. + /// If this bit is absent an implementation may invoke the any-hit shader more than once for this geometry. RAYTRACING_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION = 0x02, RAYTRACING_GEOMETRY_FLAGS_LAST = 0x02 @@ -860,6 +861,7 @@ struct BLASBuildBoundingBoxData }; typedef struct BLASBuildBoundingBoxData BLASBuildBoundingBoxData; + /// AZ TODO struct BLASBuildAttribs { @@ -897,8 +899,10 @@ struct BLASBuildAttribs }; typedef struct BLASBuildAttribs BLASBuildAttribs; + /// AZ TODO -const Uint32 TLAS_INSTANCE_OFFSET_AUTO = ~0u; +static const Uint32 TLAS_INSTANCE_OFFSET_AUTO = ~0u; + /// AZ TODO struct TLASBuildInstanceData @@ -931,6 +935,7 @@ struct TLASBuildInstanceData }; typedef struct TLASBuildInstanceData TLASBuildInstanceData; + /// AZ TODO struct TLASBuildAttribs { @@ -974,6 +979,7 @@ struct TLASBuildAttribs }; typedef struct TLASBuildAttribs TLASBuildAttribs; + /// AZ TODO struct CopyBLASAttribs { @@ -996,6 +1002,7 @@ struct CopyBLASAttribs }; typedef struct CopyBLASAttribs CopyBLASAttribs; + /// AZ TODO struct CopyTLASAttribs { @@ -1018,6 +1025,7 @@ struct CopyTLASAttribs }; typedef struct CopyTLASAttribs CopyTLASAttribs; + /// AZ TODO struct TraceRaysAttribs { @@ -1039,6 +1047,7 @@ struct TraceRaysAttribs }; typedef struct TraceRaysAttribs TraceRaysAttribs; + #define DILIGENT_INTERFACE_NAME IDeviceContext #include "../../../Primitives/interface/DefineInterfaceHelperMacros.h" diff --git a/Graphics/GraphicsEngine/interface/PipelineState.h b/Graphics/GraphicsEngine/interface/PipelineState.h index 7e17cdd4..2ea0d224 100644 --- a/Graphics/GraphicsEngine/interface/PipelineState.h +++ b/Graphics/GraphicsEngine/interface/PipelineState.h @@ -354,6 +354,7 @@ struct PipelineStateDesc DILIGENT_DERIVE(DeviceObjectAttribs) /// Compute pipeline state description. This memeber is ignored if PipelineType is not PIPELINE_TYPE_COMPUTE ComputePipelineDesc ComputePipeline; + // TODO (AZ): use pointer /// Ray tracing pipeline state description. This memeber is ignored if PipelineType is not PIPELINE_TYPE_RAY_TRACING. RayTracingPipelineDesc RayTracingPipeline; diff --git a/Graphics/GraphicsEngine/interface/RenderDevice.h b/Graphics/GraphicsEngine/interface/RenderDevice.h index 69657254..027d0f5c 100644 --- a/Graphics/GraphicsEngine/interface/RenderDevice.h +++ b/Graphics/GraphicsEngine/interface/RenderDevice.h @@ -216,21 +216,43 @@ DILIGENT_BEGIN_INTERFACE(IRenderDevice, IObject) const FramebufferDesc REF Desc, IFramebuffer** ppFramebuffer) PURE; - /// AZ TODO + + /// Creates a bottom-level acceleration structure object (BLAS). + + /// \param [in] Desc - BLAS description, see Diligent::BottomLevelASDesc for details. + /// \param [out] ppBLAS - Address of the memory location where the pointer to the + /// BLAS interface will be stored. + /// The function calls AddRef(), so that the new object will contain + /// one reference. VIRTUAL void METHOD(CreateBLAS)(THIS_ const BottomLevelASDesc REF Desc, IBottomLevelAS** ppBLAS) PURE; - /// AZ TODO + + /// Creates a top-level acceleration structure object (TLAS). + + /// \param [in] Desc - TLAS description, see Diligent::TopLevelASDesc for details. + /// \param [out] ppTLAS - Address of the memory location where the pointer to the + /// TLAS interface will be stored. + /// The function calls AddRef(), so that the new object will contain + /// one reference. VIRTUAL void METHOD(CreateTLAS)(THIS_ const TopLevelASDesc REF Desc, ITopLevelAS** ppTLAS) PURE; - /// AZ TODO + + /// Creates a shader resource binding table object (SBT). + + /// \param [in] Desc - SBT description, see Diligent::ShaderBindingTableDesc for details. + /// \param [out] ppSBT - Address of the memory location where the pointer to the + /// SBT interface will be stored. + /// The function calls AddRef(), so that the new object will contain + /// one reference. VIRTUAL void METHOD(CreateSBT)(THIS_ const ShaderBindingTableDesc REF Desc, IShaderBindingTable** ppSBT) PURE; + /// Gets the device capabilities, see Diligent::DeviceCaps for details VIRTUAL const DeviceCaps REF METHOD(GetDeviceCaps)(THIS) CONST PURE; diff --git a/Graphics/GraphicsEngine/interface/ShaderBindingTable.h b/Graphics/GraphicsEngine/interface/ShaderBindingTable.h index c2b8309c..514f9b7c 100644 --- a/Graphics/GraphicsEngine/interface/ShaderBindingTable.h +++ b/Graphics/GraphicsEngine/interface/ShaderBindingTable.h @@ -51,7 +51,7 @@ struct ShaderBindingTableDesc DILIGENT_DERIVE(DeviceObjectAttribs) /// AZ TODO IPipelineState* pPSO DEFAULT_INITIALIZER(nullptr); - // size of additional data that passed to a shader, maximum size is 4064 + // Size of the additional data passed to the shader, maximum size is 4064 bytes. Uint32 ShaderRecordSize DEFAULT_INITIALIZER(0); /// AZ TODO diff --git a/Graphics/GraphicsEngine/interface/TopLevelAS.h b/Graphics/GraphicsEngine/interface/TopLevelAS.h index 1cc30f2f..0e427864 100644 --- a/Graphics/GraphicsEngine/interface/TopLevelAS.h +++ b/Graphics/GraphicsEngine/interface/TopLevelAS.h @@ -48,21 +48,21 @@ static const INTERFACE_ID IID_TopLevelAS = /// AZ TODO DILIGENT_TYPED_ENUM(SHADER_BINDING_MODE, Uint8) { - /// Each geometry in each instance can have unique shader. + /// Each geometry in each instance can have a unique shader. SHADER_BINDING_MODE_PER_GEOMETRY = 0, - /// Each instance can have unique shader. In this mode SBT buffer will use less memory. + /// Each instance can have a unique shader. In this mode SBT buffer will use less memory. SHADER_BINDING_MODE_PER_INSTANCE, - // User must specify TLASBuildInstanceData::InstanceContributionToHitGroupIndex and use only IShaderBindingTable::BindAll() + /// The user must specify TLASBuildInstanceData::InstanceContributionToHitGroupIndex and only use IShaderBindingTable::BindAll(). SHADER_BINDING_USER_DEFINED, }; /// AZ TODO struct TopLevelASDesc DILIGENT_DERIVE(DeviceObjectAttribs) - // Here we allocate space for instances. - // Instances can be dynamicaly updated. + /// Here we allocate space for instances. + /// Instances can be dynamicaly updated. Uint32 MaxInstanceCount DEFAULT_INITIALIZER(0); /// AZ TODO @@ -86,7 +86,7 @@ typedef struct TopLevelASDesc TopLevelASDesc; struct TLASInstanceDesc { /// AZ TODO - Uint32 contributionToHitGroupIndex DEFAULT_INITIALIZER(0); + Uint32 ContributionToHitGroupIndex DEFAULT_INITIALIZER(0); /// AZ TODO IBottomLevelAS* pBLAS DEFAULT_INITIALIZER(nullptr); |
