Move TObjectReflection into public interface to clean up reflection
* Forwarding functions are left to preserve source compatibility with code using the old queries.
This commit is contained in:
parent
9983f99e87
commit
1dc5dcf0a5
4 changed files with 177 additions and 82 deletions
|
|
@ -1983,27 +1983,15 @@ bool TProgram::buildReflection()
|
|||
return true;
|
||||
}
|
||||
|
||||
int TProgram::getNumLiveUniformVariables() const { return reflection->getNumUniforms(); }
|
||||
int TProgram::getNumLiveUniformBlocks() const { return reflection->getNumUniformBlocks(); }
|
||||
const char* TProgram::getUniformName(int index) const { return reflection->getUniform(index).name.c_str(); }
|
||||
const char* TProgram::getUniformBlockName(int index) const { return reflection->getUniformBlock(index).name.c_str(); }
|
||||
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; }
|
||||
int TProgram::getUniformType(int index) const { return reflection->getUniform(index).glDefineType; }
|
||||
int TProgram::getUniformBufferOffset(int index) const { return reflection->getUniform(index).offset; }
|
||||
int TProgram::getUniformArraySize(int index) const { return reflection->getUniform(index).size; }
|
||||
int TProgram::getNumLiveAttributes() const { return reflection->getNumAttributes(); }
|
||||
const char* TProgram::getAttributeName(int index) const { return reflection->getAttribute(index).name.c_str(); }
|
||||
int TProgram::getAttributeType(int index) const { return reflection->getAttribute(index).glDefineType; }
|
||||
const TType* TProgram::getAttributeTType(int index) const { return reflection->getAttribute(index).getType(); }
|
||||
const TType* TProgram::getUniformTType(int index) const { return reflection->getUniform(index).getType(); }
|
||||
const TType* TProgram::getUniformBlockTType(int index) const { return reflection->getUniformBlock(index).getType(); }
|
||||
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::getNumUniformVariables() const { return reflection->getNumUniforms(); }
|
||||
const TObjectReflection& TProgram::getUniform(int index) const { return reflection->getUniform(index); }
|
||||
int TProgram::getNumUniformBlocks() const { return reflection->getNumUniformBlocks(); }
|
||||
const TObjectReflection& TProgram::getUniformBlock(int index) const { return reflection->getUniformBlock(index); }
|
||||
int TProgram::getNumAttributes() const { return reflection->getNumAttributes(); }
|
||||
const TObjectReflection& TProgram::getAttribute(int index) const { return reflection->getAttribute(index); }
|
||||
|
||||
void TProgram::dumpReflection() { reflection->dump(); }
|
||||
|
||||
|
|
|
|||
|
|
@ -832,6 +832,35 @@ void TReflectionTraverser::visitSymbol(TIntermSymbol* base)
|
|||
addAttribute(*base);
|
||||
}
|
||||
|
||||
//
|
||||
// Implement TObjectReflection methods.
|
||||
//
|
||||
|
||||
TObjectReflection::TObjectReflection(const std::string &pName, const TType &pType, int pOffset, int pGLDefineType,
|
||||
int pSize, int pIndex)
|
||||
: name(pName), offset(pOffset), glDefineType(pGLDefineType), size(pSize), index(pIndex), counterIndex(-1),
|
||||
stages(EShLanguageMask(0)), type(pType.clone())
|
||||
{
|
||||
}
|
||||
|
||||
int TObjectReflection::getBinding() const
|
||||
{
|
||||
if (type == nullptr || !type->getQualifier().hasBinding())
|
||||
return -1;
|
||||
return type->getQualifier().layoutBinding;
|
||||
}
|
||||
|
||||
void TObjectReflection::dump() const
|
||||
{
|
||||
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);
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
//
|
||||
// Implement TReflection methods.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -52,47 +52,6 @@ class TIntermediate;
|
|||
class TIntermAggregate;
|
||||
class TReflectionTraverser;
|
||||
|
||||
// Data needed for just a single object at the granularity exchanged by the reflection API
|
||||
class TObjectReflection {
|
||||
public:
|
||||
TObjectReflection(const std::string& pName, const TType& pType, int pOffset, int pGLDefineType, int pSize, int pIndex) :
|
||||
name(pName), offset(pOffset),
|
||||
glDefineType(pGLDefineType), size(pSize), index(pIndex), counterIndex(-1), stages(EShLanguageMask(0)), type(pType.clone()) { }
|
||||
|
||||
const TType* getType() const { return type; }
|
||||
int getBinding() const
|
||||
{
|
||||
if (type == nullptr || !type->getQualifier().hasBinding())
|
||||
return -1;
|
||||
return type->getQualifier().layoutBinding;
|
||||
}
|
||||
void dump() const
|
||||
{
|
||||
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);
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
static TObjectReflection badReflection() { return TObjectReflection(); }
|
||||
|
||||
std::string name;
|
||||
int offset;
|
||||
int glDefineType;
|
||||
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), counterIndex(-1), stages(EShLanguageMask(0)), type(nullptr) { }
|
||||
|
||||
const TType* type;
|
||||
};
|
||||
|
||||
// The full reflection database
|
||||
class TReflection {
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue