summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3DBase
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-03-23 21:14:11 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-03-23 21:14:11 +0000
commit5c6457950b1886f317efaa2831e9d801d76dbbe3 (patch)
treee1d44ba8cf8934ef491e9fb068d9f85f82699fef /Graphics/GraphicsEngineD3DBase
parentUpdated third-party submodules (diff)
downloadDiligentCore-5c6457950b1886f317efaa2831e9d801d76dbbe3.tar.gz
DiligentCore-5c6457950b1886f317efaa2831e9d801d76dbbe3.zip
Improved shader resource layout error reporting
Diffstat (limited to 'Graphics/GraphicsEngineD3DBase')
-rw-r--r--Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp55
1 files changed, 33 insertions, 22 deletions
diff --git a/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp b/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp
index 26cf7c68..e906f31b 100644
--- a/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp
+++ b/Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp
@@ -190,6 +190,24 @@ void ShaderResources::DvpVerifyResourceLayout(const PipelineResourceLayoutDesc&
const ShaderResources* const pShaderResources[],
Uint32 NumShaders)
{
+ auto GetAllowedShadersString = [&](SHADER_TYPE ShaderStages)
+ {
+ std::string ShadersStr;
+ for (Uint32 s=0; s < NumShaders; ++s)
+ {
+ const auto& Resources = *pShaderResources[s];
+ if ((ShaderStages & Resources.GetShaderType()) != 0)
+ {
+ ShadersStr.append(ShadersStr.empty() ? "'" : ", '");
+ ShadersStr.append(Resources.GetShaderName());
+ ShadersStr.append("' (");
+ ShadersStr.append(GetShaderTypeLiteralName(Resources.GetShaderType()));
+ ShadersStr.push_back(')');
+ }
+ }
+ return ShadersStr;
+ };
+
for (Uint32 v = 0; v < ResourceLayout.NumVariables; ++v)
{
const auto& VarDesc = ResourceLayout.Variables[v];
@@ -222,8 +240,9 @@ void ShaderResources::DvpVerifyResourceLayout(const PipelineResourceLayoutDesc&
if (!VariableFound)
{
- LOG_WARNING_MESSAGE("Variable '", VarDesc.Name, "' is not found in any of the designated shader stages "
- "(", GetShaderStagesString(VarDesc.ShaderStages), ")");
+ LOG_WARNING_MESSAGE(GetShaderVariableTypeLiteralName(VarDesc.Type), " variable '", VarDesc.Name,
+ "' is not found in any of the designated shader stages: ",
+ GetAllowedShadersString(VarDesc.ShaderStages));
}
}
@@ -238,36 +257,28 @@ void ShaderResources::DvpVerifyResourceLayout(const PipelineResourceLayoutDesc&
const auto* TexOrSamName = StSamDesc.SamplerOrTextureName;
- bool TextureOrSamplerFound = false;
- for (Uint32 s = 0; s < NumShaders && !TextureOrSamplerFound; ++s)
+ bool StaticSamplerFound = false;
+ for (Uint32 s = 0; s < NumShaders && !StaticSamplerFound; ++s)
{
const auto& Resources = *pShaderResources[s];
if ( (StSamDesc.ShaderStages & Resources.GetShaderType()) == 0)
continue;
- const auto UseCombinedTextureSamplers = Resources.IsUsingCombinedTextureSamplers();
- if (UseCombinedTextureSamplers)
+ // 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)
{
- for(Uint32 n=0; n < Resources.GetNumTexSRV() && !TextureOrSamplerFound; ++n)
- {
- const auto& TexSRV = Resources.GetTexSRV(n);
- TextureOrSamplerFound = (strcmp(TexSRV.Name, TexOrSamName) == 0);
- }
- }
- else
- {
- for(Uint32 n=0; n < Resources.GetNumSamplers() && !TextureOrSamplerFound; ++n)
- {
- const auto& Sampler = Resources.GetSampler(n);
- TextureOrSamplerFound = (strcmp(Sampler.Name, TexOrSamName) == 0);
- }
+ const auto& Sampler = Resources.GetSampler(n);
+ StaticSamplerFound = StreqSuff(Sampler.Name, TexOrSamName, CombinedSamplerSuffix);
}
}
- if (!TextureOrSamplerFound)
+ if (!StaticSamplerFound)
{
- LOG_WARNING_MESSAGE("Static sampler '", TexOrSamName, "' is not found in any of the designated shader stages "
- "(", GetShaderStagesString(StSamDesc.ShaderStages), ")");
+ LOG_WARNING_MESSAGE("Static sampler '", TexOrSamName, "' is not found in any of the designated shader stages: ",
+ GetAllowedShadersString(StSamDesc.ShaderStages));
}
}
}