Add options to control how reflection information is built
diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp
index 42a46ce..d26040c 100644
--- a/StandAlone/StandAlone.cpp
+++ b/StandAlone/StandAlone.cpp
@@ -152,6 +152,7 @@
}
}
+int ReflectOptions = EShReflectionDefault;
int Options = 0;
const char* ExecutableName = nullptr;
const char* binaryFileName = nullptr;
@@ -1051,7 +1052,7 @@
// Reflect
if (Options & EOptionDumpReflection) {
- program.buildReflection();
+ program.buildReflection(ReflectOptions);
program.dumpReflection();
}
diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp
index 6b330c8..3e77292 100755
--- a/glslang/MachineIndependent/ShaderLang.cpp
+++ b/glslang/MachineIndependent/ShaderLang.cpp
@@ -1966,12 +1966,12 @@
// Reflection implementation.
//
-bool TProgram::buildReflection()
+bool TProgram::buildReflection(int opts)
{
if (! linked || reflection)
return false;
- reflection = new TReflection;
+ reflection = new TReflection((EShReflectionOptions)opts);
for (int s = 0; s < EShLangCount; ++s) {
if (intermediate[s]) {
diff --git a/glslang/MachineIndependent/reflection.h b/glslang/MachineIndependent/reflection.h
index 6c1d106..c4464aa 100644
--- a/glslang/MachineIndependent/reflection.h
+++ b/glslang/MachineIndependent/reflection.h
@@ -55,7 +55,7 @@
// The full reflection database
class TReflection {
public:
- TReflection() : badReflection(TObjectReflection::badReflection())
+ TReflection(EShReflectionOptions opts) : options(opts), badReflection(TObjectReflection::badReflection())
{
for (int dim=0; dim<3; ++dim)
localSize[dim] = 0;
@@ -125,6 +125,8 @@
typedef std::map<std::string, int> TNameToIndex;
typedef std::vector<TObjectReflection> TMapIndexToReflection;
+ EShReflectionOptions options;
+
TObjectReflection badReflection; // return for queries of -1 or generally out of range; has expected descriptions with in it for this
TNameToIndex nameToIndex; // maps names to indexes; can hold all types of data: uniform/buffer and which function names have been processed
TMapIndexToReflection indexToUniform;
diff --git a/glslang/Public/ShaderLang.h b/glslang/Public/ShaderLang.h
index 341fdb2..3bb9f5e 100755
--- a/glslang/Public/ShaderLang.h
+++ b/glslang/Public/ShaderLang.h
@@ -240,6 +240,13 @@
};
//
+// Options for building reflection
+//
+typedef enum {
+ EShReflectionDefault = 0, // default is original behaviour before options were added
+} EShReflectionOptions;
+
+//
// Build a table for bindings. This can be used for locating
// attributes, uniforms, globals, etc., as needed.
//
@@ -717,7 +724,9 @@
TIntermediate* getIntermediate(EShLanguage stage) const { return intermediate[stage]; }
// Reflection Interface
- bool buildReflection(); // call first, to do liveness analysis, index mapping, etc.; returns false on failure
+
+ // call first, to do liveness analysis, index mapping, etc.; returns false on failure
+ bool buildReflection(int opts = EShReflectionDefault);
unsigned getLocalSize(int dim) const; // return dim'th local size
int getReflectionIndex(const char *name) const;