diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index 52fd80c6..8906493d 100644 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -532,6 +532,8 @@ void ProcessArguments(std::vector>& workItem 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") { @@ -1532,6 +1534,7 @@ void usage() " --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" diff --git a/Test/baseResults/hlsl.automap.frag.out b/Test/baseResults/hlsl.automap.frag.out index fb914ece..48f232c6 100644 --- a/Test/baseResults/hlsl.automap.frag.out +++ b/Test/baseResults/hlsl.automap.frag.out @@ -18,12 +18,12 @@ 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 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: @@ -32,5 +32,5 @@ Buffer block 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 diff --git a/Test/baseResults/hlsl.reflection.binding.frag.out b/Test/baseResults/hlsl.reflection.binding.frag.out index 8d5743ea..484cfc6a 100644 --- a/Test/baseResults/hlsl.reflection.binding.frag.out +++ b/Test/baseResults/hlsl.reflection.binding.frag.out @@ -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 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: @@ -22,5 +22,5 @@ Buffer block 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 diff --git a/Test/baseResults/hlsl.reflection.vert.out b/Test/baseResults/hlsl.reflection.vert.out index c9367480..30c6c9fe 100644 --- a/Test/baseResults/hlsl.reflection.vert.out +++ b/Test/baseResults/hlsl.reflection.vert.out @@ -60,23 +60,23 @@ anonMember1: offset 0, type 8b51, size 1, index 0, binding -1, stages 1 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: diff --git a/Test/baseResults/hlsl.shift.per-set.frag.out b/Test/baseResults/hlsl.shift.per-set.frag.out index a0eb574b..da2e544e 100644 --- a/Test/baseResults/hlsl.shift.per-set.frag.out +++ b/Test/baseResults/hlsl.shift.per-set.frag.out @@ -219,12 +219,12 @@ 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 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: @@ -233,5 +233,5 @@ Buffer block 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 diff --git a/Test/baseResults/reflection.linked.options.out b/Test/baseResults/reflection.linked.options.out new file mode 100644 index 00000000..b121626f --- /dev/null +++ b/Test/baseResults/reflection.linked.options.out @@ -0,0 +1,21 @@ +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 + diff --git a/Test/baseResults/reflection.linked.out b/Test/baseResults/reflection.linked.out new file mode 100644 index 00000000..bc61fadf --- /dev/null +++ b/Test/baseResults/reflection.linked.out @@ -0,0 +1,20 @@ +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 + diff --git a/Test/baseResults/reflection.options.frag.out b/Test/baseResults/reflection.options.frag.out index a0cecef6..f3ea4cad 100644 --- a/Test/baseResults/reflection.options.frag.out +++ b/Test/baseResults/reflection.options.frag.out @@ -8,7 +8,7 @@ Buffer variable reflection: 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: diff --git a/Test/baseResults/reflection.options.vert.out b/Test/baseResults/reflection.options.vert.out index add73961..0a3b1188 100644 --- a/Test/baseResults/reflection.options.vert.out +++ b/Test/baseResults/reflection.options.vert.out @@ -1,30 +1,40 @@ 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 diff --git a/Test/baseResults/reflection.vert.out b/Test/baseResults/reflection.vert.out index 6baa8ac0..f1219ef6 100644 --- a/Test/baseResults/reflection.vert.out +++ b/Test/baseResults/reflection.vert.out @@ -127,36 +127,36 @@ uf2: offset -1, type 1406, size 1, index -1, 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: diff --git a/Test/reflection.linked.frag b/Test/reflection.linked.frag new file mode 100644 index 00000000..4a88ec49 --- /dev/null +++ b/Test/reflection.linked.frag @@ -0,0 +1,19 @@ +#version 440 core + +layout(binding = 0, std140) uniform ubo_block { + float unused_uniform; + float shared_uniform; + float vsonly_uniform; + float fsonly_uniform; +} ubo; + +in float vertout; + +out float fragout; + +void main() +{ + fragout = vertout; + fragout += ubo.shared_uniform; + fragout += ubo.fsonly_uniform; +} diff --git a/Test/reflection.linked.vert b/Test/reflection.linked.vert new file mode 100644 index 00000000..e28142de --- /dev/null +++ b/Test/reflection.linked.vert @@ -0,0 +1,19 @@ +#version 440 core + +layout(binding = 0, std140) uniform ubo_block { + float unused_uniform; + float shared_uniform; + float vsonly_uniform; + float fsonly_uniform; +} ubo; + +in float vertin; + +out float vertout; + +void main() +{ + vertout = vertin; + vertout += ubo.shared_uniform; + vertout += ubo.vsonly_uniform; +} diff --git a/Test/reflection.options.vert b/Test/reflection.options.vert index 001537e0..b8ecc895 100644 --- a/Test/reflection.options.vert +++ b/Test/reflection.options.vert @@ -11,6 +11,7 @@ struct TriangleInfo { buffer VertexCollection { TriangleInfo t[5]; + uint padding[10]; }; buffer MultipleArrays { @@ -22,6 +23,7 @@ buffer MultipleArrays { uniform UBO { VertexInfo verts[2]; float flt[8]; + uvec4 unused; } ubo; out float outval; diff --git a/Test/reflection.vert b/Test/reflection.vert index 939e52a3..0f14c826 100644 --- a/Test/reflection.vert +++ b/Test/reflection.vert @@ -172,6 +172,7 @@ struct TriangleInfo { buffer VertexCollection { TriangleInfo t[5]; + uint padding[10]; }; out float outval; diff --git a/Test/runtests b/Test/runtests index d3705034..f659da4d 100755 --- a/Test/runtests +++ b/Test/runtests @@ -32,12 +32,16 @@ diff -b $BASEDIR/badMacroArgs.frag.out $TARGETDIR/badMacroArgs.frag.out || HASER 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 diff --git a/glslang/MachineIndependent/reflection.cpp b/glslang/MachineIndependent/reflection.cpp index a7d9b13a..df818796 100644 --- a/glslang/MachineIndependent/reflection.cpp +++ b/glslang/MachineIndependent/reflection.cpp @@ -94,7 +94,7 @@ public: // the dereference change expected by blowUpActiveAggregate. TList derefs; blowUpActiveAggregate(base.getType(), base.getName(), derefs, derefs.end(), -1, -1, 0, 0, - base.getQualifier().storage); + base.getQualifier().storage, true); } } @@ -110,6 +110,12 @@ public: 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(stages | 1 << intermediate.getStage()); + } else { + EShLanguageMask& stages = reflection.indexToPipeInput[it->second].stages; + stages = static_cast(stages | 1 << intermediate.getStage()); } } } @@ -126,6 +132,12 @@ public: 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(stages | 1 << intermediate.getStage()); + } else { + EShLanguageMask& stages = reflection.indexToPipeOutput[it->second].stages; + stages = static_cast(stages | 1 << intermediate.getStage()); } } } @@ -269,7 +281,7 @@ public: // 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& derefs, TList::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: @@ -306,7 +318,7 @@ public: ++nextDeref; TType derefType(*terminalType, 0); blowUpActiveAggregate(derefType, newBaseName, derefs, nextDeref, offset, blockIndex, arraySize, - topLevelArrayStride, baseStorage); + topLevelArrayStride, baseStorage, active); if (offset >= 0) offset += stride; @@ -377,7 +389,7 @@ public: 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, @@ -393,7 +405,9 @@ public: 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]; @@ -405,7 +419,7 @@ public: } blowUpActiveAggregate(derefType, newBaseName, derefs, derefs.end(), offset, blockIndex, 0, - arrayStride, baseStorage); + arrayStride, baseStorage, active); } } @@ -442,9 +456,21 @@ public: 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(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(stages | 1 << intermediate.getStage()); + } } } @@ -494,6 +520,10 @@ public: 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); @@ -502,8 +532,56 @@ public: 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 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 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. @@ -534,7 +612,7 @@ public: 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) @@ -549,9 +627,16 @@ public: 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(stages | 1 << intermediate.getStage()); + } else { blockIndex = it->second; + EShLanguageMask& stages = blocks[blockIndex].stages; + stages = static_cast(stages | 1 << intermediate.getStage()); + } + return blockIndex; } @@ -1018,6 +1103,9 @@ void TReflection::buildCounterIndices(const TIntermediate& intermediate) // 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(indexToUniform[i].stages | 1 << intermediate.getStage()); } diff --git a/glslang/Public/ShaderLang.h b/glslang/Public/ShaderLang.h index 7aaaaf3a..3512cede 100755 --- a/glslang/Public/ShaderLang.h +++ b/glslang/Public/ShaderLang.h @@ -248,6 +248,7 @@ typedef enum { 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; //