summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorazhirnov <zh1dron@gmail.com>2020-11-16 17:30:23 +0000
committerazhirnov <zh1dron@gmail.com>2020-11-16 17:53:02 +0000
commit43c3821993cb3d6ec3025fa7156da8544d2a1dac (patch)
treefa5b7cc5774c7f72a307f2b0cd250e64a7abecf0 /Graphics/GraphicsEngine
parentbug fix for ray tracing, fixed KHR via NV emulation. (diff)
downloadDiligentCore-43c3821993cb3d6ec3025fa7156da8544d2a1dac.tar.gz
DiligentCore-43c3821993cb3d6ec3025fa7156da8544d2a1dac.zip
D3D12 resource binding refactoring, rename LinearAllocator to FixedLinearAllocator.
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/BottomLevelASBase.hpp6
-rw-r--r--Graphics/GraphicsEngine/include/PipelineStateBase.hpp26
-rw-r--r--Graphics/GraphicsEngine/src/BottomLevelASBase.cpp2
-rw-r--r--Graphics/GraphicsEngine/src/PipelineStateBase.cpp29
4 files changed, 49 insertions, 14 deletions
diff --git a/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp b/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp
index 4c09607b..4e061c4c 100644
--- a/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp
+++ b/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp
@@ -36,7 +36,7 @@
#include "BottomLevelAS.h"
#include "DeviceObjectBase.hpp"
#include "RenderDeviceBase.hpp"
-#include "LinearAllocator.hpp"
+#include "FixedLinearAllocator.hpp"
#include "HashUtils.hpp"
namespace Diligent
@@ -59,7 +59,7 @@ void ValidateBottomLevelASDesc(const BottomLevelASDesc& Desc) noexcept(false);
/// Copies bottom-level AS geometry description using MemPool to allocate required dynamic space.
void CopyBLASGeometryDesc(const BottomLevelASDesc& SrcDesc,
BottomLevelASDesc& DstDesc,
- LinearAllocator& MemPool,
+ FixedLinearAllocator& MemPool,
const BLASNameToIndex* pSrcNameToIndex,
BLASNameToIndex& DstNameToIndex) noexcept(false);
@@ -219,7 +219,7 @@ public:
private:
void CopyGeometryDescriptionUnsafe(const BottomLevelASDesc& SrcDesc, const BLASNameToIndex* pSrcNameToIndex) noexcept(false)
{
- LinearAllocator MemPool{GetRawAllocator()};
+ FixedLinearAllocator MemPool{GetRawAllocator()};
CopyBLASGeometryDesc(SrcDesc, this->m_Desc, MemPool, pSrcNameToIndex, this->m_NameToIndex);
this->m_pRawPtr = MemPool.Release();
}
diff --git a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
index ec5e7389..5e8293a1 100644
--- a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
+++ b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
@@ -40,7 +40,7 @@
#include "STDAllocator.hpp"
#include "EngineMemory.h"
#include "GraphicsAccessories.hpp"
-#include "LinearAllocator.hpp"
+#include "FixedLinearAllocator.hpp"
#include "HashUtils.hpp"
namespace Diligent
@@ -50,6 +50,10 @@ void ValidateGraphicsPipelineCreateInfo(const GraphicsPipelineStateCreateInfo& C
void ValidateComputePipelineCreateInfo(const ComputePipelineStateCreateInfo& CreateInfo) noexcept(false);
void ValidateRayTracingPipelineCreateInfo(IRenderDevice* pDevice, const RayTracingPipelineStateCreateInfo& CreateInfo) noexcept(false);
+void CopyRayTracingShaderGroups(std::unordered_map<HashMapStringKey, Uint32, HashMapStringKey::Hasher>& NameToGroupIndex,
+ const RayTracingPipelineStateCreateInfo& CreateInfo,
+ FixedLinearAllocator& MemPool) noexcept(false);
+
void CorrectGraphicsPipelineDesc(GraphicsPipelineDesc& GraphicsPipeline) noexcept;
/// Template class implementing base functionality for a pipeline state object.
@@ -295,7 +299,7 @@ protected:
void ReserveSpaceForPipelineDesc(const GraphicsPipelineStateCreateInfo& CreateInfo,
- LinearAllocator& MemPool) noexcept
+ FixedLinearAllocator& MemPool) noexcept
{
MemPool.AddSpace<GraphicsPipelineDesc>();
ReserveResourceLayout(CreateInfo.PSODesc.ResourceLayout, MemPool);
@@ -315,13 +319,13 @@ protected:
}
void ReserveSpaceForPipelineDesc(const ComputePipelineStateCreateInfo& CreateInfo,
- LinearAllocator& MemPool) const noexcept
+ FixedLinearAllocator& MemPool) const noexcept
{
ReserveResourceLayout(CreateInfo.PSODesc.ResourceLayout, MemPool);
}
void ReserveSpaceForPipelineDesc(const RayTracingPipelineStateCreateInfo& CreateInfo,
- LinearAllocator& MemPool) const noexcept
+ FixedLinearAllocator& MemPool) const noexcept
{
for (Uint32 i = 0; i < CreateInfo.GeneralShaderCount; ++i)
{
@@ -478,7 +482,7 @@ protected:
void InitializePipelineDesc(const GraphicsPipelineStateCreateInfo& CreateInfo,
- LinearAllocator& MemPool)
+ FixedLinearAllocator& MemPool)
{
this->m_pGraphicsPipelineDesc = MemPool.Copy(CreateInfo.GraphicsPipeline);
@@ -608,15 +612,17 @@ protected:
}
void InitializePipelineDesc(const ComputePipelineStateCreateInfo& CreateInfo,
- LinearAllocator& MemPool)
+ FixedLinearAllocator& MemPool)
{
CopyResourceLayout(CreateInfo.PSODesc.ResourceLayout, this->m_Desc.ResourceLayout, MemPool);
}
void InitializePipelineDesc(const RayTracingPipelineStateCreateInfo& CreateInfo,
- TNameToGroupIndexMap&& NameToGroupIndex,
- LinearAllocator& MemPool) noexcept
+ FixedLinearAllocator& MemPool) noexcept
{
+ TNameToGroupIndexMap NameToGroupIndex;
+ CopyRayTracingShaderGroups(NameToGroupIndex, CreateInfo, MemPool);
+
CopyResourceLayout(CreateInfo.PSODesc.ResourceLayout, this->m_Desc.ResourceLayout, MemPool);
size_t RTDataSize = sizeof(RayTracingPipelineData);
@@ -636,7 +642,7 @@ protected:
}
private:
- static void ReserveResourceLayout(const PipelineResourceLayoutDesc& SrcLayout, LinearAllocator& MemPool) noexcept
+ static void ReserveResourceLayout(const PipelineResourceLayoutDesc& SrcLayout, FixedLinearAllocator& MemPool) noexcept
{
if (SrcLayout.Variables != nullptr)
{
@@ -662,7 +668,7 @@ private:
static_assert(std::is_trivially_destructible<decltype(*SrcLayout.ImmutableSamplers)>::value, "Add destructor for this object to Destruct()");
}
- static void CopyResourceLayout(const PipelineResourceLayoutDesc& SrcLayout, PipelineResourceLayoutDesc& DstLayout, LinearAllocator& MemPool)
+ static void CopyResourceLayout(const PipelineResourceLayoutDesc& SrcLayout, PipelineResourceLayoutDesc& DstLayout, FixedLinearAllocator& MemPool)
{
if (SrcLayout.Variables != nullptr)
{
diff --git a/Graphics/GraphicsEngine/src/BottomLevelASBase.cpp b/Graphics/GraphicsEngine/src/BottomLevelASBase.cpp
index 81168f61..3d6e4fbc 100644
--- a/Graphics/GraphicsEngine/src/BottomLevelASBase.cpp
+++ b/Graphics/GraphicsEngine/src/BottomLevelASBase.cpp
@@ -105,7 +105,7 @@ void ValidateBottomLevelASDesc(const BottomLevelASDesc& Desc) noexcept(false)
void CopyBLASGeometryDesc(const BottomLevelASDesc& SrcDesc,
BottomLevelASDesc& DstDesc,
- LinearAllocator& MemPool,
+ FixedLinearAllocator& MemPool,
const BLASNameToIndex* pSrcNameToIndex,
BLASNameToIndex& DstNameToIndex) noexcept(false)
{
diff --git a/Graphics/GraphicsEngine/src/PipelineStateBase.cpp b/Graphics/GraphicsEngine/src/PipelineStateBase.cpp
index 09c33293..009f5468 100644
--- a/Graphics/GraphicsEngine/src/PipelineStateBase.cpp
+++ b/Graphics/GraphicsEngine/src/PipelineStateBase.cpp
@@ -309,6 +309,35 @@ void ValidateRayTracingPipelineCreateInfo(IRenderDevice* pDevice, const RayTraci
}
}
+void CopyRayTracingShaderGroups(std::unordered_map<HashMapStringKey, Uint32, HashMapStringKey::Hasher>& NameToGroupIndex,
+ const RayTracingPipelineStateCreateInfo& CreateInfo,
+ FixedLinearAllocator& MemPool) noexcept(false)
+{
+ const auto& PSODesc = CreateInfo.PSODesc;
+ Uint32 GroupIndex = 0;
+
+ for (Uint32 i = 0; i < CreateInfo.GeneralShaderCount; ++i)
+ {
+ bool IsUniqueName = NameToGroupIndex.emplace(HashMapStringKey{MemPool.CopyString(CreateInfo.pGeneralShaders[i].Name)}, GroupIndex++).second;
+ if (!IsUniqueName)
+ LOG_PSO_ERROR_AND_THROW("pGeneralShaders[", i, "].Name must be unique");
+ }
+ for (Uint32 i = 0; i < CreateInfo.TriangleHitShaderCount; ++i)
+ {
+ bool IsUniqueName = NameToGroupIndex.emplace(HashMapStringKey{MemPool.CopyString(CreateInfo.pTriangleHitShaders[i].Name)}, GroupIndex++).second;
+ if (!IsUniqueName)
+ LOG_PSO_ERROR_AND_THROW("pTriangleHitShaders[", i, "].Name must be unique");
+ }
+ for (Uint32 i = 0; i < CreateInfo.ProceduralHitShaderCount; ++i)
+ {
+ bool IsUniqueName = NameToGroupIndex.emplace(HashMapStringKey{MemPool.CopyString(CreateInfo.pProceduralHitShaders[i].Name)}, GroupIndex++).second;
+ if (!IsUniqueName)
+ LOG_PSO_ERROR_AND_THROW("pProceduralHitShaders[", i, "].Name must be unique");
+ }
+
+ VERIFY_EXPR(Uint32{CreateInfo.GeneralShaderCount} + Uint32{CreateInfo.TriangleHitShaderCount} + Uint32{CreateInfo.ProceduralHitShaderCount} == GroupIndex);
+}
+
#undef VALIDATE_SHADER_TYPE
#undef LOG_PSO_ERROR_AND_THROW