diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp index f63305e1..9b3cdc6d 100755 --- a/glslang/MachineIndependent/ShaderLang.cpp +++ b/glslang/MachineIndependent/ShaderLang.cpp @@ -2048,6 +2048,9 @@ bool TProgram::buildReflection(int opts) unsigned TProgram::getLocalSize(int dim) const { return reflection->getLocalSize(dim); } int TProgram::getReflectionIndex(const char* name) const { return reflection->getIndex(name); } +int TProgram::getReflectionPipeIOIndex(const char* name, const bool inOrOut) const + { return reflection->getPipeIOIndex(name, inOrOut); } + 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(); } diff --git a/glslang/MachineIndependent/reflection.cpp b/glslang/MachineIndependent/reflection.cpp index f2be2ff1..9f1089de 100644 --- a/glslang/MachineIndependent/reflection.cpp +++ b/glslang/MachineIndependent/reflection.cpp @@ -112,6 +112,10 @@ public: TReflection::TMapIndexToReflection &ioItems = input ? reflection.indexToPipeInput : reflection.indexToPipeOutput; + + TReflection::TNameToIndex &ioMapper = + input ? reflection.pipeInNameToIndex : reflection.pipeOutNameToIndex; + if (reflection.options & EShReflectionUnwrapIOBlocks) { bool anonymous = IsAnonymous(name); @@ -129,12 +133,13 @@ public: blowUpIOAggregate(input, baseName, type); } } else { - TReflection::TNameToIndex::const_iterator it = reflection.nameToIndex.find(name.c_str()); - if (it == reflection.nameToIndex.end()) { - reflection.nameToIndex[name.c_str()] = (int)ioItems.size(); + TReflection::TNameToIndex::const_iterator it = ioMapper.find(name.c_str()); + if (it == ioMapper.end()) { + // seperate pipe i/o params from uniforms and blocks + // in is only for input in first stage as out is only for last stage. check traverse in call stack. + ioMapper[name.c_str()] = ioItems.size(); ioItems.push_back( TObjectReflection(name.c_str(), type, 0, mapToGlType(type), mapToGlArraySize(type), 0)); - EShLanguageMask& stages = ioItems.back().stages; stages = static_cast(stages | 1 << intermediate.getStage()); } else { diff --git a/glslang/MachineIndependent/reflection.h b/glslang/MachineIndependent/reflection.h index e3561a9d..efdc8934 100644 --- a/glslang/MachineIndependent/reflection.h +++ b/glslang/MachineIndependent/reflection.h @@ -152,6 +152,20 @@ public: // see getIndex(const char*) int getIndex(const TString& name) const { return getIndex(name.c_str()); } + + // for mapping any name to its index (only pipe input/output names) + int getPipeIOIndex(const char* name, const bool inOrOut) const + { + TNameToIndex::const_iterator it = inOrOut ? pipeInNameToIndex.find(name) : pipeOutNameToIndex.find(name); + if (it == (inOrOut ? pipeInNameToIndex.end() : pipeOutNameToIndex.end())) + return -1; + else + return it->second; + } + + // see gePipeIOIndex(const char*, const bool) + int getPipeIOIndex(const TString& name, const bool inOrOut) const { return getPipeIOIndex(name.c_str(), inOrOut); } + // Thread local size unsigned getLocalSize(int dim) const { return dim <= 2 ? localSize[dim] : 0; } @@ -189,6 +203,8 @@ protected: 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 pipeInNameToIndex; // maps pipe in names to indexes, this is a fix to seperate pipe I/O from uniforms and buffers. + TNameToIndex pipeOutNameToIndex; // maps pipe out names to indexes, this is a fix to seperate pipe I/O from uniforms and buffers. TMapIndexToReflection indexToUniform; TMapIndexToReflection indexToUniformBlock; TMapIndexToReflection indexToBufferVariable; diff --git a/glslang/Public/ShaderLang.h b/glslang/Public/ShaderLang.h index a071d78d..bb06acc0 100755 --- a/glslang/Public/ShaderLang.h +++ b/glslang/Public/ShaderLang.h @@ -789,6 +789,7 @@ public: bool buildReflection(int opts = EShReflectionDefault); unsigned getLocalSize(int dim) const; // return dim'th local size int getReflectionIndex(const char *name) const; + int getReflectionPipeIOIndex(const char* name, const bool inOrOut) const; int getNumUniformVariables() const; const TObjectReflection& getUniform(int index) const; int getNumUniformBlocks() const; @@ -818,6 +819,9 @@ public: // can be used for glGetUniformIndices() int getUniformIndex(const char *name) const { return getReflectionIndex(name); } + int getPipeIOIndex(const char *name, const bool inOrOut) const + { return getReflectionPipeIOIndex(name, inOrOut); } + // can be used for "name" part of glGetActiveUniform() const char *getUniformName(int index) const { return getUniform(index).name.c_str(); }