Commit 6d477858 by baldurk

Add options to control how reflection information is built

parent 1dc5dcf0
...@@ -152,6 +152,7 @@ void ProcessConfigFile() ...@@ -152,6 +152,7 @@ void ProcessConfigFile()
} }
} }
int ReflectOptions = EShReflectionDefault;
int Options = 0; int Options = 0;
const char* ExecutableName = nullptr; const char* ExecutableName = nullptr;
const char* binaryFileName = nullptr; const char* binaryFileName = nullptr;
...@@ -1051,7 +1052,7 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits) ...@@ -1051,7 +1052,7 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
// Reflect // Reflect
if (Options & EOptionDumpReflection) { if (Options & EOptionDumpReflection) {
program.buildReflection(); program.buildReflection(ReflectOptions);
program.dumpReflection(); program.dumpReflection();
} }
......
...@@ -1966,12 +1966,12 @@ const char* TProgram::getInfoDebugLog() ...@@ -1966,12 +1966,12 @@ const char* TProgram::getInfoDebugLog()
// Reflection implementation. // Reflection implementation.
// //
bool TProgram::buildReflection() bool TProgram::buildReflection(int opts)
{ {
if (! linked || reflection) if (! linked || reflection)
return false; return false;
reflection = new TReflection; reflection = new TReflection((EShReflectionOptions)opts);
for (int s = 0; s < EShLangCount; ++s) { for (int s = 0; s < EShLangCount; ++s) {
if (intermediate[s]) { if (intermediate[s]) {
......
...@@ -55,7 +55,7 @@ class TReflectionTraverser; ...@@ -55,7 +55,7 @@ class TReflectionTraverser;
// The full reflection database // The full reflection database
class TReflection { class TReflection {
public: public:
TReflection() : badReflection(TObjectReflection::badReflection()) TReflection(EShReflectionOptions opts) : options(opts), badReflection(TObjectReflection::badReflection())
{ {
for (int dim=0; dim<3; ++dim) for (int dim=0; dim<3; ++dim)
localSize[dim] = 0; localSize[dim] = 0;
...@@ -125,6 +125,8 @@ protected: ...@@ -125,6 +125,8 @@ protected:
typedef std::map<std::string, int> TNameToIndex; typedef std::map<std::string, int> TNameToIndex;
typedef std::vector<TObjectReflection> TMapIndexToReflection; 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 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 TNameToIndex nameToIndex; // maps names to indexes; can hold all types of data: uniform/buffer and which function names have been processed
TMapIndexToReflection indexToUniform; TMapIndexToReflection indexToUniform;
......
...@@ -240,6 +240,13 @@ enum EShMessages { ...@@ -240,6 +240,13 @@ enum EShMessages {
}; };
// //
// 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 // Build a table for bindings. This can be used for locating
// attributes, uniforms, globals, etc., as needed. // attributes, uniforms, globals, etc., as needed.
// //
...@@ -717,7 +724,9 @@ public: ...@@ -717,7 +724,9 @@ public:
TIntermediate* getIntermediate(EShLanguage stage) const { return intermediate[stage]; } TIntermediate* getIntermediate(EShLanguage stage) const { return intermediate[stage]; }
// Reflection Interface // 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 unsigned getLocalSize(int dim) const; // return dim'th local size
int getReflectionIndex(const char *name) const; int getReflectionIndex(const char *name) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment