diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-04-01 05:42:18 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-04-01 05:42:18 +0000 |
| commit | c8bdcc78df5434b4d53bd1f955d851e2983f9960 (patch) | |
| tree | 2577b72545c35a96fa89da434a41d126e3b0d6f3 /Graphics/GraphicsEngineD3DBase | |
| parent | Fixed Metal build error (diff) | |
| download | DiligentCore-c8bdcc78df5434b4d53bd1f955d851e2983f9960.tar.gz DiligentCore-c8bdcc78df5434b4d53bd1f955d851e2983f9960.zip | |
Enabled using PSO_CREATE_FLAGS flags in D3D11, D3D12 and Vk backends.
Diffstat (limited to 'Graphics/GraphicsEngineD3DBase')
| -rw-r--r-- | Graphics/GraphicsEngineD3DBase/include/ShaderResources.hpp | 4 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp | 114 |
2 files changed, 64 insertions, 54 deletions
diff --git a/Graphics/GraphicsEngineD3DBase/include/ShaderResources.hpp b/Graphics/GraphicsEngineD3DBase/include/ShaderResources.hpp index e12d094e..5765e20a 100644 --- a/Graphics/GraphicsEngineD3DBase/include/ShaderResources.hpp +++ b/Graphics/GraphicsEngineD3DBase/include/ShaderResources.hpp @@ -379,7 +379,9 @@ public: #ifdef DILIGENT_DEVELOPMENT static void DvpVerifyResourceLayout(const PipelineResourceLayoutDesc& ResourceLayout, const ShaderResources* const pShaderResources[], - Uint32 NumShaders); + Uint32 NumShaders, + bool VerifyVariables, + bool VerifyStaticSamplers); #endif void GetShaderModel(Uint32& Major, Uint32& Minor) const diff --git a/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp b/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp index 0482ee5a..2f23c4ba 100644 --- a/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp +++ b/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp @@ -216,7 +216,9 @@ D3DShaderResourceCounters ShaderResources::CountResources(const PipelineResource #ifdef DILIGENT_DEVELOPMENT void ShaderResources::DvpVerifyResourceLayout(const PipelineResourceLayoutDesc& ResourceLayout, const ShaderResources* const pShaderResources[], - Uint32 NumShaders) + Uint32 NumShaders, + bool VerifyVariables, + bool VerifyStaticSamplers) { auto GetAllowedShadersString = [&](SHADER_TYPE ShaderStages) // { @@ -256,77 +258,83 @@ void ShaderResources::DvpVerifyResourceLayout(const PipelineResourceLayoutDesc& return ShadersStr; }; - for (Uint32 v = 0; v < ResourceLayout.NumVariables; ++v) + if (VerifyVariables) { - const auto& VarDesc = ResourceLayout.Variables[v]; - if (VarDesc.ShaderStages == SHADER_TYPE_UNKNOWN) + for (Uint32 v = 0; v < ResourceLayout.NumVariables; ++v) { - 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) + const auto& VarDesc = ResourceLayout.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; + } - const auto UseCombinedTextureSamplers = Resources.IsUsingCombinedTextureSamplers(); - for (Uint32 n = 0; n < Resources.m_TotalResources && !VariableFound; ++n) + bool VariableFound = false; + for (Uint32 s = 0; s < NumShaders && !VariableFound; ++s) { - const auto& Res = Resources.GetResAttribs(n, Resources.m_TotalResources, 0); - - // Skip samplers if combined texture samplers are used as - // in this case they are not treated as independent variables - if (UseCombinedTextureSamplers && Res.GetInputType() == D3D_SIT_SAMPLER) + const auto& Resources = *pShaderResources[s]; + if ((VarDesc.ShaderStages & Resources.GetShaderType()) == 0) continue; - VariableFound = (strcmp(Res.Name, VarDesc.Name) == 0); + const auto UseCombinedTextureSamplers = Resources.IsUsingCombinedTextureSamplers(); + for (Uint32 n = 0; n < Resources.m_TotalResources && !VariableFound; ++n) + { + const auto& Res = Resources.GetResAttribs(n, Resources.m_TotalResources, 0); + + // Skip samplers if combined texture samplers are used as + // in this case they are not treated as independent variables + if (UseCombinedTextureSamplers && Res.GetInputType() == D3D_SIT_SAMPLER) + continue; + + VariableFound = (strcmp(Res.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 < ResourceLayout.NumStaticSamplers; ++sam) + if (VerifyStaticSamplers) { - const auto& StSamDesc = ResourceLayout.StaticSamplers[sam]; - if (StSamDesc.ShaderStages == SHADER_TYPE_UNKNOWN) + for (Uint32 sam = 0; sam < ResourceLayout.NumStaticSamplers; ++sam) { - LOG_WARNING_MESSAGE("No allowed shader stages are specified for static sampler '", StSamDesc.SamplerOrTextureName, "'."); - continue; - } - - const auto* TexOrSamName = StSamDesc.SamplerOrTextureName; - - bool StaticSamplerFound = false; - for (Uint32 s = 0; s < NumShaders && !StaticSamplerFound; ++s) - { - const auto& Resources = *pShaderResources[s]; - if ((StSamDesc.ShaderStages & Resources.GetShaderType()) == 0) + const auto& StSamDesc = ResourceLayout.StaticSamplers[sam]; + if (StSamDesc.ShaderStages == SHADER_TYPE_UNKNOWN) + { + LOG_WARNING_MESSAGE("No allowed shader stages are specified for static sampler '", StSamDesc.SamplerOrTextureName, "'."); continue; + } + + const auto* TexOrSamName = StSamDesc.SamplerOrTextureName; - // Look for static sampler. - // In case HLSL-style combined image samplers are used, the condition is Sampler.Name == "g_Texture" + "_sampler". - // Otherwise the condition is Sampler.Name == "g_Texture_sampler" + "". - const auto* CombinedSamplerSuffix = Resources.GetCombinedSamplerSuffix(); - for (Uint32 n = 0; n < Resources.GetNumSamplers() && !StaticSamplerFound; ++n) + bool StaticSamplerFound = false; + for (Uint32 s = 0; s < NumShaders && !StaticSamplerFound; ++s) { - const auto& Sampler = Resources.GetSampler(n); - StaticSamplerFound = StreqSuff(Sampler.Name, TexOrSamName, CombinedSamplerSuffix); + const auto& Resources = *pShaderResources[s]; + if ((StSamDesc.ShaderStages & Resources.GetShaderType()) == 0) + continue; + + // Look for static sampler. + // In case HLSL-style combined image samplers are used, the condition is Sampler.Name == "g_Texture" + "_sampler". + // Otherwise the condition is Sampler.Name == "g_Texture_sampler" + "". + const auto* CombinedSamplerSuffix = Resources.GetCombinedSamplerSuffix(); + for (Uint32 n = 0; n < Resources.GetNumSamplers() && !StaticSamplerFound; ++n) + { + const auto& Sampler = Resources.GetSampler(n); + StaticSamplerFound = StreqSuff(Sampler.Name, TexOrSamName, CombinedSamplerSuffix); + } } - } - if (!StaticSamplerFound) - { - LOG_WARNING_MESSAGE("Static sampler '", TexOrSamName, "' is not found in any of the designated shader stages: ", - GetAllowedShadersString(StSamDesc.ShaderStages)); + if (!StaticSamplerFound) + { + LOG_WARNING_MESSAGE("Static sampler '", TexOrSamName, "' is not found in any of the designated shader stages: ", + GetAllowedShadersString(StSamDesc.ShaderStages)); + } } } } |
