From e5296c8d10d0c4f37ac17c5394f71aad6443703a Mon Sep 17 00:00:00 2001 From: azhirnov Date: Wed, 10 Feb 2021 23:00:27 +0300 Subject: added debug checks for DXIL resource remapping --- Graphics/ShaderTools/src/DXCompiler.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Graphics/ShaderTools') diff --git a/Graphics/ShaderTools/src/DXCompiler.cpp b/Graphics/ShaderTools/src/DXCompiler.cpp index e399dcc3..19c1d78d 100644 --- a/Graphics/ShaderTools/src/DXCompiler.cpp +++ b/Graphics/ShaderTools/src/DXCompiler.cpp @@ -1187,6 +1187,21 @@ void DXCompilerImpl::PatchResourceHandle(const TResourceBindingMap& ResourceMap, ReplaceBindPoint(Iter, ArgStart, ArgEnd, NewIndexLen); startPos += NewIndexLen - (ArgEnd - ArgStart); } + +#ifdef DILIGENT_DEVELOPMENT + Uint32 IndexVarUsageCount = 0; + for (pos = 0; pos < DXIL.size();) + { + pos = DXIL.find(SrcIndexStr, pos + 1); + if (pos == String::npos) + break; + + pos += SrcIndexStr.size(); + if (DXIL[pos] == ' ' || DXIL[pos] == ',') + ++IndexVarUsageCount; + } + DEV_CHECK_ERR(IndexVarUsageCount == 2, "Temp variable '", SrcIndexStr, "' with resource bind point used more than 2 times, patching for this variable may lead to UB"); +#endif } else { -- cgit v1.2.3