summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-04-01 05:42:18 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-04-01 05:42:18 +0000
commitc8bdcc78df5434b4d53bd1f955d851e2983f9960 (patch)
tree2577b72545c35a96fa89da434a41d126e3b0d6f3 /Graphics/GraphicsEngineVulkan
parentFixed Metal build error (diff)
downloadDiligentCore-c8bdcc78df5434b4d53bd1f955d851e2983f9960.tar.gz
DiligentCore-c8bdcc78df5434b4d53bd1f955d851e2983f9960.zip
Enabled using PSO_CREATE_FLAGS flags in D3D11, D3D12 and Vk backends.
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp8
-rw-r--r--Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp4
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp122
3 files changed, 75 insertions, 59 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp
index 529255a0..07050821 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp
@@ -145,7 +145,9 @@ public:
IMemoryAllocator& LayoutDataAllocator,
const PipelineResourceLayoutDesc& ResourceLayoutDesc,
std::vector<uint32_t> SPIRVs[],
- class PipelineLayout& PipelineLayout);
+ class PipelineLayout& PipelineLayout,
+ bool VerifyVariables,
+ bool VerifyStaticSamplers);
// sizeof(VkResource) == 24 (x64)
struct VkResource
@@ -274,7 +276,9 @@ public:
bool dvpVerifyBindings(const ShaderResourceCacheVk& ResourceCache) const;
static void dvpVerifyResourceLayoutDesc(Uint32 NumShaders,
const std::shared_ptr<const SPIRVShaderResources> pShaderResources[],
- const PipelineResourceLayoutDesc& ResourceLayoutDesc);
+ const PipelineResourceLayoutDesc& ResourceLayoutDesc,
+ bool VerifyVariables,
+ bool VerifyStaticSamplers);
#endif
Uint32 GetResourceCount(SHADER_RESOURCE_VARIABLE_TYPE VarType) const
diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
index 33be3b8e..31888d8c 100644
--- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
@@ -184,7 +184,9 @@ PipelineStateVkImpl::PipelineStateVkImpl(IReferenceCounters* pRefCoun
new (m_StaticVarsMgrs + s) ShaderVariableManagerVk(*this, *pStaticResLayout, GetRawAllocator(), nullptr, 0, *pStaticResCache);
}
ShaderResourceLayoutVk::Initialize(pDeviceVk, m_NumShaders, m_ShaderResourceLayouts, ShaderResources.data(), GetRawAllocator(),
- m_Desc.ResourceLayout, ShaderSPIRVs.data(), m_PipelineLayout);
+ m_Desc.ResourceLayout, ShaderSPIRVs.data(), m_PipelineLayout,
+ (CreateInfo.Flags & PSO_CREATE_FLAG_IGNORE_MISSING_VARIABLES) == 0,
+ (CreateInfo.Flags & PSO_CREATE_FLAG_IGNORE_MISSING_STATIC_SAMPLERS) == 0);
m_PipelineLayout.Finalize(LogicalDevice);
if (m_Desc.SRBAllocationGranularity > 1)
diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp
index 76c2692f..a02cd8bb 100644
--- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp
@@ -237,7 +237,9 @@ void ShaderResourceLayoutVk::InitializeStaticResourceLayout(std::shared_ptr<cons
#ifdef DILIGENT_DEVELOPMENT
void ShaderResourceLayoutVk::dvpVerifyResourceLayoutDesc(Uint32 NumShaders,
const std::shared_ptr<const SPIRVShaderResources> pShaderResources[],
- const PipelineResourceLayoutDesc& ResourceLayoutDesc)
+ const PipelineResourceLayoutDesc& ResourceLayoutDesc,
+ bool VerifyVariables,
+ bool VerifyStaticSamplers)
{
auto GetAllowedShadersString = [&](SHADER_TYPE ShaderStages) //
{
@@ -277,79 +279,85 @@ void ShaderResourceLayoutVk::dvpVerifyResourceLayoutDesc(Uint32
return ShadersStr;
};
- for (Uint32 v = 0; v < ResourceLayoutDesc.NumVariables; ++v)
+ if (VerifyVariables)
{
- const auto& VarDesc = ResourceLayoutDesc.Variables[v];
- if (VarDesc.ShaderStages == SHADER_TYPE_UNKNOWN)
+ for (Uint32 v = 0; v < ResourceLayoutDesc.NumVariables; ++v)
{
- LOG_WARNING_MESSAGE("No allowed shader stages are specified for ", GetShaderVariableTypeLiteralName(VarDesc.Type), " variable '", VarDesc.Name, "'.");
- continue;
- }
+ const auto& VarDesc = ResourceLayoutDesc.Variables[v];
+ if (VarDesc.ShaderStages == SHADER_TYPE_UNKNOWN)
+ {
+ LOG_WARNING_MESSAGE("No allowed shader stages are specified for ", GetShaderVariableTypeLiteralName(VarDesc.Type), " variable '", VarDesc.Name, "'.");
+ continue;
+ }
- bool VariableFound = false;
- for (Uint32 s = 0; s < NumShaders && !VariableFound; ++s)
- {
- const auto& Resources = *pShaderResources[s];
- if ((VarDesc.ShaderStages & Resources.GetShaderType()) != 0)
+ bool VariableFound = false;
+ for (Uint32 s = 0; s < NumShaders && !VariableFound; ++s)
{
- for (Uint32 res = 0; res < Resources.GetTotalResources() && !VariableFound; ++res)
+ const auto& Resources = *pShaderResources[s];
+ if ((VarDesc.ShaderStages & Resources.GetShaderType()) != 0)
{
- const auto& ResAttribs = Resources.GetResource(res);
- VariableFound = (strcmp(ResAttribs.Name, VarDesc.Name) == 0);
+ for (Uint32 res = 0; res < Resources.GetTotalResources() && !VariableFound; ++res)
+ {
+ const auto& ResAttribs = Resources.GetResource(res);
+ VariableFound = (strcmp(ResAttribs.Name, VarDesc.Name) == 0);
+ }
}
}
- }
- if (!VariableFound)
- {
- LOG_WARNING_MESSAGE(GetShaderVariableTypeLiteralName(VarDesc.Type), " variable '", VarDesc.Name,
- "' is not found in any of the designated shader stages: ",
- GetAllowedShadersString(VarDesc.ShaderStages));
+ if (!VariableFound)
+ {
+ LOG_WARNING_MESSAGE(GetShaderVariableTypeLiteralName(VarDesc.Type), " variable '", VarDesc.Name,
+ "' is not found in any of the designated shader stages: ",
+ GetAllowedShadersString(VarDesc.ShaderStages));
+ }
}
}
- for (Uint32 sam = 0; sam < ResourceLayoutDesc.NumStaticSamplers; ++sam)
+ if (VerifyStaticSamplers)
{
- const auto& StSamDesc = ResourceLayoutDesc.StaticSamplers[sam];
- if (StSamDesc.ShaderStages == SHADER_TYPE_UNKNOWN)
+ for (Uint32 sam = 0; sam < ResourceLayoutDesc.NumStaticSamplers; ++sam)
{
- LOG_WARNING_MESSAGE("No allowed shader stages are specified for static sampler '", StSamDesc.SamplerOrTextureName, "'.");
- continue;
- }
-
- bool SamplerFound = false;
- for (Uint32 s = 0; s < NumShaders && !SamplerFound; ++s)
- {
- const auto& Resources = *pShaderResources[s];
- if ((StSamDesc.ShaderStages & Resources.GetShaderType()) == 0)
- continue;
-
- // Irrespective of whether HLSL-style combined image samplers are used,
- // a static sampler can be assigned to GLSL sampled image (i.e. sampler2D g_tex)
- for (Uint32 i = 0; i < Resources.GetNumSmpldImgs() && !SamplerFound; ++i)
+ const auto& StSamDesc = ResourceLayoutDesc.StaticSamplers[sam];
+ if (StSamDesc.ShaderStages == SHADER_TYPE_UNKNOWN)
{
- const auto& SmplImg = Resources.GetSmpldImg(i);
- SamplerFound = (strcmp(SmplImg.Name, StSamDesc.SamplerOrTextureName) == 0);
+ LOG_WARNING_MESSAGE("No allowed shader stages are specified for static sampler '", StSamDesc.SamplerOrTextureName, "'.");
+ continue;
}
- if (!SamplerFound)
+ bool SamplerFound = false;
+ for (Uint32 s = 0; s < NumShaders && !SamplerFound; ++s)
{
- // Check if static sampler is assigned to a separate sampler.
- // In case HLSL-style combined image samplers are used, the condition is SepSmpl.Name == "g_Texture" + "_sampler".
- // Otherwise the condition is SepSmpl.Name == "g_Texture_sampler" + "".
- const auto* CombinedSamplerSuffix = Resources.GetCombinedSamplerSuffix();
- for (Uint32 i = 0; i < Resources.GetNumSepSmplrs() && !SamplerFound; ++i)
+ const auto& Resources = *pShaderResources[s];
+ if ((StSamDesc.ShaderStages & Resources.GetShaderType()) == 0)
+ continue;
+
+ // Irrespective of whether HLSL-style combined image samplers are used,
+ // a static sampler can be assigned to GLSL sampled image (i.e. sampler2D g_tex)
+ for (Uint32 i = 0; i < Resources.GetNumSmpldImgs() && !SamplerFound; ++i)
{
- const auto& SepSmpl = Resources.GetSepSmplr(i);
- SamplerFound = StreqSuff(SepSmpl.Name, StSamDesc.SamplerOrTextureName, CombinedSamplerSuffix);
+ const auto& SmplImg = Resources.GetSmpldImg(i);
+ SamplerFound = (strcmp(SmplImg.Name, StSamDesc.SamplerOrTextureName) == 0);
+ }
+
+ if (!SamplerFound)
+ {
+ // Check if static sampler is assigned to a separate sampler.
+ // In case HLSL-style combined image samplers are used, the condition is SepSmpl.Name == "g_Texture" + "_sampler".
+ // Otherwise the condition is SepSmpl.Name == "g_Texture_sampler" + "".
+ const auto* CombinedSamplerSuffix = Resources.GetCombinedSamplerSuffix();
+ for (Uint32 i = 0; i < Resources.GetNumSepSmplrs() && !SamplerFound; ++i)
+ {
+ const auto& SepSmpl = Resources.GetSepSmplr(i);
+ SamplerFound = StreqSuff(SepSmpl.Name, StSamDesc.SamplerOrTextureName, CombinedSamplerSuffix);
+ }
}
}
- }
- if (!SamplerFound)
- {
- LOG_WARNING_MESSAGE("Static sampler '", StSamDesc.SamplerOrTextureName,
- "' is not found in any of the designated shader stages: ",
- GetAllowedShadersString(StSamDesc.ShaderStages));
+ if (!SamplerFound)
+ {
+ LOG_WARNING_MESSAGE("Static sampler '", StSamDesc.SamplerOrTextureName,
+ "' is not found in any of the designated shader stages: ",
+ GetAllowedShadersString(StSamDesc.ShaderStages));
+ }
}
}
}
@@ -362,10 +370,12 @@ void ShaderResourceLayoutVk::Initialize(IRenderDevice*
IMemoryAllocator& LayoutDataAllocator,
const PipelineResourceLayoutDesc& ResourceLayoutDesc,
std::vector<uint32_t> SPIRVs[],
- class PipelineLayout& PipelineLayout)
+ class PipelineLayout& PipelineLayout,
+ bool VerifyVariables,
+ bool VerifyStaticSamplers)
{
#ifdef DILIGENT_DEVELOPMENT
- dvpVerifyResourceLayoutDesc(NumShaders, pShaderResources, ResourceLayoutDesc);
+ dvpVerifyResourceLayoutDesc(NumShaders, pShaderResources, ResourceLayoutDesc, VerifyVariables, VerifyStaticSamplers);
#endif
const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes = nullptr;