diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index 9af2596c..3bb3af39 100644 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -772,8 +772,17 @@ void ProcessArguments(std::vector>& workItem Error("must provide -S when --stdin is given"); // Make sure that -E is not specified alongside linking (which includes SPV generation) - if ((Options & EOptionOutputPreprocessed) && (Options & EOptionLinkProgram)) - Error("can't use -E when linking is selected"); + // Or things that require linking + if (Options & EOptionOutputPreprocessed) { + if (Options & EOptionLinkProgram) + Error("can't use -E when linking is selected"); + if (Options & EOptionDumpReflection) + Error("reflection requires linking, which can't be used when -E when is selected"); + } + + // reflection requires linking + if ((Options & EOptionDumpReflection) && !(Options & EOptionLinkProgram)) + Error("reflection requires -l for linking"); // -o or -x makes no sense if there is no target binary if (binaryFileName && (Options & EOptionSpv) == 0) @@ -1512,7 +1521,7 @@ void usage() " -l link all input files together to form a single module\n" " -m memory leak mode\n" " -o save binary to , requires a binary option (e.g., -V)\n" - " -q dump reflection query database\n" + " -q dump reflection query database; requires -l for linking\n" " -r | --relaxed-errors" " relaxed GLSL semantic error-checking mode\n" " -s silence syntax and semantic error reporting\n" diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp index c7e8a342..fa21db94 100755 --- a/glslang/MachineIndependent/ShaderLang.cpp +++ b/glslang/MachineIndependent/ShaderLang.cpp @@ -1984,7 +1984,7 @@ const char* TProgram::getInfoDebugLog() bool TProgram::buildReflection(int opts) { - if (! linked || reflection) + if (! linked || reflection != nullptr) return false; int firstStage = EShLangVertex, lastStage = EShLangFragment; @@ -2014,9 +2014,8 @@ bool TProgram::buildReflection(int opts) return true; } -unsigned TProgram::getLocalSize(int dim) const { return reflection->getLocalSize(dim); } -int TProgram::getReflectionIndex(const char* name) const { return reflection->getIndex(name); } - +unsigned TProgram::getLocalSize(int dim) const { return reflection->getLocalSize(dim); } +int TProgram::getReflectionIndex(const char* name) const { return reflection->getIndex(name); } int TProgram::getNumUniformVariables() const { return reflection->getNumUniforms(); } const TObjectReflection& TProgram::getUniform(int index) const { return reflection->getUniform(index); } int TProgram::getNumUniformBlocks() const { return reflection->getNumUniformBlocks(); } @@ -2031,8 +2030,7 @@ int TProgram::getNumBufferBlocks() const { return r const TObjectReflection& TProgram::getBufferBlock(int index) const { return reflection->getStorageBufferBlock(index); } int TProgram::getNumAtomicCounters() const { return reflection->getNumAtomicCounters(); } const TObjectReflection& TProgram::getAtomicCounter(int index) const { return reflection->getAtomicCounter(index); } - -void TProgram::dumpReflection() { reflection->dump(); } +void TProgram::dumpReflection() { if (reflection != nullptr) reflection->dump(); } // // I/O mapping implementation. diff --git a/glslang/Public/ShaderLang.h b/glslang/Public/ShaderLang.h index 9d4ec675..954ce8e0 100755 --- a/glslang/Public/ShaderLang.h +++ b/glslang/Public/ShaderLang.h @@ -737,7 +737,7 @@ public: // Reflection Interface // call first, to do liveness analysis, index mapping, etc.; returns false on failure - bool buildReflection(int opts = EShReflectionDefault); + bool buildReflection(int opts = EShReflectionDefault); unsigned getLocalSize(int dim) const; // return dim'th local size int getReflectionIndex(const char *name) const;