Dereference any array type before expanding root-level SSBO members

If we don't do this then we get reflection output like so:

ArrayedBind[0].a.a: offset 0, type 1406, size 1, index 4, binding -1, stages 0
ArrayedBind[0].a.b: offset 4, type 1406, size 1, index 4, binding -1, stages 0
ArrayedBind[0].b.a: offset 4, type 1406, size 1, index 4, binding -1, stages 0
ArrayedBind[0].b.b: offset 8, type 1406, size 1, index 4, binding -1, stages 0
ArrayedBind[0].b: offset 4, type 1406, size 1, index 4, binding -1, stages 1

When the outer reflection loop that calls blowUpActiveAggregate incorrectly iterates over the struct members.
This commit is contained in:
baldurk 2019-08-26 12:41:53 +01:00
parent d6a5cc6580
commit 1f1e5369ce
3 changed files with 18 additions and 4 deletions

View File

@ -51,10 +51,15 @@ MultipleArrays.tri[0].v[2].normal[0]: offset 60, type 1406, size 3, index 1, bin
MultipleArrays.vert[0].position[0]: offset 360, type 1406, size 3, index 1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24
MultipleArrays.vert[0].normal[0]: offset 372, type 1406, size 3, index 1, binding -1, stages 0, arrayStride 4, topLevelArrayStride 24
MultipleArrays.f[0]: offset 480, type 1406, size 5, index 1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 4
ArrayedBind[0].a: offset 0, type 1406, size 1, index 4, binding -1, stages 0
ArrayedBind[0].b: offset 4, type 1406, size 1, index 4, binding -1, stages 1
Buffer block reflection:
VertexCollection: offset -1, type ffffffff, size 400, index -1, binding -1, stages 1, numMembers 7
MultipleArrays: offset -1, type ffffffff, size 500, index -1, binding -1, stages 1, numMembers 9
ArrayedBind[0]: offset -1, type ffffffff, size 8, index -1, binding -1, stages 1, numMembers 2
ArrayedBind[1]: offset -1, type ffffffff, size 8, index -1, binding -1, stages 1, numMembers 2
ArrayedBind[2]: offset -1, type ffffffff, size 8, index -1, binding -1, stages 1, numMembers 2
Pipeline input reflection:
gl_InstanceID: offset 0, type 1404, size 1, index 0, binding -1, stages 1

View File

@ -20,6 +20,11 @@ buffer MultipleArrays {
float f[5];
} multiarray;
buffer ArrayedBind {
float a;
float b;
} buffers[3];
uniform UBO {
VertexInfo verts[2];
float flt[8];
@ -52,6 +57,7 @@ void main()
f += ubo.flt[gl_InstanceID];
f += ubo.uniform_multi[0][0][0];
f += uniform_multi[gl_InstanceID][gl_InstanceID][gl_InstanceID];
f += buffers[gl_InstanceID].b;
TriangleInfo tlocal[5] = t;
outval.val = f;
outarr[2] = f;

View File

@ -556,15 +556,18 @@ public:
bool blockParent = (base->getType().getBasicType() == EbtBlock && base->getQualifier().storage == EvqBuffer);
if (strictArraySuffix && blockParent) {
const TTypeList& typeList = *base->getType().getStruct();
TType structDerefType(base->getType(), 0);
const TType &structType = base->getType().isArray() ? structDerefType : base->getType();
const TTypeList& typeList = *structType.getStruct();
TVector<int> memberOffsets;
memberOffsets.resize(typeList.size());
getOffsets(base->getType(), memberOffsets);
getOffsets(structType, memberOffsets);
for (int i = 0; i < (int)typeList.size(); ++i) {
TType derefType(base->getType(), i);
TType derefType(structType, i);
TString name = baseName;
if (name.size() > 0)
name.append(".");
@ -575,7 +578,7 @@ public:
if (derefType.isArray() && derefType.isStruct()) {
name.append("[0]");
blowUpActiveAggregate(TType(derefType, 0), name, derefs, derefs.end(), memberOffsets[i],
blockIndex, 0, getArrayStride(base->getType(), derefType),
blockIndex, 0, getArrayStride(structType, derefType),
base->getQualifier().storage, false);
} else {
blowUpActiveAggregate(derefType, name, derefs, derefs.end(), memberOffsets[i], blockIndex,