From 569fb5a399cdb1cb39fb10d8db1fd78ab56f6c9e Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 5 Nov 2020 17:31:31 -0800 Subject: A number of minor updates/fixes --- .../GraphicsEngine/include/DeviceContextBase.hpp | 13 ++- .../GraphicsEngine/include/PipelineStateBase.hpp | 4 +- .../include/ShaderBindingTableBase.hpp | 34 +++--- Graphics/GraphicsEngine/interface/BottomLevelAS.h | 30 ++--- Graphics/GraphicsEngine/interface/DeviceContext.h | 130 +++++++++++---------- Graphics/GraphicsEngine/interface/GraphicsTypes.h | 20 ++-- Graphics/GraphicsEngine/interface/PipelineState.h | 32 ++--- Graphics/GraphicsEngine/interface/TopLevelAS.h | 12 +- .../include/RenderDeviceD3D12Impl.hpp | 20 ++-- .../GraphicsEngineD3D12/include/RootSignature.hpp | 2 +- .../interface/ShaderBindingTableD3D12.h | 4 + .../GraphicsEngineD3D12/src/CommandContext.cpp | 4 +- .../src/D3D12TypeConversions.cpp | 8 +- .../src/DeviceContextD3D12Impl.cpp | 11 +- .../src/RenderDeviceD3D12Impl.cpp | 22 ++-- Graphics/GraphicsEngineD3D12/src/RootSignature.cpp | 6 +- .../GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp | 2 +- .../src/TopLevelASD3D12Impl.cpp | 2 +- .../include/RenderDeviceVkImpl.hpp | 23 ++-- .../include/ShaderResourceLayoutVk.hpp | 4 +- .../interface/ShaderBindingTableVk.h | 4 + .../src/PipelineStateVkImpl.cpp | 4 +- .../src/RenderDeviceVkImpl.cpp | 9 +- .../src/ShaderResourceLayoutVk.cpp | 14 +-- .../src/VulkanTypeConversions.cpp | 8 +- .../ShaderTools/include/SPIRVShaderResources.hpp | 2 +- Graphics/ShaderTools/src/SPIRVShaderResources.cpp | 18 +-- 27 files changed, 233 insertions(+), 209 deletions(-) (limited to 'Graphics') diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp index 8200012b..ee9a2dd4 100644 --- a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp +++ b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp @@ -1529,9 +1529,9 @@ inline bool DeviceContextBase:: LOG_WARNING_MESSAGE("DrawMesh command arguments are invalid: number of groups to dispatch is zero."); } - if (Attribs.ThreadGroupCount > m_pDevice->GetMaxDrawMeshTasksCount()) + if (Attribs.ThreadGroupCount > m_pDevice->GetProperties().MaxDrawMeshTasksCount) { - LOG_WARNING_MESSAGE("DrawMesh command arguments are invalid: number of groups to dispatch must be less then ", m_pDevice->GetMaxDrawMeshTasksCount()); + LOG_WARNING_MESSAGE("DrawMesh command arguments are invalid: number of groups to dispatch must be less then ", m_pDevice->GetProperties().MaxDrawMeshTasksCount); } return true; @@ -2272,11 +2272,11 @@ bool DeviceContextBase::BuildTLAS(const Bui // calculate instance data size for (Uint32 i = 0; i < Attribs.InstanceCount; ++i) { - VERIFY((Attribs.pInstances[i].CustomId & ~0x00FFFFFF) == 0, "Only first 24 bits are used"); + VERIFY((Attribs.pInstances[i].CustomId & ~0x00FFFFFF) == 0, "Only the lower 24 bits are used"); VERIFY(Attribs.pInstances[i].ContributionToHitGroupIndex == TLAS_INSTANCE_OFFSET_AUTO || (Attribs.pInstances[i].ContributionToHitGroupIndex & ~0x00FFFFFF) == 0, - "Only first 24 bits are used"); + "Only the lower 24 bits are used"); if (Attribs.pInstances[i].InstanceName == nullptr) { @@ -2302,8 +2302,9 @@ bool DeviceContextBase::BuildTLAS(const Bui if (TLASDesc.BindingMode != SHADER_BINDING_USER_DEFINED && Attribs.pInstances[i].ContributionToHitGroupIndex != TLAS_INSTANCE_OFFSET_AUTO) { - LOG_ERROR_MESSAGE("IDeviceContext::BuildTLAS: pInstances[", i, "].ContributionToHitGroupIndex must be TLAS_INSTANCE_OFFSET_AUTO " - "if TLAS created with BindingMode that is not SHADER_BINDING_USER_DEFINED"); + LOG_ERROR_MESSAGE("IDeviceContext::BuildTLAS: pInstances[", i, + "].ContributionToHitGroupIndex must be TLAS_INSTANCE_OFFSET_AUTO " + "if TLAS created with BindingMode that is not SHADER_BINDING_USER_DEFINED"); return false; } } diff --git a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp index d0685e4e..caa96110 100644 --- a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp +++ b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp @@ -361,7 +361,7 @@ protected: size_t RTDataSize = sizeof(RayTracingPipelineData); // reserve size for shader handles - const auto ShaderHandleSize = this->m_pDevice->GetShaderGroupHandleSize(); + const auto ShaderHandleSize = this->m_pDevice->GetProperties().ShaderGroupHandleSize; RTDataSize += ShaderHandleSize * (CreateInfo.GeneralShaderCount + CreateInfo.TriangleHitShaderCount + CreateInfo.ProceduralHitShaderCount); // Extra bytes are reserved to avoid compiler errors on zero-sized arrays RTDataSize -= sizeof(RayTracingPipelineData::Shaders); @@ -642,7 +642,7 @@ protected: size_t RTDataSize = sizeof(RayTracingPipelineData); // reserve size for shader handles - const auto ShaderHandleSize = this->m_pDevice->GetShaderGroupHandleSize(); + const auto ShaderHandleSize = this->m_pDevice->GetProperties().ShaderGroupHandleSize; const auto ShaderDataSize = ShaderHandleSize * (CreateInfo.GeneralShaderCount + CreateInfo.TriangleHitShaderCount + CreateInfo.ProceduralHitShaderCount); RTDataSize += ShaderDataSize; // Extra bytes are reserved to avoid compiler errors on zero-sized arrays diff --git a/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp b/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp index ce4e0e4c..cc657844 100644 --- a/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp +++ b/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp @@ -68,7 +68,7 @@ public: this->m_pPSO = ValidatedCast(this->m_Desc.pPSO); this->m_ShaderRecordSize = this->m_pPSO->GetRayTracingPipelineDesc().ShaderRecordSize; - this->m_ShaderRecordStride = this->m_ShaderRecordSize + this->m_pDevice->GetShaderGroupHandleSize(); + this->m_ShaderRecordStride = this->m_ShaderRecordSize + this->m_pDevice->GetProperties().ShaderGroupHandleSize; } ~ShaderBindingTableBase() @@ -97,7 +97,7 @@ public: this->m_Desc = Desc; this->m_pPSO = ValidatedCast(this->m_Desc.pPSO); this->m_ShaderRecordSize = this->m_pPSO->GetRayTracingPipelineDesc().ShaderRecordSize; - this->m_ShaderRecordStride = this->m_ShaderRecordSize + this->m_pDevice->GetShaderGroupHandleSize(); + this->m_ShaderRecordStride = this->m_ShaderRecordSize + this->m_pDevice->GetProperties().ShaderGroupHandleSize; } void DILIGENT_CALL_TYPE BindRayGenShader(const char* ShaderGroupName, const void* Data, Uint32 DataSize) override final @@ -108,7 +108,7 @@ public: this->m_RayGenShaderRecord.resize(this->m_ShaderRecordStride, EmptyElem); this->m_pPSO->CopyShaderHandle(ShaderGroupName, this->m_RayGenShaderRecord.data(), this->m_ShaderRecordStride); - const Uint32 GroupSize = this->m_pDevice->GetShaderGroupHandleSize(); + const Uint32 GroupSize = this->m_pDevice->GetProperties().ShaderGroupHandleSize; std::memcpy(this->m_RayGenShaderRecord.data() + GroupSize, Data, DataSize); this->m_Changed = true; } @@ -118,7 +118,7 @@ public: VERIFY_EXPR((Data == nullptr) == (DataSize == 0)); VERIFY_EXPR(Data == nullptr || (DataSize == this->m_ShaderRecordSize)); - const Uint32 GroupSize = this->m_pDevice->GetShaderGroupHandleSize(); + const Uint32 GroupSize = this->m_pDevice->GetProperties().ShaderGroupHandleSize; const Uint32 Offset = MissIndex * this->m_ShaderRecordStride; this->m_MissShadersRecord.resize(std::max(this->m_MissShadersRecord.size(), Offset + this->m_ShaderRecordStride), EmptyElem); @@ -148,7 +148,7 @@ public: const Uint32 GeometryIndex = Desc.pBLAS->GetGeometryIndex(GeometryName); const Uint32 Index = InstanceIndex + GeometryIndex * this->m_Desc.HitShadersPerInstance + RayOffsetInHitGroupIndex; const Uint32 Offset = Index * this->m_ShaderRecordStride; - const Uint32 GroupSize = this->m_pDevice->GetShaderGroupHandleSize(); + const Uint32 GroupSize = this->m_pDevice->GetProperties().ShaderGroupHandleSize; this->m_HitGroupsRecord.resize(std::max(this->m_HitGroupsRecord.size(), Offset + this->m_ShaderRecordStride), EmptyElem); @@ -190,7 +190,7 @@ public: const Uint32 BeginIndex = InstanceIndex + 0 * this->m_Desc.HitShadersPerInstance + RayOffsetInHitGroupIndex; const Uint32 EndIndex = InstanceIndex + GeometryCount * this->m_Desc.HitShadersPerInstance + RayOffsetInHitGroupIndex; - const Uint32 GroupSize = this->m_pDevice->GetShaderGroupHandleSize(); + const Uint32 GroupSize = this->m_pDevice->GetProperties().ShaderGroupHandleSize; const auto* DataPtr = static_cast(Data); this->m_HitGroupsRecord.resize(std::max(this->m_HitGroupsRecord.size(), EndIndex * this->m_ShaderRecordStride), EmptyElem); @@ -214,7 +214,7 @@ public: VERIFY_EXPR((Data == nullptr) == (DataSize == 0)); VERIFY_EXPR(Data == nullptr || (DataSize == this->m_ShaderRecordSize)); - const Uint32 GroupSize = this->m_pDevice->GetShaderGroupHandleSize(); + const Uint32 GroupSize = this->m_pDevice->GetProperties().ShaderGroupHandleSize; const Uint32 Offset = CallableIndex * this->m_ShaderRecordStride; this->m_CallableShadersRecord.resize(std::max(this->m_CallableShadersRecord.size(), Offset + this->m_ShaderRecordStride), EmptyElem); @@ -228,7 +228,7 @@ public: Uint32 ShCounter = 0; Uint32 RecCounter = 0; const auto Stride = this->m_ShaderRecordStride; - const auto ShSize = this->m_pDevice->GetShaderGroupHandleSize(); + const auto ShSize = this->m_pDevice->GetProperties().ShaderGroupHandleSize; const auto FindPattern = [&ShCounter, &RecCounter, Stride, ShSize](const std::vector& Data, const char* Name) -> bool // { for (size_t i = 0; i < Data.size(); i += Stride) @@ -281,7 +281,7 @@ public: BindingTable& HitShaderBindingTable, BindingTable& CallableShaderBindingTable) { - const auto ShaderGroupBaseAlignment = this->m_pDevice->GetShaderGroupBaseAlignment(); + const auto ShaderGroupBaseAlignment = this->m_pDevice->GetProperties().ShaderGroupBaseAlignment; const auto AlignToLarger = [ShaderGroupBaseAlignment](size_t offset) -> Uint32 { return Align(static_cast(offset), ShaderGroupBaseAlignment); @@ -367,19 +367,19 @@ protected: LOG_SBT_ERROR_AND_THROW("pPSO must be ray tracing pipeline"); } - const auto ShaderGroupHandleSize = this->m_pDevice->GetShaderGroupHandleSize(); - const auto MaxShaderRecordStride = this->m_pDevice->GetMaxShaderRecordStride(); - const auto ShaderRecordSize = Desc.pPSO->GetRayTracingPipelineDesc().ShaderRecordSize; - const auto ShaderRecordStride = ShaderRecordSize + ShaderGroupHandleSize; + const auto& DeviceProps = this->m_pDevice->GetProperties(); + const auto ShaderRecordSize = Desc.pPSO->GetRayTracingPipelineDesc().ShaderRecordSize; + const auto ShaderRecordStride = ShaderRecordSize + DeviceProps.ShaderGroupHandleSize; - if (ShaderRecordStride > MaxShaderRecordStride) + if (ShaderRecordStride > DeviceProps.MaxShaderRecordStride) { - LOG_SBT_ERROR_AND_THROW("ShaderRecordSize(", ShaderRecordSize, ") is too big, max size is: ", MaxShaderRecordStride - ShaderGroupHandleSize); + LOG_SBT_ERROR_AND_THROW("ShaderRecordSize(", ShaderRecordSize, ") is too big, max size is: ", DeviceProps.MaxShaderRecordStride - DeviceProps.ShaderGroupHandleSize); } - if (ShaderRecordStride % ShaderGroupHandleSize != 0) + if (ShaderRecordStride % DeviceProps.ShaderGroupHandleSize != 0) { - LOG_SBT_ERROR_AND_THROW("ShaderRecordSize(", ShaderRecordSize, ") plus ShaderGroupHandleSize(", ShaderGroupHandleSize, ") must be multiple of ", ShaderGroupHandleSize); + LOG_SBT_ERROR_AND_THROW("ShaderRecordSize(", ShaderRecordSize, ") plus ShaderGroupHandleSize(", DeviceProps.ShaderGroupHandleSize, + ") must be a multiple of ", DeviceProps.ShaderGroupHandleSize); } #undef LOG_SBT_ERROR_AND_THROW } diff --git a/Graphics/GraphicsEngine/interface/BottomLevelAS.h b/Graphics/GraphicsEngine/interface/BottomLevelAS.h index ac521756..cfabc1d5 100644 --- a/Graphics/GraphicsEngine/interface/BottomLevelAS.h +++ b/Graphics/GraphicsEngine/interface/BottomLevelAS.h @@ -50,27 +50,27 @@ static const INTERFACE_ID IID_BottomLevelAS = struct BLASTriangleDesc { /// Geometry name. - /// The name is used to map triangles data (BLASBuildTriangleData) to this geometry. + /// The name is used to map triangle data (BLASBuildTriangleData) to this geometry. const char* GeometryName DEFAULT_INITIALIZER(nullptr); - /// The maximum vertex count for this geometry. + /// The maximum vertex count in this geometry. /// Current number of vertices is defined in BLASBuildTriangleData::VertexCount. Uint32 MaxVertexCount DEFAULT_INITIALIZER(0); /// The type of vertices in this geometry, see Diligent::VALUE_TYPE. VALUE_TYPE VertexValueType DEFAULT_INITIALIZER(VT_UNDEFINED); - /// The number of components in vertex. + /// The number of components in the vertex. /// 2 and 3 are supported. Uint8 VertexComponentCount DEFAULT_INITIALIZER(0); - /// The maximum primitive count of this geometry. + /// The maximum primitive count in this geometry. /// The current number of primitives is defined in BLASBuildTriangleData::PrimitiveCount. Uint32 MaxPrimitiveCount DEFAULT_INITIALIZER(0); /// Index type of this geometry, see Diligent::VALUE_TYPE. /// Must be VT_UINT16, VT_UINT32 or VT_UNDEFINED. - /// If not defined then used vertex array instead of indexed vertices. + /// If not defined then vertex array is used instead of indexed vertices. VALUE_TYPE IndexType DEFAULT_INITIALIZER(VT_UNDEFINED); /// Vulkan only, allows to use transformations in BLASBuildTriangleData. @@ -83,7 +83,7 @@ struct BLASTriangleDesc typedef struct BLASTriangleDesc BLASTriangleDesc; -/// Defines bottom level acceleration structure axis aligned bounding boxes description. +/// Defines bottom level acceleration structure axis-aligned bounding boxes description. /// AABB geometry description. struct BLASBoundingBoxDesc @@ -92,8 +92,8 @@ struct BLASBoundingBoxDesc /// The name is used to map AABB data (BLASBuildBoundingBoxData) to this geometry. const char* GeometryName DEFAULT_INITIALIZER(nullptr); - /// The maximum AABBs count. - /// Current number of AABBs defined in BLASBuildBoundingBoxData::BoxCount. + /// The maximum AABB count. + /// Current number of AABBs is defined in BLASBuildBoundingBoxData::BoxCount. Uint32 MaxBoxCount DEFAULT_INITIALIZER(0); #if DILIGENT_CPP_INTERFACE @@ -113,7 +113,7 @@ DILIGENT_TYPED_ENUM(RAYTRACING_BUILD_AS_FLAGS, Uint8) /// Indicates that the specified acceleration structure can act as the source for /// a copy acceleration structure command IDeviceContext::CopyBLAS() or IDeviceContext::CopyTLAS() - /// with mode of COPY_AS_MODE_COMPACT to produce a compacted acceleration structure. + /// with COPY_AS_MODE_COMPACT mode to produce a compacted acceleration structure. RAYTRACING_BUILD_AS_ALLOW_COMPACTION = 0x02, /// Indicates that the given acceleration structure build should prioritize trace performance over build time. @@ -163,7 +163,7 @@ struct BottomLevelASDesc DILIGENT_DERIVE(DeviceObjectAttribs) typedef struct BottomLevelASDesc BottomLevelASDesc; -/// Defines scratch buffer info for acceleration structure. +/// Defines the scratch buffer info for acceleration structure. struct ScratchBufferSizes { /// Scratch buffer size for acceleration structure building. @@ -196,19 +196,19 @@ DILIGENT_BEGIN_INTERFACE(IBottomLevelAS, IDeviceObject) virtual const BottomLevelASDesc& DILIGENT_CALL_TYPE GetDesc() const override = 0; #endif - /// Returns geometry index that can be used in shader binding table. + /// Returns the geometry index that can be used in a shader binding table. - /// \param [in] Name - Geometry name that specified in BLASTriangleDesc or BLASBoundingBoxDesc. + /// \param [in] Name - Geometry name that is specified in BLASTriangleDesc or BLASBoundingBoxDesc. /// \return Geometry index. VIRTUAL Uint32 METHOD(GetGeometryIndex)(THIS_ const char* Name) CONST PURE; - /// Returns scratch buffer info for current acceleration structure. + /// Returns the scratch buffer info for the current acceleration structure. - /// \return structure object. + /// \return ScratchBufferSizes object, see Diligent::ScratchBufferSizes. VIRTUAL ScratchBufferSizes METHOD(GetScratchBufferSizes)(THIS) CONST PURE; - /// Returns native acceleration structure handle specific to the underlying graphics API + /// Returns the native acceleration structure handle specific to the underlying graphics API /// \return pointer to ID3D12Resource interface, for D3D12 implementation\n /// VkAccelerationStructureKHR handle, for Vulkan implementation diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h index 1e9bb188..d19021f1 100644 --- a/Graphics/GraphicsEngine/interface/DeviceContext.h +++ b/Graphics/GraphicsEngine/interface/DeviceContext.h @@ -720,7 +720,7 @@ struct BeginRenderPassAttribs typedef struct BeginRenderPassAttribs BeginRenderPassAttribs; -/// TLAS instance flags that used in IDeviceContext::BuildTLAS(). +/// TLAS instance flags that are used in IDeviceContext::BuildTLAS(). DILIGENT_TYPED_ENUM(RAYTRACING_INSTANCE_FLAGS, Uint8) { RAYTRACING_INSTANCE_NONE = 0, @@ -734,11 +734,11 @@ DILIGENT_TYPED_ENUM(RAYTRACING_INSTANCE_FLAGS, Uint8) 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 in shader by ray flags. + /// geometries referenced by this instance. This behavior can be overridden in the shader with ray flags. 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 shader by ray flags. + /// geometries referenced by this instance. This behavior can be overridden in the shader with ray flags. RAYTRACING_INSTANCE_FORCE_NO_OPAQUE = 0x08, RAYTRACING_INSTANCE_FLAGS_LAST = RAYTRACING_INSTANCE_FORCE_NO_OPAQUE @@ -748,7 +748,7 @@ DEFINE_FLAG_ENUM_OPERATORS(RAYTRACING_INSTANCE_FLAGS) /// Defines acceleration structure copy mode. -/// These flags are used by IDeviceContext::CopyBLAS() and IDeviceContext::CopyTLAS(). +/// These the flags used by IDeviceContext::CopyBLAS() and IDeviceContext::CopyTLAS(). DILIGENT_TYPED_ENUM(COPY_AS_MODE, Uint8) { /// Creates a direct copy of the acceleration structure specified in pSrc into the one specified by pDst. @@ -768,16 +768,16 @@ DILIGENT_TYPED_ENUM(COPY_AS_MODE, Uint8) /// Defines geometry flags for ray tracing. DILIGENT_TYPED_ENUM(RAYTRACING_GEOMETRY_FLAGS, Uint8) { - RAYTRACING_GEOMETRY_NONE = 0, + RAYTRACING_GEOMETRY_FLAG_NONE = 0, /// Indicates that this geometry does not invoke the any-hit shaders even if present in a hit group. - RAYTRACING_GEOMETRY_OPAQUE = 0x01, + RAYTRACING_GEOMETRY_FLAG_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. - RAYTRACING_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION = 0x02, + RAYTRACING_GEOMETRY_FLAG_NO_DUPLICATE_ANY_HIT_INVOCATION = 0x02, - RAYTRACING_GEOMETRY_FLAGS_LAST = RAYTRACING_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION + RAYTRACING_GEOMETRY_FLAGS_LAST = RAYTRACING_GEOMETRY_FLAG_NO_DUPLICATE_ANY_HIT_INVOCATION }; DEFINE_FLAG_ENUM_OPERATORS(RAYTRACING_GEOMETRY_FLAGS) @@ -785,55 +785,57 @@ DEFINE_FLAG_ENUM_OPERATORS(RAYTRACING_GEOMETRY_FLAGS) /// Triangle geometry data description. struct BLASBuildTriangleData { - /// Geometry name used to map geometry to hit group in shader binding table. - /// Put geometry data to geometry that allocated by BLASTriangleDesc with the same name. + /// Geometry name used to map a geometry to a hit group in the shader binding table. + /// Add geometry data to the geometry that is allocated by BLASTriangleDesc with the same name. const char* GeometryName DEFAULT_INITIALIZER(nullptr); /// Triangle vertices data source. /// Triangles are considered "inactive" if the x component of each vertex is NaN. - /// Buffer must be created with BIND_RAY_TRACING flag. + /// The buffer must be created with BIND_RAY_TRACING flag. IBuffer* pVertexBuffer DEFAULT_INITIALIZER(nullptr); /// Data offset in bytes in pVertexBuffer. Uint32 VertexOffset DEFAULT_INITIALIZER(0); - /// Stride in bytes between each vertex. + /// Stride in bytes between vertices. Uint32 VertexStride DEFAULT_INITIALIZER(0); - /// Number of triangle vertices. + /// The number of triangle vertices. /// Must be less than or equal to BLASTriangleDesc::MaxVertexCount. Uint32 VertexCount DEFAULT_INITIALIZER(0); - /// The type of vertex and number of components. - /// This is optional values. Must be undefined or same as in BLASTriangleDesc. + /// The type of the vertex components. + /// This is an optional values. Must be undefined or same as in BLASTriangleDesc. VALUE_TYPE VertexValueType DEFAULT_INITIALIZER(VT_UNDEFINED); + + /// The number of vertex components Uint8 VertexComponentCount DEFAULT_INITIALIZER(0); - /// Number of triangles. - /// Must equal to VertexCount / 3 if pIndexBuffer is null or must equal to index count / 3. + /// The number of triangles. + /// Must equal to VertexCount / 3 if pIndexBuffer is null or must be equal to index count / 3. Uint32 PrimitiveCount DEFAULT_INITIALIZER(0); /// Triangle indices data source. /// Must be null if BLASTriangleDesc::IndexType is undefined. - /// Buffer must be created with BIND_RAY_TRACING flag. + /// The buffer must be created with BIND_RAY_TRACING flag. IBuffer* pIndexBuffer DEFAULT_INITIALIZER(nullptr); /// Data offset in bytes in pIndexBuffer. Uint32 IndexOffset DEFAULT_INITIALIZER(0); - /// Type of triangle indices, see Diligent::VALUE_TYPE. - /// This is optional value. Must be undefined or same as in BLASTriangleDesc. + /// The type of triangle indices, see Diligent::VALUE_TYPE. + /// This is an optional value. Must be undefined or same as in BLASTriangleDesc. VALUE_TYPE IndexType DEFAULT_INITIALIZER(VT_UNDEFINED); /// Geometry transformation data source. - /// Buffer must be created with BIND_RAY_TRACING flag. + /// The buffer must be created with BIND_RAY_TRACING flag. IBuffer* pTransformBuffer DEFAULT_INITIALIZER(nullptr); /// Data offset in bytes in pTransformBuffer. Uint32 TransformBufferOffset DEFAULT_INITIALIZER(0); - /// Geometry flags. - RAYTRACING_GEOMETRY_FLAGS Flags DEFAULT_INITIALIZER(RAYTRACING_GEOMETRY_NONE); + /// Geometry flags, se Diligent::RAYTRACING_GEOMETRY_FLAGS. + RAYTRACING_GEOMETRY_FLAGS Flags DEFAULT_INITIALIZER(RAYTRACING_GEOMETRY_FLAG_NONE); #if DILIGENT_CPP_INTERFACE BLASBuildTriangleData() noexcept {} @@ -866,7 +868,7 @@ struct BLASBuildBoundingBoxData Uint32 BoxCount DEFAULT_INITIALIZER(0); /// Geometry flags, see Diligent::RAYTRACING_GEOMETRY_FLAGS. - RAYTRACING_GEOMETRY_FLAGS Flags DEFAULT_INITIALIZER(RAYTRACING_GEOMETRY_NONE); + RAYTRACING_GEOMETRY_FLAGS Flags DEFAULT_INITIALIZER(RAYTRACING_GEOMETRY_FLAG_NONE); #if DILIGENT_CPP_INTERFACE BLASBuildBoundingBoxData() noexcept {} @@ -890,20 +892,20 @@ struct BuildBLASAttribs /// A pointer to an array of TriangleDataCount BLASBuildTriangleData structures that contains triangle geometry data. BLASBuildTriangleData const* pTriangleData DEFAULT_INITIALIZER(nullptr); - /// Number of triangle grometries. + /// The number of triangle grometries. /// Must be less than or equal to BottomLevelASDesc::TriangleCount. Uint32 TriangleDataCount DEFAULT_INITIALIZER(0); - /// A pointer to an array of BoxDataCount BLASBuildBoundingBoxData structures that contains AABB geometry data. + /// A pointer to an array of BoxDataCount BLASBuildBoundingBoxData structures that contain AABB geometry data. BLASBuildBoundingBoxData const* pBoxData DEFAULT_INITIALIZER(nullptr); - /// Number of AABB geometries. + /// The number of AABB geometries. /// Must be less than or equal to BottomLevelASDesc::BoxCount. Uint32 BoxDataCount DEFAULT_INITIALIZER(0); - /// Buffer that used for acceleration structure building. + /// The buffer that is used for acceleration structure building. /// Must be created with BIND_RAY_TRACING. - /// Call IBottomLevelAS::GetScratchBufferSizes().Build to get minimal size for scratch buffer. + /// Call IBottomLevelAS::GetScratchBufferSizes().Build to get the minimal size for the scratch buffer. IBuffer* pScratchBuffer DEFAULT_INITIALIZER(nullptr); /// Offset from the beginning of the buffer. @@ -919,7 +921,7 @@ struct BuildBLASAttribs typedef struct BuildBLASAttribs BuildBLASAttribs; -/// Can be used in TLASBuildInstanceData::ContributionToHitGroupIndex to calculate index +/// Can be used in TLASBuildInstanceData::ContributionToHitGroupIndex to calculate the index /// depending on geometry count in TLASBuildInstanceData::pBLAS and shader binding mode in TopLevelASDesc::BindingMode. /// /// Example: @@ -934,11 +936,10 @@ static const Uint32 TLAS_INSTANCE_OFFSET_AUTO = ~0u; /// Row-major matrix struct InstanceMatrix { - /// (0.0 1.0 2.0) - /// (0.1 1.1 2.1) - rotation - /// (0.2 1.2 2.2) - /// - /// [0.3 1.3 2.3] - translation + /// rotation translation + /// ([0,0] [0,1] [0,2]) ([0,3]) + /// ([1,0] [1,1] [1,2]) ([1,3]) + /// ([2,0] [2,1] [2,2]) ([2,3]) float data [3][4]; #if DILIGENT_CPP_INTERFACE @@ -951,7 +952,7 @@ struct InstanceMatrix InstanceMatrix(const InstanceMatrix&) noexcept = default; - /// Set matrix translation. + /// Sets the translation part. InstanceMatrix& SetTranslation(float x, float y, float z) noexcept { data[0][3] = x; @@ -960,7 +961,7 @@ struct InstanceMatrix return *this; } - /// Set matrix rotation basis. + /// Sets the rotation part. InstanceMatrix& SetRotation(const float* pMatrix3x3) noexcept { data[0][0] = pMatrix3x3[0]; data[1][0] = pMatrix3x3[1]; data[2][0] = pMatrix3x3[2]; @@ -976,7 +977,7 @@ typedef struct InstanceMatrix InstanceMatrix; /// This structure is used by BuildTLASAttribs. struct TLASBuildInstanceData { - /// Instance name that used to map instance to hit group in shader binding table. + /// Instance name that is used to map an instance to a hit group in shader binding table. const char* InstanceName DEFAULT_INITIALIZER(nullptr); /// Bottom-level AS that represents instance geometry. @@ -985,20 +986,21 @@ struct TLASBuildInstanceData /// Instace to world transformation. InstanceMatrix Transform; - /// User-defined value that can be accessed in shader via InstanceID() in HLSL and gl_InstanceCustomIndex in GLSL. - /// Used only first 24 bits. + /// User-defined value that can be accessed in the shader via InstanceID() in HLSL and gl_InstanceCustomIndex in GLSL. + /// Only the lower 24 bits are used. Uint32 CustomId DEFAULT_INITIALIZER(0); /// Instance flags, see Diligent::RAYTRACING_INSTANCE_FLAGS. RAYTRACING_INSTANCE_FLAGS Flags DEFAULT_INITIALIZER(RAYTRACING_INSTANCE_NONE); /// Visibility mask for the geometry, the instance may only be hit if rayMask & instance.Mask != 0. - /// (rayMask in GLSL is a cullMask argument of traceRayEXT(), rayMask in HLSL is a InstanceInclusionMask argument of TraceRay()). + /// (rayMask in GLSL is a cullMask argument of traceRayEXT(), rayMask in HLSL is an InstanceInclusionMask argument of TraceRay()). Uint8 Mask DEFAULT_INITIALIZER(0xFF); - /// Index used to calculate hit group location in shader binding table. - /// Must be TLAS_INSTANCE_OFFSET_AUTO is TLAS created with BindingMode SHADER_BINDING_MODE_PER_GEOMETRY or SHADER_BINDING_MODE_PER_INSTANCE. - /// Used only first 24 bits. + /// The index used to calculate the hit group location in the shader binding table. + /// Must be TLAS_INSTANCE_OFFSET_AUTO if TLAS is created with BindingMode SHADER_BINDING_MODE_PER_GEOMETRY, + /// or SHADER_BINDING_MODE_PER_INSTANCE otherwise. + /// Only the lower 24 bits are used. Uint32 ContributionToHitGroupIndex DEFAULT_INITIALIZER(TLAS_INSTANCE_OFFSET_AUTO); #if DILIGENT_CPP_INTERFACE @@ -1025,19 +1027,19 @@ struct BuildTLASAttribs /// Bottom-level AS (in TLASBuildInstanceData::pBLAS) state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE). RESOURCE_STATE_TRANSITION_MODE BLASTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE); - /// A pointer to an array of InstanceCount TLASBuildInstanceData structures that contains instance data. + /// A pointer to an array of InstanceCount TLASBuildInstanceData structures that contain instance data. TLASBuildInstanceData const* pInstances DEFAULT_INITIALIZER(nullptr); - /// Number of instances. + /// The number of instances. /// Must be less than or equal to TopLevelASDesc::MaxInstanceCount. Uint32 InstanceCount DEFAULT_INITIALIZER(0); - /// Buffer that will be used to store instance data during AS building. - /// Buffer size must be at least TLAS_INSTANCE_DATA_SIZE * InstanceCount. - /// Buffer must be created with BIND_RAY_TRACING flag. + /// 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 BIND_RAY_TRACING flag. IBuffer* pInstanceBuffer DEFAULT_INITIALIZER(nullptr); - /// Offset from the beginning of the buffer to location of instance data. + /// Offset from the beginning of the buffer to the location of instance data. Uint32 InstanceBufferOffset DEFAULT_INITIALIZER(0); /// Instance buffer state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE). @@ -1046,9 +1048,9 @@ struct BuildTLASAttribs /// AZ TODO Uint32 HitShadersPerInstance DEFAULT_INITIALIZER(1); - /// Buffer that used for acceleration structure building. + /// Buffer that is used for acceleration structure building. /// Must be created with BIND_RAY_TRACING. - /// Call ITopLevelAS::GetScratchBufferSizes().Build to get minimal size for scratch buffer. + /// Call ITopLevelAS::GetScratchBufferSizes().Build to get the minimal size for the scratch buffer. IBuffer* pScratchBuffer DEFAULT_INITIALIZER(nullptr); /// Offset from the beginning of the buffer. @@ -1072,7 +1074,7 @@ struct CopyBLASAttribs /// Destination bottom-level AS. /// If Mode is COPY_AS_MODE_COMPACT then pDst must be created with CompactedSize - /// that is greater or equal to size that returned by IDeviceContext::WriteBLASCompactedSize. + /// that is greater or equal to the size returned by IDeviceContext::WriteBLASCompactedSize. IBottomLevelAS* pDst DEFAULT_INITIALIZER(nullptr); /// Acceleration structure copy mode, see Diligent::COPY_AS_MODE. @@ -1124,10 +1126,10 @@ struct WriteBLASCompactedSizeAttribs /// Bottom-level AS. IBottomLevelAS* pBLAS DEFAULT_INITIALIZER(nullptr); - /// Command will writes 64 bit value with acceleration structure compacted size into buffer. + /// The destination buffer into which a 64-bit value representing the acceleration structure compacted size will be written to. IBuffer* pDestBuffer DEFAULT_INITIALIZER(nullptr); - /// Offset from the beginning of the buffer to location of AS compacted size. + /// Offset from the beginning of the buffer to the location of the AS compacted size. Uint32 DestBufferOffset DEFAULT_INITIALIZER(0); /// Bottom-level AS state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE). @@ -1149,10 +1151,10 @@ struct WriteTLASCompactedSizeAttribs /// Top-level AS. ITopLevelAS* pTLAS DEFAULT_INITIALIZER(nullptr); - /// Command will writes 64 bit value with acceleration structure compacted size into buffer. + /// The destination buffer into which a 64-bit value representing the acceleration structure compacted size will be written to. IBuffer* pDestBuffer DEFAULT_INITIALIZER(nullptr); - /// Offset from the beginning of the buffer to location of AS compacted size. + /// Offset from the beginning of the buffer to the location of the AS compacted size. Uint32 DestBufferOffset DEFAULT_INITIALIZER(0); /// Top-level AS state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE). @@ -1174,9 +1176,9 @@ struct TraceRaysAttribs /// Shader binding table. IShaderBindingTable* pSBT DEFAULT_INITIALIZER(nullptr); - Uint32 DimensionX DEFAULT_INITIALIZER(1); ///< Number of rays dispatched in X direction. - Uint32 DimensionY DEFAULT_INITIALIZER(1); ///< Number of rays dispatched in Y direction. - Uint32 DimensionZ DEFAULT_INITIALIZER(1); ///< Number of rays dispatched in Z direction. + Uint32 DimensionX DEFAULT_INITIALIZER(1); ///< The number of rays dispatched in X direction. + Uint32 DimensionY DEFAULT_INITIALIZER(1); ///< The number of rays dispatched in Y direction. + Uint32 DimensionZ DEFAULT_INITIALIZER(1); ///< The number of rays dispatched in Z direction. /// Shader binding table buffer state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE). RESOURCE_STATE_TRANSITION_MODE SBTTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE); @@ -2083,14 +2085,14 @@ DILIGENT_BEGIN_INTERFACE(IDeviceContext, IObject) const ResolveTextureSubresourceAttribs REF ResolveAttribs) PURE; - /// Build Bottom-level acceleration structure with the specified geometries. + /// Builds a bottom-level acceleration structure with the specified geometries. /// \param [in] Attribs - Structure describing build BLAS command attributes, see Diligent::BuildBLASAttribs for details. VIRTUAL void METHOD(BuildBLAS)(THIS_ const BuildBLASAttribs REF Attribs) PURE; - /// Build Top-level acceleration structure with the specified instances. + /// Builds a top-level acceleration structure with the specified instances. /// \param [in] Attribs - Structure describing build TLAS command attributes, see Diligent::BuildTLASAttribs for details. VIRTUAL void METHOD(BuildTLAS)(THIS_ @@ -2111,14 +2113,14 @@ DILIGENT_BEGIN_INTERFACE(IDeviceContext, IObject) const CopyTLASAttribs REF Attribs) PURE; - /// Writes acceleration structure memory size to the buffer for compacting operation. + /// Writes a bottom-level acceleration structure memory size required for compacting operation to a buffer. /// \param [in] Attribs - Structure describing write BLAS compacted size command attributes, see Diligent::WriteBLASCompactedSizeAttribs for details. VIRTUAL void METHOD(WriteBLASCompactedSize)(THIS_ const WriteBLASCompactedSizeAttribs REF Attribs) PURE; - /// Writes acceleration structure memory size to the buffer for compacting operation. + /// Writes a top-level acceleration structure memory size required for compacting operation to a buffer. /// \param [in] Attribs - Structure describing write TLAS compacted size command attributes, see Diligent::WriteTLASCompactedSizeAttribs for details. VIRTUAL void METHOD(WriteTLASCompactedSize)(THIS_ diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h index cd32efc4..e9983eb0 100644 --- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h +++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h @@ -2683,16 +2683,16 @@ DILIGENT_TYPED_ENUM(RESOURCE_STATE, Uint32) /// The resource state is known to the engine, but is undefined. A resource is typically in an undefined state right after initialization. RESOURCE_STATE_UNDEFINED = 0x00001, - /// The resource is accessed as vertex buffer + /// The resource is accessed as a vertex buffer RESOURCE_STATE_VERTEX_BUFFER = 0x00002, - /// The resource is accessed as constant (uniform) buffer + /// The resource is accessed as a constant (uniform) buffer RESOURCE_STATE_CONSTANT_BUFFER = 0x00004, - /// The resource is accessed as index buffer + /// The resource is accessed as an index buffer RESOURCE_STATE_INDEX_BUFFER = 0x00008, - /// The resource is accessed as render target + /// The resource is accessed as a render target RESOURCE_STATE_RENDER_TARGET = 0x00010, /// The resource is used for unordered access @@ -2710,7 +2710,7 @@ DILIGENT_TYPED_ENUM(RESOURCE_STATE, Uint32) /// The resource is used as the destination for stream output RESOURCE_STATE_STREAM_OUT = 0x00200, - /// The resource is used as indirect draw/dispatch arguments buffer + /// The resource is used as an indirect draw/dispatch arguments buffer RESOURCE_STATE_INDIRECT_ARGUMENT = 0x00400, /// The resource is used as the destination in a copy operation @@ -2725,20 +2725,20 @@ DILIGENT_TYPED_ENUM(RESOURCE_STATE, Uint32) /// The resource is used as the source in a resolve operation RESOURCE_STATE_RESOLVE_SOURCE = 0x04000, - /// The resource is used as input attachment in a render pass subpass + /// The resource is used as an input attachment in a render pass subpass RESOURCE_STATE_INPUT_ATTACHMENT = 0x08000, /// The resource is used for present RESOURCE_STATE_PRESENT = 0x10000, - /// The resource is used as vertex/index/instance buffer in a AS building operation - /// or as acceleration structure source in a AS copy operation. + /// The resource is used as vertex/index/instance buffer in an AS building operation + /// or as an acceleration structure source in an AS copy operation. RESOURCE_STATE_BUILD_AS_READ = 0x20000, - /// The resource is used as target in a AS building or AS copy operations. + /// The resource is used as the target for AS building or AS copy operations. RESOURCE_STATE_BUILD_AS_WRITE = 0x40000, - /// The resource is used as top-level AS shader resource in a trace rays operation. + /// The resource is used as a top-level AS shader resource in a trace rays operation. RESOURCE_STATE_RAY_TRACING = 0x80000, RESOURCE_STATE_MAX_BIT = RESOURCE_STATE_RAY_TRACING, diff --git a/Graphics/GraphicsEngine/interface/PipelineState.h b/Graphics/GraphicsEngine/interface/PipelineState.h index 6c46fd27..7e592ba7 100644 --- a/Graphics/GraphicsEngine/interface/PipelineState.h +++ b/Graphics/GraphicsEngine/interface/PipelineState.h @@ -221,7 +221,7 @@ struct RayTracingGeneralShaderGroup /// Unique group name. const char* Name DEFAULT_INITIALIZER(nullptr); - /// Shader type must be SHADER_TYPE_RAY_GEN or SHADER_TYPE_RAY_MISS or SHADER_TYPE_CALLABLE. + /// Shader type must be SHADER_TYPE_RAY_GEN, SHADER_TYPE_RAY_MISS or SHADER_TYPE_CALLABLE. IShader* pShader DEFAULT_INITIALIZER(nullptr); #if DILIGENT_CPP_INTERFACE @@ -244,11 +244,11 @@ struct RayTracingTriangleHitShaderGroup const char* Name DEFAULT_INITIALIZER(nullptr); /// Closest hit shader. - /// Shader type must be SHADER_TYPE_RAY_CLOSEST_HIT. + /// The shader type must be SHADER_TYPE_RAY_CLOSEST_HIT. IShader* pClosestHitShader DEFAULT_INITIALIZER(nullptr); /// Any-hit shader. Can be null. - /// Shader type must be SHADER_TYPE_RAY_ANY_HIT. + /// The shader type must be SHADER_TYPE_RAY_ANY_HIT. IShader* pAnyHitShader DEFAULT_INITIALIZER(nullptr); // can be null #if DILIGENT_CPP_INTERFACE @@ -273,15 +273,15 @@ struct RayTracingProceduralHitShaderGroup const char* Name DEFAULT_INITIALIZER(nullptr); /// Intersection shader. - /// Shader type must be SHADER_TYPE_RAY_INTERSECTION. + /// The shader type must be SHADER_TYPE_RAY_INTERSECTION. IShader* pIntersectionShader DEFAULT_INITIALIZER(nullptr); /// Closest hit shader. Can be null. - /// Shader type must be SHADER_TYPE_RAY_CLOSEST_HIT. + /// The shader type must be SHADER_TYPE_RAY_CLOSEST_HIT. IShader* pClosestHitShader DEFAULT_INITIALIZER(nullptr); /// Any-hit shader. Can be null. - /// Shader type must be SHADER_TYPE_RAY_ANY_HIT. + /// The shader type must be SHADER_TYPE_RAY_ANY_HIT. IShader* pAnyHitShader DEFAULT_INITIALIZER(nullptr); #if DILIGENT_CPP_INTERFACE @@ -309,7 +309,7 @@ struct RayTracingPipelineDesc /// Shader record size plus shader group size (32 bytes) must not exceed 4096 bytes. Uint16 ShaderRecordSize DEFAULT_INITIALIZER(0); - /// Number of recursive call of TraceRay() in HLSL or traceRay() in GLSL. + /// Number of recursive calls of TraceRay() in HLSL or traceRay() in GLSL. Uint8 MaxRecursionDepth DEFAULT_INITIALIZER(0); // must be 0..31 (check current device limits) }; typedef struct RayTracingPipelineDesc RayTracingPipelineDesc; @@ -450,34 +450,34 @@ struct RayTracingPipelineStateCreateInfo DILIGENT_DERIVE(PipelineStateCreateInfo /// Ray tracing pipeline description. RayTracingPipelineDesc RayTracingPipeline; - /// A pointer to an array of GeneralShaderCount RayTracingGeneralShaderGroup structures that contains shader group description. + /// A pointer to an array of GeneralShaderCount RayTracingGeneralShaderGroup structures that contain shader group description. const RayTracingGeneralShaderGroup* pGeneralShaders DEFAULT_INITIALIZER(nullptr); - /// Number of general shader groups. + /// The number of general shader groups. Uint32 GeneralShaderCount DEFAULT_INITIALIZER(0); - /// A pointer to an array of TriangleHitShaderCount RayTracingTriangleHitShaderGroup structures that contains shader group description. + /// A pointer to an array of TriangleHitShaderCount RayTracingTriangleHitShaderGroup structures that contain shader group description. /// Can be null. const RayTracingTriangleHitShaderGroup* pTriangleHitShaders DEFAULT_INITIALIZER(nullptr); - /// Number of triangle hit shader groups. + /// The number of triangle hit shader groups. Uint32 TriangleHitShaderCount DEFAULT_INITIALIZER(0); - /// A pointer to an array of ProceduralHitShaderCount RayTracingProceduralHitShaderGroup structures that contains shader group description. + /// A pointer to an array of ProceduralHitShaderCount RayTracingProceduralHitShaderGroup structures that contain shader group description. /// Can be null. const RayTracingProceduralHitShaderGroup* pProceduralHitShaders DEFAULT_INITIALIZER(nullptr); - /// Number of procedural shader groups. + /// The number of procedural shader groups. Uint32 ProceduralHitShaderCount DEFAULT_INITIALIZER(0); - /// Direct3D12 only: set name of constant buffer that will be used by local root signature. + /// Direct3D12 only: the name of the constant buffer that will be used by the local root signature. /// Ignored if RayTracingPipelineDesc::ShaderRecordSize is zero. const char* pShaderRecordName DEFAULT_INITIALIZER(nullptr); - /// Direct3D12 only: set max hit shader attribute size in bytes. + /// Direct3D12 only: the maximum hit shader attribute size in bytes. Uint32 MaxAttributeSize DEFAULT_INITIALIZER(0); - /// Direct3D12 only: set max payload size in bytes. + /// Direct3D12 only: the maximum payload size in bytes. Uint32 MaxPayloadSize DEFAULT_INITIALIZER(0); }; typedef struct RayTracingPipelineStateCreateInfo RayTracingPipelineStateCreateInfo; diff --git a/Graphics/GraphicsEngine/interface/TopLevelAS.h b/Graphics/GraphicsEngine/interface/TopLevelAS.h index 2efd8518..0c02b920 100644 --- a/Graphics/GraphicsEngine/interface/TopLevelAS.h +++ b/Graphics/GraphicsEngine/interface/TopLevelAS.h @@ -68,11 +68,11 @@ struct TopLevelASDesc DILIGENT_DERIVE(DeviceObjectAttribs) /// Ray tracing build flags, see Diligent::RAYTRACING_BUILD_AS_FLAGS. RAYTRACING_BUILD_AS_FLAGS Flags DEFAULT_INITIALIZER(RAYTRACING_BUILD_AS_NONE); - /// Size from the result of IDeviceContext::WriteTLASCompactedSize() if this acceleration structure + /// The size returned by IDeviceContext::WriteTLASCompactedSize(), if this acceleration structure /// is going to be the target of a compacting copy (IDeviceContext::CopyTLAS() with COPY_AS_MODE_COMPACT). Uint32 CompactedSize DEFAULT_INITIALIZER(0); - /// Binding mode that used for TLASBuildInstanceData::ContributionToHitGroupIndex calculation, + /// Binding mode that i used for TLASBuildInstanceData::ContributionToHitGroupIndex calculation, /// see Diligent::SHADER_BINDING_MODE. SHADER_BINDING_MODE BindingMode DEFAULT_INITIALIZER(SHADER_BINDING_MODE_PER_GEOMETRY); @@ -89,10 +89,10 @@ typedef struct TopLevelASDesc TopLevelASDesc; /// Top-level AS instance description. struct TLASInstanceDesc { - /// Index that specified in TLASBuildInstanceData::ContributionToHitGroupIndex. + /// Index that corresponds to the one specified in TLASBuildInstanceData::ContributionToHitGroupIndex. Uint32 ContributionToHitGroupIndex DEFAULT_INITIALIZER(0); - /// Bottom-level AS that specified in TLASBuildInstanceData::pBLAS. + /// Bottom-level AS that is specified in TLASBuildInstanceData::pBLAS. IBottomLevelAS* pBLAS DEFAULT_INITIALIZER(nullptr); #if DILIGENT_CPP_INTERFACE @@ -121,12 +121,12 @@ DILIGENT_BEGIN_INTERFACE(ITopLevelAS, IDeviceObject) /// Returns instance description that can be used in shader binding table. - /// \param [in] Name - Instance name that specified in TLASBuildInstanceData::InstanceName. + /// \param [in] Name - Instance name that is specified in TLASBuildInstanceData::InstanceName. /// \return structure object. VIRTUAL TLASInstanceDesc METHOD(GetInstanceDesc)(THIS_ const char* Name) CONST PURE; - /// Returns scratch buffer info for current acceleration structure. + /// Returns scratch buffer info for the current acceleration structure. /// \return structure object. VIRTUAL ScratchBufferSizes METHOD(GetScratchBufferSizes)(THIS) CONST PURE; diff --git a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp index 619368fd..ad48b876 100644 --- a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp @@ -175,14 +175,20 @@ public: ID3D12Device2* GetD3D12Device2(); ID3D12Device5* GetD3D12Device5(); - ShaderVersion GetMaxShaderModel() const; - D3D_FEATURE_LEVEL GetD3DFeatureLevel() const; + struct Properties + { + const Uint32 ShaderGroupHandleSize = D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES; + const Uint32 MaxShaderRecordStride = D3D12_RAYTRACING_MAX_SHADER_RECORD_STRIDE; + const Uint32 ShaderGroupBaseAlignment = D3D12_RAYTRACING_SHADER_TABLE_BYTE_ALIGNMENT; + const Uint32 MaxDrawMeshTasksCount = 64000; - static Uint32 GetShaderGroupHandleSize() { return D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES; } - static Uint32 GetMaxShaderRecordStride() { return D3D12_RAYTRACING_MAX_SHADER_RECORD_STRIDE; } - static Uint32 GetShaderGroupBaseAlignment() { return D3D12_RAYTRACING_SHADER_TABLE_BYTE_ALIGNMENT; } + ShaderVersion MaxShaderVersion; + }; - static Uint32 GetMaxDrawMeshTasksCount() { return 64000; } + const Properties& GetProperties() const + { + return m_Properties; + } private: template @@ -217,7 +223,7 @@ private: QueryManagerD3D12 m_QueryMgr; - D3D_SHADER_MODEL m_MaxShaderModel = D3D_SHADER_MODEL_5_1; + Properties m_Properties; std::unique_ptr m_pDxCompiler; }; diff --git a/Graphics/GraphicsEngineD3D12/include/RootSignature.hpp b/Graphics/GraphicsEngineD3D12/include/RootSignature.hpp index 331c62e5..d74a7b0c 100644 --- a/Graphics/GraphicsEngineD3D12/include/RootSignature.hpp +++ b/Graphics/GraphicsEngineD3D12/include/RootSignature.hpp @@ -603,7 +603,7 @@ private: const char* m_pName = nullptr; Uint32 m_BindPoint = InvalidBindPoint; const Uint32 m_ShaderRecordSize = 0; - CComPtr m_LocalRootSignature; + CComPtr m_pd3d12RootSignature; }; } // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D12/interface/ShaderBindingTableD3D12.h b/Graphics/GraphicsEngineD3D12/interface/ShaderBindingTableD3D12.h index 18ebd984..827df3b7 100644 --- a/Graphics/GraphicsEngineD3D12/interface/ShaderBindingTableD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/ShaderBindingTableD3D12.h @@ -47,12 +47,16 @@ static const INTERFACE_ID IID_ShaderBindingTableD3D12 = IShaderBindingTableD3D12Methods ShaderBindingTableD3D12 // clang-format off +#if DILIGENT_CPP_INTERFACE // Empty structs are not allwed in C + /// Exposes Direct3D12-specific functionality of a shader binding table object. DILIGENT_BEGIN_INTERFACE(IShaderBindingTableD3D12, IShaderBindingTable) { }; DILIGENT_END_INTERFACE +#endif + #include "../../../Primitives/interface/UndefInterfaceHelperMacros.h" #if DILIGENT_C_INTERFACE diff --git a/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp b/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp index 1e301bb2..fdb93efb 100644 --- a/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp +++ b/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp @@ -224,8 +224,8 @@ void CommandContext::TransitionResource(const StateTransitionDesc& Barrier) "RESOURCE_STATE_UNKNOWN to make the engine use current resource state"); } - // RESOURCE_STATE_UNORDERED_ACCESS and RESOURCE_STATE_BUILD_AS_WRITE converted to D3D12_RESOURCE_STATE_UNORDERED_ACCESS. - // UAV barrier must be inserted between D3D12_RESOURCE_STATE_UNORDERED_ACCESS resource usage. + // RESOURCE_STATE_UNORDERED_ACCESS and RESOURCE_STATE_BUILD_AS_WRITE are converted to D3D12_RESOURCE_STATE_UNORDERED_ACCESS. + // UAV barrier must be inserted between D3D12_RESOURCE_STATE_UNORDERED_ACCESS resource usages. bool RequireUAVBarrier = (OldState == RESOURCE_STATE_UNORDERED_ACCESS || OldState == RESOURCE_STATE_BUILD_AS_WRITE) && (Barrier.NewState == RESOURCE_STATE_UNORDERED_ACCESS || Barrier.NewState == RESOURCE_STATE_BUILD_AS_WRITE); diff --git a/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp b/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp index 1f1f621c..12ece1da 100644 --- a/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp +++ b/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp @@ -609,18 +609,18 @@ DXGI_FORMAT ValueTypeToIndexType(VALUE_TYPE IndexType) D3D12_RAYTRACING_GEOMETRY_FLAGS GeometryFlagsToD3D12RTGeometryFlags(RAYTRACING_GEOMETRY_FLAGS Flags) { - static_assert(RAYTRACING_GEOMETRY_FLAGS_LAST == RAYTRACING_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION, + static_assert(RAYTRACING_GEOMETRY_FLAGS_LAST == RAYTRACING_GEOMETRY_FLAG_NO_DUPLICATE_ANY_HIT_INVOCATION, "Please update the switch below to handle the new ray tracing geometry flag"); D3D12_RAYTRACING_GEOMETRY_FLAGS Result = D3D12_RAYTRACING_GEOMETRY_FLAG_NONE; - while (Flags != RAYTRACING_GEOMETRY_NONE) + while (Flags != RAYTRACING_GEOMETRY_FLAG_NONE) { auto FlagBit = static_cast(1 << PlatformMisc::GetLSB(Uint32{Flags})); switch (FlagBit) { // clang-format off - case RAYTRACING_GEOMETRY_OPAQUE: Result |= D3D12_RAYTRACING_GEOMETRY_FLAG_OPAQUE; break; - case RAYTRACING_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION: Result |= D3D12_RAYTRACING_GEOMETRY_FLAG_NO_DUPLICATE_ANYHIT_INVOCATION; break; + case RAYTRACING_GEOMETRY_FLAG_OPAQUE: Result |= D3D12_RAYTRACING_GEOMETRY_FLAG_OPAQUE; break; + case RAYTRACING_GEOMETRY_FLAG_NO_DUPLICATE_ANY_HIT_INVOCATION: Result |= D3D12_RAYTRACING_GEOMETRY_FLAG_NO_DUPLICATE_ANYHIT_INVOCATION; break; // clang-format on default: UNEXPECTED("unknown geometry flag"); } diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp index 99e4156d..125c4d81 100644 --- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp @@ -2380,7 +2380,7 @@ void DeviceContextD3D12Impl::BuildBLAS(const BuildBLASAttribs& Attribs) d3d12AABs.AABBs.StartAddress = pBB->GetGPUAddress() + SrcBoxes.BoxOffset; d3d12AABs.AABBs.StrideInBytes = SrcBoxes.BoxStride; - VERIFY_EXPR(d3d12AABs.AABBs.StartAddress % D3D12_RAYTRACING_AABB_BYTE_ALIGNMENT == 0); + DEV_CHECK_ERR(d3d12AABs.AABBs.StartAddress % D3D12_RAYTRACING_AABB_BYTE_ALIGNMENT == 0, "AABB start address is not properly aligned"); TransitionOrVerifyBufferState(CmdCtx, *pBB, Attribs.GeometryTransitionMode, RESOURCE_STATE_BUILD_AS_READ, OpName); } @@ -2396,7 +2396,8 @@ void DeviceContextD3D12Impl::BuildBLAS(const BuildBLASAttribs& Attribs) d3d12BuildASDesc.ScratchAccelerationStructureData = pScratchD12->GetGPUAddress() + Attribs.ScratchBufferOffset; d3d12BuildASDesc.SourceAccelerationStructureData = 0; - VERIFY_EXPR(d3d12BuildASDesc.ScratchAccelerationStructureData % D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BYTE_ALIGNMENT == 0); + DEV_CHECK_ERR(d3d12BuildASDesc.ScratchAccelerationStructureData % D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BYTE_ALIGNMENT == 0, + "Scratch data address is not properly aligned"); CmdCtx.AsGraphicsContext4().BuildRaytracingAccelerationStructure(d3d12BuildASDesc, 0, nullptr); ++m_State.NumCommands; @@ -2463,8 +2464,10 @@ void DeviceContextD3D12Impl::BuildTLAS(const BuildTLASAttribs& Attribs) d3d12BuildASDesc.ScratchAccelerationStructureData = pScratchD12->GetGPUAddress() + Attribs.ScratchBufferOffset; d3d12BuildASDesc.SourceAccelerationStructureData = 0; - VERIFY_EXPR(d3d12BuildASInputs.InstanceDescs % D3D12_RAYTRACING_INSTANCE_DESCS_BYTE_ALIGNMENT == 0); - VERIFY_EXPR(d3d12BuildASDesc.ScratchAccelerationStructureData % D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BYTE_ALIGNMENT == 0); + DEV_CHECK_ERR(d3d12BuildASInputs.InstanceDescs % D3D12_RAYTRACING_INSTANCE_DESCS_BYTE_ALIGNMENT == 0, + "Instance data address is not properly aligned"); + DEV_CHECK_ERR(d3d12BuildASDesc.ScratchAccelerationStructureData % D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BYTE_ALIGNMENT == 0, + "Scratch data address is not properly algined"); CmdCtx.AsGraphicsContext4().BuildRaytracingAccelerationStructure(d3d12BuildASDesc, 0, nullptr); ++m_State.NumCommands; diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp index f8f545e7..9ea84f06 100644 --- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp @@ -68,12 +68,8 @@ static CComPtr DXGIAdapterFromD3D12Device(ID3D12Device* pd3d12Dev return nullptr; } -ShaderVersion RenderDeviceD3D12Impl::GetMaxShaderModel() const -{ - return ShaderVersion{static_cast((m_MaxShaderModel >> 4) & 0xF), static_cast(m_MaxShaderModel & 0xF)}; -} -D3D_FEATURE_LEVEL RenderDeviceD3D12Impl::GetD3DFeatureLevel() const +static D3D_FEATURE_LEVEL GetD3DFeatureLevel(ID3D12Device* pd3d12Device) { D3D_FEATURE_LEVEL FeatureLevels[] = { @@ -88,7 +84,7 @@ D3D_FEATURE_LEVEL RenderDeviceD3D12Impl::GetD3DFeatureLevel() const FeatureLevelsData.pFeatureLevelsRequested = FeatureLevels; FeatureLevelsData.NumFeatureLevels = _countof(FeatureLevels); - m_pd3d12Device->CheckFeatureSupport(D3D12_FEATURE_FEATURE_LEVELS, &FeatureLevelsData, sizeof(FeatureLevelsData)); + pd3d12Device->CheckFeatureSupport(D3D12_FEATURE_FEATURE_LEVELS, &FeatureLevelsData, sizeof(FeatureLevelsData)); return FeatureLevelsData.MaxSupportedFeatureLevel; } @@ -172,7 +168,7 @@ RenderDeviceD3D12Impl::RenderDeviceD3D12Impl(IReferenceCounters* pRefCo try { m_DeviceCaps.DevType = RENDER_DEVICE_TYPE_D3D12; - auto FeatureLevel = GetD3DFeatureLevel(); + auto FeatureLevel = GetD3DFeatureLevel(m_pd3d12Device); switch (FeatureLevel) { case D3D_FEATURE_LEVEL_12_0: @@ -210,10 +206,11 @@ RenderDeviceD3D12Impl::RenderDeviceD3D12Impl(IReferenceCounters* pRefCo m_DeviceCaps.Features.VertexPipelineUAVWritesAndAtomics = DEVICE_FEATURE_STATE_ENABLED; // Detect maximum shader model. + D3D_SHADER_MODEL MaxShaderModel = D3D_SHADER_MODEL_5_1; { // Direct3D12 supports shader model 5.1 on all feature levels. // https://docs.microsoft.com/en-us/windows/win32/direct3d12/hardware-feature-levels#feature-level-support - m_MaxShaderModel = D3D_SHADER_MODEL_5_1; + MaxShaderModel = D3D_SHADER_MODEL_5_1; // Header may not have constants for D3D_SHADER_MODEL_6_1 and above. const D3D_SHADER_MODEL Models[] = // @@ -231,13 +228,16 @@ RenderDeviceD3D12Impl::RenderDeviceD3D12Impl(IReferenceCounters* pRefCo D3D12_FEATURE_DATA_SHADER_MODEL ShaderModel = {Model}; if (SUCCEEDED(m_pd3d12Device->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &ShaderModel, sizeof(ShaderModel)))) { - m_MaxShaderModel = ShaderModel.HighestShaderModel; + MaxShaderModel = ShaderModel.HighestShaderModel; break; } } - LOG_INFO_MESSAGE("Max device shader model: ", (m_MaxShaderModel >> 4) & 0xF, '_', m_MaxShaderModel & 0xF); + LOG_INFO_MESSAGE("Max device shader model: ", (MaxShaderModel >> 4) & 0xF, '_', MaxShaderModel & 0xF); } + m_Properties.MaxShaderVersion.Major = static_cast((MaxShaderModel >> 4) & 0xF); + m_Properties.MaxShaderVersion.Minor = static_cast(MaxShaderModel & 0xF); + // Check if mesh shader is supported. bool MeshShadersSupported = false; #ifdef D3D12_H_HAS_MESH_SHADER @@ -248,7 +248,7 @@ RenderDeviceD3D12Impl::RenderDeviceD3D12Impl(IReferenceCounters* pRefCo SUCCEEDED(m_pd3d12Device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS7, &FeatureData, sizeof(FeatureData))) && FeatureData.MeshShaderTier != D3D12_MESH_SHADER_TIER_NOT_SUPPORTED; - MeshShadersSupported = (m_MaxShaderModel >= D3D_SHADER_MODEL_6_5 && MeshShadersSupported); + MeshShadersSupported = (MaxShaderModel >= D3D_SHADER_MODEL_6_5 && MeshShadersSupported); } #else if (EngineCI.Features.MeshShaders == DEVICE_FEATURE_STATE_ENABLED) diff --git a/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp b/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp index 921a6e4c..8a8bfd4d 100644 --- a/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp @@ -1156,10 +1156,10 @@ ID3D12RootSignature* LocalRootSignature::Create(ID3D12Device* pDevice) auto hr = D3D12SerializeRootSignature(&d3d12RootSignatureDesc, D3D_ROOT_SIGNATURE_VERSION_1, &signature, nullptr); CHECK_D3D_RESULT_THROW(hr, "Failed to serialize root signature"); - hr = pDevice->CreateRootSignature(0, signature->GetBufferPointer(), signature->GetBufferSize(), IID_PPV_ARGS(&m_LocalRootSignature)); - CHECK_D3D_RESULT_THROW(hr, "Failed to create root signature"); + hr = pDevice->CreateRootSignature(0, signature->GetBufferPointer(), signature->GetBufferSize(), IID_PPV_ARGS(&m_pd3d12RootSignature)); + CHECK_D3D_RESULT_THROW(hr, "Failed to create D3D12 root signature"); - return m_LocalRootSignature; + return m_pd3d12RootSignature; } } // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp index a356d73a..52c39f23 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp @@ -59,7 +59,7 @@ static ShaderVersion GetD3D12ShaderModel(RenderDeviceD3D12Impl* pDevice, const S CompilerSM = ShaderVersion{5, 1}; } - ShaderVersion DeviceSM = pDevice->GetMaxShaderModel(); + ShaderVersion DeviceSM = pDevice->GetProperties().MaxShaderVersion; ShaderVersion MaxSupportedSM = DeviceSM.Major == CompilerSM.Major ? (DeviceSM.Minor < CompilerSM.Minor ? DeviceSM : CompilerSM) : diff --git a/Graphics/GraphicsEngineD3D12/src/TopLevelASD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/TopLevelASD3D12Impl.cpp index 2d087d08..ad26155a 100644 --- a/Graphics/GraphicsEngineD3D12/src/TopLevelASD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/TopLevelASD3D12Impl.cpp @@ -112,7 +112,7 @@ TopLevelASD3D12Impl::TopLevelASD3D12Impl(IReferenceCounters* pRefCounte d3d12SRVDesc.RaytracingAccelerationStructure.Location = GetGPUAddress(); pd3d12Device->CreateShaderResourceView(nullptr, &d3d12SRVDesc, m_DescriptorHandle.GetCpuHandle()); - VERIFY_EXPR(GetGPUAddress() % D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BYTE_ALIGNMENT == 0); + DEV_CHECK_ERR(GetGPUAddress() % D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BYTE_ALIGNMENT == 0, "GPU virtual address is expect to be at least 256-byte aligned"); SetState(RESOURCE_STATE_BUILD_AS_READ); } diff --git a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.hpp index 556e3aa5..bd95d81b 100644 --- a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.hpp @@ -197,22 +197,17 @@ public: IDXCompiler* GetDxCompiler() const { return m_pDxCompiler.get(); } - Uint32 GetShaderGroupHandleSize() const + struct Properties { - return GetPhysicalDevice().GetExtProperties().RayTracing.shaderGroupHandleSize; - } - Uint32 GetMaxShaderRecordStride() const - { - return GetPhysicalDevice().GetExtProperties().RayTracing.maxShaderGroupStride; - } - Uint32 GetShaderGroupBaseAlignment() const - { - return GetPhysicalDevice().GetExtProperties().RayTracing.shaderGroupBaseAlignment; - } + const Uint32 ShaderGroupHandleSize = 0; + const Uint32 MaxShaderRecordStride = 0; + const Uint32 ShaderGroupBaseAlignment = 0; + const Uint32 MaxDrawMeshTasksCount = 0; + }; - Uint32 GetMaxDrawMeshTasksCount() const + const Properties& GetProperties() const { - return GetPhysicalDevice().GetExtProperties().MeshShader.maxDrawMeshTasksCount; + return m_Properties; } private: @@ -249,6 +244,8 @@ private: VulkanDynamicMemoryManager m_DynamicMemoryManager; std::unique_ptr m_pDxCompiler; + + Properties m_Properties; }; } // namespace Diligent diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp index bee3de1f..44a377fd 100644 --- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp +++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp @@ -198,7 +198,7 @@ public: /* 16 */ const char* const Name; /* 24 */ const ShaderResourceLayoutVk& ParentResLayout; -#ifdef DILIGENT_DEBUG +#ifdef DILIGENT_DEVELOPMENT /* 32 */ const Uint32 BufferStaticSize; /* 36 */ const Uint32 BufferStride; #endif @@ -229,7 +229,7 @@ public: Type {_Type }, ResourceDim {_ResourceDim }, IsMS {_IsMS ? Uint8{1} : Uint8{0}}, -#ifdef DILIGENT_DEBUG +#ifdef DILIGENT_DEVELOPMENT BufferStaticSize {_BufferStaticSize}, BufferStride {_BufferStride }, #endif diff --git a/Graphics/GraphicsEngineVulkan/interface/ShaderBindingTableVk.h b/Graphics/GraphicsEngineVulkan/interface/ShaderBindingTableVk.h index ee4ea3c8..10970156 100644 --- a/Graphics/GraphicsEngineVulkan/interface/ShaderBindingTableVk.h +++ b/Graphics/GraphicsEngineVulkan/interface/ShaderBindingTableVk.h @@ -46,6 +46,8 @@ static const INTERFACE_ID IID_ShaderBindingTableVk = IShaderBindingTableInclusiveMethods; \ IShaderBindingTableVkMethods ShaderBindingTableVk +#if DILIGENT_CPP_INTERFACE // Empty structs are not allwed in C + // clang-format off /// Exposes Vulkan-specific functionality of a Shader binding table object. DILIGENT_BEGIN_INTERFACE(IShaderBindingTableVk, IShaderBindingTable) @@ -54,6 +56,8 @@ DILIGENT_BEGIN_INTERFACE(IShaderBindingTableVk, IShaderBindingTable) DILIGENT_END_INTERFACE // clang-format on +#endif + #include "../../../Primitives/interface/UndefInterfaceHelperMacros.h" #if DILIGENT_C_INTERFACE diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp index a9dcc5cb..6bfd4eeb 100644 --- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp @@ -758,8 +758,8 @@ PipelineStateVkImpl::PipelineStateVkImpl(IReferenceCounters* { try { - const auto& LogicalDevice = GetDevice()->GetLogicalDevice(); - const auto ShaderGroupHandleSize = pDeviceVk->GetShaderGroupHandleSize(); + const auto& LogicalDevice = pDeviceVk->GetLogicalDevice(); + const auto ShaderGroupHandleSize = pDeviceVk->GetProperties().ShaderGroupHandleSize; std::vector vkShaderStages; std::vector ShaderModules; diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp index 4d2c01e3..addf3440 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp @@ -159,7 +159,14 @@ RenderDeviceVkImpl::RenderDeviceVkImpl(IReferenceCounters* EngineCI.DynamicHeapSize, ~Uint64{0} }, - m_pDxCompiler{CreateDXCompiler(DXCompilerTarget::Vulkan, EngineCI.pDxCompilerPath)} + m_pDxCompiler{CreateDXCompiler(DXCompilerTarget::Vulkan, EngineCI.pDxCompilerPath)}, + m_Properties + { + m_PhysicalDevice->GetExtProperties().RayTracing.shaderGroupHandleSize, + m_PhysicalDevice->GetExtProperties().RayTracing.maxShaderGroupStride, + m_PhysicalDevice->GetExtProperties().RayTracing.shaderGroupBaseAlignment, + m_PhysicalDevice->GetExtProperties().MeshShader.maxDrawMeshTasksCount + } // clang-format on { static_assert(sizeof(VulkanDescriptorPoolSize) == sizeof(Uint32) * 11, "Please add new descriptors to m_DescriptorSetAllocator and m_DynamicDescriptorPool constructors"); diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp index 7763b480..ba8d567a 100644 --- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp @@ -827,12 +827,12 @@ void ShaderResourceLayoutVk::VkResource::CacheUniformBuffer(IDeviceObject* #ifdef DILIGENT_DEVELOPMENT VerifyConstantBufferBinding(*this, GetVariableType(), ArrayInd, pBuffer, pBufferVk.RawPtr(), DstRes.pObject.RawPtr(), ParentResLayout.GetShaderName()); - if (pBufferVk->GetDesc().uiSizeInBytes != BufferStaticSize) + if (pBufferVk->GetDesc().uiSizeInBytes < BufferStaticSize) { std::stringstream ss; - ss << "binding buffer '" << pBufferVk->GetDesc().Name << "' size (" << pBufferVk->GetDesc().uiSizeInBytes - << ") doesn't match buffer size in shader (" << BufferStaticSize << ")"; - LOG_INFO_MESSAGE(ss.str()); + ss << "The size of buffer '" << pBufferVk->GetDesc().Name << "' (" << pBufferVk->GetDesc().uiSizeInBytes + << ") is not large enough for what the shader expects (" << BufferStaticSize << ")"; + LOG_ERROR_MESSAGE(ss.str()); } #endif @@ -890,9 +890,9 @@ void ShaderResourceLayoutVk::VkResource::CacheStorageBuffer(IDeviceObject* if (ViewDesc.ByteWidth < BufferStaticSize || (ViewDesc.ByteWidth - BufferStaticSize) % BufferStride != 0) { - LOG_INFO_MESSAGE("binding buffer view '", ViewDesc.Name, "' of buffer '", BuffDesc.Name, "' to shader variable '", - Name, "' in shader '", ParentResLayout.GetShaderName(), "': size mismatch, in shader buffer has static size (", - BufferStaticSize, ") and array stride (", BufferStride, "), but actual size is (", ViewDesc.ByteWidth, ")."); + LOG_ERROR_MESSAGE("Error binding buffer view '", ViewDesc.Name, "' of buffer '", BuffDesc.Name, "' to shader variable '", + Name, "' in shader '", ParentResLayout.GetShaderName(), "': static buffer size in the shader (", + BufferStaticSize, ") and array element stride (", BufferStride, ") are incompatible with the actual buffer size (", ViewDesc.ByteWidth, ")."); } } } diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp index 53719439..edfa7625 100644 --- a/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp +++ b/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp @@ -1634,18 +1634,18 @@ VkBuildAccelerationStructureFlagsKHR BuildASFlagsToVkBuildAccelerationStructureF VkGeometryFlagsKHR GeometryFlagsToVkGeometryFlags(RAYTRACING_GEOMETRY_FLAGS Flags) { - static_assert(RAYTRACING_GEOMETRY_FLAGS_LAST == RAYTRACING_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION, + static_assert(RAYTRACING_GEOMETRY_FLAGS_LAST == RAYTRACING_GEOMETRY_FLAG_NO_DUPLICATE_ANY_HIT_INVOCATION, "Please update the switch below to handle the new ray tracing geometry flag"); VkGeometryFlagsKHR Result = 0; - while (Flags != RAYTRACING_GEOMETRY_NONE) + while (Flags != RAYTRACING_GEOMETRY_FLAG_NONE) { auto FlagBit = static_cast(1 << PlatformMisc::GetLSB(Uint32{Flags})); switch (FlagBit) { // clang-format off - case RAYTRACING_GEOMETRY_OPAQUE: Result |= VK_GEOMETRY_OPAQUE_BIT_KHR; break; - case RAYTRACING_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION: Result |= VK_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION_BIT_KHR; break; + case RAYTRACING_GEOMETRY_FLAG_OPAQUE: Result |= VK_GEOMETRY_OPAQUE_BIT_KHR; break; + case RAYTRACING_GEOMETRY_FLAG_NO_DUPLICATE_ANY_HIT_INVOCATION: Result |= VK_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION_BIT_KHR; break; // clang-format on default: UNEXPECTED("unknown geometry flag"); } diff --git a/Graphics/ShaderTools/include/SPIRVShaderResources.hpp b/Graphics/ShaderTools/include/SPIRVShaderResources.hpp index 7bb35f72..97ad1303 100644 --- a/Graphics/ShaderTools/include/SPIRVShaderResources.hpp +++ b/Graphics/ShaderTools/include/SPIRVShaderResources.hpp @@ -58,7 +58,7 @@ namespace Diligent // sizeof(SPIRVShaderResourceAttribs) == 32, msvc x64 struct SPIRVShaderResourceAttribs { - enum class ResourceType : Uint8 + enum ResourceType : Uint8 { UniformBuffer = 0, ROStorageBuffer, diff --git a/Graphics/ShaderTools/src/SPIRVShaderResources.cpp b/Graphics/ShaderTools/src/SPIRVShaderResources.cpp index ceeecbe8..873180b3 100644 --- a/Graphics/ShaderTools/src/SPIRVShaderResources.cpp +++ b/Graphics/ShaderTools/src/SPIRVShaderResources.cpp @@ -381,16 +381,16 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator, Uint32 CurrUB = 0; for (const auto& UB : resources.uniform_buffers) { - const auto& name = GetUBName(Compiler, UB, ParsedIRSource); - const auto& Type = Compiler.get_type(UB.type_id); - const size_t Size = Compiler.get_declared_struct_size(Type); + const auto& name = GetUBName(Compiler, UB, ParsedIRSource); + const auto& Type = Compiler.get_type(UB.type_id); + const auto Size = Compiler.get_declared_struct_size(Type); new (&GetUB(CurrUB++)) SPIRVShaderResourceAttribs(Compiler, UB, ResourceNamesPool.CopyString(name), SPIRVShaderResourceAttribs::ResourceType::UniformBuffer, SPIRVShaderResourceAttribs::InvalidSepSmplrOrImgInd, - Uint32(Size)); + static_cast(Size)); } VERIFY_EXPR(CurrUB == GetNumUBs()); } @@ -404,17 +404,17 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator, auto ResType = IsReadOnly ? SPIRVShaderResourceAttribs::ResourceType::ROStorageBuffer : SPIRVShaderResourceAttribs::ResourceType::RWStorageBuffer; - const auto& Type = Compiler.get_type(SB.type_id); - const size_t Size = Compiler.get_declared_struct_size(Type); - const size_t Stride = Compiler.get_declared_struct_size_runtime_array(Type, 1); + const auto& Type = Compiler.get_type(SB.type_id); + const auto Size = Compiler.get_declared_struct_size(Type); + const auto Stride = Compiler.get_declared_struct_size_runtime_array(Type, 1); new (&GetSB(CurrSB++)) SPIRVShaderResourceAttribs(Compiler, SB, ResourceNamesPool.CopyString(SB.name), ResType, SPIRVShaderResourceAttribs::InvalidSepSmplrOrImgInd, - Uint32(Size), - Uint32(Stride)); + static_cast(Size), + static_cast(Stride)); } VERIFY_EXPR(CurrSB == GetNumSBs()); } -- cgit v1.2.3