Commit 4a2aa822 by baldurk

Reflect array stride, top-level array stride, and block member count

parent 0af5e3e3
...@@ -3,8 +3,8 @@ Uniform reflection: ...@@ -3,8 +3,8 @@ Uniform reflection:
t1: offset -1, type 8b5d, size 1, index -1, binding 11, stages 16 t1: offset -1, type 8b5d, size 1, index -1, binding 11, stages 16
t2: offset -1, type 8b5e, size 1, index -1, binding 12, stages 16 t2: offset -1, type 8b5e, size 1, index -1, binding 12, stages 16
t3: offset -1, type 8b5f, size 1, index -1, binding 13, stages 16 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, stages 16 t4.@data: offset 0, type 8b52, size 1, index 0, binding -1, stages 16, arrayStride 16, topLevelArrayStride 16
t5.@data: offset 0, type 1405, size 0, index 1, binding -1, stages 16 t5.@data: offset 0, type 1405, size 0, index 1, binding -1, stages 16, arrayStride 4, topLevelArrayStride 4
t6: offset -1, type 8dc2, size 1, index -1, binding 16, stages 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, stages 16 s1: offset -1, type 0, size 1, index -1, binding 31, stages 16
s2: offset -1, type 0, size 1, index -1, binding 32, stages 16 s2: offset -1, type 0, size 1, index -1, binding 32, stages 16
...@@ -12,18 +12,18 @@ u1: offset -1, type 904c, size 1, index -1, binding 41, stages 16 ...@@ -12,18 +12,18 @@ u1: offset -1, type 904c, size 1, index -1, binding 41, stages 16
u2: offset -1, type 904d, size 1, index -1, binding 42, stages 16 u2: offset -1, type 904d, size 1, index -1, binding 42, stages 16
u3: offset -1, type 904e, size 1, index -1, binding 43, stages 16 u3: offset -1, type 904e, size 1, index -1, binding 43, stages 16
u4: offset -1, type 9051, size 1, index -1, binding 44, stages 16 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, stages 16 u5.@data: offset 0, type 1405, size 0, index 2, binding -1, stages 16, arrayStride 4, topLevelArrayStride 4
u6.@data: offset 0, type 1406, size 1, index 3, binding -1, stages 16 u6.@data: offset 0, type 1406, size 1, index 3, binding -1, stages 16, arrayStride 4, topLevelArrayStride 4
cb1: offset 0, type 1404, size 1, index 4, binding -1, stages 16 cb1: offset 0, type 1404, size 1, index 4, binding -1, stages 16
tb1: offset 0, type 1404, size 1, index 5, binding -1, stages 16 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, stages 0 t4: offset -1, type ffffffff, size 0, index -1, binding 14, stages 0, numMembers 1
t5: offset -1, type ffffffff, size 0, index -1, binding 15, stages 0 t5: offset -1, type ffffffff, size 0, index -1, binding 15, stages 0, numMembers 1
u5: offset -1, type ffffffff, size 0, index -1, binding 45, stages 0 u5: offset -1, type ffffffff, size 0, index -1, binding 45, stages 0, numMembers 1
u6: offset -1, type ffffffff, size 0, index -1, binding 46, stages 0 u6: offset -1, type ffffffff, size 0, index -1, binding 46, stages 0, numMembers 1
cb: offset -1, type ffffffff, size 4, index -1, binding 51, stages 0 cb: offset -1, type ffffffff, size 4, index -1, binding 51, stages 0, numMembers 1
tb: offset -1, type ffffffff, size 4, index -1, binding 17, stages 0 tb: offset -1, type ffffffff, size 4, index -1, binding 17, stages 0, numMembers 1
Pipeline input reflection: Pipeline input reflection:
......
...@@ -2,8 +2,8 @@ hlsl.reflection.binding.frag ...@@ -2,8 +2,8 @@ hlsl.reflection.binding.frag
Uniform reflection: Uniform reflection:
t1: offset -1, type 8b5d, size 1, index -1, binding 15, stages 16 t1: offset -1, type 8b5d, size 1, index -1, binding 15, stages 16
s1: offset -1, type 0, size 1, index -1, binding 5, stages 16 s1: offset -1, type 0, size 1, index -1, binding 5, stages 16
t1a: offset -1, type 8b5d, size 1, index -1, binding 16, stages 16 t1a: offset -1, type 8b5d, size 1, index -1, binding 16, stages 16, arrayStride 4, topLevelArrayStride 4
s1a: offset -1, type 0, size 1, index -1, binding 6, stages 16 s1a: offset -1, type 0, size 1, index -1, binding 6, stages 16, arrayStride 4, topLevelArrayStride 4
c1_a: offset 0, type 8b52, size 1, index 0, binding -1, stages 16 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, stages 16 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, stages 16 c1_c: offset 20, type 1406, size 1, index 0, binding -1, stages 16
...@@ -12,8 +12,8 @@ c2_b: offset 16, type 1404, size 1, index 1, binding -1, stages 16 ...@@ -12,8 +12,8 @@ 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, stages 16 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, stages 0 cbuff1: offset -1, type ffffffff, size 24, index -1, binding 2, stages 0, numMembers 3
cbuff2: offset -1, type ffffffff, size 24, index -1, binding 3, stages 0 cbuff2: offset -1, type ffffffff, size 24, index -1, binding 3, stages 0, numMembers 3
Pipeline input reflection: Pipeline input reflection:
......
...@@ -203,8 +203,8 @@ Uniform reflection: ...@@ -203,8 +203,8 @@ Uniform reflection:
t1: offset -1, type 8b5d, size 1, index -1, binding 21, stages 16 t1: offset -1, type 8b5d, size 1, index -1, binding 21, stages 16
t2: offset -1, type 8b5e, size 1, index -1, binding 22, stages 16 t2: offset -1, type 8b5e, size 1, index -1, binding 22, stages 16
t3: offset -1, type 8b5f, size 1, index -1, binding 26, stages 16 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, stages 16 t4.@data: offset 0, type 8b52, size 1, index 0, binding -1, stages 16, arrayStride 16, topLevelArrayStride 16
t5.@data: offset 0, type 1405, size 0, index 1, binding -1, stages 16 t5.@data: offset 0, type 1405, size 0, index 1, binding -1, stages 16, arrayStride 4, topLevelArrayStride 4
t6: offset -1, type 8dc2, size 1, index -1, binding 23, stages 16 t6: offset -1, type 8dc2, size 1, index -1, binding 23, stages 16
s1: offset -1, type 0, size 1, index -1, binding 11, stages 16 s1: offset -1, type 0, size 1, index -1, binding 11, stages 16
s2: offset -1, type 0, size 1, index -1, binding 17, stages 16 s2: offset -1, type 0, size 1, index -1, binding 17, stages 16
...@@ -212,19 +212,19 @@ u1: offset -1, type 904c, size 1, index -1, binding 31, stages 16 ...@@ -212,19 +212,19 @@ u1: offset -1, type 904c, size 1, index -1, binding 31, stages 16
u2: offset -1, type 904d, size 1, index -1, binding 42, stages 16 u2: offset -1, type 904d, size 1, index -1, binding 42, stages 16
u3: offset -1, type 904e, size 1, index -1, binding 43, stages 16 u3: offset -1, type 904e, size 1, index -1, binding 43, stages 16
u4: offset -1, type 9051, size 1, index -1, binding 34, stages 16 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, stages 16 u5.@data: offset 0, type 1405, size 0, index 2, binding -1, stages 16, arrayStride 4, topLevelArrayStride 4
u6.@data: offset 0, type 1406, size 1, index 3, binding -1, stages 16 u6.@data: offset 0, type 1406, size 1, index 3, binding -1, stages 16, arrayStride 4, topLevelArrayStride 4
cb1: offset 0, type 1404, size 1, index 4, binding -1, stages 16 cb1: offset 0, type 1404, size 1, index 4, binding -1, stages 16
tb1: offset 0, type 1404, size 1, index 5, binding -1, stages 16 tb1: offset 0, type 1404, size 1, index 5, binding -1, stages 16
ts6: offset -1, type 8b5f, size 1, index -1, binding 71, stages 16 ts6: offset -1, type 8b5f, size 1, index -1, binding 71, stages 16
Uniform block reflection: Uniform block reflection:
t4: offset -1, type ffffffff, size 0, index -1, binding 21, stages 0 t4: offset -1, type ffffffff, size 0, index -1, binding 21, stages 0, numMembers 1
t5: offset -1, type ffffffff, size 0, index -1, binding 22, stages 0 t5: offset -1, type ffffffff, size 0, index -1, binding 22, stages 0, numMembers 1
u5: offset -1, type ffffffff, size 0, index -1, binding 44, stages 0 u5: offset -1, type ffffffff, size 0, index -1, binding 44, stages 0, numMembers 1
u6: offset -1, type ffffffff, size 0, index -1, binding 34, stages 0 u6: offset -1, type ffffffff, size 0, index -1, binding 34, stages 0, numMembers 1
cb: offset -1, type ffffffff, size 4, index -1, binding 51, stages 0 cb: offset -1, type ffffffff, size 4, index -1, binding 51, stages 0, numMembers 1
tb: offset -1, type ffffffff, size 4, index -1, binding 27, stages 0 tb: offset -1, type ffffffff, size 4, index -1, binding 27, stages 0, numMembers 1
Pipeline input reflection: Pipeline input reflection:
......
reflection.options.vert reflection.options.vert
Uniform reflection: Uniform reflection:
t[0].v[0].position[0]: offset 0, type 1406, size 3, index 0, binding -1, stages 1 t[0].v[0].position[0]: offset 0, type 1406, size 3, index 0, binding -1, stages 1, arrayStride 4, topLevelArrayStride 72
t[0].v[1].position[0]: offset 24, type 1406, size 3, index 0, binding -1, stages 1 t[0].v[1].position[0]: offset 24, type 1406, size 3, index 0, binding -1, stages 1, arrayStride 4, topLevelArrayStride 72
t[0].v[2].position[0]: offset 48, type 1406, size 3, index 0, binding -1, stages 1 t[0].v[2].position[0]: offset 48, type 1406, size 3, index 0, binding -1, stages 1, arrayStride 4, topLevelArrayStride 72
t[0].v[0].normal[0]: offset 12, type 1406, size 3, index 0, binding -1, stages 1 t[0].v[0].normal[0]: offset 12, type 1406, size 3, index 0, binding -1, stages 1, arrayStride 4, topLevelArrayStride 72
t[0].v[1].normal[0]: offset 36, type 1406, size 3, index 0, binding -1, stages 1 t[0].v[1].normal[0]: offset 36, type 1406, size 3, index 0, binding -1, stages 1, arrayStride 4, topLevelArrayStride 72
t[0].v[2].normal[0]: offset 60, type 1406, size 3, index 0, binding -1, stages 1 t[0].v[2].normal[0]: offset 60, type 1406, size 3, index 0, binding -1, stages 1, arrayStride 4, topLevelArrayStride 72
MultipleArrays.tri[0].v[0].position[0]: offset 0, type 1406, size 1, index 1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 72
MultipleArrays.vert[0].position[0]: offset 360, type 1406, size 1, index 1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24
MultipleArrays.f[0]: offset 480, type 1406, size 5, index 1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 4
Uniform block reflection: Uniform block reflection:
VertexCollection: offset -1, type ffffffff, size 360, index -1, binding -1, stages 0 VertexCollection: offset -1, type ffffffff, size 360, index -1, binding -1, stages 0, numMembers 6
MultipleArrays: offset -1, type ffffffff, size 500, index -1, binding -1, stages 0, numMembers 9
Pipeline input reflection: Pipeline input reflection:
gl_InstanceID: offset 0, type 1404, size 0, index 0, binding -1, stages 0 gl_InstanceID: offset 0, type 1404, size 0, index 0, binding -1, stages 0
......
...@@ -13,6 +13,12 @@ buffer VertexCollection { ...@@ -13,6 +13,12 @@ buffer VertexCollection {
TriangleInfo t[5]; TriangleInfo t[5];
}; };
buffer MultipleArrays {
TriangleInfo tri[5];
VertexInfo vert[5];
float f[5];
} multiarray;
out float outval; out float outval;
void main() void main()
...@@ -21,6 +27,9 @@ void main() ...@@ -21,6 +27,9 @@ void main()
f += t[0].v[0].position[0]; f += t[0].v[0].position[0];
f += t[gl_InstanceID].v[gl_InstanceID].position[gl_InstanceID]; f += t[gl_InstanceID].v[gl_InstanceID].position[gl_InstanceID];
f += t[gl_InstanceID].v[gl_InstanceID].normal[gl_InstanceID]; f += t[gl_InstanceID].v[gl_InstanceID].normal[gl_InstanceID];
f += multiarray.tri[gl_InstanceID].v[0].position[0];
f += multiarray.vert[gl_InstanceID].position[0];
f += multiarray.f[gl_InstanceID];
TriangleInfo tlocal[5] = t; TriangleInfo tlocal[5] = t;
outval = f; outval = f;
} }
...@@ -93,7 +93,7 @@ public: ...@@ -93,7 +93,7 @@ public:
// Use a degenerate (empty) set of dereferences to immediately put as at the end of // Use a degenerate (empty) set of dereferences to immediately put as at the end of
// the dereference change expected by blowUpActiveAggregate. // the dereference change expected by blowUpActiveAggregate.
TList<TIntermBinary*> derefs; TList<TIntermBinary*> derefs;
blowUpActiveAggregate(base.getType(), base.getName(), derefs, derefs.end(), -1, -1, 0); blowUpActiveAggregate(base.getType(), base.getName(), derefs, derefs.end(), -1, -1, 0, 0);
} }
} }
...@@ -229,6 +229,36 @@ public: ...@@ -229,6 +229,36 @@ public:
return lastOffset + lastMemberSize; return lastOffset + lastMemberSize;
} }
// count the total number of leaf members from iterating out of a block type
int countAggregateMembers(const TType& parentType)
{
if (! parentType.isStruct())
return 1;
const bool strictArraySuffix = (reflection.options & EShReflectionStrictArraySuffix);
bool blockParent = (parentType.getBasicType() == EbtBlock && parentType.getQualifier().storage == EvqBuffer);
const TTypeList &memberList = *parentType.getStruct();
int ret = 0;
for (size_t i = 0; i < memberList.size(); i++)
{
const TType &memberType = *memberList[i].type;
int numMembers = countAggregateMembers(memberType);
// for sized arrays of structs, apply logic to expand out the same as we would below in
// blowUpActiveAggregate
if (memberType.isArray() && ! memberType.getArraySizes()->hasUnsized() && memberType.isStruct()) {
if (! strictArraySuffix || ! blockParent)
numMembers *= memberType.getArraySizes()->getCumulativeSize();
}
ret += numMembers;
}
return ret;
}
// Traverse the provided deref chain, including the base, and // Traverse the provided deref chain, including the base, and
// - build a full reflection-granularity name, array size, etc. entry out of it, if it goes down to that granularity // - build a full reflection-granularity name, array size, etc. entry out of it, if it goes down to that granularity
// - recursively expand any variable array index in the middle of that traversal // - recursively expand any variable array index in the middle of that traversal
...@@ -237,7 +267,8 @@ public: ...@@ -237,7 +267,8 @@ public:
// arraySize tracks, just for the final dereference in the chain, if there was a specific known size. // arraySize tracks, just for the final dereference in the chain, if there was a specific known size.
// A value of 0 for arraySize will mean to use the full array's size. // A value of 0 for arraySize will mean to use the full array's size.
void blowUpActiveAggregate(const TType& baseType, const TString& baseName, const TList<TIntermBinary*>& derefs, void blowUpActiveAggregate(const TType& baseType, const TString& baseName, const TList<TIntermBinary*>& derefs,
TList<TIntermBinary*>::const_iterator deref, int offset, int blockIndex, int arraySize) TList<TIntermBinary*>::const_iterator deref, int offset, int blockIndex, int arraySize,
int topLevelArrayStride)
{ {
// when strictArraySuffix is enabled, we closely follow the rules from ARB_program_interface_query. // when strictArraySuffix is enabled, we closely follow the rules from ARB_program_interface_query.
// Broadly: // Broadly:
...@@ -260,6 +291,9 @@ public: ...@@ -260,6 +291,9 @@ public:
case EOpIndexIndirect: { case EOpIndexIndirect: {
int stride = getArrayStride(baseType, visitNode->getLeft()->getType()); int stride = getArrayStride(baseType, visitNode->getLeft()->getType());
if (topLevelArrayStride == 0)
topLevelArrayStride = stride;
// Visit all the indices of this array, and for each one add on the remaining dereferencing // Visit all the indices of this array, and for each one add on the remaining dereferencing
for (int i = 0; i < std::max(visitNode->getLeft()->getType().getOuterArraySize(), 1); ++i) { for (int i = 0; i < std::max(visitNode->getLeft()->getType().getOuterArraySize(), 1); ++i) {
TString newBaseName = name; TString newBaseName = name;
...@@ -270,7 +304,8 @@ public: ...@@ -270,7 +304,8 @@ public:
TList<TIntermBinary*>::const_iterator nextDeref = deref; TList<TIntermBinary*>::const_iterator nextDeref = deref;
++nextDeref; ++nextDeref;
TType derefType(*terminalType, 0); TType derefType(*terminalType, 0);
blowUpActiveAggregate(derefType, newBaseName, derefs, nextDeref, offset, blockIndex, arraySize); blowUpActiveAggregate(derefType, newBaseName, derefs, nextDeref, offset, blockIndex, arraySize,
topLevelArrayStride);
if (offset >= 0) if (offset >= 0)
offset += stride; offset += stride;
...@@ -279,7 +314,9 @@ public: ...@@ -279,7 +314,9 @@ public:
// it was all completed in the recursive calls above // it was all completed in the recursive calls above
return; return;
} }
case EOpIndexDirect: case EOpIndexDirect: {
int stride = getArrayStride(baseType, visitNode->getLeft()->getType());
index = visitNode->getRight()->getAsConstantUnion()->getConstArray()[0].getIConst(); index = visitNode->getRight()->getAsConstantUnion()->getConstArray()[0].getIConst();
if (strictArraySuffix && blockParent) { if (strictArraySuffix && blockParent) {
name.append(TString("[0]")); name.append(TString("[0]"));
...@@ -287,10 +324,15 @@ public: ...@@ -287,10 +324,15 @@ public:
name.append(TString("[") + String(index) + "]"); name.append(TString("[") + String(index) + "]");
if (offset >= 0) if (offset >= 0)
offset += getArrayStride(baseType, visitNode->getLeft()->getType()) * index; offset += stride * index;
} }
if (topLevelArrayStride == 0)
topLevelArrayStride = stride;
blockParent = false; blockParent = false;
break; break;
}
case EOpIndexDirectStruct: case EOpIndexDirectStruct:
index = visitNode->getRight()->getAsConstantUnion()->getConstArray()[0].getIConst(); index = visitNode->getRight()->getAsConstantUnion()->getConstArray()[0].getIConst();
if (offset >= 0) if (offset >= 0)
...@@ -317,6 +359,9 @@ public: ...@@ -317,6 +359,9 @@ public:
if (offset >= 0) if (offset >= 0)
stride = getArrayStride(baseType, *terminalType); stride = getArrayStride(baseType, *terminalType);
if (topLevelArrayStride == 0)
topLevelArrayStride = stride;
int arrayIterateSize = std::max(terminalType->getOuterArraySize(), 1); int arrayIterateSize = std::max(terminalType->getOuterArraySize(), 1);
// for top-level arrays in blocks, only expand [0] to avoid explosion of items // for top-level arrays in blocks, only expand [0] to avoid explosion of items
...@@ -329,7 +374,9 @@ public: ...@@ -329,7 +374,9 @@ public:
TType derefType(*terminalType, 0); TType derefType(*terminalType, 0);
if (offset >= 0) if (offset >= 0)
offset = baseOffset + stride * i; offset = baseOffset + stride * i;
blowUpActiveAggregate(derefType, newBaseName, derefs, derefs.end(), offset, blockIndex, 0);
blowUpActiveAggregate(derefType, newBaseName, derefs, derefs.end(), offset, blockIndex, 0,
topLevelArrayStride);
} }
} else { } else {
// Visit all members of this aggregate, and for each one, // Visit all members of this aggregate, and for each one,
...@@ -349,7 +396,15 @@ public: ...@@ -349,7 +396,15 @@ public:
TType derefType(*terminalType, i); TType derefType(*terminalType, i);
if (offset >= 0) if (offset >= 0)
offset = baseOffset + memberOffsets[i]; offset = baseOffset + memberOffsets[i];
blowUpActiveAggregate(derefType, newBaseName, derefs, derefs.end(), offset, blockIndex, 0);
int arrayStride = topLevelArrayStride;
if (terminalType->getBasicType() == EbtBlock && terminalType->getQualifier().storage == EvqBuffer &&
derefType.isArray()) {
arrayStride = getArrayStride(baseType, derefType);
}
blowUpActiveAggregate(derefType, newBaseName, derefs, derefs.end(), offset, blockIndex, 0,
arrayStride);
} }
} }
...@@ -371,9 +426,17 @@ public: ...@@ -371,9 +426,17 @@ public:
TReflection::TNameToIndex::const_iterator it = reflection.nameToIndex.find(name.c_str()); TReflection::TNameToIndex::const_iterator it = reflection.nameToIndex.find(name.c_str());
if (it == reflection.nameToIndex.end()) { if (it == reflection.nameToIndex.end()) {
reflection.nameToIndex[name.c_str()] = (int)reflection.indexToUniform.size(); reflection.nameToIndex[name.c_str()] = (int)reflection.indexToUniform.size();
reflection.indexToUniform.push_back(TObjectReflection(name.c_str(), *terminalType, offset, reflection.indexToUniform.push_back(TObjectReflection(name.c_str(), *terminalType, offset,
mapToGlType(*terminalType), mapToGlType(*terminalType),
arraySize, blockIndex)); arraySize, blockIndex));
if (terminalType->isArray()) {
reflection.indexToUniform.back().arrayStride = getArrayStride(baseType, *terminalType);
if (topLevelArrayStride == 0)
topLevelArrayStride = reflection.indexToUniform.back().arrayStride;
}
reflection.indexToUniform.back().topLevelArrayStride = topLevelArrayStride;
} else if (arraySize > 1) { } else if (arraySize > 1) {
int& reflectedArraySize = reflection.indexToUniform[it->second].size; int& reflectedArraySize = reflection.indexToUniform[it->second].size;
reflectedArraySize = std::max(arraySize, reflectedArraySize); reflectedArraySize = std::max(arraySize, reflectedArraySize);
...@@ -465,7 +528,7 @@ public: ...@@ -465,7 +528,7 @@ public:
else else
baseName = base->getName(); baseName = base->getName();
} }
blowUpActiveAggregate(base->getType(), baseName, derefs, derefs.begin(), offset, blockIndex, arraySize); blowUpActiveAggregate(base->getType(), baseName, derefs, derefs.begin(), offset, blockIndex, arraySize, 0);
} }
int addBlockName(const TString& name, const TType& type, int size) int addBlockName(const TString& name, const TType& type, int size)
...@@ -476,6 +539,8 @@ public: ...@@ -476,6 +539,8 @@ public:
blockIndex = (int)reflection.indexToUniformBlock.size(); blockIndex = (int)reflection.indexToUniformBlock.size();
reflection.nameToIndex[name.c_str()] = blockIndex; reflection.nameToIndex[name.c_str()] = blockIndex;
reflection.indexToUniformBlock.push_back(TObjectReflection(name.c_str(), type, -1, -1, size, -1)); reflection.indexToUniformBlock.push_back(TObjectReflection(name.c_str(), type, -1, -1, size, -1));
reflection.indexToUniformBlock.back().numMembers = countAggregateMembers(type);
} else } else
blockIndex = it->second; blockIndex = it->second;
...@@ -883,7 +948,7 @@ void TReflectionTraverser::visitSymbol(TIntermSymbol* base) ...@@ -883,7 +948,7 @@ void TReflectionTraverser::visitSymbol(TIntermSymbol* base)
TObjectReflection::TObjectReflection(const std::string &pName, const TType &pType, int pOffset, int pGLDefineType, TObjectReflection::TObjectReflection(const std::string &pName, const TType &pType, int pOffset, int pGLDefineType,
int pSize, int pIndex) int pSize, int pIndex)
: name(pName), offset(pOffset), glDefineType(pGLDefineType), size(pSize), index(pIndex), counterIndex(-1), : name(pName), offset(pOffset), glDefineType(pGLDefineType), size(pSize), index(pIndex), counterIndex(-1),
stages(EShLanguageMask(0)), type(pType.clone()) numMembers(-1), arrayStride(0), topLevelArrayStride(0), stages(EShLanguageMask(0)), type(pType.clone())
{ {
} }
...@@ -902,6 +967,15 @@ void TObjectReflection::dump() const ...@@ -902,6 +967,15 @@ void TObjectReflection::dump() const
if (counterIndex != -1) if (counterIndex != -1)
printf(", counter %d", counterIndex); printf(", counter %d", counterIndex);
if (numMembers != -1)
printf(", numMembers %d", numMembers);
if (arrayStride != 0)
printf(", arrayStride %d", arrayStride);
if (topLevelArrayStride != 0)
printf(", topLevelArrayStride %d", topLevelArrayStride);
printf("\n"); printf("\n");
} }
......
...@@ -629,11 +629,17 @@ public: ...@@ -629,11 +629,17 @@ 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;
int numMembers;
int arrayStride; // stride of an array variable
int topLevelArrayStride; // stride of the top-level variable in a storage buffer member
EShLanguageMask stages; EShLanguageMask stages;
protected: protected:
TObjectReflection() : TObjectReflection()
offset(-1), glDefineType(-1), size(-1), index(-1), counterIndex(-1), stages(EShLanguageMask(0)), type(nullptr) { } : offset(-1), glDefineType(-1), size(-1), index(-1), counterIndex(-1), numMembers(-1), arrayStride(0),
topLevelArrayStride(0), stages(EShLanguageMask(0)), type(nullptr)
{
}
const TType* type; const TType* type;
}; };
......
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