Merge pull request #835 from steve-lunarg/sb-counters
HLSL: structuredbuffer counter functionality
This commit is contained in:
commit
a8d3db6b32
15 changed files with 847 additions and 27 deletions
|
|
@ -1778,6 +1778,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::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; }
|
||||
|
|
|
|||
|
|
@ -707,6 +707,19 @@ void TReflection::buildAttributeReflection(EShLanguage stage, const TIntermediat
|
|||
}
|
||||
}
|
||||
|
||||
// build counter block index associations for buffers
|
||||
void TReflection::buildCounterIndices()
|
||||
{
|
||||
// search for ones that have counters
|
||||
for (int i = 0; i < int(indexToUniformBlock.size()); ++i) {
|
||||
const TString counterName(indexToUniformBlock[i].name + "@count");
|
||||
const int index = getIndex(counterName);
|
||||
|
||||
if (index >= 0)
|
||||
indexToUniformBlock[i].counterIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
// Merge live symbols from 'intermediate' into the existing reflection database.
|
||||
//
|
||||
// Returns false if the input is too malformed to do this.
|
||||
|
|
@ -729,6 +742,8 @@ bool TReflection::addStage(EShLanguage stage, const TIntermediate& intermediate)
|
|||
function->traverse(&it);
|
||||
}
|
||||
|
||||
buildCounterIndices();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,11 +57,16 @@ 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), type(pType.clone()) { }
|
||||
glDefineType(pGLDefineType), size(pSize), index(pIndex), counterIndex(-1), type(pType.clone()) { }
|
||||
|
||||
void dump() const {
|
||||
printf("%s: offset %d, type %x, size %d, index %d, binding %d\n",
|
||||
printf("%s: offset %d, type %x, size %d, index %d, binding %d",
|
||||
name.c_str(), offset, glDefineType, size, index, getBinding() );
|
||||
|
||||
if (counterIndex != -1)
|
||||
printf(", counter %d", counterIndex);
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
const TType* const getType() const { return type; }
|
||||
|
|
@ -71,6 +76,7 @@ public:
|
|||
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;
|
||||
|
||||
static TObjectReflection badReflection() { return TObjectReflection(); }
|
||||
|
||||
|
|
@ -140,6 +146,9 @@ public:
|
|||
return it->second;
|
||||
}
|
||||
|
||||
// see getIndex(const char*)
|
||||
int getIndex(const TString& name) const { return getIndex(name.c_str()); }
|
||||
|
||||
// Thread local size
|
||||
unsigned getLocalSize(int dim) const { return dim <= 2 ? localSize[dim] : 0; }
|
||||
|
||||
|
|
@ -148,6 +157,7 @@ public:
|
|||
protected:
|
||||
friend class glslang::TReflectionTraverser;
|
||||
|
||||
void buildCounterIndices();
|
||||
void buildAttributeReflection(EShLanguage, const TIntermediate&);
|
||||
|
||||
// Need a TString hash: typedef std::unordered_map<TString, int> TNameToIndex;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue