summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2021-01-27 05:58:44 +0000
committerassiduous <assiduous@diligentgraphics.com>2021-01-27 05:58:44 +0000
commitf1dbc752658cff61f95172fa1fad57f7bb17372c (patch)
treea5c654ef240dee1187312456ef83f3c598be17d3 /Graphics/GraphicsEngineVulkan
parentMoved CreateShaderResourceBinding, GetStaticVariableByName, GetStaticVariable... (diff)
downloadDiligentCore-f1dbc752658cff61f95172fa1fad57f7bb17372c.tar.gz
DiligentCore-f1dbc752658cff61f95172fa1fad57f7bb17372c.zip
Resource signature: added validation that texture and assigned samplers are compatible; some code cleanup.
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.hpp4
-rw-r--r--Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp39
-rw-r--r--Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp15
3 files changed, 32 insertions, 26 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.hpp
index 00ca6f64..6d7e355e 100644
--- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.hpp
@@ -524,7 +524,9 @@ private:
void BindShaderResources(PipelineStateVkImpl* pPipelineStateVk);
void BindDescriptorSetsWithDynamicOffsets(DescriptorSetBindInfo& DescrSetBindInfo);
- void ValidateShaderResources();
+#ifdef DILIGENT_DEVELOPMENT
+ void DvpValidateShaderResources();
+#endif
/// Descriptor set binding information for each pipeline type (graphics/mesh, compute, ray tracing)
std::array<DescriptorSetBindInfo, NUM_PIPELINE_BIND_POINTS> m_DescrSetBindInfo;
diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
index 315ffeae..eb90bd69 100644
--- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
@@ -366,7 +366,6 @@ __forceinline void DeviceContextVkImpl::BindShaderResources(PipelineStateVkImpl*
// (14.2.2. Pipeline Layouts, clause 'Pipeline Layout Compatibility')
// https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#descriptorsets-compatibility
-#ifdef DILIGENT_DEBUG
auto& Resources = BindInfo.Resources;
Uint32 CompatSignCount = SignCount;
@@ -395,7 +394,6 @@ __forceinline void DeviceContextVkImpl::BindShaderResources(PipelineStateVkImpl*
BindInfo.vkSets[i * MAX_DESCR_SET_PER_SIGNATURE + 0] = VK_NULL_HANDLE;
BindInfo.vkSets[i * MAX_DESCR_SET_PER_SIGNATURE + 1] = VK_NULL_HANDLE;
}
-#endif
}
void DeviceContextVkImpl::BindDescriptorSetsWithDynamicOffsets(DescriptorSetBindInfo& BindInfo)
@@ -456,14 +454,13 @@ void DeviceContextVkImpl::BindDescriptorSetsWithDynamicOffsets(DescriptorSetBind
VERIFY_EXPR(!(BindInfo.PendingSRB & BindInfo.ActiveSRBMask));
}
-void DeviceContextVkImpl::ValidateShaderResources()
+#ifdef DILIGENT_DEVELOPMENT
+void DeviceContextVkImpl::DvpValidateShaderResources()
{
-#ifdef DILIGENT_DEBUG
- auto* pPipelineStateVk = ValidatedCast<PipelineStateVkImpl>(m_pPipelineState.RawPtr());
- const auto& Layout = pPipelineStateVk->GetPipelineLayout();
- const auto BindIndex = PipelineTypeToBindPointIndex(pPipelineStateVk->GetDesc().PipelineType);
- auto& BindInfo = m_DescrSetBindInfo[BindIndex];
- const auto SignCount = Layout.GetSignatureCount();
+ const auto& Layout = m_pPipelineState->GetPipelineLayout();
+ const auto BindIndex = PipelineTypeToBindPointIndex(m_pPipelineState->GetDesc().PipelineType);
+ auto& BindInfo = m_DescrSetBindInfo[BindIndex];
+ const auto SignCount = Layout.GetSignatureCount();
for (Uint32 i = 0; i < SignCount; ++i)
{
@@ -483,7 +480,7 @@ void DeviceContextVkImpl::ValidateShaderResources()
if (!LayoutSign->IsCompatibleWith(*ResSign))
{
LOG_ERROR_MESSAGE("Shader resource binding with signature '", ResSign->GetDesc().Name,
- "' is not compatible with pipeline layout in current pipeline '", pPipelineStateVk->GetDesc().Name, "'.");
+ "' is not compatible with pipeline layout in current pipeline '", m_pPipelineState->GetDesc().Name, "'.");
}
// You must call BindDescriptorSetsWithDynamicOffsets() before validation.
@@ -499,8 +496,8 @@ void DeviceContextVkImpl::ValidateShaderResources()
LayoutSign->GetDesc().Name, "' binding index (", i, ").");
}
}
-#endif
}
+#endif
void DeviceContextVkImpl::TransitionShaderResources(IPipelineState*, IShaderResourceBinding* pShaderResourceBinding)
{
@@ -521,7 +518,6 @@ void DeviceContextVkImpl::TransitionShaderResources(IPipelineState*, IShaderReso
auto* pResBindingVkImpl = ValidatedCast<ShaderResourceBindingVkImpl>(pShaderResourceBinding);
auto& ResourceCache = pResBindingVkImpl->GetResourceCache();
- // AZ TODO: exclude stages that is not supported by pipeline
ResourceCache.TransitionResources<false>(this);
}
@@ -539,7 +535,6 @@ void DeviceContextVkImpl::CommitShaderResources(IShaderResourceBinding* pShaderR
if (StateTransitionMode == RESOURCE_STATE_TRANSITION_MODE_TRANSITION)
{
- // AZ TODO: exclude stages that is not supported by pipeline
ResourceCache.TransitionResources<false>(this);
}
#ifdef DILIGENT_DEVELOPMENT
@@ -579,8 +574,10 @@ void DeviceContextVkImpl::CommitShaderResources(IShaderResourceBinding* pShaderR
VkDescriptorSet DynamicDescrSet = VK_NULL_HANDLE;
const char* DynamicDescrSetName = "Dynamic Descriptor Set";
#ifdef DILIGENT_DEVELOPMENT
- String _DynamicDescrSetName("AZ TODO");
- _DynamicDescrSetName.append(" - dynamic set");
+ String _DynamicDescrSetName{DynamicDescrSetName};
+ _DynamicDescrSetName.append(" (");
+ _DynamicDescrSetName.append(pSignature->GetDesc().Name);
+ _DynamicDescrSetName += ')';
DynamicDescrSetName = _DynamicDescrSetName.c_str();
#endif
// Allocate vulkan descriptor set for dynamic resources
@@ -768,7 +765,9 @@ void DeviceContextVkImpl::PrepareForDraw(DRAW_FLAGS Flags)
CommitRenderPassAndFramebuffer((Flags & DRAW_FLAG_VERIFY_STATES) != 0);
}
- ValidateShaderResources();
+#ifdef DILIGENT_DEVELOPMENT
+ DvpValidateShaderResources();
+#endif
}
BufferVkImpl* DeviceContextVkImpl::PrepareIndirectDrawAttribsBuffer(IBuffer* pAttribsBuffer, RESOURCE_STATE_TRANSITION_MODE TransitonMode)
@@ -904,7 +903,9 @@ void DeviceContextVkImpl::PrepareForDispatchCompute()
# endif
#endif
- ValidateShaderResources();
+#ifdef DILIGENT_DEVELOPMENT
+ DvpValidateShaderResources();
+#endif
}
void DeviceContextVkImpl::PrepareForRayTracing()
@@ -918,7 +919,9 @@ void DeviceContextVkImpl::PrepareForRayTracing()
BindDescriptorSetsWithDynamicOffsets(DescrSetBindInfo);
}
- ValidateShaderResources();
+#ifdef DILIGENT_DEVELOPMENT
+ DvpValidateShaderResources();
+#endif
}
void DeviceContextVkImpl::DispatchCompute(const DispatchComputeAttribs& Attribs)
diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
index 06388005..9e3bafe4 100644
--- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
@@ -720,7 +720,7 @@ void PipelineStateVkImpl::InitPipelineLayout(const PipelineStateCreateInfo& Crea
TShaderStages& ShaderStages)
{
std::array<IPipelineResourceSignature*, MAX_RESOURCE_SIGNATURES> Signatures;
- RefCntAutoPtr<IPipelineResourceSignature> TempSignature;
+ RefCntAutoPtr<IPipelineResourceSignature> pImplicitSignature;
Uint32 SignatureCount = CreateInfo.ResourceSignaturesCount;
@@ -745,6 +745,7 @@ void PipelineStateVkImpl::InitPipelineLayout(const PipelineStateCreateInfo& Crea
for (auto& Stage : ShaderStages)
{
+ // Variables in all shader stages are separate in implicit layout
UniqueNames.clear();
for (auto* pShader : Stage.Shaders)
{
@@ -794,7 +795,7 @@ void PipelineStateVkImpl::InitPipelineLayout(const PipelineStateCreateInfo& Crea
auto& Res = Resources[Iter->second.DescIndex];
Res.VarType = Var.Type;
- // apply new variable type to sampler too
+ // Apply new variable type to sampler too
if (ShaderResources.IsUsingCombinedSamplers() && Res.ResourceType == SHADER_RESOURCE_TYPE_TEXTURE_SRV)
{
String SampName = String{Var.Name} + ShaderResources.GetCombinedSamplerSuffix();
@@ -820,20 +821,20 @@ void PipelineStateVkImpl::InitPipelineLayout(const PipelineStateCreateInfo& Crea
ResSignDesc.UseCombinedTextureSamplers = pCombinedSamplerSuffix != nullptr;
ResSignDesc.CombinedSamplerSuffix = pCombinedSamplerSuffix;
- GetDevice()->CreatePipelineResourceSignature(ResSignDesc, &TempSignature, true);
+ GetDevice()->CreatePipelineResourceSignature(ResSignDesc, &pImplicitSignature, true);
- if (TempSignature == nullptr)
+ if (pImplicitSignature == nullptr)
LOG_ERROR_AND_THROW("Failed to create resource signature for pipeline state");
- Signatures[0] = TempSignature;
+ Signatures[0] = pImplicitSignature;
SignatureCount = 1;
}
}
m_PipelineLayout.Create(GetDevice(), CreateInfo.PSODesc.PipelineType, Signatures.data(), SignatureCount);
- // verify that pipeline layout is compatible with shader resources and
- // remap resource bindings
+ // Verify that pipeline layout is compatible with shader resources and
+ // remap resource bindings.
for (size_t s = 0; s < ShaderStages.size(); ++s)
{
const auto& Shaders = ShaderStages[s].Shaders;