summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2021-03-08 18:27:35 +0000
committerassiduous <assiduous@diligentgraphics.com>2021-03-19 00:38:17 +0000
commit1dfd5042779a493285c397d46f8d903d67c9f972 (patch)
tree4fbb33befdb618afc58a806da4d274596f47261b /Graphics/GraphicsEngine
parentShaderResourceBinding{D3D12, Vk, GL} - removed the remaining duplicate code (diff)
downloadDiligentCore-1dfd5042779a493285c397d46f8d903d67c9f972.tar.gz
DiligentCore-1dfd5042779a493285c397d46f8d903d67c9f972.zip
Resource singature: moved allocation of static resource cache and var managers to PipelineResourceSignatureBase
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp57
-rw-r--r--Graphics/GraphicsEngine/include/ShaderResourceBindingBase.hpp3
2 files changed, 36 insertions, 24 deletions
diff --git a/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp b/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp
index c2e407ee..db5cb061 100644
--- a/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp
+++ b/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp
@@ -44,6 +44,7 @@
#include "StringTools.hpp"
#include "PlatformMisc.hpp"
#include "SRBMemoryAllocator.hpp"
+#include "ShaderResourceCacheCommon.hpp"
namespace Diligent
{
@@ -377,12 +378,44 @@ public:
protected:
template <typename TReserveCustomData>
- FixedLinearAllocator ReserveSpace(IMemoryAllocator& RawAllocator,
- const PipelineResourceSignatureDesc& Desc,
- TReserveCustomData ReserveCustomData) noexcept(false)
+ FixedLinearAllocator AllocateInternalObjects(IMemoryAllocator& RawAllocator,
+ const PipelineResourceSignatureDesc& Desc,
+ TReserveCustomData ReserveCustomData) noexcept(false)
{
FixedLinearAllocator Allocator{RawAllocator};
+ ReserveSpaceForDescription(Allocator, Desc);
+
+ const auto NumStaticResStages = GetNumStaticResStages();
+ if (NumStaticResStages > 0)
+ {
+ Allocator.AddSpace<ShaderResourceCacheImplType>(1);
+ Allocator.AddSpace<ShaderVariableManagerImplType>(NumStaticResStages);
+ }
+
+ ReserveCustomData(Allocator);
+
+ Allocator.Reserve();
+ // The memory is now owned by PipelineResourceSignatureBase and will be freed by Destruct().
+ m_pRawMemory = decltype(m_pRawMemory){Allocator.ReleaseOwnership(), STDDeleterRawMem<void>{RawAllocator}};
+
+ CopyDescription(Allocator, Desc);
+
+ if (NumStaticResStages > 0)
+ {
+ m_pStaticResCache = Allocator.Construct<ShaderResourceCacheImplType>(ResourceCacheContentType::Signature);
+
+ static_assert(std::is_nothrow_constructible<ShaderVariableManagerImplType, decltype(*this), ShaderResourceCacheImplType&>::value,
+ "Constructor of ShaderVariableManagerImplType must be noexcept, so we can safely construct all manager objects");
+ m_StaticVarsMgrs = Allocator.ConstructArray<ShaderVariableManagerImplType>(NumStaticResStages, std::ref(*this), std::ref(*m_pStaticResCache));
+ }
+
+ return Allocator;
+ }
+
+private:
+ static void ReserveSpaceForDescription(FixedLinearAllocator& Allocator, const PipelineResourceSignatureDesc& Desc)
+ {
Allocator.AddSpace<PipelineResourceDesc>(Desc.NumResources);
Allocator.AddSpace<ImmutableSamplerDesc>(Desc.NumImmutableSamplers);
@@ -408,26 +441,8 @@ protected:
if (Desc.UseCombinedTextureSamplers)
Allocator.AddSpaceForString(Desc.CombinedSamplerSuffix);
-
- ReserveCustomData(Allocator);
-
- const auto NumStaticResStages = GetNumStaticResStages();
- if (NumStaticResStages > 0)
- {
- Allocator.AddSpace<ShaderResourceCacheImplType>(1);
- Allocator.AddSpace<ShaderVariableManagerImplType>(NumStaticResStages);
- }
-
- Allocator.Reserve();
- // The memory is now owned by PipelineResourceSignatureBase and will be freed by Destruct().
- m_pRawMemory = decltype(m_pRawMemory){Allocator.ReleaseOwnership(), STDDeleterRawMem<void>{RawAllocator}};
-
- CopyDescription(Allocator, Desc);
-
- return Allocator;
}
-private:
void CopyDescription(FixedLinearAllocator& Allocator, const PipelineResourceSignatureDesc& Desc) noexcept(false)
{
PipelineResourceDesc* pResources = Allocator.ConstructArray<PipelineResourceDesc>(Desc.NumResources);
diff --git a/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.hpp b/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.hpp
index 3dc62905..e6dddb0c 100644
--- a/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.hpp
+++ b/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.hpp
@@ -70,8 +70,6 @@ public:
/// \param pRefCounters - Reference counters object that controls the lifetime of this SRB.
/// \param pPRS - Pipeline resource signature that this SRB belongs to.
- /// \param IsInternal - Flag indicating if the shader resource binding is an internal object and
- /// must not keep a strong reference to the pipeline resource signature.
ShaderResourceBindingBase(IReferenceCounters* pRefCounters, ResourceSignatureType* pPRS) :
TObjectBase{pRefCounters},
m_pPRS{pPRS},
@@ -117,7 +115,6 @@ public:
auto& VarDataAllocator = SRBMemAllocator.GetShaderVariableDataAllocator(s);
- // Create shader variable manager in place
// Initialize vars manager to reference mutable and dynamic variables
// Note that the cache has space for all variable types
const SHADER_RESOURCE_VARIABLE_TYPE VarTypes[] = {SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE, SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC};