Commit f556e5da by dmpakas

Reflection exposes the Shader Stages where a Uniform is present

parent 64315a8a
hlsl.automap.frag hlsl.automap.frag
Uniform reflection: Uniform reflection:
t1: offset -1, type 8b5d, size 1, index -1, binding 11 t1: offset -1, type 8b5d, size 1, index -1, binding 11, stages 16
t2: offset -1, type 8b5e, size 1, index -1, binding 12 t2: offset -1, type 8b5e, size 1, index -1, binding 12, stages 16
t3: offset -1, type 8b5f, size 1, index -1, binding 13 t3: offset -1, type 8b5f, size 1, index -1, binding 13, stages 16
t4.@data: offset 0, type 8b52, size 1, index 0, binding -1 t4.@data: offset 0, type 8b52, size 1, index 0, binding -1, stages 16
t5.@data: offset 0, type 1405, size 0, index 1, binding -1 t5.@data: offset 0, type 1405, size 0, index 1, binding -1, stages 16
t6: offset -1, type 8dc2, size 1, index -1, binding 16 t6: offset -1, type 8dc2, size 1, index -1, binding 16, stages 16
s1: offset -1, type 0, size 1, index -1, binding 31 s1: offset -1, type 0, size 1, index -1, binding 31, stages 16
s2: offset -1, type 0, size 1, index -1, binding 32 s2: offset -1, type 0, size 1, index -1, binding 32, stages 16
u1: offset -1, type 904c, size 1, index -1, binding 41 u1: offset -1, type 904c, size 1, index -1, binding 41, stages 16
u2: offset -1, type 904d, size 1, index -1, binding 42 u2: offset -1, type 904d, size 1, index -1, binding 42, stages 16
u3: offset -1, type 904e, size 1, index -1, binding 43 u3: offset -1, type 904e, size 1, index -1, binding 43, stages 16
u4: offset -1, type 9051, size 1, index -1, binding 44 u4: offset -1, type 9051, size 1, index -1, binding 44, stages 16
u5.@data: offset 0, type 1405, size 0, index 2, binding -1 u5.@data: offset 0, type 1405, size 0, index 2, binding -1, stages 16
u6.@data: offset 0, type 1406, size 1, index 3, binding -1 u6.@data: offset 0, type 1406, size 1, index 3, binding -1, stages 16
cb1: offset 0, type 1404, size 1, index 4, binding -1 cb1: offset 0, type 1404, size 1, index 4, binding -1, stages 16
tb1: offset 0, type 1404, size 1, index 5, binding -1 tb1: offset 0, type 1404, size 1, index 5, binding -1, stages 16
Uniform block reflection: Uniform block reflection:
t4: offset -1, type ffffffff, size 0, index -1, binding 14 t4: offset -1, type ffffffff, size 0, index -1, binding 14, stages 0
t5: offset -1, type ffffffff, size 0, index -1, binding 15 t5: offset -1, type ffffffff, size 0, index -1, binding 15, stages 0
u5: offset -1, type ffffffff, size 0, index -1, binding 45 u5: offset -1, type ffffffff, size 0, index -1, binding 45, stages 0
u6: offset -1, type ffffffff, size 0, index -1, binding 46 u6: offset -1, type ffffffff, size 0, index -1, binding 46, stages 0
cb: offset -1, type ffffffff, size 4, index -1, binding 51 cb: offset -1, type ffffffff, size 4, index -1, binding 51, stages 0
tb: offset -1, type ffffffff, size 4, index -1, binding 17 tb: offset -1, type ffffffff, size 4, index -1, binding 17, stages 0
Vertex attribute reflection: Vertex attribute reflection:
hlsl.reflection.binding.frag hlsl.reflection.binding.frag
Uniform reflection: Uniform reflection:
t1: offset -1, type 8b5d, size 1, index -1, binding 15 t1: offset -1, type 8b5d, size 1, index -1, binding 15, stages 16
s1: offset -1, type 0, size 1, index -1, binding 5 s1: offset -1, type 0, size 1, index -1, binding 5, stages 16
t1a: offset -1, type 8b5d, size 1, index -1, binding 16 t1a: offset -1, type 8b5d, size 1, index -1, binding 16, stages 16
s1a: offset -1, type 0, size 1, index -1, binding 6 s1a: offset -1, type 0, size 1, index -1, binding 6, stages 16
c1_a: offset 0, type 8b52, size 1, index 0, binding -1 c1_a: offset 0, type 8b52, size 1, index 0, binding -1, stages 16
c1_b: offset 16, type 1404, size 1, index 0, binding -1 c1_b: offset 16, type 1404, size 1, index 0, binding -1, stages 16
c1_c: offset 20, type 1406, size 1, index 0, binding -1 c1_c: offset 20, type 1406, size 1, index 0, binding -1, stages 16
c2_a: offset 0, type 8b52, size 1, index 1, binding -1 c2_a: offset 0, type 8b52, size 1, index 1, binding -1, stages 16
c2_b: offset 16, type 1404, size 1, index 1, binding -1 c2_b: offset 16, type 1404, size 1, index 1, binding -1, stages 16
c2_c: offset 20, type 1406, size 1, index 1, binding -1 c2_c: offset 20, type 1406, size 1, index 1, binding -1, stages 16
Uniform block reflection: Uniform block reflection:
cbuff1: offset -1, type ffffffff, size 24, index -1, binding 2 cbuff1: offset -1, type ffffffff, size 24, index -1, binding 2, stages 0
cbuff2: offset -1, type ffffffff, size 24, index -1, binding 3 cbuff2: offset -1, type ffffffff, size 24, index -1, binding 3, stages 0
Vertex attribute reflection: Vertex attribute reflection:
...@@ -196,30 +196,30 @@ gl_FragCoord origin is upper left ...@@ -196,30 +196,30 @@ gl_FragCoord origin is upper left
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) 0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
Uniform reflection: Uniform reflection:
t1: offset -1, type 8b5d, size 1, index -1, binding 21 t1: offset -1, type 8b5d, size 1, index -1, binding 21, stages 16
t2: offset -1, type 8b5e, size 1, index -1, binding 22 t2: offset -1, type 8b5e, size 1, index -1, binding 22, stages 16
t3: offset -1, type 8b5f, size 1, index -1, binding 26 t3: offset -1, type 8b5f, size 1, index -1, binding 26, stages 16
t4.@data: offset 0, type 8b52, size 1, index 0, binding -1 t4.@data: offset 0, type 8b52, size 1, index 0, binding -1, stages 16
t5.@data: offset 0, type 1405, size 0, index 1, binding -1 t5.@data: offset 0, type 1405, size 0, index 1, binding -1, stages 16
t6: offset -1, type 8dc2, size 1, index -1, binding 23 t6: offset -1, type 8dc2, size 1, index -1, binding 23, stages 16
s1: offset -1, type 0, size 1, index -1, binding 11 s1: offset -1, type 0, size 1, index -1, binding 11, stages 16
s2: offset -1, type 0, size 1, index -1, binding 17 s2: offset -1, type 0, size 1, index -1, binding 17, stages 16
u1: offset -1, type 904c, size 1, index -1, binding 31 u1: offset -1, type 904c, size 1, index -1, binding 31, stages 16
u2: offset -1, type 904d, size 1, index -1, binding 42 u2: offset -1, type 904d, size 1, index -1, binding 42, stages 16
u3: offset -1, type 904e, size 1, index -1, binding 43 u3: offset -1, type 904e, size 1, index -1, binding 43, stages 16
u4: offset -1, type 9051, size 1, index -1, binding 34 u4: offset -1, type 9051, size 1, index -1, binding 34, stages 16
u5.@data: offset 0, type 1405, size 0, index 2, binding -1 u5.@data: offset 0, type 1405, size 0, index 2, binding -1, stages 16
u6.@data: offset 0, type 1406, size 1, index 3, binding -1 u6.@data: offset 0, type 1406, size 1, index 3, binding -1, stages 16
cb1: offset 0, type 1404, size 1, index 4, binding -1 cb1: offset 0, type 1404, size 1, index 4, binding -1, stages 16
tb1: offset 0, type 1404, size 1, index 5, binding -1 tb1: offset 0, type 1404, size 1, index 5, binding -1, stages 16
Uniform block reflection: Uniform block reflection:
t4: offset -1, type ffffffff, size 0, index -1, binding 21 t4: offset -1, type ffffffff, size 0, index -1, binding 21, stages 0
t5: offset -1, type ffffffff, size 0, index -1, binding 22 t5: offset -1, type ffffffff, size 0, index -1, binding 22, stages 0
u5: offset -1, type ffffffff, size 0, index -1, binding 44 u5: offset -1, type ffffffff, size 0, index -1, binding 44, stages 0
u6: offset -1, type ffffffff, size 0, index -1, binding 34 u6: offset -1, type ffffffff, size 0, index -1, binding 34, stages 0
cb: offset -1, type ffffffff, size 4, index -1, binding 51 cb: offset -1, type ffffffff, size 4, index -1, binding 51, stages 0
tb: offset -1, type ffffffff, size 4, index -1, binding 27 tb: offset -1, type ffffffff, size 4, index -1, binding 27, stages 0
Vertex attribute reflection: Vertex attribute reflection:
...@@ -1910,6 +1910,7 @@ const char* TProgram::getUniformBlockName(int index) const { return reflection ...@@ -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::getUniformBlockSize(int index) const { return reflection->getUniformBlock(index).size; }
int TProgram::getUniformIndex(const char* name) const { return reflection->getIndex(name); } int TProgram::getUniformIndex(const char* name) const { return reflection->getIndex(name); }
int TProgram::getUniformBinding(int index) const { return reflection->getUniform(index).getBinding(); } 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::getUniformBlockBinding(int index) const { return reflection->getUniformBlock(index).getBinding(); }
int TProgram::getUniformBlockIndex(int index) const { return reflection->getUniform(index).index; } int TProgram::getUniformBlockIndex(int index) const { return reflection->getUniform(index).index; }
int TProgram::getUniformBlockCounterIndex(int index) const { return reflection->getUniformBlock(index).counterIndex; } int TProgram::getUniformBlockCounterIndex(int index) const { return reflection->getUniformBlock(index).counterIndex; }
......
...@@ -778,6 +778,14 @@ void TReflection::buildCounterIndices(const TIntermediate& intermediate) ...@@ -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. // Merge live symbols from 'intermediate' into the existing reflection database.
// //
// Returns false if the input is too malformed to do this. // Returns false if the input is too malformed to do this.
...@@ -803,6 +811,7 @@ bool TReflection::addStage(EShLanguage stage, const TIntermediate& intermediate) ...@@ -803,6 +811,7 @@ bool TReflection::addStage(EShLanguage stage, const TIntermediate& intermediate)
} }
buildCounterIndices(intermediate); buildCounterIndices(intermediate);
buildUniformStageMask(intermediate);
return true; return true;
} }
......
...@@ -57,7 +57,7 @@ class TObjectReflection { ...@@ -57,7 +57,7 @@ class TObjectReflection {
public: public:
TObjectReflection(const TString& pName, const TType& pType, int pOffset, int pGLDefineType, int pSize, int pIndex) : TObjectReflection(const TString& pName, const TType& pType, int pOffset, int pGLDefineType, int pSize, int pIndex) :
name(pName), offset(pOffset), 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; } const TType* const getType() const { return type; }
int getBinding() const int getBinding() const
...@@ -68,8 +68,8 @@ public: ...@@ -68,8 +68,8 @@ public:
} }
void dump() const void dump() const
{ {
printf("%s: offset %d, type %x, size %d, index %d, binding %d", printf("%s: offset %d, type %x, size %d, index %d, binding %d, stages %d",
name.c_str(), offset, glDefineType, size, index, getBinding() ); name.c_str(), offset, glDefineType, size, index, getBinding(), stages );
if (counterIndex != -1) if (counterIndex != -1)
printf(", counter %d", counterIndex); printf(", counter %d", counterIndex);
...@@ -84,6 +84,7 @@ public: ...@@ -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 size; // data size in bytes for a block, array size for a (non-block) object that's an array
int index; int index;
int counterIndex; int counterIndex;
EShLanguageMask stages;
protected: protected:
TObjectReflection() : offset(-1), glDefineType(-1), size(-1), index(-1), type(nullptr) { } TObjectReflection() : offset(-1), glDefineType(-1), size(-1), index(-1), type(nullptr) { }
...@@ -157,6 +158,7 @@ protected: ...@@ -157,6 +158,7 @@ protected:
friend class glslang::TReflectionTraverser; friend class glslang::TReflectionTraverser;
void buildCounterIndices(const TIntermediate&); void buildCounterIndices(const TIntermediate&);
void buildUniformStageMask(const TIntermediate& intermediate);
void buildAttributeReflection(EShLanguage, const TIntermediate&); void buildAttributeReflection(EShLanguage, const TIntermediate&);
// Need a TString hash: typedef std::unordered_map<TString, int> TNameToIndex; // Need a TString hash: typedef std::unordered_map<TString, int> TNameToIndex;
......
...@@ -671,6 +671,7 @@ public: ...@@ -671,6 +671,7 @@ public:
int getUniformBlockSize(int blockIndex) const; // can be used for glGetActiveUniformBlockiv(UNIFORM_BLOCK_DATA_SIZE) 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 getUniformIndex(const char* name) const; // can be used for glGetUniformIndices()
int getUniformBinding(int index) const; // returns the binding number 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 getUniformBlockBinding(int index) const; // returns the block binding number
int getUniformBlockIndex(int index) const; // can be used for glGetActiveUniformsiv(GL_UNIFORM_BLOCK_INDEX) 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. int getUniformBlockCounterIndex(int index) const; // returns block index of associated counter.
......
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