Unverified Commit 7bc04732 by John Kessenich Committed by GitHub

Merge pull request #1906 from ShchchowAMD/master

Reflection will crash when the VS input symbol defines the same name with FS output symbol
parents 973d0e53 f4b2ba2c
...@@ -2048,6 +2048,9 @@ bool TProgram::buildReflection(int opts) ...@@ -2048,6 +2048,9 @@ bool TProgram::buildReflection(int opts)
unsigned TProgram::getLocalSize(int dim) const { return reflection->getLocalSize(dim); } unsigned TProgram::getLocalSize(int dim) const { return reflection->getLocalSize(dim); }
int TProgram::getReflectionIndex(const char* name) const { return reflection->getIndex(name); } 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(); } int TProgram::getNumUniformVariables() const { return reflection->getNumUniforms(); }
const TObjectReflection& TProgram::getUniform(int index) const { return reflection->getUniform(index); } const TObjectReflection& TProgram::getUniform(int index) const { return reflection->getUniform(index); }
int TProgram::getNumUniformBlocks() const { return reflection->getNumUniformBlocks(); } int TProgram::getNumUniformBlocks() const { return reflection->getNumUniformBlocks(); }
......
...@@ -112,6 +112,10 @@ public: ...@@ -112,6 +112,10 @@ public:
TReflection::TMapIndexToReflection &ioItems = TReflection::TMapIndexToReflection &ioItems =
input ? reflection.indexToPipeInput : reflection.indexToPipeOutput; input ? reflection.indexToPipeInput : reflection.indexToPipeOutput;
TReflection::TNameToIndex &ioMapper =
input ? reflection.pipeInNameToIndex : reflection.pipeOutNameToIndex;
if (reflection.options & EShReflectionUnwrapIOBlocks) { if (reflection.options & EShReflectionUnwrapIOBlocks) {
bool anonymous = IsAnonymous(name); bool anonymous = IsAnonymous(name);
...@@ -129,12 +133,13 @@ public: ...@@ -129,12 +133,13 @@ public:
blowUpIOAggregate(input, baseName, type); blowUpIOAggregate(input, baseName, type);
} }
} else { } else {
TReflection::TNameToIndex::const_iterator it = reflection.nameToIndex.find(name.c_str()); TReflection::TNameToIndex::const_iterator it = ioMapper.find(name.c_str());
if (it == reflection.nameToIndex.end()) { if (it == ioMapper.end()) {
reflection.nameToIndex[name.c_str()] = (int)ioItems.size(); // 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( ioItems.push_back(
TObjectReflection(name.c_str(), type, 0, mapToGlType(type), mapToGlArraySize(type), 0)); TObjectReflection(name.c_str(), type, 0, mapToGlType(type), mapToGlArraySize(type), 0));
EShLanguageMask& stages = ioItems.back().stages; EShLanguageMask& stages = ioItems.back().stages;
stages = static_cast<EShLanguageMask>(stages | 1 << intermediate.getStage()); stages = static_cast<EShLanguageMask>(stages | 1 << intermediate.getStage());
} else { } else {
......
...@@ -152,6 +152,20 @@ public: ...@@ -152,6 +152,20 @@ public:
// see getIndex(const char*) // see getIndex(const char*)
int getIndex(const TString& name) const { return getIndex(name.c_str()); } 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 // Thread local size
unsigned getLocalSize(int dim) const { return dim <= 2 ? localSize[dim] : 0; } unsigned getLocalSize(int dim) const { return dim <= 2 ? localSize[dim] : 0; }
...@@ -189,6 +203,8 @@ protected: ...@@ -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 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
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 indexToUniform;
TMapIndexToReflection indexToUniformBlock; TMapIndexToReflection indexToUniformBlock;
TMapIndexToReflection indexToBufferVariable; TMapIndexToReflection indexToBufferVariable;
......
...@@ -789,6 +789,7 @@ public: ...@@ -789,6 +789,7 @@ public:
bool buildReflection(int opts = EShReflectionDefault); 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;
int getReflectionPipeIOIndex(const char* name, const bool inOrOut) const;
int getNumUniformVariables() const; int getNumUniformVariables() const;
const TObjectReflection& getUniform(int index) const; const TObjectReflection& getUniform(int index) const;
int getNumUniformBlocks() const; int getNumUniformBlocks() const;
...@@ -818,6 +819,9 @@ public: ...@@ -818,6 +819,9 @@ public:
// can be used for glGetUniformIndices() // can be used for glGetUniformIndices()
int getUniformIndex(const char *name) const { return getReflectionIndex(name); } 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() // can be used for "name" part of glGetActiveUniform()
const char *getUniformName(int index) const { return getUniform(index).name.c_str(); } const char *getUniformName(int index) const { return getUniform(index).name.c_str(); }
......
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