summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorazhirnov <zh1dron@gmail.com>2021-02-25 18:00:12 +0000
committerassiduous <assiduous@diligentgraphics.com>2021-03-19 00:38:11 +0000
commit65dd6c5aa598653cf6b828efd51fc359fc758b36 (patch)
tree1cef78e3c36f99af95dc8edcc477ed0fc17f575d /Graphics/GraphicsEngine
parentD3D12 backend: added extra validation of pipeline resource signature resource... (diff)
downloadDiligentCore-65dd6c5aa598653cf6b828efd51fc359fc758b36.tar.gz
DiligentCore-65dd6c5aa598653cf6b828efd51fc359fc758b36.zip
some fixes and improvements for D3D12 & Vulkan
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp49
-rw-r--r--Graphics/GraphicsEngine/interface/GraphicsTypes.h2
-rw-r--r--Graphics/GraphicsEngine/interface/PipelineResourceSignature.h3
-rw-r--r--Graphics/GraphicsEngine/interface/PipelineState.h7
-rw-r--r--Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp7
5 files changed, 59 insertions, 9 deletions
diff --git a/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp b/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp
index 4cc9f3b6..49be28cf 100644
--- a/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp
+++ b/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp
@@ -47,7 +47,7 @@ namespace Diligent
{
/// Validates pipeline resource signature description and throws an exception in case of an error.
-void ValidatePipelineResourceSignatureDesc(const PipelineResourceSignatureDesc& Desc) noexcept(false);
+void ValidatePipelineResourceSignatureDesc(const PipelineResourceSignatureDesc& Desc, bool ShaderResourceRuntimeArraySupported) noexcept(false);
static constexpr Uint32 InvalidImmutableSamplerIndex = ~0u;
/// Finds an immutable sampler for the resource name 'ResourceName' that is defined in shader stages 'ShaderStages'.
@@ -94,7 +94,7 @@ public:
this->m_Desc.ImmutableSamplers = nullptr;
this->m_Desc.CombinedSamplerSuffix = nullptr;
- ValidatePipelineResourceSignatureDesc(Desc);
+ ValidatePipelineResourceSignatureDesc(Desc, pDevice->GetDeviceCaps().Features.ShaderResourceRuntimeArray);
// Determine shader stages that have any resources as well as
// shader stages that have static resources.
@@ -155,6 +155,11 @@ public:
return PlatformMisc::CountOneBits(Uint32{m_ShaderStages});
}
+ SHADER_TYPE GetActiveShaderStages() const
+ {
+ return m_ShaderStages;
+ }
+
// Returns the number of shader stages that have static resources.
Uint32 GetNumStaticResStages() const
{
@@ -214,6 +219,46 @@ public:
return this->m_Desc.ImmutableSamplers[SampIndex];
}
+ template <typename TPipelineResourceSignature>
+ static void CopyResourceSignatures(PIPELINE_TYPE PipelineType,
+ const Uint32 SignatureCount,
+ IPipelineResourceSignature* ppResourceSignatures[],
+ RefCntAutoPtr<TPipelineResourceSignature> DstSignatures[],
+ const size_t MaxDstSignatureCount,
+ Uint8& DstSignatureCount)
+ {
+ for (Uint32 i = 0; i < SignatureCount; ++i)
+ {
+ auto* pSignature = ValidatedCast<TPipelineResourceSignature>(ppResourceSignatures[i]);
+ VERIFY(pSignature != nullptr, "Pipeline resource signature at index ", i, " is null. This error should've been caught by ValidatePipelineResourceSignatures.");
+
+ const Uint8 Index = pSignature->GetDesc().BindingIndex;
+
+#ifdef DILIGENT_DEBUG
+ VERIFY(Index < MaxDstSignatureCount,
+ "Pipeline resource signature specifies binding index ", Uint32{Index}, " that exceeds the limit (", MaxDstSignatureCount - 1,
+ "). This error should've been caught by ValidatePipelineResourceSignatureDesc.");
+
+ VERIFY(DstSignatures[Index] == nullptr,
+ "Pipeline resource signature '", pSignature->GetDesc().Name, "' at index ", Uint32{Index},
+ " conflicts with another resource signature '", DstSignatures[Index]->GetDesc().Name,
+ "' that uses the same index. This error should've been caught by ValidatePipelineResourceSignatures.");
+
+ for (Uint32 s = 0, StageCount = pSignature->GetNumActiveShaderStages(); s < StageCount; ++s)
+ {
+ const auto ShaderType = pSignature->GetActiveShaderStageType(s);
+ VERIFY(IsConsistentShaderType(ShaderType, PipelineType),
+ "Pipeline resource signature '", pSignature->GetDesc().Name, "' at index ", Uint32{Index},
+ " has shader stage '", GetShaderTypeLiteralName(ShaderType), "' that is not compatible with pipeline type '",
+ GetPipelineTypeString(PipelineType), "'.");
+ }
+#endif
+
+ DstSignatureCount = std::max<Uint8>(DstSignatureCount, Index + 1);
+ DstSignatures[Index] = pSignature;
+ }
+ }
+
protected:
void ReserveSpaceForDescription(FixedLinearAllocator& Allocator, const PipelineResourceSignatureDesc& Desc) const noexcept(false)
{
diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h
index 5e236134..ae11a655 100644
--- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h
+++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h
@@ -860,7 +860,7 @@ DILIGENT_TYPED_ENUM(TEXTURE_ADDRESS_MODE, Uint8)
/// Direct3D Counterpart: D3D11_TEXTURE_ADDRESS_CLAMP/D3D12_TEXTURE_ADDRESS_MODE_CLAMP. OpenGL counterpart: GL_CLAMP_TO_EDGE
TEXTURE_ADDRESS_CLAMP = 3,
- /// Texture coordinates outside the range [0.0, 1.0] are set to the border color specified
+ /// Texture coordinates outside the range [0.0, 1.0] are set to the border color
/// specified in SamplerDesc structure. \n
/// Direct3D Counterpart: D3D11_TEXTURE_ADDRESS_BORDER/D3D12_TEXTURE_ADDRESS_MODE_BORDER. OpenGL counterpart: GL_CLAMP_TO_BORDER
TEXTURE_ADDRESS_BORDER = 4,
diff --git a/Graphics/GraphicsEngine/interface/PipelineResourceSignature.h b/Graphics/GraphicsEngine/interface/PipelineResourceSignature.h
index 5b6aac96..e4461e75 100644
--- a/Graphics/GraphicsEngine/interface/PipelineResourceSignature.h
+++ b/Graphics/GraphicsEngine/interface/PipelineResourceSignature.h
@@ -185,9 +185,6 @@ struct PipelineResourceSignatureDesc DILIGENT_DERIVE(DeviceObjectAttribs)
/// to different slots.
Uint8 BindingIndex DEFAULT_INITIALIZER(0);
- /// AZ TODO: comment
- Uint16 BindingOffsets [SHADER_RESOURCE_TYPE_LAST + 1] DEFAULT_INITIALIZER({});
-
/// If set to true, textures will be combined with texture samplers.
/// The CombinedSamplerSuffix member defines the suffix added to the texture variable
/// name to get corresponding sampler name. When using combined samplers,
diff --git a/Graphics/GraphicsEngine/interface/PipelineState.h b/Graphics/GraphicsEngine/interface/PipelineState.h
index 801548e1..749344a0 100644
--- a/Graphics/GraphicsEngine/interface/PipelineState.h
+++ b/Graphics/GraphicsEngine/interface/PipelineState.h
@@ -630,7 +630,7 @@ DILIGENT_BEGIN_INTERFACE(IPipelineState, IDeviceObject)
/// If two pipeline state objects are compatible, they can use shader resource binding
/// objects interchangebly, i.e. SRBs created by one PSO can be committed
/// when another PSO is bound.
- /// \param [in] pPSO - Pointer to the pipeline state object to check compatibility with
+ /// \param [in] pPSO - Pointer to the pipeline state object to check compatibility with.
/// \return true if this PSO is compatbile with pPSO. false otherwise.
/// \remarks The function only checks that shader resource layouts are compatible, but
/// does not check if resource types match. For instance, if a pixel shader in one PSO
@@ -652,11 +652,14 @@ DILIGENT_BEGIN_INTERFACE(IPipelineState, IDeviceObject)
VIRTUAL bool METHOD(IsCompatibleWith)(THIS_
const struct IPipelineState* pPSO) CONST PURE;
-
+
/// Returns the number of pipeline resource signature used to created this pipeline.
VIRTUAL Uint32 METHOD(GetResourceSignatureCount)(THIS) CONST PURE;
/// Returns pipeline resource signature at the give index.
+
+ /// \param [in] Index - Index of the resource signature, same as BindingIndex in PipelineResourceSignatureDesc.
+ /// \return Pointer to pipeline resource signature interface.
VIRTUAL IPipelineResourceSignature* METHOD(GetResourceSignature)(THIS_
Uint32 Index) CONST PURE;
};
diff --git a/Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp b/Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp
index a85e20dd..0f359e52 100644
--- a/Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp
+++ b/Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp
@@ -37,7 +37,7 @@ namespace Diligent
#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 ValidatePipelineResourceSignatureDesc(const PipelineResourceSignatureDesc& Desc) noexcept(false)
+void ValidatePipelineResourceSignatureDesc(const PipelineResourceSignatureDesc& Desc, bool ShaderResourceRuntimeArraySupported) noexcept(false)
{
if (Desc.BindingIndex >= MAX_RESOURCE_SIGNATURES)
LOG_PRS_ERROR_AND_THROW("Desc.BindingIndex (", Uint32{Desc.BindingIndex}, ") exceeds the maximum allowed value (", MAX_RESOURCE_SIGNATURES - 1, ").");
@@ -81,6 +81,11 @@ void ValidatePipelineResourceSignatureDesc(const PipelineResourceSignatureDesc&
}
UsedStages |= Res.ShaderStages;
+ if ((Res.Flags & PIPELINE_RESOURCE_FLAG_RUNTIME_ARRAY) != 0 && !ShaderResourceRuntimeArraySupported)
+ {
+ LOG_PRS_ERROR_AND_THROW("Incorrect Desc.Resources[", i, "].Flags: RUNTIME_ARRAY can be used only if ShaderResourceRuntimeArray device feature is enabled.");
+ }
+
static_assert(SHADER_RESOURCE_TYPE_LAST == 8, "Please add the new resource type to the switch below");
switch (Res.ResourceType)
{