summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorazhirnov <zh1dron@gmail.com>2020-11-13 01:11:49 +0000
committerazhirnov <zh1dron@gmail.com>2020-11-16 17:27:22 +0000
commit275afc41cf421a1a78d8d9c7e46883248689b379 (patch)
tree44c982b9bc62cb0beb4647296559cd5115e3285d /Graphics/GraphicsEngine
parentadded IntToStr instead of _itoa_s, fixed compilation (diff)
downloadDiligentCore-275afc41cf421a1a78d8d9c7e46883248689b379.tar.gz
DiligentCore-275afc41cf421a1a78d8d9c7e46883248689b379.zip
bug fix for ray tracing, fixed KHR via NV emulation.
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/BottomLevelASBase.hpp5
-rw-r--r--Graphics/GraphicsEngine/include/PipelineStateBase.hpp14
-rw-r--r--Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp15
-rw-r--r--Graphics/GraphicsEngine/include/TopLevelASBase.hpp19
-rw-r--r--Graphics/GraphicsEngine/interface/DeviceContext.h3
-rw-r--r--Graphics/GraphicsEngine/interface/PipelineState.h10
-rw-r--r--Graphics/GraphicsEngine/interface/ShaderBindingTable.h2
-rw-r--r--Graphics/GraphicsEngine/interface/TopLevelAS.h6
-rw-r--r--Graphics/GraphicsEngine/src/DeviceContextBase.cpp1
9 files changed, 15 insertions, 60 deletions
diff --git a/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp b/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp
index d95595d6..4c09607b 100644
--- a/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp
+++ b/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp
@@ -216,11 +216,6 @@ public:
return m_GeometryCount;
}
- Uint32 GetMaxGeometryCount() const
- {
- return this->m_Desc.TriangleCount + this->m_Desc.BoxCount;
- }
-
private:
void CopyGeometryDescriptionUnsafe(const BottomLevelASDesc& SrcDesc, const BLASNameToIndex* pSrcNameToIndex) noexcept(false)
{
diff --git a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
index 829437d4..ec5e7389 100644
--- a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
+++ b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
@@ -205,20 +205,6 @@ public:
return m_pRayTracingPipelineData->Desc;
}
- virtual Uint32 DILIGENT_CALL_TYPE GetShaderGroupIndex(const char* Name) const override final
- {
- VERIFY_EXPR(Name != nullptr && Name[0] != '\0');
- VERIFY_EXPR(this->m_Desc.IsRayTracingPipeline());
- VERIFY_EXPR(m_pRayTracingPipelineData != nullptr);
-
- auto iter = m_pRayTracingPipelineData->NameToGroupIndex.find(Name);
- if (iter != m_pRayTracingPipelineData->NameToGroupIndex.end())
- return iter->second;
-
- UNEXPECTED("Can't find shader group with specified name");
- return INVALID_INDEX;
- }
-
inline void CopyShaderHandle(const char* Name, void* pData, size_t DataSize) const
{
VERIFY_EXPR(this->m_Desc.IsRayTracingPipeline());
diff --git a/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp b/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp
index 9ac643c4..340d8821 100644
--- a/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp
+++ b/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp
@@ -193,13 +193,10 @@ public:
const auto Info = pTLASImpl->GetBuildInfo();
const auto Desc = pTLASImpl->GetInstanceDesc(pInstanceName);
- VERIFY_EXPR(Info.BindingMode == HIT_GROUP_BINDING_MODE_PER_GEOMETRY ||
- Info.BindingMode == HIT_GROUP_BINDING_MODE_PER_MAX_GEOMETRY);
+ VERIFY_EXPR(Info.BindingMode == HIT_GROUP_BINDING_MODE_PER_GEOMETRY);
VERIFY_EXPR(RayOffsetInHitGroupIndex < Info.HitGroupStride);
VERIFY_EXPR(Desc.ContributionToHitGroupIndex != ~0u);
-
- if (Desc.pBLAS == nullptr)
- return; // this is a disabled instance
+ VERIFY_EXPR(Desc.pBLAS != nullptr);
const Uint32 InstanceOffset = Desc.ContributionToHitGroupIndex;
const Uint32 GeometryIndex = Desc.pBLAS->GetGeometryIndex(pGeometryName);
@@ -239,10 +236,10 @@ public:
const auto Desc = pTLASImpl->GetInstanceDesc(pInstanceName);
VERIFY_EXPR(Info.BindingMode == HIT_GROUP_BINDING_MODE_PER_GEOMETRY ||
- Info.BindingMode == HIT_GROUP_BINDING_MODE_PER_MAX_GEOMETRY ||
Info.BindingMode == HIT_GROUP_BINDING_MODE_PER_INSTANCE);
VERIFY_EXPR(RayOffsetInHitGroupIndex < Info.HitGroupStride);
VERIFY_EXPR(Desc.ContributionToHitGroupIndex != INVALID_INDEX);
+ VERIFY_EXPR(Desc.pBLAS != nullptr);
const Uint32 InstanceOffset = Desc.ContributionToHitGroupIndex;
Uint32 GeometryCount = 0;
@@ -250,9 +247,8 @@ public:
switch (Info.BindingMode)
{
// clang-format off
- case HIT_GROUP_BINDING_MODE_PER_GEOMETRY: GeometryCount = Desc.pBLAS ? Desc.pBLAS->GetActualGeometryCount() : 0; break;
- case HIT_GROUP_BINDING_MODE_PER_MAX_GEOMETRY: GeometryCount = Desc.pBLAS ? Desc.pBLAS->GetDesc().TriangleCount + Desc.pBLAS->GetDesc().BoxCount: 0; break;
- case HIT_GROUP_BINDING_MODE_PER_INSTANCE: GeometryCount = 1; break;
+ case HIT_GROUP_BINDING_MODE_PER_GEOMETRY: GeometryCount = Desc.pBLAS->GetActualGeometryCount(); break;
+ case HIT_GROUP_BINDING_MODE_PER_INSTANCE: GeometryCount = 1; break;
default: UNEXPECTED("unknown binding mode");
// clang-format on
}
@@ -294,7 +290,6 @@ public:
auto* pTLASImpl = ValidatedCast<TopLevelASImplType>(pTLAS);
const auto Info = pTLASImpl->GetBuildInfo();
VERIFY_EXPR(Info.BindingMode == HIT_GROUP_BINDING_MODE_PER_GEOMETRY ||
- Info.BindingMode == HIT_GROUP_BINDING_MODE_PER_MAX_GEOMETRY ||
Info.BindingMode == HIT_GROUP_BINDING_MODE_PER_INSTANCE ||
Info.BindingMode == HIT_GROUP_BINDING_MODE_PER_ACCEL_STRUCT);
VERIFY_EXPR(RayOffsetInHitGroupIndex < Info.HitGroupStride);
diff --git a/Graphics/GraphicsEngine/include/TopLevelASBase.hpp b/Graphics/GraphicsEngine/include/TopLevelASBase.hpp
index 006d876a..c1b73ebc 100644
--- a/Graphics/GraphicsEngine/include/TopLevelASBase.hpp
+++ b/Graphics/GraphicsEngine/include/TopLevelASBase.hpp
@@ -122,7 +122,7 @@ public:
CalculateHitGroupIndex(Desc, InstanceOffset, HitGroupStride, BindingMode);
#ifdef DILIGENT_DEVELOPMENT
- Desc.Version = Desc.pBLAS ? Desc.pBLAS->GetVersion() : ~0u;
+ Desc.Version = Desc.pBLAS->GetVersion();
#endif
bool IsUniqueName = this->m_Instances.emplace(NameCopy, Desc).second;
if (!IsUniqueName)
@@ -177,9 +177,9 @@ public:
return false;
}
- auto& Desc = Iter->second;
- const auto PrevIndex = Desc.ContributionToHitGroupIndex;
- const auto* pPrevBLAS = Desc.pBLAS.template RawPtr<IBottomLevelAS>();
+ auto& Desc = Iter->second;
+ const auto PrevIndex = Desc.ContributionToHitGroupIndex;
+ const auto pPrevBLAS = Desc.pBLAS;
Desc.pBLAS = ValidatedCast<BottomLevelASType>(Inst.pBLAS);
Desc.ContributionToHitGroupIndex = Inst.ContributionToHitGroupIndex;
@@ -187,10 +187,9 @@ public:
CalculateHitGroupIndex(Desc, InstanceOffset, HitGroupStride, BindingMode);
#ifdef DILIGENT_DEVELOPMENT
- Changed = Changed || (pPrevBLAS != Inst.pBLAS);
- Changed = Changed || (Desc.pBLAS ? Desc.Version != Desc.pBLAS->GetVersion() : false);
+ Changed = Changed || (pPrevBLAS != Desc.pBLAS);
Changed = Changed || (PrevIndex != Desc.ContributionToHitGroupIndex);
- Desc.Version = Desc.pBLAS ? Desc.pBLAS->GetVersion() : ~0u;
+ Desc.Version = Desc.pBLAS->GetVersion();
#endif
}
@@ -307,9 +306,6 @@ public:
{
const InstanceDesc& Inst = NameAndInst.second;
- if (Inst.pBLAS == nullptr)
- continue;
-
if (Inst.Version != Inst.pBLAS->GetVersion())
{
LOG_ERROR_MESSAGE("Instance with name ('", NameAndInst.first.GetStr(), "') has BLAS with name ('", Inst.pBLAS->GetDesc().Name,
@@ -356,8 +352,7 @@ private:
switch (BindingMode)
{
// clang-format off
- case HIT_GROUP_BINDING_MODE_PER_GEOMETRY: InstanceOffset += Desc.pBLAS ? Desc.pBLAS->GetActualGeometryCount() * HitGroupStride : 0; break;
- case HIT_GROUP_BINDING_MODE_PER_MAX_GEOMETRY: InstanceOffset += Desc.pBLAS ? Desc.pBLAS->GetMaxGeometryCount() * HitGroupStride : 0; break;
+ case HIT_GROUP_BINDING_MODE_PER_GEOMETRY: InstanceOffset += Desc.pBLAS->GetActualGeometryCount() * HitGroupStride; break;
case HIT_GROUP_BINDING_MODE_PER_INSTANCE: InstanceOffset += HitGroupStride; break;
case HIT_GROUP_BINDING_MODE_PER_ACCEL_STRUCT: /* InstanceOffset is a constant */ break;
case HIT_GROUP_BINDING_MODE_USER_DEFINED: UNEXPECTED("TLAS_INSTANCE_OFFSET_AUTO is not compatible with HIT_GROUP_BINDING_MODE_USER_DEFINED"); break;
diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h
index 833c1dad..2b253947 100644
--- a/Graphics/GraphicsEngine/interface/DeviceContext.h
+++ b/Graphics/GraphicsEngine/interface/DeviceContext.h
@@ -1001,7 +1001,6 @@ struct TLASBuildInstanceData
/// Bottom-level AS that represents instance geometry.
/// Once built, TLAS will hold strong reference to pBLAS until next build or copy operation.
- /// Can be null to disable instance.
/// Access to the BLAS must be externally synchronized.
IBottomLevelAS* pBLAS DEFAULT_INITIALIZER(nullptr);
@@ -1052,7 +1051,7 @@ struct BuildTLASAttribs
/// A pointer to an array of InstanceCount TLASBuildInstanceData structures that contain instance data.
/// If Update is true:
/// - Any instance data can be changed.
- /// - To disable an instance, set pBLAS to null.
+ /// - To disable an instance set TLASBuildInstanceData::Mask to zero or set empty TLASBuildInstanceData::BLAS to pBLAS.
TLASBuildInstanceData const* pInstances DEFAULT_INITIALIZER(nullptr);
/// The number of instances.
diff --git a/Graphics/GraphicsEngine/interface/PipelineState.h b/Graphics/GraphicsEngine/interface/PipelineState.h
index 56e72643..b43ee206 100644
--- a/Graphics/GraphicsEngine/interface/PipelineState.h
+++ b/Graphics/GraphicsEngine/interface/PipelineState.h
@@ -592,15 +592,6 @@ DILIGENT_BEGIN_INTERFACE(IPipelineState, IDeviceObject)
/// into account vertex shader input layout, number of outputs, etc.
VIRTUAL bool METHOD(IsCompatibleWith)(THIS_
const struct IPipelineState* pPSO) CONST PURE;
-
-
- /// Returns index of shader group that is used by shader binding table.
- /// This method must only be called for a ray tracing pipeline.
-
- /// \param [in] Name - Shader group name.
- /// \return Shader group index or INVALID_INDEX if group does not exist.
- VIRTUAL Uint32 METHOD(GetShaderGroupIndex)(THIS_
- const char* Name) CONST PURE;
};
DILIGENT_END_INTERFACE
@@ -620,7 +611,6 @@ DILIGENT_END_INTERFACE
# define IPipelineState_GetStaticVariableByIndex(This, ...) CALL_IFACE_METHOD(PipelineState, GetStaticVariableByIndex, This, __VA_ARGS__)
# define IPipelineState_CreateShaderResourceBinding(This, ...) CALL_IFACE_METHOD(PipelineState, CreateShaderResourceBinding, This, __VA_ARGS__)
# define IPipelineState_IsCompatibleWith(This, ...) CALL_IFACE_METHOD(PipelineState, IsCompatibleWith, This, __VA_ARGS__)
-# define IPipelineState_GetShaderGroupIndex(This, ...) CALL_IFACE_METHOD(PipelineState, GetShaderGroupIndex, This, __VA_ARGS__)
// clang-format on
diff --git a/Graphics/GraphicsEngine/interface/ShaderBindingTable.h b/Graphics/GraphicsEngine/interface/ShaderBindingTable.h
index e79cb62a..78680cd8 100644
--- a/Graphics/GraphicsEngine/interface/ShaderBindingTable.h
+++ b/Graphics/GraphicsEngine/interface/ShaderBindingTable.h
@@ -263,7 +263,7 @@ DILIGENT_END_INTERFACE
# define IShaderBindingTable_Verify(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, Verify, This, __VA_ARGS__)
# define IShaderBindingTable_Reset(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, Reset, This, __VA_ARGS__)
-# define IShaderBindingTable_ResetHitGroups(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, ResetHitGroups, This, __VA_ARGS__)
+# define IShaderBindingTable_ResetHitGroups(This) CALL_IFACE_METHOD(ShaderBindingTable, ResetHitGroups, This)
# define IShaderBindingTable_BindRayGenShader(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, BindRayGenShader, This, __VA_ARGS__)
# define IShaderBindingTable_BindMissShader(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, BindMissShader, This, __VA_ARGS__)
# define IShaderBindingTable_BindHitGroupByIndex(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, BindHitGroupByIndex, This, __VA_ARGS__)
diff --git a/Graphics/GraphicsEngine/interface/TopLevelAS.h b/Graphics/GraphicsEngine/interface/TopLevelAS.h
index f5ced5ed..272f6c61 100644
--- a/Graphics/GraphicsEngine/interface/TopLevelAS.h
+++ b/Graphics/GraphicsEngine/interface/TopLevelAS.h
@@ -75,12 +75,6 @@ DILIGENT_TYPED_ENUM(HIT_GROUP_BINDING_MODE, Uint8)
/// Each geometry can have unique hit shader group.
/// See IShaderBindingTable::BindHitGroup().
HIT_GROUP_BINDING_MODE_PER_GEOMETRY = 0,
-
- /// Same as HIT_GROUP_BINDING_MODE_PER_GEOMETRY but space reserved for maximum number of geometries in instance.
- /// This may be useful if you update instance with new BLAS with different number of geometries but with
- /// same maximum geometry count that defined in BottomLevelASDesc::TriangleCount or BottomLevelASDesc::BoxCount.
- /// See IShaderBindingTable::BindHitGroup().
- HIT_GROUP_BINDING_MODE_PER_MAX_GEOMETRY,
/// Reserve space for each instance in TLAS so each instance can have a unique hit shader group.
/// In this mode SBT buffer will use less memory. See IShaderBindingTable::BindHitGroups().
diff --git a/Graphics/GraphicsEngine/src/DeviceContextBase.cpp b/Graphics/GraphicsEngine/src/DeviceContextBase.cpp
index bccd0cc2..72a05729 100644
--- a/Graphics/GraphicsEngine/src/DeviceContextBase.cpp
+++ b/Graphics/GraphicsEngine/src/DeviceContextBase.cpp
@@ -531,6 +531,7 @@ bool VerifyBuildTLASAttribs(const BuildTLASAttribs& Attribs)
"Only the lower 24 bits are used");
CHECK_BUILD_TLAS_ATTRIBS(Inst.InstanceName != nullptr, "pInstances[", i, "].InstanceName must not be null");
+ CHECK_BUILD_TLAS_ATTRIBS(Inst.pBLAS != nullptr, "pInstances[", i, "].pBLAS must not be null");
if (Attribs.Update)
{