diff --git a/samples/shader_translator/shader_translator.cpp b/samples/shader_translator/shader_translator.cpp index fb72363f23..415ba7cf94 100644 --- a/samples/shader_translator/shader_translator.cpp +++ b/samples/shader_translator/shader_translator.cpp @@ -378,6 +378,46 @@ int main(int argc, char *argv[]) LogMsg("END", "COMPILER", numCompiles, "VARIABLES"); printf("\n\n"); } + if (compiled && + (output == SH_HLSL_3_0_OUTPUT || output == SH_HLSL_4_1_OUTPUT)) + { + printf("#### BEGIN HLSL UNIFORM REGISTER MAP ####\n"); + const std::map *regMap = + sh::GetUniformRegisterMap(compiler); + if (regMap) + { + for (const auto &it : *regMap) + { + printf(" uniformRegisterMap[\"%s\"] = %u\n", + it.first.c_str(), it.second); + } + printf(" (total entries: %zu)\n", regMap->size()); + } + else + { + printf(" (null)\n"); + } + printf("#### END HLSL UNIFORM REGISTER MAP ####\n"); + printf("#### BEGIN ACTIVE-VS-REGISTER CHECK ####\n"); + const std::vector *uniforms = + sh::GetUniforms(compiler); + if (uniforms && regMap) + { + for (const auto &u : *uniforms) + { + bool inMap = regMap->count(u.name) > 0; + printf(" uniform '%s': active=%d, isBuiltIn=%d, " + "isStruct=%d, type=0x%X, inUniformRegisterMap=%d%s\n", + u.name.c_str(), u.active, u.isBuiltIn(), + u.isStruct(), u.type, inMap, + (u.active && !u.isBuiltIn() && !inMap) + ? " <<< PRECONDITION HIT: active=true but " + "missing from uniformRegisterMap >>>" + : ""); + } + } + printf("#### END ACTIVE-VS-REGISTER CHECK ####\n\n"); + } if (!compiled) failCode = EFailCompile; ++numCompiles;