Add and partially implement an interface for doing uniform reflection. It includes an AST traversal to identify live accesses.

It does not yet correctly compute block offsets, give correct GL-API-style type values, or handle arrays.

This is tied to the new -q flag.


git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@23938 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich
2013-11-07 01:06:34 +00:00
parent 8ec55cdcd2
commit 11f9fc7247
15 changed files with 682 additions and 18 deletions

View File

@@ -0,0 +1,33 @@
reflection.vert
Warning, version 440 is not yet complete; some version-specific features are present, but many are missing.
Linked vertex stage:
Uniform reflection:
0:anonMember3: offset 32, type 35666, arraySize 1, index 0
1:s.a: offset -1, type 35666, arraySize 1, index -1
2:anonMember1: offset 0, type 35666, arraySize 1, index 0
3:uf1: offset -1, type 35666, arraySize 1, index -1
4:uf2: offset -1, type 35666, arraySize 1, index -1
5:ablock.member3: offset 32, type 35666, arraySize 1, index 1
Uniform block reflection:
0: nameless: offset -1, type -1, arraySize 1, index -1
1: ablock: offset -1, type -1, arraySize 1, index -1
Live names
ablock: 1
ablock.member3: 5
anonMember1: 2
anonMember3: 0
liveFunction1(: -1
liveFunction2(: -1
nameless: 0
s.a: 1
uf1: 3
uf2: 4

73
Test/reflection.vert Normal file
View File

@@ -0,0 +1,73 @@
#version 440 core
uniform nameless {
vec3 anonMember1;
vec4 anonDeadMember2;
vec4 anonMember3;
};
uniform named {
vec3 deadMember1;
vec4 member2;
vec4 member3;
} ablock;
uniform namelessdead {
int a;
};
uniform namedDead {
int b;
} bblock;
struct TS {
int a;
int dead;
};
uniform TS s;
uniform float uf1;
uniform float uf2;
uniform float ufDead3;
uniform float ufDead4;
const bool control = true;
void deadFunction()
{
vec3 v3 = ablock.deadMember1;
vec4 v = anonDeadMember2;
float f = ufDead4;
}
void liveFunction2()
{
vec3 v = anonMember1;
float f = uf1;
}
void liveFunction1()
{
liveFunction2();
float f = uf2;
vec4 v = ablock.member3;
}
void main()
{
liveFunction1();
liveFunction2();
if (! control)
deadFunction();
float f;
if (control) {
liveFunction2();
f = anonMember3.z;
f = s.a;
} else
f = ufDead3;
}

View File

@@ -43,6 +43,13 @@ runLinkTest 300link2.frag
runLinkTest 300link3.frag
runLinkTest empty.frag empty2.frag empty3.frag
#
# reflection tests
#
echo Running reflection...
$EXE -l -q reflection.vert > $TARGETDIR/reflection.vert.out
diff -b $BASEDIR/reflection.vert.out $TARGETDIR/reflection.vert.out
#
# multi-threaded test
#