summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-12-23 17:26:16 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-12-23 17:26:16 +0000
commit76a183bf0780c70191de2fca31526280e78211e9 (patch)
tree7d5c31faee501bd5ab107a060dab2e9ad136c246 /Graphics/GraphicsEngine
parentFixed few more issues in PSO create info validation (diff)
downloadDiligentCore-76a183bf0780c70191de2fca31526280e78211e9.tar.gz
DiligentCore-76a183bf0780c70191de2fca31526280e78211e9.zip
Few minor improvements to RT pipeline initialization
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/PipelineStateBase.hpp24
-rw-r--r--Graphics/GraphicsEngine/src/PipelineStateBase.cpp8
2 files changed, 20 insertions, 12 deletions
diff --git a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
index 2c46f314..79033337 100644
--- a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
+++ b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
@@ -51,9 +51,9 @@ void ValidateComputePipelineCreateInfo(const ComputePipelineStateCreateInfo& Cre
void ValidateRayTracingPipelineCreateInfo(IRenderDevice* pDevice, Uint32 MaxRecursion, const RayTracingPipelineStateCreateInfo& CreateInfo) noexcept(false);
/// Copies ray tracing shader group names and also initializes the mapping from the group name to its index.
-void CopyRayTracingShaderGroups(std::unordered_map<HashMapStringKey, Uint32, HashMapStringKey::Hasher>& NameToGroupIndex,
- const RayTracingPipelineStateCreateInfo& CreateInfo,
- FixedLinearAllocator& MemPool) noexcept;
+void CopyRTShaderGroupNames(std::unordered_map<HashMapStringKey, Uint32, HashMapStringKey::Hasher>& NameToGroupIndex,
+ const RayTracingPipelineStateCreateInfo& CreateInfo,
+ FixedLinearAllocator& MemPool) noexcept;
void CorrectGraphicsPipelineDesc(GraphicsPipelineDesc& GraphicsPipeline) noexcept;
@@ -246,7 +246,7 @@ public:
VERIFY_EXPR(m_pRayTracingPipelineData != nullptr);
const auto ShaderHandleSize = m_pRayTracingPipelineData->ShaderHandleSize;
- VERIFY_EXPR(ShaderHandleSize <= DataSize);
+ VERIFY(ShaderHandleSize <= DataSize, "DataSize (", DataSize, ") must be at least as large as the shader handle size (", ShaderHandleSize, ").");
if (Name == nullptr || Name[0] == '\0')
{
@@ -262,7 +262,7 @@ public:
std::memcpy(pData, &m_pRayTracingPipelineData->ShaderHandles[ShaderHandleSize * iter->second], ShaderHandleSize);
return;
}
- UNEXPECTED("Can't find shader group with the specified name");
+ UNEXPECTED("Can't find shader group '", Name, "'.");
}
protected:
@@ -657,7 +657,7 @@ protected:
FixedLinearAllocator& MemPool) noexcept
{
TNameToGroupIndexMap NameToGroupIndex;
- CopyRayTracingShaderGroups(NameToGroupIndex, CreateInfo, MemPool);
+ CopyRTShaderGroupNames(NameToGroupIndex, CreateInfo, MemPool);
CopyResourceLayout(CreateInfo.PSODesc.ResourceLayout, this->m_Desc.ResourceLayout, MemPool);
@@ -761,12 +761,20 @@ protected:
struct RayTracingPipelineData
{
RayTracingPipelineDesc Desc;
- TNameToGroupIndexMap NameToGroupIndex;
+
+ // Mapping from the shader group name to its index in the pipeline.
+ // It is used to find the shader handle in ShaderHandles array.
+ TNameToGroupIndexMap NameToGroupIndex;
Uint32 ShaderHandleSize = 0;
Uint32 ShaderDataSize = 0;
- Uint8 ShaderHandles[sizeof(void*)] = {}; // The actual array size will be ShaderDataSize
+ // Array of shader handles for every group in the pipeline.
+ // The handles will be copied to the SBT using NameToGroupIndex to find
+ // handles by group name.
+ // The actual array size will be determined at run time and will be stored
+ // in ShaderDataSize.
+ Uint8 ShaderHandles[sizeof(void*)] = {};
};
static_assert(offsetof(RayTracingPipelineData, ShaderHandles) % sizeof(void*) == 0, "ShaderHandles member is expected to be sizeof(void*)-aligned");
diff --git a/Graphics/GraphicsEngine/src/PipelineStateBase.cpp b/Graphics/GraphicsEngine/src/PipelineStateBase.cpp
index f99b3a0f..2f0297bf 100644
--- a/Graphics/GraphicsEngine/src/PipelineStateBase.cpp
+++ b/Graphics/GraphicsEngine/src/PipelineStateBase.cpp
@@ -278,7 +278,7 @@ void ValidateRayTracingPipelineCreateInfo(IRenderDevice* pDevice, Uint32 MaxRecu
if (GroupName == nullptr)
LOG_PSO_ERROR_AND_THROW(MemberName, "[", GroupInd, "].Name must not be null.");
- if (*GroupName == 0)
+ if (GroupName[0] == '\0')
LOG_PSO_ERROR_AND_THROW(MemberName, "[", GroupInd, "].Name must not be empty.");
const bool IsNewName = GroupNames.emplace(HashMapStringKey{GroupName}).second;
@@ -335,9 +335,9 @@ void ValidateRayTracingPipelineCreateInfo(IRenderDevice* pDevice, Uint32 MaxRecu
}
}
-void CopyRayTracingShaderGroups(std::unordered_map<HashMapStringKey, Uint32, HashMapStringKey::Hasher>& NameToGroupIndex,
- const RayTracingPipelineStateCreateInfo& CreateInfo,
- FixedLinearAllocator& MemPool) noexcept
+void CopyRTShaderGroupNames(std::unordered_map<HashMapStringKey, Uint32, HashMapStringKey::Hasher>& NameToGroupIndex,
+ const RayTracingPipelineStateCreateInfo& CreateInfo,
+ FixedLinearAllocator& MemPool) noexcept
{
Uint32 GroupIndex = 0;