ReflectOptions |= EShReflectionIntermediateIO;
} else if (lowerword == "reflect-separate-buffers") {
ReflectOptions |= EShReflectionSeparateBuffers;
+ } else if (lowerword == "reflect-all-block-variables") {
+ ReflectOptions |= EShReflectionAllBlockVariables;
} else if (lowerword == "resource-set-bindings" || // synonyms
lowerword == "resource-set-binding" ||
lowerword == "rsb") {
" --reflect-intermediate-io reflection includes inputs/outputs of linked shaders\n"
" rather than just vertex/fragment\n"
" --reflect-separate-buffers reflect buffer variables and blocks separately to uniforms\n"
+ " --reflect-all-block-variables reflect all variables in blocks, whether inactive or active\n"
" --resource-set-binding [stage] name set binding\n"
" set descriptor set and binding for\n"
" individual resources\n"
tb1: offset 0, type 1404, size 1, index 5, binding -1, stages 16
Uniform block reflection:
-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, numMembers 1
-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, numMembers 1
-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, numMembers 1
+t4: offset -1, type ffffffff, size 0, index -1, binding 14, stages 16, numMembers 1
+t5: offset -1, type ffffffff, size 0, index -1, binding 15, stages 16, numMembers 1
+u5: offset -1, type ffffffff, size 0, index -1, binding 45, stages 16, numMembers 1
+u6: offset -1, type ffffffff, size 0, index -1, binding 46, stages 16, numMembers 1
+cb: offset -1, type ffffffff, size 4, index -1, binding 51, stages 16, numMembers 1
+tb: offset -1, type ffffffff, size 4, index -1, binding 17, stages 16, numMembers 1
Buffer variable reflection:
Pipeline input reflection:
Pipeline output reflection:
-@entryPointOutput: offset 0, type 8b52, size 0, index 0, binding -1, stages 0
+@entryPointOutput: offset 0, type 8b52, size 0, index 0, binding -1, stages 16
c2_c: offset 20, type 1406, size 1, index 1, binding -1, stages 16
Uniform block reflection:
-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, numMembers 3
+cbuff1: offset -1, type ffffffff, size 24, index -1, binding 2, stages 16, numMembers 3
+cbuff2: offset -1, type ffffffff, size 24, index -1, binding 3, stages 16, numMembers 3
Buffer variable reflection:
Pipeline input reflection:
Pipeline output reflection:
-psout.Color: offset 0, type 8b52, size 0, index 0, binding -1, stages 0
+psout.Color: offset 0, type 8b52, size 0, index 0, binding -1, stages 16
uf1: offset 16, type 1406, size 1, index 1, binding -1, stages 1
Uniform block reflection:
-nameless: offset -1, type ffffffff, size 496, index -1, binding -1, stages 0, numMembers 9
-$Global: offset -1, type ffffffff, size 3088, index -1, binding -1, stages 0, numMembers 106
-c_nameless: offset -1, type ffffffff, size 96, index -1, binding -1, stages 0, numMembers 5
-nested: offset -1, type ffffffff, size 32, index -1, binding -1, stages 0, numMembers 4
-abl: offset -1, type ffffffff, size 4, index -1, binding -1, stages 0, numMembers 1
-abl2: offset -1, type ffffffff, size 4, index -1, binding -1, stages 0, numMembers 1
+nameless: offset -1, type ffffffff, size 496, index -1, binding -1, stages 1, numMembers 9
+$Global: offset -1, type ffffffff, size 3088, index -1, binding -1, stages 1, numMembers 106
+c_nameless: offset -1, type ffffffff, size 96, index -1, binding -1, stages 1, numMembers 5
+nested: offset -1, type ffffffff, size 32, index -1, binding -1, stages 1, numMembers 4
+abl: offset -1, type ffffffff, size 4, index -1, binding -1, stages 1, numMembers 1
+abl2: offset -1, type ffffffff, size 4, index -1, binding -1, stages 1, numMembers 1
Buffer variable reflection:
Buffer block reflection:
Pipeline input reflection:
-attributeFloat: offset 0, type 1406, size 0, index 0, binding -1, stages 0
-attributeFloat2: offset 0, type 8b50, size 0, index 0, binding -1, stages 0
-attributeFloat3: offset 0, type 8b51, size 0, index 0, binding -1, stages 0
-attributeFloat4: offset 0, type 8b52, size 0, index 0, binding -1, stages 0
-attributeMat4: offset 0, type 8b5c, size 0, index 0, binding -1, stages 0
+attributeFloat: offset 0, type 1406, size 0, index 0, binding -1, stages 1
+attributeFloat2: offset 0, type 8b50, size 0, index 0, binding -1, stages 1
+attributeFloat3: offset 0, type 8b51, size 0, index 0, binding -1, stages 1
+attributeFloat4: offset 0, type 8b52, size 0, index 0, binding -1, stages 1
+attributeMat4: offset 0, type 8b5c, size 0, index 0, binding -1, stages 1
Pipeline output reflection:
ts6: offset -1, type 8b5f, size 1, index -1, binding 71, stages 16
Uniform block reflection:
-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, numMembers 1
-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, numMembers 1
-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, numMembers 1
+t4: offset -1, type ffffffff, size 0, index -1, binding 21, stages 16, numMembers 1
+t5: offset -1, type ffffffff, size 0, index -1, binding 22, stages 16, numMembers 1
+u5: offset -1, type ffffffff, size 0, index -1, binding 44, stages 16, numMembers 1
+u6: offset -1, type ffffffff, size 0, index -1, binding 34, stages 16, numMembers 1
+cb: offset -1, type ffffffff, size 4, index -1, binding 51, stages 16, numMembers 1
+tb: offset -1, type ffffffff, size 4, index -1, binding 27, stages 16, numMembers 1
Buffer variable reflection:
Pipeline input reflection:
Pipeline output reflection:
-@entryPointOutput: offset 0, type 8b52, size 0, index 0, binding -1, stages 0
+@entryPointOutput: offset 0, type 8b52, size 0, index 0, binding -1, stages 16
--- /dev/null
+reflection.linked.vert
+reflection.linked.frag
+Uniform reflection:
+ubo_block.unused_uniform: offset 0, type 1406, size 1, index 0, binding -1, stages 0
+ubo_block.shared_uniform: offset 4, type 1406, size 1, index 0, binding -1, stages 17
+ubo_block.vsonly_uniform: offset 8, type 1406, size 1, index 0, binding -1, stages 1
+ubo_block.fsonly_uniform: offset 12, type 1406, size 1, index 0, binding -1, stages 16
+
+Uniform block reflection:
+ubo_block: offset -1, type ffffffff, size 16, index -1, binding 0, stages 17, numMembers 4
+
+Buffer variable reflection:
+
+Buffer block reflection:
+
+Pipeline input reflection:
+vertin: offset 0, type 1406, size 0, index 0, binding -1, stages 1
+
+Pipeline output reflection:
+fragout: offset 0, type 1406, size 0, index 0, binding -1, stages 16
+
--- /dev/null
+reflection.linked.vert
+reflection.linked.frag
+Uniform reflection:
+ubo_block.shared_uniform: offset 4, type 1406, size 1, index 0, binding -1, stages 17
+ubo_block.vsonly_uniform: offset 8, type 1406, size 1, index 0, binding -1, stages 17
+ubo_block.fsonly_uniform: offset 12, type 1406, size 1, index 0, binding -1, stages 16
+
+Uniform block reflection:
+ubo_block: offset -1, type ffffffff, size 16, index -1, binding 0, stages 17, numMembers 4
+
+Buffer variable reflection:
+
+Buffer block reflection:
+
+Pipeline input reflection:
+vertin: offset 0, type 1406, size 0, index 0, binding -1, stages 1
+
+Pipeline output reflection:
+fragout: offset 0, type 1406, size 0, index 0, binding -1, stages 16
+
Buffer block reflection:
Pipeline input reflection:
-inval: offset 0, type 1406, size 0, index 0, binding -1, stages 0
+inval: offset 0, type 1406, size 0, index 0, binding -1, stages 16
Pipeline output reflection:
reflection.options.vert
Uniform reflection:
-UBO.verts[0].position[0]: offset 0, type 1406, size 1, index 0, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24
-UBO.verts[1].position[0]: offset 24, type 1406, size 1, index 0, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24
+UBO.verts[0].position[0]: offset 0, type 1406, size 3, index 0, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24
+UBO.verts[0].normal[0]: offset 12, type 1406, size 3, index 0, binding -1, stages 0, arrayStride 4, topLevelArrayStride 24
+UBO.verts[1].position[0]: offset 24, type 1406, size 3, index 0, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24
+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
Uniform block reflection:
-UBO: offset -1, type ffffffff, size 80, index -1, binding -1, stages 0, numMembers 5
+UBO: offset -1, type ffffffff, size 96, index -1, binding -1, stages 1, numMembers 6
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
-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, arrayStride 4, topLevelArrayStride 72
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].position[0]: offset 24, 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, arrayStride 4, topLevelArrayStride 72
+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[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
+padding[0]: offset 360, type 1405, size 10, index 0, binding -1, stages 0, arrayStride 4, topLevelArrayStride 4
+MultipleArrays.tri[0].v[0].position[0]: offset 0, type 1406, size 3, index 1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 72
+MultipleArrays.tri[0].v[0].normal[0]: offset 12, type 1406, size 3, index 1, binding -1, stages 0, arrayStride 4, topLevelArrayStride 72
+MultipleArrays.tri[0].v[1].position[0]: offset 24, type 1406, size 3, index 1, binding -1, stages 0, arrayStride 4, topLevelArrayStride 72
+MultipleArrays.tri[0].v[1].normal[0]: offset 36, type 1406, size 3, index 1, binding -1, stages 0, arrayStride 4, topLevelArrayStride 72
+MultipleArrays.tri[0].v[2].position[0]: offset 48, type 1406, size 3, index 1, binding -1, stages 0, arrayStride 4, topLevelArrayStride 72
+MultipleArrays.tri[0].v[2].normal[0]: offset 60, type 1406, size 3, index 1, binding -1, stages 0, arrayStride 4, topLevelArrayStride 72
+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
Buffer block reflection:
-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
+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
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 1
Pipeline output reflection:
-outval: offset 0, type 1406, size 0, index 0, binding -1, stages 0
+outval: offset 0, type 1406, size 0, index 0, binding -1, stages 1
named.member3: offset 32, type 8b52, size 1, index 1, binding -1, stages 1
Uniform block reflection:
-nameless: offset -1, type ffffffff, size 496, index -1, binding -1, stages 0, numMembers 9
-named: offset -1, type ffffffff, size 304, index -1, binding -1, stages 0, numMembers 10
-c_nameless: offset -1, type ffffffff, size 112, index -1, binding -1, stages 0, numMembers 5
-nested: offset -1, type ffffffff, size 32, index -1, binding -1, stages 0, numMembers 4
-abl[0]: offset -1, type ffffffff, size 4, index -1, binding -1, stages 0, numMembers 1
-abl[1]: offset -1, type ffffffff, size 4, index -1, binding -1, stages 0, numMembers 1
-abl[2]: offset -1, type ffffffff, size 4, index -1, binding -1, stages 0, numMembers 1
-abl[3]: offset -1, type ffffffff, size 4, index -1, binding -1, stages 0, numMembers 1
-abl2[0]: offset -1, type ffffffff, size 4, index -1, binding -1, stages 0, numMembers 1
-abl2[1]: offset -1, type ffffffff, size 4, index -1, binding -1, stages 0, numMembers 1
-abl2[2]: offset -1, type ffffffff, size 4, index -1, binding -1, stages 0, numMembers 1
-abl2[3]: offset -1, type ffffffff, size 4, index -1, binding -1, stages 0, numMembers 1
-buf1: offset -1, type ffffffff, size 4, index -1, binding -1, stages 0, numMembers 2
-buf2: offset -1, type ffffffff, size 4, index -1, binding -1, stages 0, numMembers 4
-buf3: offset -1, type ffffffff, size 4, index -1, binding -1, stages 0, numMembers 2
-buf4: offset -1, type ffffffff, size 4, index -1, binding -1, stages 0, numMembers 4
-nested2: offset -1, type ffffffff, size 208, index -1, binding -1, stages 0, numMembers 15
-VertexCollection: offset -1, type ffffffff, size 360, index -1, binding -1, stages 0, numMembers 30
+nameless: offset -1, type ffffffff, size 496, index -1, binding -1, stages 1, numMembers 9
+named: offset -1, type ffffffff, size 304, index -1, binding -1, stages 1, numMembers 10
+c_nameless: offset -1, type ffffffff, size 112, index -1, binding -1, stages 1, numMembers 5
+nested: offset -1, type ffffffff, size 32, index -1, binding -1, stages 1, numMembers 4
+abl[0]: offset -1, type ffffffff, size 4, index -1, binding -1, stages 1, numMembers 1
+abl[1]: offset -1, type ffffffff, size 4, index -1, binding -1, stages 1, numMembers 1
+abl[2]: offset -1, type ffffffff, size 4, index -1, binding -1, stages 1, numMembers 1
+abl[3]: offset -1, type ffffffff, size 4, index -1, binding -1, stages 1, numMembers 1
+abl2[0]: offset -1, type ffffffff, size 4, index -1, binding -1, stages 1, numMembers 1
+abl2[1]: offset -1, type ffffffff, size 4, index -1, binding -1, stages 1, numMembers 1
+abl2[2]: offset -1, type ffffffff, size 4, index -1, binding -1, stages 1, numMembers 1
+abl2[3]: offset -1, type ffffffff, size 4, index -1, binding -1, stages 1, numMembers 1
+buf1: offset -1, type ffffffff, size 4, index -1, binding -1, stages 1, numMembers 2
+buf2: offset -1, type ffffffff, size 4, index -1, binding -1, stages 1, numMembers 4
+buf3: offset -1, type ffffffff, size 4, index -1, binding -1, stages 1, numMembers 2
+buf4: offset -1, type ffffffff, size 4, index -1, binding -1, stages 1, numMembers 4
+nested2: offset -1, type ffffffff, size 208, index -1, binding -1, stages 1, numMembers 15
+VertexCollection: offset -1, type ffffffff, size 400, index -1, binding -1, stages 1, numMembers 31
Buffer variable reflection:
Buffer block reflection:
Pipeline input reflection:
-attributeFloat: offset 0, type 1406, size 0, index 0, binding -1, stages 0
-attributeFloat2: offset 0, type 8b50, size 0, index 0, binding -1, stages 0
-attributeFloat3: offset 0, type 8b51, size 0, index 0, binding -1, stages 0
-attributeFloat4: offset 0, type 8b52, size 0, index 0, binding -1, stages 0
-attributeMat4: offset 0, type 8b5c, size 0, index 0, binding -1, stages 0
-gl_InstanceID: offset 0, type 1404, size 0, index 0, binding -1, stages 0
+attributeFloat: offset 0, type 1406, size 0, index 0, binding -1, stages 1
+attributeFloat2: offset 0, type 8b50, size 0, index 0, binding -1, stages 1
+attributeFloat3: offset 0, type 8b51, size 0, index 0, binding -1, stages 1
+attributeFloat4: offset 0, type 8b52, size 0, index 0, binding -1, stages 1
+attributeMat4: offset 0, type 8b5c, size 0, index 0, binding -1, stages 1
+gl_InstanceID: offset 0, type 1404, size 0, index 0, binding -1, stages 1
Pipeline output reflection:
--- /dev/null
+#version 440 core\r
+\r
+layout(binding = 0, std140) uniform ubo_block {\r
+ float unused_uniform;\r
+ float shared_uniform;\r
+ float vsonly_uniform;\r
+ float fsonly_uniform;\r
+} ubo;\r
+\r
+in float vertout;\r
+\r
+out float fragout;\r
+\r
+void main()\r
+{\r
+ fragout = vertout;\r
+ fragout += ubo.shared_uniform;\r
+ fragout += ubo.fsonly_uniform;\r
+}\r
--- /dev/null
+#version 440 core\r
+\r
+layout(binding = 0, std140) uniform ubo_block {\r
+ float unused_uniform;\r
+ float shared_uniform;\r
+ float vsonly_uniform;\r
+ float fsonly_uniform;\r
+} ubo;\r
+\r
+in float vertin;\r
+\r
+out float vertout;\r
+\r
+void main()\r
+{\r
+ vertout = vertin;\r
+ vertout += ubo.shared_uniform;\r
+ vertout += ubo.vsonly_uniform;\r
+}\r
\r
buffer VertexCollection {\r
TriangleInfo t[5];\r
+ uint padding[10];\r
};\r
\r
buffer MultipleArrays {\r
uniform UBO {\r
VertexInfo verts[2];\r
float flt[8];\r
+ uvec4 unused;\r
} ubo;\r
\r
out float outval;\r
\r
buffer VertexCollection {\r
TriangleInfo t[5];\r
+ uint padding[10];\r
};\r
\r
out float outval;\r
echo Running reflection...
$EXE -l -q -C reflection.vert > $TARGETDIR/reflection.vert.out
diff -b $BASEDIR/reflection.vert.out $TARGETDIR/reflection.vert.out || HASERROR=1
-$EXE -l -q -C --reflect-strict-array-suffix --reflect-basic-array-suffix --reflect-intermediate-io --reflect-separate-buffers reflection.options.vert > $TARGETDIR/reflection.options.vert.out
+$EXE -l -q -C --reflect-strict-array-suffix --reflect-basic-array-suffix --reflect-intermediate-io --reflect-separate-buffers --reflect-all-block-variables reflection.options.vert > $TARGETDIR/reflection.options.vert.out
diff -b $BASEDIR/reflection.options.vert.out $TARGETDIR/reflection.options.vert.out || HASERROR=1
$EXE -l -q -C reflection.frag > $TARGETDIR/reflection.frag.out
diff -b $BASEDIR/reflection.frag.out $TARGETDIR/reflection.frag.out || HASERROR=1
-$EXE -l -q -C --reflect-strict-array-suffix --reflect-basic-array-suffix --reflect-intermediate-io --reflect-separate-buffers reflection.frag > $TARGETDIR/reflection.options.frag.out
+$EXE -l -q -C --reflect-strict-array-suffix --reflect-basic-array-suffix --reflect-intermediate-io --reflect-separate-buffers --reflect-all-block-variables reflection.frag > $TARGETDIR/reflection.options.frag.out
diff -b $BASEDIR/reflection.options.frag.out $TARGETDIR/reflection.options.frag.out || HASERROR=1
+$EXE -l -q -C reflection.linked.vert reflection.linked.frag > $TARGETDIR/reflection.linked.out
+diff -b $BASEDIR/reflection.linked.out $TARGETDIR/reflection.linked.out || HASERROR=1
+$EXE -l -q -C --reflect-strict-array-suffix --reflect-basic-array-suffix --reflect-intermediate-io --reflect-separate-buffers --reflect-all-block-variables reflection.linked.vert reflection.linked.frag > $TARGETDIR/reflection.linked.options.out
+diff -b $BASEDIR/reflection.linked.options.out $TARGETDIR/reflection.linked.options.out || HASERROR=1
$EXE -D -Od -e flizv -l -q -C -V -Od hlsl.reflection.vert > $TARGETDIR/hlsl.reflection.vert.out
diff -b $BASEDIR/hlsl.reflection.vert.out $TARGETDIR/hlsl.reflection.vert.out || HASERROR=1
$EXE -D -Od -e main -l -q -C -V -Od hlsl.reflection.binding.frag > $TARGETDIR/hlsl.reflection.binding.frag.out
// the dereference change expected by blowUpActiveAggregate.
TList<TIntermBinary*> derefs;
blowUpActiveAggregate(base.getType(), base.getName(), derefs, derefs.end(), -1, -1, 0, 0,
- base.getQualifier().storage);
+ base.getQualifier().storage, true);
}
}
if (it == reflection.nameToIndex.end()) {
reflection.nameToIndex[name.c_str()] = (int)reflection.indexToPipeInput.size();
reflection.indexToPipeInput.push_back(TObjectReflection(name.c_str(), type, 0, mapToGlType(type), 0, 0));
+
+ EShLanguageMask& stages = reflection.indexToPipeInput.back().stages;
+ stages = static_cast<EShLanguageMask>(stages | 1 << intermediate.getStage());
+ } else {
+ EShLanguageMask& stages = reflection.indexToPipeInput[it->second].stages;
+ stages = static_cast<EShLanguageMask>(stages | 1 << intermediate.getStage());
}
}
}
if (it == reflection.nameToIndex.end()) {
reflection.nameToIndex[name.c_str()] = (int)reflection.indexToPipeOutput.size();
reflection.indexToPipeOutput.push_back(TObjectReflection(name.c_str(), type, 0, mapToGlType(type), 0, 0));
+
+ EShLanguageMask& stages = reflection.indexToPipeOutput.back().stages;
+ stages = static_cast<EShLanguageMask>(stages | 1 << intermediate.getStage());
+ } else {
+ EShLanguageMask& stages = reflection.indexToPipeOutput[it->second].stages;
+ stages = static_cast<EShLanguageMask>(stages | 1 << intermediate.getStage());
}
}
}
// 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,
TList<TIntermBinary*>::const_iterator deref, int offset, int blockIndex, int arraySize,
- int topLevelArrayStride, TStorageQualifier baseStorage)
+ int topLevelArrayStride, TStorageQualifier baseStorage, bool active)
{
// when strictArraySuffix is enabled, we closely follow the rules from ARB_program_interface_query.
// Broadly:
++nextDeref;
TType derefType(*terminalType, 0);
blowUpActiveAggregate(derefType, newBaseName, derefs, nextDeref, offset, blockIndex, arraySize,
- topLevelArrayStride, baseStorage);
+ topLevelArrayStride, baseStorage, active);
if (offset >= 0)
offset += stride;
offset = baseOffset + stride * i;
blowUpActiveAggregate(derefType, newBaseName, derefs, derefs.end(), offset, blockIndex, 0,
- topLevelArrayStride, baseStorage);
+ topLevelArrayStride, baseStorage, active);
}
} else {
// Visit all members of this aggregate, and for each one,
for (int i = 0; i < (int)typeList.size(); ++i) {
TString newBaseName = name;
- newBaseName.append(TString(".") + typeList[i].type->getFieldName());
+ if (newBaseName.size() > 0)
+ newBaseName.append(".");
+ newBaseName.append(typeList[i].type->getFieldName());
TType derefType(*terminalType, i);
if (offset >= 0)
offset = baseOffset + memberOffsets[i];
}
blowUpActiveAggregate(derefType, newBaseName, derefs, derefs.end(), offset, blockIndex, 0,
- arrayStride, baseStorage);
+ arrayStride, baseStorage, active);
}
}
reflection.atomicCounterUniformIndices.push_back(uniformIndex);
variables.back().topLevelArrayStride = topLevelArrayStride;
- } else if (arraySize > 1) {
- int& reflectedArraySize = variables[it->second].size;
- reflectedArraySize = std::max(arraySize, reflectedArraySize);
+
+ if ((reflection.options & EShReflectionAllBlockVariables) && active) {
+ EShLanguageMask& stages = variables.back().stages;
+ stages = static_cast<EShLanguageMask>(stages | 1 << intermediate.getStage());
+ }
+ } else {
+ if (arraySize > 1) {
+ int& reflectedArraySize = variables[it->second].size;
+ reflectedArraySize = std::max(arraySize, reflectedArraySize);
+ }
+
+ if ((reflection.options & EShReflectionAllBlockVariables) && active) {
+ EShLanguageMask& stages = variables[it->second].stages;
+ stages = static_cast<EShLanguageMask>(stages | 1 << intermediate.getStage());
+ }
}
}
anonymous = IsAnonymous(base->getName());
const TString& blockName = base->getType().getTypeName();
+ TString baseName;
+
+ if (! anonymous)
+ baseName = blockName;
if (base->getType().isArray()) {
TType derefType(base->getType(), 0);
for (int e = 0; e < base->getType().getCumulativeArraySize(); ++e)
blockIndex = addBlockName(blockName + "[" + String(e) + "]", derefType,
getBlockSize(base->getType()));
+ baseName.append(TString("[0]"));
} else
blockIndex = addBlockName(blockName, base->getType(), getBlockSize(base->getType()));
+
+ if (reflection.options & EShReflectionAllBlockVariables) {
+ // Use a degenerate (empty) set of dereferences to immediately put as at the end of
+ // the dereference change expected by blowUpActiveAggregate.
+ TList<TIntermBinary*> derefs;
+
+ // because we don't have any derefs, the first thing blowUpActiveAggregate will do is iterate over each
+ // member in the struct definition. This will lose any information about whether the parent was a buffer
+ // block. So if we're using strict array rules which don't expand the first child of a buffer block we
+ // instead iterate over the children here.
+ const bool strictArraySuffix = (reflection.options & EShReflectionStrictArraySuffix);
+ bool blockParent = (base->getType().getBasicType() == EbtBlock && base->getQualifier().storage == EvqBuffer);
+
+ if (strictArraySuffix && blockParent) {
+ const TTypeList& typeList = *base->getType().getStruct();
+
+ TVector<int> memberOffsets;
+
+ memberOffsets.resize(typeList.size());
+ getOffsets(base->getType(), memberOffsets);
+
+ for (int i = 0; i < (int)typeList.size(); ++i) {
+ TType derefType(base->getType(), i);
+ TString name = baseName;
+ if (name.size() > 0)
+ name.append(".");
+ name.append(typeList[i].type->getFieldName());
+
+ // if this member is an array, store the top-level array stride but start the explosion from
+ // the inner struct type.
+ if (derefType.isArray() && derefType.isStruct()) {
+ name.append("[0]");
+ blowUpActiveAggregate(TType(derefType, 0), name, derefs, derefs.end(), memberOffsets[i],
+ blockIndex, 0, getArrayStride(base->getType(), derefType),
+ base->getQualifier().storage, false);
+ } else {
+ blowUpActiveAggregate(derefType, name, derefs, derefs.end(), memberOffsets[i], blockIndex,
+ 0, 0, base->getQualifier().storage, false);
+ }
+ }
+ } else {
+ // otherwise - if we're not using strict array suffix rules, or this isn't a block so we are
+ // expanding root arrays anyway, just start the iteration from the base block type.
+ blowUpActiveAggregate(base->getType(), baseName, derefs, derefs.end(), 0, blockIndex, 0, 0,
+ base->getQualifier().storage, false);
+ }
+ }
}
// Process the dereference chain, backward, accumulating the pieces for later forward traversal.
baseName = base->getName();
}
blowUpActiveAggregate(base->getType(), baseName, derefs, derefs.begin(), offset, blockIndex, arraySize, 0,
- base->getQualifier().storage);
+ base->getQualifier().storage, true);
}
int addBlockName(const TString& name, const TType& type, int size)
blocks.push_back(TObjectReflection(name.c_str(), type, -1, -1, size, -1));
blocks.back().numMembers = countAggregateMembers(type);
- } else
+
+ EShLanguageMask& stages = blocks.back().stages;
+ stages = static_cast<EShLanguageMask>(stages | 1 << intermediate.getStage());
+ } else {
blockIndex = it->second;
+ EShLanguageMask& stages = blocks[blockIndex].stages;
+ stages = static_cast<EShLanguageMask>(stages | 1 << intermediate.getStage());
+ }
+
return blockIndex;
}
// build Shader Stages mask for all uniforms
void TReflection::buildUniformStageMask(const TIntermediate& intermediate)
{
+ if (options & EShReflectionAllBlockVariables)
+ return;
+
for (int i = 0; i < int(indexToUniform.size()); ++i) {
indexToUniform[i].stages = static_cast<EShLanguageMask>(indexToUniform[i].stages | 1 << intermediate.getStage());
}
EShReflectionBasicArraySuffix = (1 << 1), // arrays of basic types will be appended with [0] as in GL reflection
EShReflectionIntermediateIO = (1 << 2), // reflect inputs and outputs to program, even with no vertex shader
EShReflectionSeparateBuffers = (1 << 3), // buffer variables and buffer blocks are reflected separately
+ EShReflectionAllBlockVariables = (1 << 4), // reflect all variables in blocks, even if they are inactive
} EShReflectionOptions;
//