summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
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/GraphicsEngineVulkan
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/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/PipelineResourceSignatureVkImpl.hpp7
-rw-r--r--Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.hpp1
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp21
-rw-r--r--Graphics/GraphicsEngineVulkan/src/PipelineLayoutVk.cpp32
-rw-r--r--Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp1
7 files changed, 25 insertions, 41 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/PipelineResourceSignatureVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/PipelineResourceSignatureVkImpl.hpp
index f8215d49..e1dd094d 100644
--- a/Graphics/GraphicsEngineVulkan/include/PipelineResourceSignatureVkImpl.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/PipelineResourceSignatureVkImpl.hpp
@@ -224,7 +224,10 @@ public:
/// Implementation of IPipelineResourceSignature::IsCompatibleWith.
virtual bool DILIGENT_CALL_TYPE IsCompatibleWith(const IPipelineResourceSignature* pPRS) const override final
{
- VERIFY_EXPR(pPRS != nullptr);
+ if (pPRS == nullptr)
+ {
+ return GetHash() == 0;
+ }
return IsCompatibleWith(*ValidatedCast<const PipelineResourceSignatureVkImpl>(pPRS));
}
@@ -329,7 +332,7 @@ private:
// Static resource cache for all static resources
ShaderResourceCacheVk* m_pStaticResCache = nullptr;
// Static variables manager for every shader stage
- ShaderVariableManagerVk* m_StaticVarsMgrs = nullptr; // [m_NumShaderStages]
+ ShaderVariableManagerVk* m_StaticVarsMgrs = nullptr; // [GetNumStaticResStages()]
ImmutableSamplerAttribs* m_ImmutableSamplers = nullptr; // [m_Desc.NumImmutableSamplers]
diff --git a/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.hpp
index a37638dd..16206349 100644
--- a/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.hpp
@@ -92,7 +92,6 @@ public:
SubpassDesc& SubpassDesc);
- void InitializeStaticSRBResources(ShaderResourceCacheVk& ResourceCache) const;
struct ShaderStageInfo
{
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp
index 54cd3b3a..c0e012a2 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp
@@ -74,7 +74,7 @@ private:
void Destruct();
ShaderResourceCacheVk m_ShaderResourceCache;
- ShaderVariableManagerVk* m_pShaderVarMgrs = nullptr;
+ ShaderVariableManagerVk* m_pShaderVarMgrs = nullptr; // [m_NumShaders]
};
} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
index 2ae180e7..27cdfbee 100644
--- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
@@ -326,7 +326,7 @@ void DeviceContextVkImpl::SetPipelineState(IPipelineState* pPipelineState)
for (Uint32 i = 0; i < SignCount; ++i)
{
auto* pSignature = Layout.GetSignature(i);
- if (pSignature == nullptr)
+ if (pSignature == nullptr || pSignature->GetNumDescriptorSets() == 0)
continue;
BindInfo.ActiveSRBMask |= 1u << i;
@@ -349,13 +349,20 @@ void DeviceContextVkImpl::SetPipelineState(IPipelineState* pPipelineState)
Uint32 sign = 0;
for (; sign < SignCount; ++sign)
{
- const auto* LayoutSign = Layout.GetSignature(sign);
- if (LayoutSign == nullptr)
- continue;
+ const auto* pLayoutSign = Layout.GetSignature(sign);
+ const auto* pSRBSign = BindInfo.SRBs[sign] != nullptr ? BindInfo.SRBs[sign]->GetSignature() : nullptr;
- auto* pSRB = BindInfo.SRBs[sign];
- if (pSRB == nullptr || LayoutSign->IsIncompatibleWith(*pSRB->GetSignature()))
+ if ((pLayoutSign == nullptr || pLayoutSign->GetNumDescriptorSets() == 0) != (pSRBSign == nullptr || pSRBSign->GetNumDescriptorSets() == 0))
+ {
+ // One signature is null or empty while the other is not - SRB is not compatible with the layout.
break;
+ }
+
+ if (pLayoutSign != nullptr && pSRBSign != nullptr && pLayoutSign->IsIncompatibleWith(*pSRBSign))
+ {
+ // Signatures are incompatible
+ break;
+ }
}
// Unbind incompatible shader resources
@@ -375,6 +382,8 @@ void DeviceContextVkImpl::SetPipelineState(IPipelineState* pPipelineState)
BindInfo.ClearDynamicBufferBit(sign);
}
#endif
+
+ m_State.CommittedResourcesValidated = false;
}
DeviceContextVkImpl::DescriptorSetBindInfo& DeviceContextVkImpl::GetDescriptorSetBindInfo(PIPELINE_TYPE Type)
diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineLayoutVk.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineLayoutVk.cpp
index b7aaaa26..febc0002 100644
--- a/Graphics/GraphicsEngineVulkan/src/PipelineLayoutVk.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/PipelineLayoutVk.cpp
@@ -61,36 +61,8 @@ void PipelineLayoutVk::Create(RenderDeviceVkImpl* pDeviceVk, PIPELINE_TYPE Pipel
VERIFY(m_SignatureCount == 0 && m_DescrSetCount == 0 && !m_VkPipelineLayout,
"This pipeline layout is already initialized");
- for (Uint32 i = 0; i < SignatureCount; ++i)
- {
- auto* pSignature = ValidatedCast<PipelineResourceSignatureVkImpl>(ppSignatures[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 < m_Signatures.size(),
- "Pipeline resource signature specifies binding index ", Uint32{Index}, " that exceeds the limit (", m_Signatures.size() - 1,
- "). This error should've been caught by ValidatePipelineResourceSignatureDesc.");
-
- VERIFY(m_Signatures[Index] == nullptr,
- "Pipeline resource signature '", pSignature->GetDesc().Name, "' at index ", Uint32{Index},
- " conflicts with another resource signature '", m_Signatures[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
-
- m_SignatureCount = std::max<Uint8>(m_SignatureCount, Index + 1);
- m_Signatures[Index] = pSignature;
- }
+ PipelineResourceSignatureVkImpl::CopyResourceSignatures(PipelineType, SignatureCount, ppSignatures,
+ m_Signatures.data(), m_Signatures.size(), m_SignatureCount);
std::array<VkDescriptorSetLayout, MAX_RESOURCE_SIGNATURES * PipelineResourceSignatureVkImpl::MAX_DESCRIPTOR_SETS> DescSetLayouts;
diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
index 93262266..14417af0 100644
--- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
@@ -1114,7 +1114,7 @@ void PipelineStateVkImpl::DvpVerifySRBResources(SRBArray& SRBs) const
}
else
{
- LOG_ERROR_MESSAGE("No SRB is bound to binding index ", SignBindIndex, " for signature '", SignDesc.Name, '\'');
+ LOG_ERROR_MESSAGE("No SRB is bound to binding index ", Uint32{SignBindIndex}, " for signature '", SignDesc.Name, '\'');
}
}
++res_info;
diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp
index 7456e66c..e0d0d39f 100644
--- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp
@@ -110,6 +110,7 @@ void ShaderResourceBindingVkImpl::Destruct()
}
GetRawAllocator().Free(m_pShaderVarMgrs);
+ m_pShaderVarMgrs = nullptr;
}
}