Skip to content

Commit

Permalink
Fix type recursion with EOpIndexIndirect dereferences
Browse files Browse the repository at this point in the history
* This primarily affects arrays-of-arrays but it can also affect arrays-of-
  structs if there are no further dereferences.
  • Loading branch information
baldurk committed Feb 21, 2019
1 parent 5432f0d commit 141bc5a
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
26 changes: 25 additions & 1 deletion Test/baseResults/reflection.options.vert.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,33 @@ UBO.verts[1].position[0]: offset 24, type 1406, size 3, index 0, binding -1, sta
UBO.verts[1].normal[0]: offset 36, type 1406, size 3, index 0, binding -1, stages 0, arrayStride 4, topLevelArrayStride 24
UBO.flt[0]: offset 48, type 1406, size 8, index 0, binding -1, stages 1, arrayStride 4, topLevelArrayStride 4
UBO.unused: offset 80, type 8dc8, size 1, index 0, binding -1, stages 0
UBO.uniform_multi[0][0][0]: offset 96, type 1406, size 2, index 0, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24
UBO.uniform_multi[0][1][0]: offset 104, type 1406, size 2, index 0, binding -1, stages 0, arrayStride 4, topLevelArrayStride 24
UBO.uniform_multi[0][2][0]: offset 112, type 1406, size 2, index 0, binding -1, stages 0, arrayStride 4, topLevelArrayStride 24
UBO.uniform_multi[1][0][0]: offset 120, type 1406, size 2, index 0, binding -1, stages 0, arrayStride 4, topLevelArrayStride 24
UBO.uniform_multi[1][1][0]: offset 128, type 1406, size 2, index 0, binding -1, stages 0, arrayStride 4, topLevelArrayStride 24
UBO.uniform_multi[1][2][0]: offset 136, type 1406, size 2, index 0, binding -1, stages 0, arrayStride 4, topLevelArrayStride 24
UBO.uniform_multi[2][0][0]: offset 144, type 1406, size 2, index 0, binding -1, stages 0, arrayStride 4, topLevelArrayStride 24
UBO.uniform_multi[2][1][0]: offset 152, type 1406, size 2, index 0, binding -1, stages 0, arrayStride 4, topLevelArrayStride 24
UBO.uniform_multi[2][2][0]: offset 160, type 1406, size 2, index 0, binding -1, stages 0, arrayStride 4, topLevelArrayStride 24
UBO.uniform_multi[3][0][0]: offset 168, type 1406, size 2, index 0, binding -1, stages 0, arrayStride 4, topLevelArrayStride 24
UBO.uniform_multi[3][1][0]: offset 176, type 1406, size 2, index 0, binding -1, stages 0, arrayStride 4, topLevelArrayStride 24
UBO.uniform_multi[3][2][0]: offset 184, type 1406, size 2, index 0, binding -1, stages 0, arrayStride 4, topLevelArrayStride 24
uniform_multi[0][0][0]: offset -1, type 1406, size 2, index -1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24
uniform_multi[0][1][0]: offset -1, type 1406, size 2, index -1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24
uniform_multi[0][2][0]: offset -1, type 1406, size 2, index -1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24
uniform_multi[1][0][0]: offset -1, type 1406, size 2, index -1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24
uniform_multi[1][1][0]: offset -1, type 1406, size 2, index -1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24
uniform_multi[1][2][0]: offset -1, type 1406, size 2, index -1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24
uniform_multi[2][0][0]: offset -1, type 1406, size 2, index -1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24
uniform_multi[2][1][0]: offset -1, type 1406, size 2, index -1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24
uniform_multi[2][2][0]: offset -1, type 1406, size 2, index -1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24
uniform_multi[3][0][0]: offset -1, type 1406, size 2, index -1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24
uniform_multi[3][1][0]: offset -1, type 1406, size 2, index -1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24
uniform_multi[3][2][0]: offset -1, type 1406, size 2, index -1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24

Uniform block reflection:
UBO: offset -1, type ffffffff, size 96, index -1, binding -1, stages 1, numMembers 6
UBO: offset -1, type ffffffff, size 192, index -1, binding -1, stages 1, numMembers 7

Buffer variable reflection:
t[0].v[0].position[0]: offset 0, type 1406, size 3, index 0, binding -1, stages 1, arrayStride 4, topLevelArrayStride 72
Expand Down
18 changes: 16 additions & 2 deletions Test/baseResults/reflection.vert.out
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ nested.foo.n1.a: offset 0, type 1406, size 1, index 3, binding -1, stages 1
nested.foo.n2.b: offset 16, type 1406, size 1, index 3, binding -1, stages 1
nested.foo.n2.c: offset 20, type 1406, size 1, index 3, binding -1, stages 1
nested.foo.n2.d: offset 24, type 1406, size 1, index 3, binding -1, stages 1
deepA[0].d2.d1[2].va: offset -1, type 8b50, size 2, index -1, binding -1, stages 1, arrayStride 8, topLevelArrayStride 176
deepA[1].d2.d1[2].va: offset -1, type 8b50, size 2, index -1, binding -1, stages 1, arrayStride 8, topLevelArrayStride 176
deepA[0].d2.d1[2].va: offset -1, type 8b50, size 3, index -1, binding -1, stages 1, arrayStride 8, topLevelArrayStride 176
deepA[1].d2.d1[2].va: offset -1, type 8b50, size 3, index -1, binding -1, stages 1, arrayStride 8, topLevelArrayStride 176
deepB[1].d2.d1[0].va: offset -1, type 8b50, size 2, index -1, binding -1, stages 1, arrayStride 8, topLevelArrayStride 176
deepB[1].d2.d1[1].va: offset -1, type 8b50, size 2, index -1, binding -1, stages 1, arrayStride 8, topLevelArrayStride 176
deepB[1].d2.d1[2].va: offset -1, type 8b50, size 2, index -1, binding -1, stages 1, arrayStride 8, topLevelArrayStride 176
Expand Down Expand Up @@ -68,6 +68,20 @@ deepD[1].d2.d1[2].b: offset -1, type 8b56, size 1, index -1, binding -1, stages
deepD[1].d2.d1[3].va: offset -1, type 8b50, size 3, index -1, binding -1, stages 1, arrayStride 8, topLevelArrayStride 8
deepD[1].d2.d1[3].b: offset -1, type 8b56, size 1, index -1, binding -1, stages 1
deepD[1].v3: offset -1, type 8b54, size 1, index -1, binding -1, stages 1
deepA[0].d2.d1[0].va: offset -1, type 8b50, size 3, index -1, binding -1, stages 1, arrayStride 8, topLevelArrayStride 176
deepA[0].d2.d1[0].b: offset -1, type 8b56, size 1, index -1, binding -1, stages 1, topLevelArrayStride 176
deepA[0].d2.d1[1].va: offset -1, type 8b50, size 3, index -1, binding -1, stages 1, arrayStride 8, topLevelArrayStride 176
deepA[0].d2.d1[1].b: offset -1, type 8b56, size 1, index -1, binding -1, stages 1, topLevelArrayStride 176
deepA[0].d2.d1[2].b: offset -1, type 8b56, size 1, index -1, binding -1, stages 1, topLevelArrayStride 176
deepA[0].d2.d1[3].va: offset -1, type 8b50, size 3, index -1, binding -1, stages 1, arrayStride 8, topLevelArrayStride 176
deepA[0].d2.d1[3].b: offset -1, type 8b56, size 1, index -1, binding -1, stages 1, topLevelArrayStride 176
deepA[1].d2.d1[0].va: offset -1, type 8b50, size 3, index -1, binding -1, stages 1, arrayStride 8, topLevelArrayStride 176
deepA[1].d2.d1[0].b: offset -1, type 8b56, size 1, index -1, binding -1, stages 1, topLevelArrayStride 176
deepA[1].d2.d1[1].va: offset -1, type 8b50, size 3, index -1, binding -1, stages 1, arrayStride 8, topLevelArrayStride 176
deepA[1].d2.d1[1].b: offset -1, type 8b56, size 1, index -1, binding -1, stages 1, topLevelArrayStride 176
deepA[1].d2.d1[2].b: offset -1, type 8b56, size 1, index -1, binding -1, stages 1, topLevelArrayStride 176
deepA[1].d2.d1[3].va: offset -1, type 8b50, size 3, index -1, binding -1, stages 1, arrayStride 8, topLevelArrayStride 176
deepA[1].d2.d1[3].b: offset -1, type 8b56, size 1, index -1, binding -1, stages 1, topLevelArrayStride 176
abl.foo: offset 0, type 1406, size 1, index 7, binding -1, stages 1
abl2.foo: offset 0, type 1406, size 1, index 11, binding -1, stages 1
buf1.runtimeArray: offset 4, type 1406, size 4, index 12, binding -1, stages 1, arrayStride 4, topLevelArrayStride 4
Expand Down
5 changes: 5 additions & 0 deletions Test/reflection.options.vert
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ uniform UBO {
VertexInfo verts[2];
float flt[8];
uvec4 unused;
float uniform_multi[4][3][2];
} ubo;

uniform float uniform_multi[4][3][2];

struct OutputStruct {
float val;
vec3 a;
Expand All @@ -47,6 +50,8 @@ void main()
f += multiarray.f[gl_InstanceID];
f += ubo.verts[gl_InstanceID].position[0];
f += ubo.flt[gl_InstanceID];
f += ubo.uniform_multi[0][0][0];
f += uniform_multi[gl_InstanceID][gl_InstanceID][gl_InstanceID];
TriangleInfo tlocal[5] = t;
outval.val = f;
outarr[2] = f;
Expand Down
1 change: 1 addition & 0 deletions Test/reflection.vert
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ void main()
f += deepB[i].d2.d1[i].va[1].x;
deep3 d = deepC[1];
deep3 da[2] = deepD;
deep1 db = deepA[i].d2.d1[i];
} else
f = ufDead3;

Expand Down
5 changes: 2 additions & 3 deletions glslang/MachineIndependent/reflection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ class TReflectionTraverser : public TLiveTraverser {
newBaseName.append(TString("[") + String(i) + "]");
TList<TIntermBinary*>::const_iterator nextDeref = deref;
++nextDeref;
TType derefType(*terminalType, 0);
blowUpActiveAggregate(derefType, newBaseName, derefs, nextDeref, offset, blockIndex, arraySize,
blowUpActiveAggregate(*terminalType, newBaseName, derefs, nextDeref, offset, blockIndex, arraySize,
topLevelArrayStride, baseStorage, active);

if (offset >= 0)
Expand Down Expand Up @@ -705,7 +704,7 @@ class TReflectionTraverser : public TLiveTraverser {
// Are we at a level in a dereference chain at which individual active uniform queries are made?
bool isReflectionGranularity(const TType& type)
{
return type.getBasicType() != EbtBlock && type.getBasicType() != EbtStruct;
return type.getBasicType() != EbtBlock && type.getBasicType() != EbtStruct && !type.isArrayOfArrays();
}

// For a binary operation indexing into an aggregate, chase down the base of the aggregate.
Expand Down

0 comments on commit 141bc5a

Please sign in to comment.