Merge pull request #1438 from Think-Silicon/getUniformStages
Reflection exposes the Shader Stages where a Uniform is present
This commit is contained in:
commit
8dafeab47e
9 changed files with 241 additions and 228 deletions
|
|
@ -1910,6 +1910,7 @@ const char* TProgram::getUniformBlockName(int index) const { return reflection
|
|||
int TProgram::getUniformBlockSize(int index) const { return reflection->getUniformBlock(index).size; }
|
||||
int TProgram::getUniformIndex(const char* name) const { return reflection->getIndex(name); }
|
||||
int TProgram::getUniformBinding(int index) const { return reflection->getUniform(index).getBinding(); }
|
||||
EShLanguageMask TProgram::getUniformStages(int index) const { return reflection->getUniform(index).stages; }
|
||||
int TProgram::getUniformBlockBinding(int index) const { return reflection->getUniformBlock(index).getBinding(); }
|
||||
int TProgram::getUniformBlockIndex(int index) const { return reflection->getUniform(index).index; }
|
||||
int TProgram::getUniformBlockCounterIndex(int index) const { return reflection->getUniformBlock(index).counterIndex; }
|
||||
|
|
|
|||
|
|
@ -778,6 +778,14 @@ void TReflection::buildCounterIndices(const TIntermediate& intermediate)
|
|||
}
|
||||
}
|
||||
|
||||
// build Shader Stages mask for all uniforms
|
||||
void TReflection::buildUniformStageMask(const TIntermediate& intermediate)
|
||||
{
|
||||
for (int i = 0; i < int(indexToUniform.size()); ++i) {
|
||||
indexToUniform[i].stages = static_cast<EShLanguageMask>(indexToUniform[i].stages | 1 << intermediate.getStage());
|
||||
}
|
||||
}
|
||||
|
||||
// Merge live symbols from 'intermediate' into the existing reflection database.
|
||||
//
|
||||
// Returns false if the input is too malformed to do this.
|
||||
|
|
@ -803,6 +811,7 @@ bool TReflection::addStage(EShLanguage stage, const TIntermediate& intermediate)
|
|||
}
|
||||
|
||||
buildCounterIndices(intermediate);
|
||||
buildUniformStageMask(intermediate);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class TObjectReflection {
|
|||
public:
|
||||
TObjectReflection(const TString& pName, const TType& pType, int pOffset, int pGLDefineType, int pSize, int pIndex) :
|
||||
name(pName), offset(pOffset),
|
||||
glDefineType(pGLDefineType), size(pSize), index(pIndex), counterIndex(-1), type(pType.clone()) { }
|
||||
glDefineType(pGLDefineType), size(pSize), index(pIndex), counterIndex(-1), type(pType.clone()), stages(EShLanguageMask(0)) { }
|
||||
|
||||
const TType* const getType() const { return type; }
|
||||
int getBinding() const
|
||||
|
|
@ -68,8 +68,8 @@ public:
|
|||
}
|
||||
void dump() const
|
||||
{
|
||||
printf("%s: offset %d, type %x, size %d, index %d, binding %d",
|
||||
name.c_str(), offset, glDefineType, size, index, getBinding() );
|
||||
printf("%s: offset %d, type %x, size %d, index %d, binding %d, stages %d",
|
||||
name.c_str(), offset, glDefineType, size, index, getBinding(), stages );
|
||||
|
||||
if (counterIndex != -1)
|
||||
printf(", counter %d", counterIndex);
|
||||
|
|
@ -84,6 +84,7 @@ public:
|
|||
int size; // data size in bytes for a block, array size for a (non-block) object that's an array
|
||||
int index;
|
||||
int counterIndex;
|
||||
EShLanguageMask stages;
|
||||
|
||||
protected:
|
||||
TObjectReflection() : offset(-1), glDefineType(-1), size(-1), index(-1), type(nullptr) { }
|
||||
|
|
@ -157,6 +158,7 @@ protected:
|
|||
friend class glslang::TReflectionTraverser;
|
||||
|
||||
void buildCounterIndices(const TIntermediate&);
|
||||
void buildUniformStageMask(const TIntermediate& intermediate);
|
||||
void buildAttributeReflection(EShLanguage, const TIntermediate&);
|
||||
|
||||
// Need a TString hash: typedef std::unordered_map<TString, int> TNameToIndex;
|
||||
|
|
|
|||
|
|
@ -671,6 +671,7 @@ public:
|
|||
int getUniformBlockSize(int blockIndex) const; // can be used for glGetActiveUniformBlockiv(UNIFORM_BLOCK_DATA_SIZE)
|
||||
int getUniformIndex(const char* name) const; // can be used for glGetUniformIndices()
|
||||
int getUniformBinding(int index) const; // returns the binding number
|
||||
EShLanguageMask getUniformStages(int index) const; // returns Shaders Stages where a Uniform is present
|
||||
int getUniformBlockBinding(int index) const; // returns the block binding number
|
||||
int getUniformBlockIndex(int index) const; // can be used for glGetActiveUniformsiv(GL_UNIFORM_BLOCK_INDEX)
|
||||
int getUniformBlockCounterIndex(int index) const; // returns block index of associated counter.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue