Add option to reflect all block members, inactive or active.

* The stages mask is more fine-grained, and each variable or block's mask
  indicates which stages it's active in.
This commit is contained in:
baldurk 2019-01-30 15:34:02 +00:00
parent 657acc0c40
commit a972e73ad7
17 changed files with 265 additions and 77 deletions

View File

@ -532,6 +532,8 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
ReflectOptions |= EShReflectionIntermediateIO; ReflectOptions |= EShReflectionIntermediateIO;
} else if (lowerword == "reflect-separate-buffers") { } else if (lowerword == "reflect-separate-buffers") {
ReflectOptions |= EShReflectionSeparateBuffers; ReflectOptions |= EShReflectionSeparateBuffers;
} else if (lowerword == "reflect-all-block-variables") {
ReflectOptions |= EShReflectionAllBlockVariables;
} else if (lowerword == "resource-set-bindings" || // synonyms } else if (lowerword == "resource-set-bindings" || // synonyms
lowerword == "resource-set-binding" || lowerword == "resource-set-binding" ||
lowerword == "rsb") { lowerword == "rsb") {
@ -1532,6 +1534,7 @@ void usage()
" --reflect-intermediate-io reflection includes inputs/outputs of linked shaders\n" " --reflect-intermediate-io reflection includes inputs/outputs of linked shaders\n"
" rather than just vertex/fragment\n" " rather than just vertex/fragment\n"
" --reflect-separate-buffers reflect buffer variables and blocks separately to uniforms\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" " --resource-set-binding [stage] name set binding\n"
" set descriptor set and binding for\n" " set descriptor set and binding for\n"
" individual resources\n" " individual resources\n"

View File

@ -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 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, 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 0, 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 0, 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 0, 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 0, 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 0, numMembers 1 tb: offset -1, type ffffffff, size 4, index -1, binding 17, stages 16, numMembers 1
Buffer variable reflection: Buffer variable reflection:
@ -32,5 +32,5 @@ Buffer block reflection:
Pipeline input reflection: Pipeline input reflection:
Pipeline output 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

View File

@ -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, 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 0, numMembers 3 cbuff2: offset -1, type ffffffff, size 24, index -1, binding 3, stages 16, numMembers 3
Buffer variable reflection: Buffer variable reflection:
@ -22,5 +22,5 @@ Buffer block reflection:
Pipeline input reflection: Pipeline input reflection:
Pipeline output 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

View File

@ -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 uf1: offset 16, type 1406, size 1, index 1, binding -1, stages 1
Uniform block reflection: Uniform block reflection:
nameless: offset -1, type ffffffff, size 496, index -1, binding -1, stages 0, numMembers 9 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 0, numMembers 106 $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 0, numMembers 5 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 0, numMembers 4 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 0, numMembers 1 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 0, numMembers 1 abl2: offset -1, type ffffffff, size 4, index -1, binding -1, stages 1, numMembers 1
Buffer variable reflection: Buffer variable reflection:
Buffer block reflection: Buffer block reflection:
Pipeline input reflection: Pipeline input reflection:
attributeFloat: offset 0, type 1406, 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 0 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 0 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 0 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 0 attributeMat4: offset 0, type 8b5c, size 0, index 0, binding -1, stages 1
Pipeline output reflection: Pipeline output reflection:

View File

@ -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 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, 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 0, 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 0, 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 0, 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 0, 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 0, numMembers 1 tb: offset -1, type ffffffff, size 4, index -1, binding 27, stages 16, numMembers 1
Buffer variable reflection: Buffer variable reflection:
@ -233,5 +233,5 @@ Buffer block reflection:
Pipeline input reflection: Pipeline input reflection:
Pipeline output 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

View File

@ -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

View File

@ -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

View File

@ -8,7 +8,7 @@ Buffer variable reflection:
Buffer block reflection: Buffer block reflection:
Pipeline input 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: Pipeline output reflection:

View File

@ -1,30 +1,40 @@
reflection.options.vert reflection.options.vert
Uniform reflection: 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[0].position[0]: offset 0, type 1406, size 3, 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].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.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: 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: 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[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[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[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 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 padding[0]: offset 360, type 1405, size 10, index 0, binding -1, stages 0, arrayStride 4, topLevelArrayStride 4
MultipleArrays.vert[0].position[0]: offset 360, type 1406, size 1, index 1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 24 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 MultipleArrays.f[0]: offset 480, type 1406, size 5, index 1, binding -1, stages 1, arrayStride 4, topLevelArrayStride 4
Buffer block reflection: Buffer block reflection:
VertexCollection: offset -1, type ffffffff, size 360, index -1, binding -1, stages 0, numMembers 6 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 0, numMembers 9 MultipleArrays: offset -1, type ffffffff, size 500, index -1, binding -1, stages 1, 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 1
Pipeline output reflection: 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

View File

@ -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 named.member3: offset 32, type 8b52, size 1, index 1, binding -1, stages 1
Uniform block reflection: Uniform block reflection:
nameless: offset -1, type ffffffff, size 496, index -1, binding -1, stages 0, numMembers 9 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 0, numMembers 10 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 0, numMembers 5 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 0, numMembers 4 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 0, numMembers 1 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 0, 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 0, 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 0, 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 0, 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 0, 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 0, 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 0, 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 0, numMembers 2 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 0, numMembers 4 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 0, numMembers 2 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 0, numMembers 4 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 0, numMembers 15 nested2: offset -1, type ffffffff, size 208, index -1, binding -1, stages 1, numMembers 15
VertexCollection: offset -1, type ffffffff, size 360, index -1, binding -1, stages 0, numMembers 30 VertexCollection: offset -1, type ffffffff, size 400, index -1, binding -1, stages 1, numMembers 31
Buffer variable reflection: Buffer variable reflection:
Buffer block reflection: Buffer block reflection:
Pipeline input reflection: Pipeline input reflection:
attributeFloat: offset 0, type 1406, 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 0 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 0 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 0 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 0 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 0 gl_InstanceID: offset 0, type 1404, size 0, index 0, binding -1, stages 1
Pipeline output reflection: Pipeline output reflection:

View File

@ -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;
}

View File

@ -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;
}

View File

@ -11,6 +11,7 @@ struct TriangleInfo {
buffer VertexCollection { buffer VertexCollection {
TriangleInfo t[5]; TriangleInfo t[5];
uint padding[10];
}; };
buffer MultipleArrays { buffer MultipleArrays {
@ -22,6 +23,7 @@ buffer MultipleArrays {
uniform UBO { uniform UBO {
VertexInfo verts[2]; VertexInfo verts[2];
float flt[8]; float flt[8];
uvec4 unused;
} ubo; } ubo;
out float outval; out float outval;

View File

@ -172,6 +172,7 @@ struct TriangleInfo {
buffer VertexCollection { buffer VertexCollection {
TriangleInfo t[5]; TriangleInfo t[5];
uint padding[10];
}; };
out float outval; out float outval;

View File

@ -32,12 +32,16 @@ diff -b $BASEDIR/badMacroArgs.frag.out $TARGETDIR/badMacroArgs.frag.out || HASER
echo Running reflection... echo Running reflection...
$EXE -l -q -C reflection.vert > $TARGETDIR/reflection.vert.out $EXE -l -q -C reflection.vert > $TARGETDIR/reflection.vert.out
diff -b $BASEDIR/reflection.vert.out $TARGETDIR/reflection.vert.out || HASERROR=1 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 diff -b $BASEDIR/reflection.options.vert.out $TARGETDIR/reflection.options.vert.out || HASERROR=1
$EXE -l -q -C reflection.frag > $TARGETDIR/reflection.frag.out $EXE -l -q -C reflection.frag > $TARGETDIR/reflection.frag.out
diff -b $BASEDIR/reflection.frag.out $TARGETDIR/reflection.frag.out || HASERROR=1 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 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 $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 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 $EXE -D -Od -e main -l -q -C -V -Od hlsl.reflection.binding.frag > $TARGETDIR/hlsl.reflection.binding.frag.out

View File

@ -94,7 +94,7 @@ public:
// 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, 0, 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()) { if (it == reflection.nameToIndex.end()) {
reflection.nameToIndex[name.c_str()] = (int)reflection.indexToPipeInput.size(); reflection.nameToIndex[name.c_str()] = (int)reflection.indexToPipeInput.size();
reflection.indexToPipeInput.push_back(TObjectReflection(name.c_str(), type, 0, mapToGlType(type), 0, 0)); 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());
} }
} }
} }
@ -126,6 +132,12 @@ public:
if (it == reflection.nameToIndex.end()) { if (it == reflection.nameToIndex.end()) {
reflection.nameToIndex[name.c_str()] = (int)reflection.indexToPipeOutput.size(); reflection.nameToIndex[name.c_str()] = (int)reflection.indexToPipeOutput.size();
reflection.indexToPipeOutput.push_back(TObjectReflection(name.c_str(), type, 0, mapToGlType(type), 0, 0)); 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());
} }
} }
} }
@ -269,7 +281,7 @@ public:
// 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, TStorageQualifier baseStorage) int topLevelArrayStride, TStorageQualifier baseStorage, bool active)
{ {
// 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:
@ -306,7 +318,7 @@ public:
++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, baseStorage); topLevelArrayStride, baseStorage, active);
if (offset >= 0) if (offset >= 0)
offset += stride; offset += stride;
@ -377,7 +389,7 @@ public:
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, baseStorage); topLevelArrayStride, baseStorage, active);
} }
} else { } else {
// Visit all members of this aggregate, and for each one, // Visit all members of this aggregate, and for each one,
@ -393,7 +405,9 @@ public:
for (int i = 0; i < (int)typeList.size(); ++i) { for (int i = 0; i < (int)typeList.size(); ++i) {
TString newBaseName = name; 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); TType derefType(*terminalType, i);
if (offset >= 0) if (offset >= 0)
offset = baseOffset + memberOffsets[i]; offset = baseOffset + memberOffsets[i];
@ -405,7 +419,7 @@ public:
} }
blowUpActiveAggregate(derefType, newBaseName, derefs, derefs.end(), offset, blockIndex, 0, blowUpActiveAggregate(derefType, newBaseName, derefs, derefs.end(), offset, blockIndex, 0,
arrayStride, baseStorage); arrayStride, baseStorage, active);
} }
} }
@ -442,9 +456,21 @@ public:
reflection.atomicCounterUniformIndices.push_back(uniformIndex); reflection.atomicCounterUniformIndices.push_back(uniformIndex);
variables.back().topLevelArrayStride = topLevelArrayStride; variables.back().topLevelArrayStride = topLevelArrayStride;
} else if (arraySize > 1) {
int& reflectedArraySize = variables[it->second].size; if ((reflection.options & EShReflectionAllBlockVariables) && active) {
reflectedArraySize = std::max(arraySize, reflectedArraySize); 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());
}
} }
} }
@ -494,6 +520,10 @@ public:
anonymous = IsAnonymous(base->getName()); anonymous = IsAnonymous(base->getName());
const TString& blockName = base->getType().getTypeName(); const TString& blockName = base->getType().getTypeName();
TString baseName;
if (! anonymous)
baseName = blockName;
if (base->getType().isArray()) { if (base->getType().isArray()) {
TType derefType(base->getType(), 0); TType derefType(base->getType(), 0);
@ -502,8 +532,56 @@ public:
for (int e = 0; e < base->getType().getCumulativeArraySize(); ++e) for (int e = 0; e < base->getType().getCumulativeArraySize(); ++e)
blockIndex = addBlockName(blockName + "[" + String(e) + "]", derefType, blockIndex = addBlockName(blockName + "[" + String(e) + "]", derefType,
getBlockSize(base->getType())); getBlockSize(base->getType()));
baseName.append(TString("[0]"));
} else } else
blockIndex = addBlockName(blockName, base->getType(), getBlockSize(base->getType())); 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. // Process the dereference chain, backward, accumulating the pieces for later forward traversal.
@ -534,7 +612,7 @@ public:
baseName = base->getName(); baseName = base->getName();
} }
blowUpActiveAggregate(base->getType(), baseName, derefs, derefs.begin(), offset, blockIndex, arraySize, 0, 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) 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.push_back(TObjectReflection(name.c_str(), type, -1, -1, size, -1));
blocks.back().numMembers = countAggregateMembers(type); blocks.back().numMembers = countAggregateMembers(type);
} else
EShLanguageMask& stages = blocks.back().stages;
stages = static_cast<EShLanguageMask>(stages | 1 << intermediate.getStage());
} else {
blockIndex = it->second; blockIndex = it->second;
EShLanguageMask& stages = blocks[blockIndex].stages;
stages = static_cast<EShLanguageMask>(stages | 1 << intermediate.getStage());
}
return blockIndex; return blockIndex;
} }
@ -1018,6 +1103,9 @@ void TReflection::buildCounterIndices(const TIntermediate& intermediate)
// build Shader Stages mask for all uniforms // build Shader Stages mask for all uniforms
void TReflection::buildUniformStageMask(const TIntermediate& intermediate) void TReflection::buildUniformStageMask(const TIntermediate& intermediate)
{ {
if (options & EShReflectionAllBlockVariables)
return;
for (int i = 0; i < int(indexToUniform.size()); ++i) { for (int i = 0; i < int(indexToUniform.size()); ++i) {
indexToUniform[i].stages = static_cast<EShLanguageMask>(indexToUniform[i].stages | 1 << intermediate.getStage()); indexToUniform[i].stages = static_cast<EShLanguageMask>(indexToUniform[i].stages | 1 << intermediate.getStage());
} }

View File

@ -248,6 +248,7 @@ typedef enum {
EShReflectionBasicArraySuffix = (1 << 1), // arrays of basic types will be appended with [0] as in GL reflection 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 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 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; } EShReflectionOptions;
// //