summaryrefslogtreecommitdiffstats
path: root/Graphics
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2021-03-07 21:21:43 +0000
committerassiduous <assiduous@diligentgraphics.com>2021-03-19 00:38:17 +0000
commit68bb8ce116ce83bc94d2af87563e8dc1c9fab0b4 (patch)
tree0a015869da0e3b1c3c45276be8aca3aabeaa76b0 /Graphics
parentFixed ShaderResourceLayoutTest for non-separable programs (diff)
downloadDiligentCore-68bb8ce116ce83bc94d2af87563e8dc1c9fab0b4.tar.gz
DiligentCore-68bb8ce116ce83bc94d2af87563e8dc1c9fab0b4.zip
Replaced duplicate CacheContentType enums with the common ResourceCacheContentType
Diffstat (limited to 'Graphics')
-rw-r--r--Graphics/GraphicsEngine/CMakeLists.txt1
-rw-r--r--Graphics/GraphicsEngine/include/ShaderResourceCacheCommon.hpp48
-rw-r--r--Graphics/GraphicsEngineD3D12/include/PipelineResourceSignatureD3D12Impl.hpp12
-rw-r--r--Graphics/GraphicsEngineD3D12/include/ShaderResourceCacheD3D12.hpp13
-rw-r--r--Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp35
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp2
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp6
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/ShaderResourceCacheGL.hpp13
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/PipelineResourceSignatureGLImpl.cpp6
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/ShaderResourceBindingGLImpl.cpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/include/PipelineResourceSignatureVkImpl.hpp11
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderResourceCacheVk.hpp7
-rw-r--r--Graphics/GraphicsEngineVulkan/src/PipelineResourceSignatureVkImpl.cpp17
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp2
14 files changed, 105 insertions, 70 deletions
diff --git a/Graphics/GraphicsEngine/CMakeLists.txt b/Graphics/GraphicsEngine/CMakeLists.txt
index 0cc1e740..0b255049 100644
--- a/Graphics/GraphicsEngine/CMakeLists.txt
+++ b/Graphics/GraphicsEngine/CMakeLists.txt
@@ -23,6 +23,7 @@ set(INCLUDE
include/SamplerBase.hpp
include/ShaderBase.hpp
include/ShaderResourceBindingBase.hpp
+ include/ShaderResourceCacheCommon.hpp
include/ShaderResourceVariableBase.hpp
include/StateObjectsRegistry.hpp
include/SwapChainBase.hpp
diff --git a/Graphics/GraphicsEngine/include/ShaderResourceCacheCommon.hpp b/Graphics/GraphicsEngine/include/ShaderResourceCacheCommon.hpp
new file mode 100644
index 00000000..7618669d
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/ShaderResourceCacheCommon.hpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2019-2021 Diligent Graphics LLC
+ * Copyright 2015-2019 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#pragma once
+
+/// \file
+/// Definition of the common share resource cache constants
+
+#include "BasicTypes.h"
+
+namespace Diligent
+{
+
+/// The type of the content that is stored in the shader resource cache.
+enum class ResourceCacheContentType : Uint8
+{
+ /// Static resources of a pipeline resource signature.
+ Signature,
+
+ /// Resources of a shader resource binding.
+ SRB
+};
+
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineD3D12/include/PipelineResourceSignatureD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/PipelineResourceSignatureD3D12Impl.hpp
index 00526a16..d68385f3 100644
--- a/Graphics/GraphicsEngineD3D12/include/PipelineResourceSignatureD3D12Impl.hpp
+++ b/Graphics/GraphicsEngineD3D12/include/PipelineResourceSignatureD3D12Impl.hpp
@@ -58,8 +58,6 @@ public:
bool bIsDeviceInternal = false);
~PipelineResourceSignatureD3D12Impl();
- using CacheContentType = ShaderResourceCacheD3D12::CacheContentType;
-
// sizeof(ResourceAttribs) == 16, x64
struct ResourceAttribs
{
@@ -128,8 +126,14 @@ public:
bool IsImmutableSamplerAssigned() const { return ImtblSamplerAssigned != 0; }
bool IsCombinedWithSampler() const { return SamplerInd != InvalidSamplerInd; }
- Uint32 RootIndex(CacheContentType Type) const { return Type == CacheContentType::SRB ? SRBRootIndex : SigRootIndex; }
- Uint32 OffsetFromTableStart(CacheContentType Type) const { return Type == CacheContentType::SRB ? SRBOffsetFromTableStart : SigOffsetFromTableStart; }
+ Uint32 RootIndex(ResourceCacheContentType Type) const
+ {
+ return Type == ResourceCacheContentType::SRB ? SRBRootIndex : SigRootIndex;
+ }
+ Uint32 OffsetFromTableStart(ResourceCacheContentType Type) const
+ {
+ return Type == ResourceCacheContentType::SRB ? SRBOffsetFromTableStart : SigOffsetFromTableStart;
+ }
D3D12_ROOT_PARAMETER_TYPE GetD3D12RootParamType() const { return static_cast<D3D12_ROOT_PARAMETER_TYPE>(RootParamType); }
diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderResourceCacheD3D12.hpp b/Graphics/GraphicsEngineD3D12/include/ShaderResourceCacheD3D12.hpp
index 95cdc81f..4177fcc1 100644
--- a/Graphics/GraphicsEngineD3D12/include/ShaderResourceCacheD3D12.hpp
+++ b/Graphics/GraphicsEngineD3D12/include/ShaderResourceCacheD3D12.hpp
@@ -108,6 +108,7 @@
#include "DescriptorHeap.hpp"
#include "Shader.h"
#include "RootParamsManager.hpp"
+#include "ShaderResourceCacheCommon.hpp"
namespace Diligent
{
@@ -118,13 +119,7 @@ class RenderDeviceD3D12Impl;
class ShaderResourceCacheD3D12
{
public:
- enum class CacheContentType : Uint8
- {
- Signature = 0, // The cache is used by the pipeline resource signature to hold static resources.
- SRB = 1 // The cache is used by SRB to hold resources of all types (static, mutable, dynamic).
- };
-
- explicit ShaderResourceCacheD3D12(CacheContentType ContentType) noexcept :
+ explicit ShaderResourceCacheD3D12(ResourceCacheContentType ContentType) noexcept :
m_ContentType{ContentType}
{
for (auto& HeapIndex : m_AllocationIndex)
@@ -305,7 +300,7 @@ public:
// Transitions all resources in the cache
void TransitionResourceStates(CommandContext& Ctx, StateTransitionMode Mode);
- CacheContentType GetContentType() const { return m_ContentType; }
+ ResourceCacheContentType GetContentType() const { return m_ContentType; }
// Returns the bitmask indicating root views with bound dynamic buffers
Uint64 GetDynamicRootBuffersMask() const { return m_DynamicRootBuffersMask; }
@@ -350,7 +345,7 @@ private:
Uint8 m_NumDescriptorAllocations = 0;
// Indicates what types of resources are stored in the cache
- const CacheContentType m_ContentType;
+ const ResourceCacheContentType m_ContentType;
// Descriptor allocation index in m_DescriptorAllocations array for every descriptor heap type
// (CBV_SRV_UAV, SAMPLER) and GPU visibility (false, true).
diff --git a/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp
index 088a052e..27e51fae 100644
--- a/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp
@@ -158,7 +158,7 @@ PipelineResourceSignatureD3D12Impl::PipelineResourceSignatureD3D12Impl(IReferenc
const auto NumStaticResStages = GetNumStaticResStages();
if (NumStaticResStages > 0)
{
- m_pStaticResCache = MemPool.Construct<ShaderResourceCacheD3D12>(CacheContentType::Signature);
+ m_pStaticResCache = MemPool.Construct<ShaderResourceCacheD3D12>(ResourceCacheContentType::Signature);
// Constructor of ShaderVariableManagerD3D12 is noexcept, so we can safely construct all manager objects.
// Moreover, all objects must be constructed if an exception is thrown for Destruct() method to work properly.
m_StaticVarsMgrs = MemPool.ConstructArray<ShaderVariableManagerD3D12>(NumStaticResStages, std::ref(*this), std::ref(*m_pStaticResCache));
@@ -492,8 +492,8 @@ void PipelineResourceSignatureD3D12Impl::CopyStaticResources(ShaderResourceCache
auto* const d3d12Device = GetDevice()->GetD3D12Device();
const auto SrcCacheType = SrcResourceCache.GetContentType();
const auto DstCacheType = DstResourceCache.GetContentType();
- VERIFY_EXPR(SrcCacheType == ShaderResourceCacheD3D12::CacheContentType::Signature);
- VERIFY_EXPR(DstCacheType == ShaderResourceCacheD3D12::CacheContentType::SRB);
+ VERIFY_EXPR(SrcCacheType == ResourceCacheContentType::Signature);
+ VERIFY_EXPR(DstCacheType == ResourceCacheContentType::SRB);
for (Uint32 r = ResIdxRange.first; r < ResIdxRange.second; ++r)
{
@@ -505,8 +505,8 @@ void PipelineResourceSignatureD3D12Impl::CopyStaticResources(ShaderResourceCache
if (IsSampler && Attr.IsImmutableSamplerAssigned())
{
// Immutable samplers should not be assigned cache space
- VERIFY_EXPR(Attr.RootIndex(CacheContentType::Signature) == ResourceAttribs::InvalidSigRootIndex);
- VERIFY_EXPR(Attr.RootIndex(CacheContentType::SRB) == ResourceAttribs::InvalidSRBRootIndex);
+ VERIFY_EXPR(Attr.RootIndex(ResourceCacheContentType::Signature) == ResourceAttribs::InvalidSigRootIndex);
+ VERIFY_EXPR(Attr.RootIndex(ResourceCacheContentType::SRB) == ResourceAttribs::InvalidSRBRootIndex);
VERIFY_EXPR(Attr.SigOffsetFromTableStart == ResourceAttribs::InvalidOffset);
VERIFY_EXPR(Attr.SRBOffsetFromTableStart == ResourceAttribs::InvalidOffset);
continue;
@@ -852,7 +852,6 @@ private:
private:
using ResourceAttribs = PipelineResourceSignatureD3D12Impl::ResourceAttribs;
- using ContentType = PipelineResourceSignatureD3D12Impl::CacheContentType;
const PipelineResourceSignatureD3D12Impl& m_Signature;
ShaderResourceCacheD3D12& m_ResourceCache;
@@ -860,10 +859,10 @@ private:
const PipelineResourceDesc& m_ResDesc;
const ResourceAttribs& m_Attribs; // Must go before m_RootIndex, m_OffsetFromTableStart
- const ContentType m_CacheType; // Must go before m_RootIndex, m_OffsetFromTableStart
- const Uint32 m_RootIndex; // Must go before m_DstRes
- const Uint32 m_ArrayIndex;
- const Uint32 m_OffsetFromTableStart; // Must go before m_DstRes
+ const ResourceCacheContentType m_CacheType; // Must go before m_RootIndex, m_OffsetFromTableStart
+ const Uint32 m_RootIndex; // Must go before m_DstRes
+ const Uint32 m_ArrayIndex;
+ const Uint32 m_OffsetFromTableStart; // Must go before m_DstRes
const ShaderResourceCacheD3D12::Resource& m_DstRes;
@@ -888,7 +887,7 @@ BindResourceHelper::BindResourceHelper(const PipelineResourceSignatureD3D12Impl&
{
VERIFY(ArrayIndex < m_ResDesc.ArraySize, "Array index is out of range");
- if (m_CacheType != ShaderResourceCacheD3D12::CacheContentType::Signature && !m_Attribs.IsRootView())
+ if (m_CacheType != ResourceCacheContentType::Signature && !m_Attribs.IsRootView())
{
const auto IsSampler = (m_ResDesc.ResourceType == SHADER_RESOURCE_TYPE_SAMPLER);
const auto RootParamGroup = VariableTypeToRootParameterGroup(m_ResDesc.VarType);
@@ -900,11 +899,11 @@ BindResourceHelper::BindResourceHelper(const PipelineResourceSignatureD3D12Impl&
}
#ifdef DILIGENT_DEBUG
- if (m_CacheType == ContentType::Signature)
+ if (m_CacheType == ResourceCacheContentType::Signature)
{
VERIFY(m_DstTableCPUDescriptorHandle.ptr == 0, "Static shader resource cache should never be assigned descriptor space.");
}
- else if (m_CacheType == ContentType::SRB)
+ else if (m_CacheType == ResourceCacheContentType::SRB)
{
if (m_Attribs.GetD3D12RootParamType() == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE)
{
@@ -981,7 +980,7 @@ void BindResourceHelper::CacheSampler(IDeviceObject* pSampler) const
const auto CPUDescriptorHandle = pSamplerD3D12->GetCPUDescriptorHandle();
VERIFY(CPUDescriptorHandle.ptr != 0, "Samplers must always have valid CPU descriptors");
- VERIFY(m_CacheType == ShaderResourceCacheD3D12::CacheContentType::Signature || m_DstTableCPUDescriptorHandle.ptr != 0,
+ VERIFY(m_CacheType == ResourceCacheContentType::Signature || m_DstTableCPUDescriptorHandle.ptr != 0,
"Samplers in SRB cache must always be allocated in root tables and thus assigned descriptor in the table");
SetResource(CPUDescriptorHandle, std::move(pSamplerD3D12));
@@ -1008,7 +1007,7 @@ void BindResourceHelper::CacheAccelStruct(IDeviceObject* pTLAS) const
const auto CPUDescriptorHandle = pTLASD3D12->GetCPUDescriptorHandle();
VERIFY(CPUDescriptorHandle.ptr != 0, "Acceleration structures must always have valid CPU descriptor handles");
- VERIFY(m_CacheType == ShaderResourceCacheD3D12::CacheContentType::Signature || m_DstTableCPUDescriptorHandle.ptr != 0,
+ VERIFY(m_CacheType == ResourceCacheContentType::Signature || m_DstTableCPUDescriptorHandle.ptr != 0,
"Acceleration structures in SRB cache are always allocated in root tables and thus must have a descriptor");
SetResource(CPUDescriptorHandle, std::move(pTLASD3D12));
@@ -1110,8 +1109,8 @@ void BindResourceHelper::BindCombinedSampler(TextureViewD3D12Impl* pTexView) con
if (SamplerAttribs.IsImmutableSamplerAssigned())
{
// Immutable samplers should not be assigned cache space
- VERIFY_EXPR(SamplerAttribs.RootIndex(ContentType::Signature) == ResourceAttribs::InvalidSigRootIndex);
- VERIFY_EXPR(SamplerAttribs.RootIndex(ContentType::SRB) == ResourceAttribs::InvalidSRBRootIndex);
+ VERIFY_EXPR(SamplerAttribs.RootIndex(ResourceCacheContentType::Signature) == ResourceAttribs::InvalidSigRootIndex);
+ VERIFY_EXPR(SamplerAttribs.RootIndex(ResourceCacheContentType::SRB) == ResourceAttribs::InvalidSRBRootIndex);
VERIFY_EXPR(SamplerAttribs.SigOffsetFromTableStart == ResourceAttribs::InvalidOffset);
VERIFY_EXPR(SamplerAttribs.SRBOffsetFromTableStart == ResourceAttribs::InvalidOffset);
return;
@@ -1260,7 +1259,7 @@ bool PipelineResourceSignatureD3D12Impl::DvpValidateCommittedResource(const D3DS
return true;
const auto CacheType = ResourceCache.GetContentType();
- VERIFY(CacheType == CacheContentType::SRB, "Only SRB resource cache can be committed");
+ VERIFY(CacheType == ResourceCacheContentType::SRB, "Only SRB resource cache can be committed");
const auto RootIndex = ResAttribs.RootIndex(CacheType);
const auto OffsetFromTableStart = ResAttribs.OffsetFromTableStart(CacheType);
const auto& RootTable = ResourceCache.GetRootTable(RootIndex);
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp
index 3d33710f..0b6adc73 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp
@@ -41,7 +41,7 @@ ShaderResourceBindingD3D12Impl::ShaderResourceBindingD3D12Impl(IReferenceCounter
pRefCounters,
pPRS
},
- m_ShaderResourceCache{ShaderResourceCacheD3D12::CacheContentType::SRB}
+ m_ShaderResourceCache{ResourceCacheContentType::SRB}
// clang-format on
{
try
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp
index 073fbdc9..c1cbe819 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp
@@ -121,7 +121,7 @@ void ShaderResourceCacheD3D12::Initialize(IMemoryAllocator& MemAllocator,
Uint32 NumTables,
const Uint32 TableSizes[])
{
- VERIFY(GetContentType() == CacheContentType::Signature,
+ VERIFY(GetContentType() == ResourceCacheContentType::Signature,
"This method should be called to initialize the cache to store resources of a pipeline resource signature");
DEV_CHECK_ERR(NumTables <= MaxRootTables, "The number of root tables (", NumTables, ") exceeds maximum allowed value (", MaxRootTables, ").");
@@ -151,7 +151,7 @@ void ShaderResourceCacheD3D12::Initialize(IMemoryAllocator& MemAllocator,
RenderDeviceD3D12Impl* pDevice,
const RootParamsManager& RootParams)
{
- VERIFY(GetContentType() == CacheContentType::SRB,
+ VERIFY(GetContentType() == ResourceCacheContentType::SRB,
"This method should be called to initialize the cache to store resources of an SRB");
const auto MemReq = GetMemoryRequirements(RootParams);
@@ -332,7 +332,7 @@ const ShaderResourceCacheD3D12::Resource& ShaderResourceCacheD3D12::SetResource(
else
{
#ifdef DILIGENT_DEVELOPMENT
- if (GetContentType() == CacheContentType::SRB)
+ if (GetContentType() == ResourceCacheContentType::SRB)
{
const BufferD3D12Impl* pBuffer = nullptr;
switch (Type)
diff --git a/Graphics/GraphicsEngineOpenGL/include/ShaderResourceCacheGL.hpp b/Graphics/GraphicsEngineOpenGL/include/ShaderResourceCacheGL.hpp
index 38b7e6ec..61972aeb 100644
--- a/Graphics/GraphicsEngineOpenGL/include/ShaderResourceCacheGL.hpp
+++ b/Graphics/GraphicsEngineOpenGL/include/ShaderResourceCacheGL.hpp
@@ -33,6 +33,7 @@
#include "BufferGLImpl.hpp"
#include "TextureBaseGL.hpp"
#include "SamplerGLImpl.hpp"
+#include "ShaderResourceCacheCommon.hpp"
namespace Diligent
{
@@ -48,13 +49,7 @@ namespace Diligent
class ShaderResourceCacheGL
{
public:
- enum class CacheContentType : Uint8
- {
- Signature = 0, // The cache is used by the pipeline resource signature to hold static resources.
- SRB = 1 // The cache is used by SRB to hold resources of all types (static, mutable, dynamic).
- };
-
- explicit ShaderResourceCacheGL(CacheContentType ContentType) noexcept :
+ explicit ShaderResourceCacheGL(ResourceCacheContentType ContentType) noexcept :
m_ContentType{ContentType}
{}
@@ -246,7 +241,7 @@ public:
return m_MemoryEndOffset != InvalidResourceOffset;
}
- CacheContentType GetContentType() const { return m_ContentType; }
+ ResourceCacheContentType GetContentType() const { return m_ContentType; }
#ifdef DILIGENT_DEVELOPMENT
void SetStaticResourcesInitialized()
@@ -295,7 +290,7 @@ private:
IMemoryAllocator* m_pAllocator = nullptr;
// Indicates what types of resources are stored in the cache
- const CacheContentType m_ContentType;
+ const ResourceCacheContentType m_ContentType;
#ifdef DILIGENT_DEVELOPMENT
bool m_bStaticResourcesInitialized = false;
diff --git a/Graphics/GraphicsEngineOpenGL/src/PipelineResourceSignatureGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/PipelineResourceSignatureGLImpl.cpp
index 1373c446..67c2c5bf 100644
--- a/Graphics/GraphicsEngineOpenGL/src/PipelineResourceSignatureGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/PipelineResourceSignatureGLImpl.cpp
@@ -113,7 +113,7 @@ PipelineResourceSignatureGLImpl::PipelineResourceSignatureGLImpl(IReferenceCount
const auto NumStaticResStages = GetNumStaticResStages();
if (NumStaticResStages > 0)
{
- m_pStaticResCache = MemPool.Construct<ShaderResourceCacheGL>(ShaderResourceCacheGL::CacheContentType::Signature);
+ m_pStaticResCache = MemPool.Construct<ShaderResourceCacheGL>(ResourceCacheContentType::Signature);
m_StaticVarsMgrs = MemPool.ConstructArray<ShaderVariableManagerGL>(NumStaticResStages, std::ref(*this), std::ref(*m_pStaticResCache));
}
@@ -469,8 +469,8 @@ void PipelineResourceSignatureGLImpl::CopyStaticResources(ShaderResourceCacheGL&
const auto& SrcResourceCache = *m_pStaticResCache;
const auto ResIdxRange = GetResourceIndexRange(SHADER_RESOURCE_VARIABLE_TYPE_STATIC);
- VERIFY_EXPR(SrcResourceCache.GetContentType() == ShaderResourceCacheGL::CacheContentType::Signature);
- VERIFY_EXPR(DstResourceCache.GetContentType() == ShaderResourceCacheGL::CacheContentType::SRB);
+ VERIFY_EXPR(SrcResourceCache.GetContentType() == ResourceCacheContentType::Signature);
+ VERIFY_EXPR(DstResourceCache.GetContentType() == ResourceCacheContentType::SRB);
for (Uint32 r = ResIdxRange.first; r < ResIdxRange.second; ++r)
{
diff --git a/Graphics/GraphicsEngineOpenGL/src/ShaderResourceBindingGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/ShaderResourceBindingGLImpl.cpp
index 515331de..2538d66b 100644
--- a/Graphics/GraphicsEngineOpenGL/src/ShaderResourceBindingGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/ShaderResourceBindingGLImpl.cpp
@@ -42,7 +42,7 @@ ShaderResourceBindingGLImpl::ShaderResourceBindingGLImpl(IReferenceCounters*
pRefCounters,
pPRS
},
- m_ShaderResourceCache{ShaderResourceCacheGL::CacheContentType::SRB}
+ m_ShaderResourceCache{ResourceCacheContentType::SRB}
// clang-format on
{
try
diff --git a/Graphics/GraphicsEngineVulkan/include/PipelineResourceSignatureVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/PipelineResourceSignatureVkImpl.hpp
index 57173a57..a1513c03 100644
--- a/Graphics/GraphicsEngineVulkan/include/PipelineResourceSignatureVkImpl.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/PipelineResourceSignatureVkImpl.hpp
@@ -36,6 +36,7 @@
#include "PipelineResourceSignatureBase.hpp"
#include "VulkanUtilities/VulkanObjectWrappers.hpp"
#include "SRBMemoryAllocator.hpp"
+#include "ShaderResourceCacheCommon.hpp"
namespace Diligent
{
@@ -102,12 +103,6 @@ public:
return (HasDescriptorSet(DESCRIPTOR_SET_ID_STATIC_MUTABLE) ? 1 : 0) + (HasDescriptorSet(DESCRIPTOR_SET_ID_DYNAMIC) ? 1 : 0);
}
- enum class CacheContentType
- {
- Signature = 0, // only static resources
- SRB = 1 // in SRB
- };
-
// sizeof(ResourceAttribs) == 16, x64
struct ResourceAttribs
{
@@ -167,9 +162,9 @@ public:
VERIFY(DescrSet == _DescrSet, "Descriptor set (", _DescrSet, ") exceeds maximum representable value");
}
- Uint32 CacheOffset(CacheContentType CacheType) const
+ Uint32 CacheOffset(ResourceCacheContentType CacheType) const
{
- return CacheType == CacheContentType::SRB ? SRBCacheOffset : StaticCacheOffset;
+ return CacheType == ResourceCacheContentType::SRB ? SRBCacheOffset : StaticCacheOffset;
}
DescriptorType GetDescriptorType() const { return static_cast<DescriptorType>(DescrType); }
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceCacheVk.hpp b/Graphics/GraphicsEngineVulkan/include/ShaderResourceCacheVk.hpp
index a508ccaf..7c8621c0 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceCacheVk.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceCacheVk.hpp
@@ -60,6 +60,7 @@
#include "SPIRVShaderResources.hpp"
#include "BufferVkImpl.hpp"
#include "PipelineResourceSignatureVkImpl.hpp"
+#include "ShaderResourceCacheCommon.hpp"
namespace Diligent
{
@@ -70,9 +71,7 @@ class DeviceContextVkImpl;
class ShaderResourceCacheVk
{
public:
- using CacheContentType = PipelineResourceSignatureVkImpl::CacheContentType;
-
- explicit ShaderResourceCacheVk(CacheContentType ContentType) noexcept :
+ explicit ShaderResourceCacheVk(ResourceCacheContentType ContentType) noexcept :
m_TotalResources{0},
m_ContentType{static_cast<Uint32>(ContentType)}
{
@@ -186,7 +185,7 @@ public:
Uint16& GetDynamicBuffersCounter() { return m_NumDynamicBuffers; }
- CacheContentType GetContentType() const { return static_cast<CacheContentType>(m_ContentType); }
+ ResourceCacheContentType GetContentType() const { return static_cast<ResourceCacheContentType>(m_ContentType); }
#ifdef DILIGENT_DEBUG
// Only for debug purposes: indicates what types of resources are stored in the cache
diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineResourceSignatureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineResourceSignatureVkImpl.cpp
index 5c57d040..799d98db 100644
--- a/Graphics/GraphicsEngineVulkan/src/PipelineResourceSignatureVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/PipelineResourceSignatureVkImpl.cpp
@@ -241,7 +241,7 @@ PipelineResourceSignatureVkImpl::PipelineResourceSignatureVkImpl(IReferenceCount
const auto NumStaticResStages = GetNumStaticResStages();
if (NumStaticResStages > 0)
{
- m_pStaticResCache = MemPool.Construct<ShaderResourceCacheVk>(CacheContentType::Signature);
+ m_pStaticResCache = MemPool.Construct<ShaderResourceCacheVk>(ResourceCacheContentType::Signature);
m_StaticVarsMgrs = MemPool.ConstructArray<ShaderVariableManagerVk>(NumStaticResStages, std::ref(*this), std::ref(*m_pStaticResCache));
Uint32 StaticResourceCount = 0; // The total number of static resources in all stages
@@ -764,7 +764,7 @@ void PipelineResourceSignatureVkImpl::CommitDynamicResources(const ShaderResourc
{
VERIFY(HasDescriptorSet(DESCRIPTOR_SET_ID_DYNAMIC), "This signature does not contain dynamic resources");
VERIFY_EXPR(vkDynamicDescriptorSet != VK_NULL_HANDLE);
- VERIFY_EXPR(ResourceCache.GetContentType() == CacheContentType::SRB);
+ VERIFY_EXPR(ResourceCache.GetContentType() == ResourceCacheContentType::SRB);
#ifdef DILIGENT_DEBUG
static constexpr size_t ImgUpdateBatchSize = 4;
@@ -798,7 +798,7 @@ void PipelineResourceSignatureVkImpl::CommitDynamicResources(const ShaderResourc
const auto& LogicalDevice = GetDevice()->GetLogicalDevice();
const auto DynResIdxRange = GetResourceIndexRange(SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC);
- constexpr auto CacheType = CacheContentType::SRB;
+ constexpr auto CacheType = ResourceCacheContentType::SRB;
for (Uint32 ResIdx = DynResIdxRange.first, ArrElem = 0; ResIdx < DynResIdxRange.second;)
{
@@ -993,14 +993,13 @@ private:
const VkWriteDescriptorSetAccelerationStructureKHR* pAccelStructInfo = nullptr) const;
private:
- using CacheContentType = ShaderResourceCacheVk::CacheContentType;
- using ResourceAttribs = PipelineResourceSignatureVkImpl::ResourceAttribs;
- using CachedSet = ShaderResourceCacheVk::DescriptorSet;
+ using ResourceAttribs = PipelineResourceSignatureVkImpl::ResourceAttribs;
+ using CachedSet = ShaderResourceCacheVk::DescriptorSet;
const PipelineResourceSignatureVkImpl& m_Signature;
ShaderResourceCacheVk& m_ResourceCache;
const Uint32 m_ArrayIndex;
- const CacheContentType m_CacheType;
+ const ResourceCacheContentType m_CacheType;
const PipelineResourceDesc& m_ResDesc;
const ResourceAttribs& m_Attribs;
CachedSet& m_CachedSet;
@@ -1026,7 +1025,7 @@ BindResourceHelper::BindResourceHelper(const PipelineResourceSignatureVkImpl& Si
VERIFY(m_DstRes.Type == m_Attribs.GetDescriptorType(), "Inconsistent types");
#ifdef DILIGENT_DEBUG
- if (m_CacheType == CacheContentType::SRB)
+ if (m_CacheType == ResourceCacheContentType::SRB)
{
if (m_ResDesc.VarType == SHADER_RESOURCE_VARIABLE_TYPE_STATIC || m_ResDesc.VarType == SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE)
{
@@ -1034,7 +1033,7 @@ BindResourceHelper::BindResourceHelper(const PipelineResourceSignatureVkImpl& Si
// Dynamic variables do not have vulkan descriptor set only until they are assigned one the first time
}
}
- else if (m_CacheType == CacheContentType::Signature)
+ else if (m_CacheType == ResourceCacheContentType::Signature)
{
VERIFY(m_vkDescrSet == VK_NULL_HANDLE, "Static shader resource cache should not have vulkan descriptor set allocation");
}
diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp
index 15722f79..797718fd 100644
--- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp
@@ -43,7 +43,7 @@ ShaderResourceBindingVkImpl::ShaderResourceBindingVkImpl(IReferenceCounters*
pRefCounters,
pPRS
},
- m_ShaderResourceCache{ShaderResourceCacheVk::CacheContentType::SRB}
+ m_ShaderResourceCache{ResourceCacheContentType::SRB}
// clang-format on
{
try