summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorazhirnov <zh1dron@gmail.com>2021-01-15 23:56:25 +0000
committerazhirnov <zh1dron@gmail.com>2021-01-15 23:56:25 +0000
commit8a3b697948704337d08af7bea93627f5e647899e (patch)
tree852d3b0f7ea9fa9fa0ffcf2df81a5a5472371183 /Graphics/GraphicsEngine
parentIBufferSuballocation: added SetUserData()/GetUserData() methods (diff)
downloadDiligentCore-8a3b697948704337d08af7bea93627f5e647899e.tar.gz
DiligentCore-8a3b697948704337d08af7bea93627f5e647899e.zip
added pipeline resource signature (wip)
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/CMakeLists.txt2
-rw-r--r--Graphics/GraphicsEngine/include/DeviceContextBase.hpp13
-rw-r--r--Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp294
-rw-r--r--Graphics/GraphicsEngine/include/PipelineStateBase.hpp109
-rw-r--r--Graphics/GraphicsEngine/include/RenderDeviceBase.hpp5
-rw-r--r--Graphics/GraphicsEngine/include/ShaderResourceBindingBase.hpp83
-rw-r--r--Graphics/GraphicsEngine/interface/Constants.h2
-rw-r--r--Graphics/GraphicsEngine/interface/PipelineResourceSignature.h254
-rw-r--r--Graphics/GraphicsEngine/interface/PipelineState.h61
-rw-r--r--Graphics/GraphicsEngine/interface/RenderDevice.h6
-rw-r--r--Graphics/GraphicsEngine/interface/ShaderResourceBinding.h33
11 files changed, 714 insertions, 148 deletions
diff --git a/Graphics/GraphicsEngine/CMakeLists.txt b/Graphics/GraphicsEngine/CMakeLists.txt
index 604f3442..0e47e286 100644
--- a/Graphics/GraphicsEngine/CMakeLists.txt
+++ b/Graphics/GraphicsEngine/CMakeLists.txt
@@ -30,6 +30,7 @@ set(INCLUDE
include/BottomLevelASBase.hpp
include/TopLevelASBase.hpp
include/ShaderBindingTableBase.hpp
+ include/PipelineResourceSignatureBase.hpp
)
set(INTERFACE
@@ -48,6 +49,7 @@ set(INTERFACE
interface/GraphicsTypes.h
interface/InputLayout.h
interface/PipelineState.h
+ interface/PipelineResourceSignature.h
interface/Query.h
interface/RasterizerState.h
interface/RenderDevice.h
diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp
index f8741d60..8626c57b 100644
--- a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp
+++ b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp
@@ -495,20 +495,11 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::CommitShader
"Resource state transitons are not allowed inside a render pass and may result in an undefined behavior. "
"Do not use RESOURCE_STATE_TRANSITION_MODE_TRANSITION or end the render pass first.");
- if (!m_pPipelineState)
+ if (pShaderResourceBinding == nullptr)
{
- LOG_ERROR_MESSAGE("No pipeline state is bound to the pipeline");
+ LOG_ERROR_MESSAGE("TODO");
return false;
}
-
- if (pShaderResourceBinding)
- {
- if (m_pPipelineState->IsIncompatibleWith(pShaderResourceBinding->GetPipelineState()))
- {
- LOG_ERROR_MESSAGE("Shader resource binding object is not compatible with the currently bound pipeline state '", m_pPipelineState->GetDesc().Name, '\'');
- return false;
- }
- }
#endif
return true;
diff --git a/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp b/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp
new file mode 100644
index 00000000..5fcc5a1b
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp
@@ -0,0 +1,294 @@
+/*
+ * 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
+/// Implementation of the Diligent::PipelineResourceSignatureBase template class
+#include <unordered_map>
+#include <algorithm>
+
+#include "PipelineResourceSignature.h"
+#include "DeviceObjectBase.hpp"
+#include "RenderDeviceBase.hpp"
+#include "FixedLinearAllocator.hpp"
+
+namespace Diligent
+{
+
+/// Template class implementing base functionality of the pipeline resource signature object.
+
+/// \tparam BaseInterface - Base interface that this class will inheret
+/// (Diligent::IPipelineResourceSignatureD3D12, Diligent::PipelineResourceSignatureVk, ...).
+/// \tparam RenderDeviceImplType - Type of the render device implementation
+/// (Diligent::RenderDeviceD3D12Impl or Diligent::RenderDeviceVkImpl)
+template <class BaseInterface, class RenderDeviceImplType>
+class PipelineResourceSignatureBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, PipelineResourceSignatureDesc>
+{
+public:
+ using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, PipelineResourceSignatureDesc>;
+
+ /// \param pRefCounters - Reference counters object that controls the lifetime of this BLAS.
+ /// \param pDevice - Pointer to the device.
+ /// \param Desc - TLAS description.
+ /// \param bIsDeviceInternal - Flag indicating if the BLAS is an internal device object and
+ /// must not keep a strong reference to the device.
+ PipelineResourceSignatureBase(IReferenceCounters* pRefCounters,
+ RenderDeviceImplType* pDevice,
+ const PipelineResourceSignatureDesc& Desc,
+ bool bIsDeviceInternal = false) :
+ TDeviceObjectBase{pRefCounters, pDevice, Desc, bIsDeviceInternal}
+ {
+ this->m_Desc.Resources = nullptr;
+ this->m_Desc.ImmutableSamplers = nullptr;
+ }
+
+ ~PipelineResourceSignatureBase()
+ {
+ VERIFY(m_IsDestructed, "This object must be explicitly destructed with Destruct()");
+ }
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_PipelineResourceSignature, TDeviceObjectBase)
+
+ Uint32 GetVariableCount(SHADER_TYPE ShaderType) const
+ {
+ // AZ TODO: optimize
+ Uint32 Count = 0;
+ for (Uint32 i = 0; i < this->m_Desc.NumResources; ++i)
+ {
+ auto& Res = this->m_Desc.Resources[i];
+ if (Res.VarType != SHADER_RESOURCE_VARIABLE_TYPE_STATIC && (Res.ShaderStages & ShaderType))
+ ++Count;
+ }
+ return Count;
+ }
+
+ Uint32 GetVariableGlobalIndexByName(SHADER_TYPE ShaderType, const char* Name) const
+ {
+ // AZ TODO: optimize
+ for (Uint32 i = 0; i < this->m_Desc.NumResources; ++i)
+ {
+ auto& Res = this->m_Desc.Resources[i];
+ if (Res.VarType != SHADER_RESOURCE_VARIABLE_TYPE_STATIC && (Res.ShaderStages & ShaderType))
+ {
+ if (strcmp(Name, Res.Name) == 0)
+ return i;
+ }
+ }
+ return ~0u;
+ }
+
+ Uint32 GetVariableGlobalIndexByIndex(SHADER_TYPE ShaderType, Uint32 Index) const
+ {
+ // AZ TODO: optimize
+ Uint32 Count = 0;
+ for (Uint32 i = 0; i < this->m_Desc.NumResources; ++i)
+ {
+ auto& Res = this->m_Desc.Resources[i];
+ if (Res.VarType != SHADER_RESOURCE_VARIABLE_TYPE_STATIC && (Res.ShaderStages & ShaderType))
+ {
+ if (Index == Count)
+ return i;
+
+ ++Count;
+ }
+ }
+ return ~0u;
+ }
+
+ Uint32 GetResourceCount(SHADER_RESOURCE_VARIABLE_TYPE VarType) const
+ {
+ // AZ TODO: optimize
+ Uint32 Count = 0;
+ for (Uint32 i = 0; i < this->m_Desc.NumResources; ++i)
+ {
+ auto& Res = this->m_Desc.Resources[i];
+ if (Res.VarType == VarType)
+ Count += Res.ArraySize;
+ }
+ return Count;
+ }
+
+ PipelineResourceDesc GetResource(SHADER_RESOURCE_VARIABLE_TYPE VarType, Uint32 Index) const
+ {
+ return {};
+ }
+
+ size_t GetHash() const { return m_Hash; }
+
+ PIPELINE_TYPE GetPipelineType() const { return m_PipelineType; }
+
+protected:
+#define LOG_PRS_ERROR_AND_THROW(...) LOG_ERROR_AND_THROW("Description of a pipeline resource signature '", (Desc.Name ? Desc.Name : ""), "' is invalid: ", ##__VA_ARGS__)
+
+ void ReserveSpaceForDescription(FixedLinearAllocator& Allocator, const PipelineResourceSignatureDesc& Desc) noexcept(false)
+ {
+ if (Desc.NumResources == 0)
+ LOG_PRS_ERROR_AND_THROW("AZ TODO");
+
+ Allocator.AddSpace<PipelineResourceDesc>(Desc.NumResources);
+ Allocator.AddSpace<ImmutableSamplerDesc>(Desc.NumImmutableSamplers);
+
+ for (Uint32 i = 0; i < Desc.NumResources; ++i)
+ {
+ const auto& Res = Desc.Resources[i];
+
+ if (Res.Name == nullptr)
+ LOG_PRS_ERROR_AND_THROW("AZ TODO");
+
+ if (Res.ShaderStages == SHADER_TYPE_UNKNOWN)
+ LOG_PRS_ERROR_AND_THROW("AZ TODO");
+
+ if (Res.ArraySize == 0)
+ LOG_PRS_ERROR_AND_THROW("AZ TODO");
+
+ Allocator.AddSpaceForString(Res.Name);
+ }
+
+ for (Uint32 i = 0; i < Desc.NumImmutableSamplers; ++i)
+ {
+ if (Desc.ImmutableSamplers[i].SamplerOrTextureName == nullptr)
+ LOG_PRS_ERROR_AND_THROW("AZ TODO");
+
+ Allocator.AddSpaceForString(Desc.ImmutableSamplers[i].SamplerOrTextureName);
+ }
+ }
+
+ void CopyDescription(FixedLinearAllocator& Allocator, const PipelineResourceSignatureDesc& Desc) noexcept(false)
+ {
+ PipelineResourceDesc* pResources = Allocator.Allocate<PipelineResourceDesc>(this->m_Desc.NumResources);
+ ImmutableSamplerDesc* pSamplers = Allocator.Allocate<ImmutableSamplerDesc>(this->m_Desc.NumImmutableSamplers);
+
+ m_Hash = ComputeHash(Desc.NumResources, Desc.NumImmutableSamplers);
+
+ for (Uint32 i = 0; i < Desc.NumResources; ++i)
+ {
+ auto& Dst = pResources[i];
+ Dst = Desc.Resources[i];
+ Dst.Name = Allocator.CopyString(Desc.Resources[i].Name);
+
+ HashCombine(m_Hash, CStringHash<char>{}(Dst.Name), Dst.ArraySize, Dst.ResourceType, Dst.ShaderStages, Dst.VarType, Dst.Flags);
+ }
+
+ for (Uint32 i = 0; i < Desc.NumImmutableSamplers; ++i)
+ {
+ auto& Dst = pSamplers[i];
+ Dst = Desc.ImmutableSamplers[i];
+ Dst.SamplerOrTextureName = Allocator.CopyString(Desc.ImmutableSamplers[i].SamplerOrTextureName);
+
+ //HashCombine(m_Hash, CStringHash<char>{}(Dst.Name), Dst.ShaderStages, Dst.Desc); // AZ TODO
+ }
+
+ this->m_Desc.Resources = pResources;
+ this->m_Desc.ImmutableSamplers = pSamplers;
+ }
+
+ void Destruct()
+ {
+ VERIFY(!m_IsDestructed, "This object has already been destructed");
+
+ this->m_Desc.Resources = nullptr;
+ this->m_Desc.ImmutableSamplers = nullptr;
+
+#if DILIGENT_DEBUG
+ m_IsDestructed = true;
+#endif
+ }
+
+#undef LOG_PRS_ERROR_AND_THROW
+
+ Int8 GetStaticVariableCountHelper(SHADER_TYPE ShaderType, const std::array<Int8, MAX_SHADERS_IN_PIPELINE>& StaticVarIndex) const
+ {
+ if (!IsConsistentShaderType(ShaderType, m_PipelineType))
+ {
+ LOG_WARNING_MESSAGE("Unable to get the number of static variables in shader stage ", GetShaderTypeLiteralName(ShaderType),
+ " as the stage is invalid for ", GetPipelineTypeString(m_PipelineType), " pipeline resource signature '", this->m_Desc.Name, "'.");
+ return -1;
+ }
+
+ const auto ShaderTypeInd = GetShaderTypePipelineIndex(ShaderType, m_PipelineType);
+ const auto LayoutInd = StaticVarIndex[ShaderTypeInd];
+ if (LayoutInd < 0)
+ {
+ LOG_WARNING_MESSAGE("Unable to get the number of static variables in shader stage ", GetShaderTypeLiteralName(ShaderType),
+ " as the stage is inactive in PSO '", this->m_Desc.Name, "'.");
+ }
+
+ return LayoutInd;
+ }
+
+ Int8 GetStaticVariableByNameHelper(SHADER_TYPE ShaderType, const Char* Name, const std::array<Int8, MAX_SHADERS_IN_PIPELINE>& StaticVarIndex) const
+ {
+ if (!IsConsistentShaderType(ShaderType, m_PipelineType))
+ {
+ LOG_WARNING_MESSAGE("Unable to find static variable '", Name, "' in shader stage ", GetShaderTypeLiteralName(ShaderType),
+ " as the stage is invalid for ", GetPipelineTypeString(m_PipelineType), " pipeline resource signature '", this->m_Desc.Name, "'.");
+ return -1;
+ }
+
+ const auto ShaderTypeInd = GetShaderTypePipelineIndex(ShaderType, m_PipelineType);
+ const auto LayoutInd = StaticVarIndex[ShaderTypeInd];
+ if (LayoutInd < 0)
+ {
+ LOG_WARNING_MESSAGE("Unable to find static variable '", Name, "' in shader stage ", GetShaderTypeLiteralName(ShaderType),
+ " as the stage is inactive in PSO '", this->m_Desc.Name, "'.");
+ }
+
+ return LayoutInd;
+ }
+
+ Int8 GetStaticVariableByIndexHelper(SHADER_TYPE ShaderType, Uint32 Index, const std::array<Int8, MAX_SHADERS_IN_PIPELINE>& StaticVarIndex) const
+ {
+ if (!IsConsistentShaderType(ShaderType, m_PipelineType))
+ {
+ LOG_WARNING_MESSAGE("Unable to get static variable at index ", Index, " in shader stage ", GetShaderTypeLiteralName(ShaderType),
+ " as the stage is invalid for ", GetPipelineTypeString(m_PipelineType), " pipeline resource signature '", this->m_Desc.Name, "'.");
+ return -1;
+ }
+
+ const auto ShaderTypeInd = GetShaderTypePipelineIndex(ShaderType, m_PipelineType);
+ const auto LayoutInd = StaticVarIndex[ShaderTypeInd];
+ if (LayoutInd < 0)
+ {
+ LOG_WARNING_MESSAGE("Unable to get static variable at index ", Index, " in shader stage ", GetShaderTypeLiteralName(ShaderType),
+ " as the stage is inactive in PSO '", this->m_Desc.Name, "'.");
+ }
+
+ return LayoutInd;
+ }
+
+protected:
+ size_t m_Hash = 0;
+
+ PIPELINE_TYPE m_PipelineType = PIPELINE_TYPE(0xFF);
+
+#ifdef DILIGENT_DEBUG
+ bool m_IsDestructed = false;
+#endif
+};
+
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
index dbc3473d..d5ab5fb7 100644
--- a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
+++ b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
@@ -223,7 +223,8 @@ public:
// it can potentially give false negatives
bool IsIncompatibleWith(const IPipelineState* pPSO) const
{
- return m_ShaderResourceLayoutHash != ValidatedCast<const PipelineStateBase>(pPSO)->m_ShaderResourceLayoutHash;
+ return false;
+ //return m_ShaderResourceLayoutHash != ValidatedCast<const PipelineStateBase>(pPSO)->m_ShaderResourceLayoutHash;
}
virtual const GraphicsPipelineDesc& DILIGENT_CALL_TYPE GetGraphicsPipelineDesc() const override final
@@ -240,6 +241,49 @@ public:
return m_pRayTracingPipelineData->Desc;
}
+ virtual void DILIGENT_CALL_TYPE CreateShaderResourceBinding(IShaderResourceBinding** ppShaderResourceBinding,
+ bool InitStaticResources) override final
+ {
+ auto* pSign = GetResourceSignature(0);
+ if (pSign)
+ return pSign->CreateShaderResourceBinding(ppShaderResourceBinding, InitStaticResources);
+ }
+
+ virtual IShaderResourceVariable* DILIGENT_CALL_TYPE GetStaticVariableByName(SHADER_TYPE ShaderType,
+ const Char* Name) override final
+ {
+ VERIFY_EXPR(GetResourceSignatureCount() == 1);
+
+ auto* pSign = GetResourceSignature(0);
+ if (pSign)
+ return pSign->GetStaticVariableByName(ShaderType, Name);
+
+ return nullptr;
+ }
+
+ virtual IShaderResourceVariable* DILIGENT_CALL_TYPE GetStaticVariableByIndex(SHADER_TYPE ShaderType,
+ Uint32 Index) override final
+ {
+ VERIFY_EXPR(GetResourceSignatureCount() == 1);
+
+ auto* pSign = GetResourceSignature(0);
+ if (pSign)
+ return pSign->GetStaticVariableByIndex(ShaderType, Index);
+
+ return nullptr;
+ }
+
+ virtual Uint32 DILIGENT_CALL_TYPE GetStaticVariableCount(SHADER_TYPE ShaderType) const override final
+ {
+ VERIFY_EXPR(GetResourceSignatureCount() == 1);
+
+ auto* pSign = GetResourceSignature(0);
+ if (pSign)
+ return pSign->GetStaticVariableCount(ShaderType);
+
+ return 0;
+ }
+
inline void CopyShaderHandle(const char* Name, void* pData, size_t DataSize) const
{
VERIFY_EXPR(this->m_Desc.IsRayTracingPipeline());
@@ -268,67 +312,6 @@ public:
protected:
using TNameToGroupIndexMap = std::unordered_map<HashMapStringKey, Uint32, HashMapStringKey::Hasher>;
- Int8 GetStaticVariableCountHelper(SHADER_TYPE ShaderType, const std::array<Int8, MAX_SHADERS_IN_PIPELINE>& ResourceLayoutIndex) const
- {
- if (!IsConsistentShaderType(ShaderType, this->m_Desc.PipelineType))
- {
- LOG_WARNING_MESSAGE("Unable to get the number of static variables in shader stage ", GetShaderTypeLiteralName(ShaderType),
- " as the stage is invalid for ", GetPipelineTypeString(this->m_Desc.PipelineType), " pipeline '", this->m_Desc.Name, "'.");
- return -1;
- }
-
- const auto ShaderTypeInd = GetShaderTypePipelineIndex(ShaderType, this->m_Desc.PipelineType);
- const auto LayoutInd = ResourceLayoutIndex[ShaderTypeInd];
- if (LayoutInd < 0)
- {
- LOG_WARNING_MESSAGE("Unable to get the number of static variables in shader stage ", GetShaderTypeLiteralName(ShaderType),
- " as the stage is inactive in PSO '", this->m_Desc.Name, "'.");
- }
-
- return LayoutInd;
- }
-
- Int8 GetStaticVariableByNameHelper(SHADER_TYPE ShaderType, const Char* Name, const std::array<Int8, MAX_SHADERS_IN_PIPELINE>& ResourceLayoutIndex) const
- {
- if (!IsConsistentShaderType(ShaderType, this->m_Desc.PipelineType))
- {
- LOG_WARNING_MESSAGE("Unable to find static variable '", Name, "' in shader stage ", GetShaderTypeLiteralName(ShaderType),
- " as the stage is invalid for ", GetPipelineTypeString(this->m_Desc.PipelineType), " pipeline '", this->m_Desc.Name, "'.");
- return -1;
- }
-
- const auto ShaderTypeInd = GetShaderTypePipelineIndex(ShaderType, this->m_Desc.PipelineType);
- const auto LayoutInd = ResourceLayoutIndex[ShaderTypeInd];
- if (LayoutInd < 0)
- {
- LOG_WARNING_MESSAGE("Unable to find static variable '", Name, "' in shader stage ", GetShaderTypeLiteralName(ShaderType),
- " as the stage is inactive in PSO '", this->m_Desc.Name, "'.");
- }
-
- return LayoutInd;
- }
-
- Int8 GetStaticVariableByIndexHelper(SHADER_TYPE ShaderType, Uint32 Index, const std::array<Int8, MAX_SHADERS_IN_PIPELINE>& ResourceLayoutIndex) const
- {
- if (!IsConsistentShaderType(ShaderType, this->m_Desc.PipelineType))
- {
- LOG_WARNING_MESSAGE("Unable to get static variable at index ", Index, " in shader stage ", GetShaderTypeLiteralName(ShaderType),
- " as the stage is invalid for ", GetPipelineTypeString(this->m_Desc.PipelineType), " pipeline '", this->m_Desc.Name, "'.");
- return -1;
- }
-
- const auto ShaderTypeInd = GetShaderTypePipelineIndex(ShaderType, this->m_Desc.PipelineType);
- const auto LayoutInd = ResourceLayoutIndex[ShaderTypeInd];
- if (LayoutInd < 0)
- {
- LOG_WARNING_MESSAGE("Unable to get static variable at index ", Index, " in shader stage ", GetShaderTypeLiteralName(ShaderType),
- " as the stage is inactive in PSO '", this->m_Desc.Name, "'.");
- }
-
- return LayoutInd;
- }
-
-
void ReserveSpaceForPipelineDesc(const GraphicsPipelineStateCreateInfo& CreateInfo,
FixedLinearAllocator& MemPool) noexcept
{
@@ -746,8 +729,6 @@ private:
}
protected:
- size_t m_ShaderResourceLayoutHash = 0; ///< Hash computed from the shader resource layout
-
Uint32* m_pStrides = nullptr;
Uint8 m_BufferSlotsUsed = 0;
diff --git a/Graphics/GraphicsEngine/include/RenderDeviceBase.hpp b/Graphics/GraphicsEngine/include/RenderDeviceBase.hpp
index bc53d07f..b67d15a9 100644
--- a/Graphics/GraphicsEngine/include/RenderDeviceBase.hpp
+++ b/Graphics/GraphicsEngine/include/RenderDeviceBase.hpp
@@ -235,6 +235,9 @@ public:
/// Size of the SBT object (ShaderBindingTableD3D12Impl, ShaderBindingtableVkImpl, etc.), in bytes
const size_t SBTObjSize;
+
+ /// AZ TODO: comment
+ const size_t PipeResSignObjSize;
};
/// \param pRefCounters - Reference counters object that controls the lifetime of this render device
@@ -274,6 +277,7 @@ public:
m_BLASAllocator {RawMemAllocator, ObjectSizes.BLASObjSize, 16 },
m_TLASAllocator {RawMemAllocator, ObjectSizes.TLASObjSize, 16 },
m_SBTAllocator {RawMemAllocator, ObjectSizes.SBTObjSize, 16 },
+ m_PipeResSignAllocator {RawMemAllocator, ObjectSizes.PipeResSignObjSize, 128 },
m_DeviceProperties {}
// clang-format on
{
@@ -459,6 +463,7 @@ protected:
FixedBlockMemoryAllocator m_BLASAllocator; ///< Allocator for bottom-level acceleration structure objects
FixedBlockMemoryAllocator m_TLASAllocator; ///< Allocator for top-level acceleration structure objects
FixedBlockMemoryAllocator m_SBTAllocator; ///< Allocator for shader binding table objects
+ FixedBlockMemoryAllocator m_PipeResSignAllocator; ///< Allocator for pipeline resource signature objects
};
diff --git a/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.hpp b/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.hpp
index d001d6a3..e69b785b 100644
--- a/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.hpp
+++ b/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.hpp
@@ -47,52 +47,73 @@ namespace Diligent
/// \tparam BaseInterface - Base interface that this class will inheret
/// (Diligent::IShaderResourceBindingGL, Diligent::IShaderResourceBindingD3D11,
/// Diligent::IShaderResourceBindingD3D12 or Diligent::IShaderResourceBindingVk).
-/// \tparam PipelineStateImplType - Type of the pipeline state implementation
-/// (Diligent::PipelineStateD3D12Impl, Diligent::PipelineStateVkImpl, etc.)
-template <class BaseInterface, class PipelineStateImplType>
+/// \tparam ResourceSignatureType - Type of the pipeline resource signature implementation
+/// (Diligent::PipelineResourceSignatureD3D12Impl, Diligent::PipelineResourceSignatureVkImpl, etc.)
+template <class BaseInterface, class ResourceSignatureType>
class ShaderResourceBindingBase : public ObjectBase<BaseInterface>
{
public:
typedef ObjectBase<BaseInterface> TObjectBase;
/// \param pRefCounters - Reference counters object that controls the lifetime of this SRB.
- /// \param pPSO - Pipeline state that this SRB belongs to.
- /// \param IsInternal - Flag indicating if the shader resource binding is an internal PSO object and
- /// must not keep a strong reference to the PSO.
- ShaderResourceBindingBase(IReferenceCounters* pRefCounters, PipelineStateImplType* pPSO, bool IsInternal = false) :
+ /// \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, bool IsInternal = false) :
TObjectBase{pRefCounters},
- m_spPSO{IsInternal ? nullptr : pPSO},
- m_pPSO{pPSO}
+ m_spPRS{IsInternal ? nullptr : pPRS},
+ m_pPRS{pPRS}
{}
IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_ShaderResourceBinding, TObjectBase)
/// Implementation of IShaderResourceBinding::GetPipelineState().
- virtual IPipelineState* DILIGENT_CALL_TYPE GetPipelineState() override final
+ //virtual IPipelineState* DILIGENT_CALL_TYPE GetPipelineState() override final
+ //{
+ // return m_pPSO;
+ //}
+
+ //template <typename PSOType>
+ //PSOType* GetPipelineState()
+ //{
+ // return ValidatedCast<PSOType>(m_pPSO);
+ //}
+
+ //template <typename PSOType>
+ //PSOType* GetPipelineState() const
+ //{
+ // return ValidatedCast<PSOType>(m_pPSO);
+ //}
+
+ Uint32 GetBindingIndex() const
{
- return m_pPSO;
+ return m_pPRS->GetDesc().BindingIndex;
}
- template <typename PSOType>
- PSOType* GetPipelineState()
+ PIPELINE_TYPE GetPipelineType() const
{
- return ValidatedCast<PSOType>(m_pPSO);
+ return ValidatedCast<ResourceSignatureType>(m_pPRS)->GetPipelineType();
}
- template <typename PSOType>
- PSOType* GetPipelineState() const
+ /// Implementation of IShaderResourceBinding::GetPipelineResourceSignature().
+ virtual IPipelineResourceSignature* DILIGENT_CALL_TYPE GetPipelineResourceSignature() override final
{
- return ValidatedCast<PSOType>(m_pPSO);
+ return m_pPRS;
+ }
+
+ ResourceSignatureType* GetSignature() const
+ {
+ return ValidatedCast<ResourceSignatureType>(m_pPRS);
}
protected:
Int8 GetVariableByNameHelper(SHADER_TYPE ShaderType, const char* Name, const std::array<Int8, MAX_SHADERS_IN_PIPELINE>& ResourceLayoutIndex) const
{
- const auto PipelineType = m_pPSO->GetDesc().PipelineType;
+ const auto PipelineType = GetPipelineType();
if (!IsConsistentShaderType(ShaderType, PipelineType))
{
LOG_WARNING_MESSAGE("Unable to find mutable/dynamic variable '", Name, "' in shader stage ", GetShaderTypeLiteralName(ShaderType),
- " as the stage is invalid for ", GetPipelineTypeString(m_pPSO->GetDesc().PipelineType), " pipeline '", m_pPSO->GetDesc().Name, "'.");
+ " as the stage is invalid for ", GetPipelineTypeString(PipelineType), " pipeline resource signature '", m_pPRS->GetDesc().Name, "'.");
return -1;
}
@@ -101,7 +122,7 @@ protected:
if (ResLayoutInd < 0)
{
LOG_WARNING_MESSAGE("Unable to find mutable/dynamic variable '", Name, "' in shader stage ", GetShaderTypeLiteralName(ShaderType),
- " as the stage is inactive in PSO '", m_pPSO->GetDesc().Name, "'.");
+ " as the stage is inactive in pipeline resource signature '", m_pPRS->GetDesc().Name, "'.");
}
return ResLayoutInd;
@@ -109,11 +130,11 @@ protected:
Int8 GetVariableCountHelper(SHADER_TYPE ShaderType, const std::array<Int8, MAX_SHADERS_IN_PIPELINE>& ResourceLayoutIndex) const
{
- const auto PipelineType = m_pPSO->GetDesc().PipelineType;
+ const auto PipelineType = GetPipelineType();
if (!IsConsistentShaderType(ShaderType, PipelineType))
{
LOG_WARNING_MESSAGE("Unable to get the number of mutable/dynamic variables in shader stage ", GetShaderTypeLiteralName(ShaderType),
- " as the stage is invalid for ", GetPipelineTypeString(m_pPSO->GetDesc().PipelineType), " pipeline '", m_pPSO->GetDesc().Name, "'.");
+ " as the stage is invalid for ", GetPipelineTypeString(PipelineType), " pipeline resource signature '", m_pPRS->GetDesc().Name, "'.");
return -1;
}
@@ -122,7 +143,7 @@ protected:
if (ResLayoutInd < 0)
{
LOG_WARNING_MESSAGE("Unable to get the number of mutable/dynamic variables in shader stage ", GetShaderTypeLiteralName(ShaderType),
- " as the stage is inactive in PSO '", m_pPSO->GetDesc().Name, "'.");
+ " as the stage is inactive in pipeline resource signature '", m_pPRS->GetDesc().Name, "'.");
}
return ResLayoutInd;
@@ -130,11 +151,11 @@ protected:
Int8 GetVariableByIndexHelper(SHADER_TYPE ShaderType, Uint32 Index, const std::array<Int8, MAX_SHADERS_IN_PIPELINE>& ResourceLayoutIndex) const
{
- const auto PipelineType = m_pPSO->GetDesc().PipelineType;
+ const auto PipelineType = GetPipelineType();
if (!IsConsistentShaderType(ShaderType, PipelineType))
{
LOG_WARNING_MESSAGE("Unable to get mutable/dynamic variable at index ", Index, " in shader stage ", GetShaderTypeLiteralName(ShaderType),
- " as the stage is invalid for ", GetPipelineTypeString(m_pPSO->GetDesc().PipelineType), " pipeline '", m_pPSO->GetDesc().Name, "'.");
+ " as the stage is invalid for ", GetPipelineTypeString(PipelineType), " pipeline resource signature '", m_pPRS->GetDesc().Name, "'.");
return -1;
}
@@ -143,17 +164,19 @@ protected:
if (ResLayoutInd < 0)
{
LOG_WARNING_MESSAGE("Unable to get mutable/dynamic variable at index ", Index, " in shader stage ", GetShaderTypeLiteralName(ShaderType),
- " as the stage is inactive in PSO '", m_pPSO->GetDesc().Name, "'.");
+ " as the stage is inactive in pipeline resource signature '", m_pPRS->GetDesc().Name, "'.");
}
return ResLayoutInd;
}
- /// Strong reference to PSO. We must use strong reference, because
- /// shader resource binding uses PSO's memory allocator to allocate
+protected:
+ /// Strong reference to pipeline resource signature. We must use strong reference, because
+ /// shader resource binding uses pipeline resource signature's memory allocator to allocate
/// memory for shader resource cache.
- RefCntAutoPtr<PipelineStateImplType> m_spPSO;
- PipelineStateImplType* const m_pPSO;
+ RefCntAutoPtr<ResourceSignatureType> m_spPRS;
+
+ IPipelineResourceSignature* m_pPRS = nullptr;
};
} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/Constants.h b/Graphics/GraphicsEngine/interface/Constants.h
index f72bff62..e91cbdad 100644
--- a/Graphics/GraphicsEngine/interface/Constants.h
+++ b/Graphics/GraphicsEngine/interface/Constants.h
@@ -54,6 +54,8 @@ static const Uint32 MAX_VIEWPORTS = DILIGENT_MAX_VIEWPORTS;
/// (Vertex, Hull, Domain, Geometry, Pixel) or (Amplification, Mesh, Pixel), or (Compute) or (RayGen, Miss, ClosestHit, AnyHit, Intersection, Callable)
static const Uint32 MAX_SHADERS_IN_PIPELINE = 6;
+static const Uint32 MAX_RESOURCE_SIGNATURES = 8;
+
// clang-format on
DILIGENT_END_NAMESPACE // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/PipelineResourceSignature.h b/Graphics/GraphicsEngine/interface/PipelineResourceSignature.h
new file mode 100644
index 00000000..d4c58e92
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/PipelineResourceSignature.h
@@ -0,0 +1,254 @@
+/*
+ * 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
+
+// clang-format off
+
+/// \file
+/// Definition of the Diligent::IRenderDevice interface and related data structures
+
+#include "../../../Primitives/interface/Object.h"
+#include "../../../Platforms/interface/PlatformDefinitions.h"
+#include "GraphicsTypes.h"
+#include "Shader.h"
+#include "Sampler.h"
+#include "ShaderResourceVariable.h"
+#include "ShaderResourceBinding.h"
+
+DILIGENT_BEGIN_NAMESPACE(Diligent)
+
+
+/// Immutable sampler description.
+
+/// An immutable sampler is compiled into the pipeline state and can't be changed.
+/// It is generally more efficient than a regular sampler and should be used
+/// whenever possible.
+struct ImmutableSamplerDesc
+{
+ /// Shader stages that this immutable sampler applies to. More than one shader stage can be specified.
+ SHADER_TYPE ShaderStages DEFAULT_INITIALIZER(SHADER_TYPE_UNKNOWN);
+
+ /// The name of the sampler itself or the name of the texture variable that
+ /// this immutable sampler is assigned to if combined texture samplers are used.
+ const Char* SamplerOrTextureName DEFAULT_INITIALIZER(nullptr);
+
+ /// Sampler description
+ struct SamplerDesc Desc;
+
+#if DILIGENT_CPP_INTERFACE
+ ImmutableSamplerDesc()noexcept{}
+
+ ImmutableSamplerDesc(SHADER_TYPE _ShaderStages,
+ const Char* _SamplerOrTextureName,
+ const SamplerDesc& _Desc)noexcept :
+ ShaderStages {_ShaderStages },
+ SamplerOrTextureName{_SamplerOrTextureName},
+ Desc {_Desc }
+ {}
+#endif
+};
+typedef struct ImmutableSamplerDesc ImmutableSamplerDesc;
+
+
+/// AZ TODO: comment
+DILIGENT_TYPED_ENUM(PIPELINE_RESOURCE_FLAGS, Uint8)
+{
+ PIPELINE_RESOURCE_FLAG_UNKNOWN = 0x00,
+ PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_OFFSETS = 0x01, ///< Vulkan only, for SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, SHADER_RESOURCE_TYPE_BUFFER_UAV, SHADER_RESOURCE_TYPE_BUFFER_SRV
+ PIPELINE_RESOURCE_FLAG_COMBINED_IMAGE = 0x02, ///< For SHADER_RESOURCE_TYPE_TEXTURE_SRV
+ PIPELINE_RESOURCE_FLAG_TEXEL_BUFFER = 0x04, ///< For SHADER_RESOURCE_TYPE_BUFFER_UAV, SHADER_RESOURCE_TYPE_BUFFER_SRV
+};
+DEFINE_FLAG_ENUM_OPERATORS(PIPELINE_RESOURCE_FLAGS);
+
+
+/// AZ TODO: comment
+struct PipelineResourceDesc
+{
+ /// AZ TODO: comment
+ const char* Name DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO: comment
+ SHADER_TYPE ShaderStages DEFAULT_INITIALIZER(SHADER_TYPE_UNKNOWN);
+
+ /// AZ TODO: comment
+ Uint32 ArraySize DEFAULT_INITIALIZER(1);
+
+ /// AZ TODO: comment
+ SHADER_RESOURCE_TYPE ResourceType DEFAULT_INITIALIZER(SHADER_RESOURCE_TYPE_UNKNOWN);
+
+ /// AZ TODO: comment
+ SHADER_RESOURCE_VARIABLE_TYPE VarType DEFAULT_INITIALIZER(SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE);
+
+ /// AZ TODO: comment
+ PIPELINE_RESOURCE_FLAGS Flags DEFAULT_INITIALIZER(PIPELINE_RESOURCE_FLAG_UNKNOWN);
+
+ /// AZ TODO: comment
+ RESOURCE_DIMENSION ResourceDim DEFAULT_INITIALIZER(RESOURCE_DIM_UNDEFINED);
+
+#if DILIGENT_CPP_INTERFACE
+ PipelineResourceDesc()noexcept{}
+
+ PipelineResourceDesc(const char* _Name,
+ Uint32 _ArraySize,
+ SHADER_RESOURCE_TYPE _ResourceType,
+ SHADER_TYPE _ShaderStages,
+ SHADER_RESOURCE_VARIABLE_TYPE _VarType,
+ RESOURCE_DIMENSION _Dim = RESOURCE_DIM_UNDEFINED,
+ PIPELINE_RESOURCE_FLAGS _Flags = PIPELINE_RESOURCE_FLAG_UNKNOWN)noexcept :
+ Name {_Name },
+ ArraySize {_ArraySize },
+ ResourceType{_ResourceType},
+ ShaderStages{_ShaderStages},
+ VarType {_VarType },
+ Flags {_Flags },
+ ResourceDim {_Dim }
+ {}
+#endif
+};
+typedef struct PipelineResourceDesc PipelineResourceDesc;
+
+
+/// AZ TODO: comment
+struct PipelineResourceSignatureDesc DILIGENT_DERIVE(DeviceObjectAttribs)
+
+ /// AZ TODO: comment
+ const PipelineResourceDesc* Resources DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO: comment
+ Uint32 NumResources DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO: comment
+ const ImmutableSamplerDesc* ImmutableSamplers DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO: comment
+ Uint32 NumImmutableSamplers DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO: comment
+ Uint8 BindingIndex DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO: comment
+ Uint16 BindingOffsets [SHADER_RESOURCE_TYPE_LAST + 1] DEFAULT_INITIALIZER({});
+
+ /// Shader resource binding allocation granularity
+
+ /// This member defines allocation granularity for internal resources required by the shader resource
+ /// binding object instances.
+ Uint32 SRBAllocationGranularity DEFAULT_INITIALIZER(1);
+};
+typedef struct PipelineResourceSignatureDesc PipelineResourceSignatureDesc;
+
+
+// {DCE499A5-F812-4C93-B108-D684A0B56118}
+static const INTERFACE_ID IID_PipelineResourceSignature =
+ {0xdce499a5, 0xf812, 0x4c93, {0xb1, 0x8, 0xd6, 0x84, 0xa0, 0xb5, 0x61, 0x18}};
+
+#define DILIGENT_INTERFACE_NAME IPipelineResourceSignature
+#include "../../../Primitives/interface/DefineInterfaceHelperMacros.h"
+
+#define IPipelineResourceSignatureInclusiveMethods \
+ IDeviceObjectInclusiveMethods; \
+ IPipelineResourceSignatureMethods PipelineResourceSignature
+
+// clang-format off
+
+/// Pipeline state interface
+DILIGENT_BEGIN_INTERFACE(IPipelineResourceSignature, IDeviceObject)
+{
+#if DILIGENT_CPP_INTERFACE
+ /// AZ TODO: comment
+ virtual const PipelineResourceSignatureDesc& METHOD(GetDesc)() const override = 0;
+#endif
+
+ /// Creates a shader resource binding object
+
+ /// \param [out] ppShaderResourceBinding - memory location where pointer to the new shader resource
+ /// binding object is written.
+ /// \param [in] InitStaticResources - if set to true, the method will initialize static resources in
+ /// the created object, which has the exact same effect as calling
+ /// IShaderResourceBinding::InitializeStaticResources().
+ VIRTUAL void METHOD(CreateShaderResourceBinding)(THIS_
+ IShaderResourceBinding** ppShaderResourceBinding,
+ bool InitStaticResources DEFAULT_VALUE(false)) PURE;
+
+
+ /// Returns static shader resource variable. If the variable is not found,
+ /// returns nullptr.
+
+ /// \param [in] ShaderType - Type of the shader to look up the variable.
+ /// Must be one of Diligent::SHADER_TYPE.
+ /// \param [in] Name - Name of the variable.
+ /// \remark The method does not increment the reference counter
+ /// of the returned interface.
+ VIRTUAL IShaderResourceVariable* METHOD(GetStaticVariableByName)(THIS_
+ SHADER_TYPE ShaderType,
+ const Char* Name) PURE;
+
+
+ /// Returns static shader resource variable by its index.
+
+ /// \param [in] ShaderType - Type of the shader to look up the variable.
+ /// Must be one of Diligent::SHADER_TYPE.
+ /// \param [in] Index - Shader variable index. The index must be between
+ /// 0 and the total number of variables returned by
+ /// GetStaticVariableCount().
+ /// \remark Only static shader resource variables can be accessed through this method.
+ /// Mutable and dynamic variables are accessed through Shader Resource
+ /// Binding object
+ VIRTUAL IShaderResourceVariable* METHOD(GetStaticVariableByIndex)(THIS_
+ SHADER_TYPE ShaderType,
+ Uint32 Index) PURE;
+
+
+ /// Returns the number of static shader resource variables.
+
+ /// \param [in] ShaderType - Type of the shader.
+ /// \remark Only static variables (that can be accessed directly through the PSO) are counted.
+ /// Mutable and dynamic variables are accessed through Shader Resource Binding object.
+ VIRTUAL Uint32 METHOD(GetStaticVariableCount)(THIS_
+ SHADER_TYPE ShaderType) CONST PURE;
+};
+DILIGENT_END_INTERFACE
+
+#include "../../../Primitives/interface/UndefInterfaceHelperMacros.h"
+
+#if DILIGENT_C_INTERFACE
+
+// clang-format off
+
+# define IPipelineResourceSignature_GetDesc(This) (const struct PipelineResourceSignatureDesc*)IDeviceObject_GetDesc(This)
+
+# define IPipelineResourceSignature_CreateShaderResourceBinding(This, ...) CALL_IFACE_METHOD(PipelineResourceSignature, CreateShaderResourceBinding, This, __VA_ARGS__)
+# define IPipelineResourceSignature_GetStaticVariableByName(This, ...) CALL_IFACE_METHOD(PipelineResourceSignature, GetStaticVariableByName, This, __VA_ARGS__)
+# define IPipelineResourceSignature_GetStaticVariableByIndex(This, ...) CALL_IFACE_METHOD(PipelineResourceSignature, GetStaticVariableByIndex, This, __VA_ARGS__)
+# define IPipelineResourceSignature_GetStaticVariableCount(This, ...) CALL_IFACE_METHOD(PipelineResourceSignature, GetStaticVariableCount, This, __VA_ARGS__)
+
+// clang-format on
+
+#endif
+
+DILIGENT_END_NAMESPACE
diff --git a/Graphics/GraphicsEngine/interface/PipelineState.h b/Graphics/GraphicsEngine/interface/PipelineState.h
index a76df40b..f780d4d6 100644
--- a/Graphics/GraphicsEngine/interface/PipelineState.h
+++ b/Graphics/GraphicsEngine/interface/PipelineState.h
@@ -44,6 +44,7 @@
#include "Shader.h"
#include "Sampler.h"
#include "RenderPass.h"
+#include "PipelineResourceSignature.h"
DILIGENT_BEGIN_NAMESPACE(Diligent)
@@ -96,37 +97,6 @@ struct ShaderResourceVariableDesc
typedef struct ShaderResourceVariableDesc ShaderResourceVariableDesc;
-/// Immutable sampler description.
-
-/// An immutable sampler is compiled into the pipeline state and can't be changed.
-/// It is generally more efficient than a regular sampler and should be used
-/// whenever possible.
-struct ImmutableSamplerDesc
-{
- /// Shader stages that this immutable sampler applies to. More than one shader stage can be specified.
- SHADER_TYPE ShaderStages DEFAULT_INITIALIZER(SHADER_TYPE_UNKNOWN);
-
- /// The name of the sampler itself or the name of the texture variable that
- /// this immutable sampler is assigned to if combined texture samplers are used.
- const Char* SamplerOrTextureName DEFAULT_INITIALIZER(nullptr);
-
- /// Sampler description
- struct SamplerDesc Desc;
-
-#if DILIGENT_CPP_INTERFACE
- ImmutableSamplerDesc()noexcept{}
-
- ImmutableSamplerDesc(SHADER_TYPE _ShaderStages,
- const Char* _SamplerOrTextureName,
- const SamplerDesc& _Desc)noexcept :
- ShaderStages {_ShaderStages },
- SamplerOrTextureName{_SamplerOrTextureName},
- Desc {_Desc }
- {}
-#endif
-};
-typedef struct ImmutableSamplerDesc ImmutableSamplerDesc;
-
/// Pipeline layout description
struct PipelineResourceLayoutDesc
{
@@ -396,6 +366,12 @@ struct PipelineStateCreateInfo
/// Pipeline state creation flags, see Diligent::PSO_CREATE_FLAGS.
PSO_CREATE_FLAGS Flags DEFAULT_INITIALIZER(PSO_CREATE_FLAG_NONE);
+
+ /// AZ TODO
+ IPipelineResourceSignature** ppResourceSignatures DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ Uint32 ResourceSignaturesCount DEFAULT_INITIALIZER(0);
};
typedef struct PipelineStateCreateInfo PipelineStateCreateInfo;
@@ -524,6 +500,7 @@ DILIGENT_BEGIN_INTERFACE(IPipelineState, IDeviceObject)
/// This method must only be called for a ray tracing pipeline.
VIRTUAL const RayTracingPipelineDesc REF METHOD(GetRayTracingPipelineDesc)(THIS) CONST PURE;
+
/// Binds resources for all shaders in the pipeline state
/// \param [in] ShaderFlags - Flags that specify shader stages, for which resources will be bound.
@@ -535,8 +512,9 @@ DILIGENT_BEGIN_INTERFACE(IPipelineState, IDeviceObject)
IResourceMapping* pResourceMapping,
Uint32 Flags) PURE;
-
+
/// Returns the number of static shader resource variables.
+ /// Deprecated: use GetResourceSignature() and call IPipelineResourceSignature::GetStaticVariableCount().
/// \param [in] ShaderType - Type of the shader.
/// \remark Only static variables (that can be accessed directly through the PSO) are counted.
@@ -544,9 +522,10 @@ DILIGENT_BEGIN_INTERFACE(IPipelineState, IDeviceObject)
VIRTUAL Uint32 METHOD(GetStaticVariableCount)(THIS_
SHADER_TYPE ShaderType) CONST PURE;
-
+
/// Returns static shader resource variable. If the variable is not found,
/// returns nullptr.
+ /// Deprecated: use GetResourceSignature() and call IPipelineResourceSignature::GetStaticVariableByName().
/// \param [in] ShaderType - Type of the shader to look up the variable.
/// Must be one of Diligent::SHADER_TYPE.
@@ -557,8 +536,9 @@ DILIGENT_BEGIN_INTERFACE(IPipelineState, IDeviceObject)
SHADER_TYPE ShaderType,
const Char* Name) PURE;
-
+
/// Returns static shader resource variable by its index.
+ /// Deprecated: use GetResourceSignature() and call IPipelineResourceSignature::GetStaticVariableByIndex().
/// \param [in] ShaderType - Type of the shader to look up the variable.
/// Must be one of Diligent::SHADER_TYPE.
@@ -573,7 +553,8 @@ DILIGENT_BEGIN_INTERFACE(IPipelineState, IDeviceObject)
Uint32 Index) PURE;
- /// Creates a shader resource binding object
+ /// Creates a shader resource binding object.
+ /// Deprecated: use GetResourceSignature() and call IPipelineResourceSignature::CreateShaderResourceBinding().
/// \param [out] ppShaderResourceBinding - memory location where pointer to the new shader resource
/// binding object is written.
@@ -601,6 +582,14 @@ DILIGENT_BEGIN_INTERFACE(IPipelineState, IDeviceObject)
/// into account vertex shader input layout, number of outputs, etc.
VIRTUAL bool METHOD(IsCompatibleWith)(THIS_
const struct IPipelineState* pPSO) CONST PURE;
+
+
+ /// AZ TODO: comment
+ VIRTUAL Uint32 METHOD(GetResourceSignatureCount)(THIS) CONST PURE;
+
+ /// AZ TODO: comment
+ VIRTUAL IPipelineResourceSignature* METHOD(GetResourceSignature)(THIS_
+ Uint32 Index) CONST PURE;
};
DILIGENT_END_INTERFACE
@@ -620,6 +609,8 @@ DILIGENT_END_INTERFACE
# define IPipelineState_GetStaticVariableByIndex(This, ...) CALL_IFACE_METHOD(PipelineState, GetStaticVariableByIndex, This, __VA_ARGS__)
# define IPipelineState_CreateShaderResourceBinding(This, ...) CALL_IFACE_METHOD(PipelineState, CreateShaderResourceBinding, This, __VA_ARGS__)
# define IPipelineState_IsCompatibleWith(This, ...) CALL_IFACE_METHOD(PipelineState, IsCompatibleWith, This, __VA_ARGS__)
+# define IPipelineState_GetResourceSignatureCount(This) CALL_IFACE_METHOD(PipelineState, GetResourceSignatureCount, This)
+# define IPipelineState_GetResourceSignature(This, ...) CALL_IFACE_METHOD(PipelineState, GetResourceSignature, This, __VA_ARGS__)
// clang-format on
diff --git a/Graphics/GraphicsEngine/interface/RenderDevice.h b/Graphics/GraphicsEngine/interface/RenderDevice.h
index 04abda25..b9fba033 100644
--- a/Graphics/GraphicsEngine/interface/RenderDevice.h
+++ b/Graphics/GraphicsEngine/interface/RenderDevice.h
@@ -50,6 +50,7 @@
#include "BottomLevelAS.h"
#include "TopLevelAS.h"
#include "ShaderBindingTable.h"
+#include "PipelineResourceSignature.h"
#include "DepthStencilState.h"
#include "RasterizerState.h"
@@ -273,6 +274,11 @@ DILIGENT_BEGIN_INTERFACE(IRenderDevice, IObject)
const ShaderBindingTableDesc REF Desc,
IShaderBindingTable** ppSBT) PURE;
+ /// AZ TODO: comment
+ VIRTUAL void METHOD(CreatePipelineResourceSignature)(THIS_
+ const PipelineResourceSignatureDesc REF Desc,
+ IPipelineResourceSignature** ppSignature) PURE;
+
/// Gets the device capabilities, see Diligent::DeviceCaps for details
VIRTUAL const DeviceCaps REF METHOD(GetDeviceCaps)(THIS) CONST PURE;
diff --git a/Graphics/GraphicsEngine/interface/ShaderResourceBinding.h b/Graphics/GraphicsEngine/interface/ShaderResourceBinding.h
index b5ba9cac..8c7f006f 100644
--- a/Graphics/GraphicsEngine/interface/ShaderResourceBinding.h
+++ b/Graphics/GraphicsEngine/interface/ShaderResourceBinding.h
@@ -38,6 +38,7 @@
DILIGENT_BEGIN_NAMESPACE(Diligent)
struct IPipelineState;
+struct IPipelineResourceSignature;
// {061F8774-9A09-48E8-8411-B5BD20560104}
static const INTERFACE_ID IID_ShaderResourceBinding =
@@ -56,11 +57,20 @@ static const INTERFACE_ID IID_ShaderResourceBinding =
/// Shader resource binding interface
DILIGENT_BEGIN_INTERFACE(IShaderResourceBinding, IObject)
{
- /// Returns pointer to the referenced buffer object.
+ /// Returns pointer to the referenced PSO object.
+ /// Deprecated: use GetPipelineResourceSignature() instead.
/// The method calls AddRef() on the returned interface,
/// so Release() must be called to avoid memory leaks.
- VIRTUAL struct IPipelineState* METHOD(GetPipelineState)(THIS) PURE;
+// VIRTUAL struct IPipelineState* METHOD(GetPipelineState)(THIS) PURE;
+
+
+ /// Returns pointer to the referenced pipeline resource signature object.
+
+ /// The method calls AddRef() on the returned interface,
+ /// so Release() must be called to avoid memory leaks.
+ VIRTUAL struct IPipelineResourceSignature* METHOD(GetPipelineResourceSignature)(THIS) PURE;
+
/// Binds mutable and dynamice resources using the resource mapping
@@ -112,6 +122,7 @@ DILIGENT_BEGIN_INTERFACE(IShaderResourceBinding, IObject)
/// Initializes static resources
+ // Deprecated: use
/// If the parent pipeline state object contain static resources
/// (see Diligent::SHADER_RESOURCE_VARIABLE_TYPE_STATIC), this method must be called
@@ -128,6 +139,10 @@ DILIGENT_BEGIN_INTERFACE(IShaderResourceBinding, IObject)
/// no effect and a warning messge will be displayed.
VIRTUAL void METHOD(InitializeStaticResources)(THIS_
const struct IPipelineState* pPipelineState DEFAULT_VALUE(nullptr)) PURE;
+
+ /// AZ TODO: comment
+ VIRTUAL void METHOD(InitializeStaticResourcesWithSignature)(THIS_
+ const struct IPipelineResourceSignature* pResourceSignature DEFAULT_VALUE(nullptr)) PURE;
};
DILIGENT_END_INTERFACE
@@ -137,12 +152,14 @@ DILIGENT_END_INTERFACE
// clang-format off
-# define IShaderResourceBinding_GetPipelineState(This) CALL_IFACE_METHOD(ShaderResourceBinding, GetPipelineState, This)
-# define IShaderResourceBinding_BindResources(This, ...) CALL_IFACE_METHOD(ShaderResourceBinding, BindResources, This, __VA_ARGS__)
-# define IShaderResourceBinding_GetVariableByName(This, ...) CALL_IFACE_METHOD(ShaderResourceBinding, GetVariableByName, This, __VA_ARGS__)
-# define IShaderResourceBinding_GetVariableCount(This, ...) CALL_IFACE_METHOD(ShaderResourceBinding, GetVariableCount, This, __VA_ARGS__)
-# define IShaderResourceBinding_GetVariableByIndex(This, ...) CALL_IFACE_METHOD(ShaderResourceBinding, GetVariableByIndex, This, __VA_ARGS__)
-# define IShaderResourceBinding_InitializeStaticResources(This, ...) CALL_IFACE_METHOD(ShaderResourceBinding, InitializeStaticResources, This, __VA_ARGS__)
+//# define IShaderResourceBinding_GetPipelineState(This) CALL_IFACE_METHOD(ShaderResourceBinding, GetPipelineState, This)
+# define IShaderResourceBinding_GetPipelineResourceSignature(This) CALL_IFACE_METHOD(ShaderResourceBinding, GetPipelineResourceSignature, This)
+# define IShaderResourceBinding_BindResources(This, ...) CALL_IFACE_METHOD(ShaderResourceBinding, BindResources, This, __VA_ARGS__)
+# define IShaderResourceBinding_GetVariableByName(This, ...) CALL_IFACE_METHOD(ShaderResourceBinding, GetVariableByName, This, __VA_ARGS__)
+# define IShaderResourceBinding_GetVariableCount(This, ...) CALL_IFACE_METHOD(ShaderResourceBinding, GetVariableCount, This, __VA_ARGS__)
+# define IShaderResourceBinding_GetVariableByIndex(This, ...) CALL_IFACE_METHOD(ShaderResourceBinding, GetVariableByIndex, This, __VA_ARGS__)
+# define IShaderResourceBinding_InitializeStaticResources(This, ...) CALL_IFACE_METHOD(ShaderResourceBinding, InitializeStaticResources, This, __VA_ARGS__)
+# define IShaderResourceBinding_InitializeStaticResourcesWithSignature(This, ...) CALL_IFACE_METHOD(ShaderResourceBinding, InitializeStaticResourcesWithSignature, This, __VA_ARGS__)
// clang-format on