summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
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/GraphicsEngineD3D12
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/GraphicsEngineD3D12')
-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
5 files changed, 33 insertions, 35 deletions
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)