From 8e8161f743531dcdde1a41262818b9cf3f36eb83 Mon Sep 17 00:00:00 2001 From: attilaz Date: Thu, 17 Jan 2019 21:04:23 +0100 Subject: [PATCH] Fix for 'used samplers was converted to static' It seems reflection doesn't have a way to query used(live) samplers. --- tools/shaderc/shaderc_spirv.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/tools/shaderc/shaderc_spirv.cpp b/tools/shaderc/shaderc_spirv.cpp index d3459272c..a42cb9cb9 100644 --- a/tools/shaderc/shaderc_spirv.cpp +++ b/tools/shaderc/shaderc_spirv.cpp @@ -699,17 +699,25 @@ namespace bgfx { namespace spirv { bool found = false; - for (int32_t ii = 0, num = program->getNumLiveUniformVariables(); ii < num; ++ii) + if (!bx::findIdentifierMatch(strLine.c_str(), "SamplerState").isEmpty()) { - // matching lines like: uniform u_name; - // we want to replace "uniform" with "static" so that it's no longer - // included in the uniform blob that the application must upload - // we can't just remove them, because unused functions might still reference - // them and cause a compile error when they're gone - if (!bx::findIdentifierMatch(strLine.c_str(), program->getUniformName(ii) ).isEmpty() ) + found = true; + } + else + { + + for (int32_t ii = 0, num = program->getNumLiveUniformVariables(); ii < num; ++ii) { - found = true; - break; + // matching lines like: uniform u_name; + // we want to replace "uniform" with "static" so that it's no longer + // included in the uniform blob that the application must upload + // we can't just remove them, because unused functions might still reference + // them and cause a compile error when they're gone + if (!bx::findIdentifierMatch(strLine.c_str(), program->getUniformName(ii)).isEmpty()) + { + found = true; + break; + } } }