Implement implicit conversions of function-call arguments (both in and out) as explicit conversions in the AST, through handleArgumentConversions().

Also
 - uniformly handle EvqConstReadOnly as an input argument in a function, with 
   isParamInput() and isParamOutput() queries in TQualifier.
 - provide a makeTemporary() in TQualifier, for erasing original qualification when making a temp
 - provide a makeInternalVariable() call to make a shader variable not seen in the shader source


git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@25912 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich
2014-03-16 23:03:07 +00:00
parent e5d92eb194
commit 75694fdacd
11 changed files with 530 additions and 235 deletions

View File

@@ -58,15 +58,15 @@ float overloadA(float); // ERROR, different return value for same sig
float overloadA(out float f, int);
float overloadA(int i);
vec2 overloadB(float, float);
void overloadB(float, const in float) { }
vec2 overloadC(int, int);
vec2 overloadC(int, float);
vec2 overloadC(const in int, float);
vec2 overloadC(float, int);
vec2 overloadC(vec2, vec2);
vec3 overloadD(int, float);
vec3 overloadD(float, int);
vec3 overloadD(float, in int);
vec3 overloadE(float[2]);
vec3 overloadE(mat2 m);
@@ -119,3 +119,21 @@ void foo()
}
varying vec4 gl_TexCoord[35]; // ERROR, size too big
// tests for output conversions
void outFun(in float, out ivec2, in int, out float);
int outFunRet(in float, out int, const in int, out ivec4);
ivec2 outFunRet(in float, out ivec4, in int, out ivec4);
void foo2()
{
vec2 v2;
vec4 v4;
float f;
int i;
outFun(i, v2, i, f);
outFunRet(i, f, i, v4);
float ret = outFunRet(i, f, i, v4);
vec2 ret2 = outFunRet(i, v4, i, v4);
}

View File

@@ -94,20 +94,25 @@ ERROR: node is still EOpNull!
0:43 'gl_PointSize' (invariant gl_PointSize float)
0:43 Constant:
0:43 3.800000
0:61 Function Definition: overloadB(f1;f1; (void)
0:61 Function Parameters:
0:61 '' (in float)
0:61 '' (const (read only) float)
0:78 Function Definition: foo( (void)
0:78 Function Parameters:
0:? Sequence
0:83 Function Call: overloadB(f1;f1; (2-component vector of float)
0:83 Function Call: overloadB(f1;f1; (void)
0:83 'f' (float)
0:83 'f' (float)
0:84 Function Call: overloadB(f1;f1; (2-component vector of float)
0:84 Function Call: overloadB(f1;f1; (void)
0:84 'f' (float)
0:84 Constant:
0:84 2 (const int)
0:85 Function Call: overloadB(f1;f1; (2-component vector of float)
0:84 2.000000
0:85 Function Call: overloadB(f1;f1; (void)
0:85 Constant:
0:85 1 (const int)
0:85 'i' (int)
0:85 1.000000
0:85 Convert int to float (float)
0:85 'i' (int)
0:87 Constant:
0:87 0.000000
0:88 Function Call: overloadC(i1;i1; (2-component vector of float)
@@ -125,8 +130,8 @@ ERROR: node is still EOpNull!
0:90 0.000000
0:91 Function Call: overloadC(vf2;vf2; (2-component vector of float)
0:91 Constant:
0:91 1 (const int)
0:91 1 (const int)
0:91 1.000000
0:91 1.000000
0:91 Constant:
0:91 2.000000
0:91 2.000000
@@ -137,7 +142,8 @@ ERROR: node is still EOpNull!
0:94 'f' (float)
0:94 'i' (int)
0:95 Function Call: overloadD(f1;i1; (3-component vector of float)
0:95 'i' (int)
0:95 Convert int to float (float)
0:95 'i' (int)
0:95 'i' (int)
0:98 Constant:
0:98 0.000000
@@ -146,8 +152,8 @@ ERROR: node is still EOpNull!
0:101 Function Call: texture2D(s21;vf2; (4-component vector of float)
0:101 's2D' (uniform sampler2D)
0:101 Constant:
0:101 0 (const int)
0:101 0 (const int)
0:101 0.000000
0:101 0.000000
0:102 clamp (4-component vector of float)
0:102 'attv4' (in 4-component vector of float)
0:102 Constant:
@@ -181,8 +187,8 @@ ERROR: node is still EOpNull!
0:111 0.000000
0:112 Function Call: overloadE(vf2; (3-component vector of float)
0:112 Constant:
0:112 1 (const int)
0:112 1 (const int)
0:112 1.000000
0:112 1.000000
0:115 Function Call: overloadE(f1[2]; (3-component vector of float)
0:115 'b' (2-element array of float)
0:117 Constant:
@@ -190,6 +196,82 @@ ERROR: node is still EOpNull!
0:118 Function Call: overloadF(i1; (3-component vector of float)
0:118 Constant:
0:118 1 (const int)
0:128 Function Definition: foo2( (void)
0:128 Function Parameters:
0:? Sequence
0:135 Comma (void)
0:135 Function Call: outFun(f1;vi2;i1;f1; (void)
0:135 Convert int to float (float)
0:135 'i' (int)
0:135 'tempArg' (out 2-component vector of int)
0:135 'i' (int)
0:135 'f' (float)
0:135 move second child to first child (2-component vector of float)
0:135 'v2' (2-component vector of float)
0:135 Convert int to float (2-component vector of float)
0:135 'tempArg' (out 2-component vector of int)
0:136 Comma (int)
0:136 move second child to first child (int)
0:136 'tempReturn' (int)
0:136 Function Call: outFunRet(f1;i1;i1;vi4; (int)
0:136 Convert int to float (float)
0:136 'i' (int)
0:136 'tempArg' (out int)
0:136 'i' (int)
0:136 'tempArg' (out 4-component vector of int)
0:136 move second child to first child (float)
0:136 'f' (float)
0:136 Convert int to float (float)
0:136 'tempArg' (out int)
0:136 move second child to first child (4-component vector of float)
0:136 'v4' (4-component vector of float)
0:136 Convert int to float (4-component vector of float)
0:136 'tempArg' (out 4-component vector of int)
0:136 'tempReturn' (int)
0:137 Sequence
0:137 move second child to first child (float)
0:137 'ret' (float)
0:137 Convert int to float (float)
0:137 Comma (int)
0:137 move second child to first child (int)
0:137 'tempReturn' (int)
0:137 Function Call: outFunRet(f1;i1;i1;vi4; (int)
0:137 Convert int to float (float)
0:137 'i' (int)
0:137 'tempArg' (out int)
0:137 'i' (int)
0:137 'tempArg' (out 4-component vector of int)
0:137 move second child to first child (float)
0:137 'f' (float)
0:137 Convert int to float (float)
0:137 'tempArg' (out int)
0:137 move second child to first child (4-component vector of float)
0:137 'v4' (4-component vector of float)
0:137 Convert int to float (4-component vector of float)
0:137 'tempArg' (out 4-component vector of int)
0:137 'tempReturn' (int)
0:138 Sequence
0:138 move second child to first child (2-component vector of float)
0:138 'ret2' (2-component vector of float)
0:138 Convert int to float (2-component vector of float)
0:138 Comma (2-component vector of int)
0:138 move second child to first child (2-component vector of int)
0:138 'tempReturn' (2-component vector of int)
0:138 Function Call: outFunRet(f1;vi4;i1;vi4; (2-component vector of int)
0:138 Convert int to float (float)
0:138 'i' (int)
0:138 'tempArg' (out 4-component vector of int)
0:138 'i' (int)
0:138 'tempArg' (out 4-component vector of int)
0:138 move second child to first child (4-component vector of float)
0:138 'v4' (4-component vector of float)
0:138 Convert int to float (4-component vector of float)
0:138 'tempArg' (out 4-component vector of int)
0:138 move second child to first child (4-component vector of float)
0:138 'v4' (4-component vector of float)
0:138 Convert int to float (4-component vector of float)
0:138 'tempArg' (out 4-component vector of int)
0:138 'tempReturn' (2-component vector of int)
0:? Linker Objects
0:? 'i' (in 4-component vector of float)
0:? 'o' (smooth out 4-component vector of float)

View File

@@ -1,122 +1,170 @@
../../LunarGLASS/test/functionSemantics.frag
Warning, version 400 is not yet complete; some version-specific features are present, but many are missing.
0:? Sequence
0:3 Function Definition: foo(i1;i1;i1;i1;i1;i1; (mediump int)
0:3 Function Definition: foo(i1;i1;i1;i1;i1;i1; (int)
0:3 Function Parameters:
0:3 'a' (in mediump int)
0:3 'b' (const (read only) mediump int)
0:3 'c' (in mediump int)
0:3 'd' (const (read only) mediump int)
0:3 'e' (out mediump int)
0:3 'f' (inout mediump int)
0:3 'a' (in int)
0:3 'b' (const (read only) int)
0:3 'c' (in int)
0:3 'd' (const (read only) int)
0:3 'e' (out int)
0:3 'f' (inout int)
0:5 Sequence
0:5 Sequence
0:5 move second child to first child (mediump int)
0:5 'sum' (mediump int)
0:5 add (mediump int)
0:5 add (mediump int)
0:5 add (mediump int)
0:5 add (mediump int)
0:5 'a' (in mediump int)
0:5 'b' (const (read only) mediump int)
0:5 'c' (in mediump int)
0:5 'd' (const (read only) mediump int)
0:5 'f' (inout mediump int)
0:8 multiply second child into first child (mediump int)
0:8 'a' (in mediump int)
0:5 move second child to first child (int)
0:5 'sum' (int)
0:5 add (int)
0:5 add (int)
0:5 add (int)
0:5 add (int)
0:5 'a' (in int)
0:5 'b' (const (read only) int)
0:5 'c' (in int)
0:5 'd' (const (read only) int)
0:5 'f' (inout int)
0:8 multiply second child into first child (int)
0:8 'a' (in int)
0:8 Constant:
0:8 64 (const int)
0:10 multiply second child into first child (mediump int)
0:10 'c' (in mediump int)
0:10 multiply second child into first child (int)
0:10 'c' (in int)
0:10 Constant:
0:10 64 (const int)
0:12 move second child to first child (mediump int)
0:12 'e' (out mediump int)
0:12 move second child to first child (int)
0:12 'e' (out int)
0:12 Constant:
0:12 1024 (const int)
0:13 multiply second child into first child (mediump int)
0:13 'f' (inout mediump int)
0:13 multiply second child into first child (int)
0:13 'f' (inout int)
0:13 Constant:
0:13 64 (const int)
0:15 add second child into first child (mediump int)
0:15 'sum' (mediump int)
0:15 add (mediump int)
0:15 add (mediump int)
0:15 add (mediump int)
0:15 add (mediump int)
0:15 add (mediump int)
0:15 'a' (in mediump int)
0:15 component-wise multiply (mediump int)
0:15 add second child into first child (int)
0:15 'sum' (int)
0:15 add (int)
0:15 add (int)
0:15 add (int)
0:15 add (int)
0:15 add (int)
0:15 'a' (in int)
0:15 component-wise multiply (int)
0:15 Constant:
0:15 64 (const int)
0:15 'b' (const (read only) mediump int)
0:15 'c' (in mediump int)
0:15 component-wise multiply (mediump int)
0:15 'b' (const (read only) int)
0:15 'c' (in int)
0:15 component-wise multiply (int)
0:15 Constant:
0:15 64 (const int)
0:15 'd' (const (read only) mediump int)
0:15 'e' (out mediump int)
0:15 'f' (inout mediump int)
0:15 'd' (const (read only) int)
0:15 'e' (out int)
0:15 'f' (inout int)
0:18 Branch: Return with expression
0:18 'sum' (mediump int)
0:21 Function Definition: main( (void)
0:18 'sum' (int)
0:21 Function Definition: foo2(f1;vf3;i1; (int)
0:21 Function Parameters:
0:21 'a' (in float)
0:21 'b' (in 3-component vector of float)
0:21 'r' (out int)
0:23 Sequence
0:23 move second child to first child (int)
0:23 'r' (out int)
0:23 Convert float to int (int)
0:23 component-wise multiply (float)
0:23 Constant:
0:23 3.000000
0:23 'a' (in float)
0:24 Branch: Return with expression
0:24 Convert float to int (int)
0:24 component-wise multiply (float)
0:24 Constant:
0:24 5.000000
0:24 direct index (float)
0:24 'b' (in 3-component vector of float)
0:24 Constant:
0:24 1 (const int)
0:27 Function Definition: main( (void)
0:27 Function Parameters:
0:? Sequence
0:24 Sequence
0:24 move second child to first child (mediump int)
0:24 't' (mediump int)
0:24 Constant:
0:24 2 (const int)
0:28 move second child to first child (mediump int)
0:28 direct index (mediump int)
0:28 t: direct index for structure (mediump 4-component vector of int)
0:28 'f' (structure{mediump 4-component vector of int t})
0:28 Constant:
0:28 0 (const int)
0:28 Constant:
0:28 1 (const int)
0:28 Constant:
0:28 32 (const int)
0:30 Sequence
0:30 move second child to first child (mediump int)
0:30 'color' (mediump int)
0:30 Function Call: foo(i1;i1;i1;i1;i1;i1; (mediump int)
0:30 Constant:
0:30 1 (const int)
0:30 Constant:
0:30 2 (const int)
0:30 add (mediump int)
0:30 't' (mediump int)
0:30 't' (mediump int)
0:30 Constant:
0:30 8 (const int)
0:30 'e' (mediump int)
0:30 direct index (mediump int)
0:30 t: direct index for structure (mediump 4-component vector of int)
0:30 'f' (structure{mediump 4-component vector of int t})
0:30 Constant:
0:30 0 (const int)
0:30 Constant:
0:30 1 (const int)
0:32 add second child into first child (mediump int)
0:32 'color' (mediump int)
0:32 component-wise multiply (mediump int)
0:32 Constant:
0:32 128 (const int)
0:32 add (mediump int)
0:32 'e' (mediump int)
0:32 direct index (mediump int)
0:32 t: direct index for structure (mediump 4-component vector of int)
0:32 'f' (structure{mediump 4-component vector of int t})
0:32 Constant:
0:32 0 (const int)
0:32 Constant:
0:32 1 (const int)
0:35 move second child to first child (mediump 4-component vector of float)
0:35 'gl_FragColor' (fragColor mediump 4-component vector of float)
0:35 Construct vec4 (mediump 4-component vector of float)
0:35 Convert int to float (mediump float)
0:35 'color' (mediump int)
0:30 move second child to first child (int)
0:30 't' (int)
0:30 Constant:
0:30 2 (const int)
0:34 move second child to first child (int)
0:34 direct index (int)
0:34 t: direct index for structure (4-component vector of int)
0:34 'f' (structure{4-component vector of int t})
0:34 Constant:
0:34 0 (const int)
0:34 Constant:
0:34 1 (const int)
0:34 Constant:
0:34 32 (const int)
0:37 Sequence
0:37 move second child to first child (int)
0:37 'color' (int)
0:37 Function Call: foo(i1;i1;i1;i1;i1;i1; (int)
0:37 Constant:
0:37 1 (const int)
0:37 Constant:
0:37 2 (const int)
0:37 add (int)
0:37 't' (int)
0:37 't' (int)
0:37 Constant:
0:37 8 (const int)
0:37 'e' (int)
0:37 direct index (int)
0:37 t: direct index for structure (4-component vector of int)
0:37 'f' (structure{4-component vector of int t})
0:37 Constant:
0:37 0 (const int)
0:37 Constant:
0:37 1 (const int)
0:39 add second child into first child (int)
0:39 'color' (int)
0:39 component-wise multiply (int)
0:39 Constant:
0:39 128 (const int)
0:39 add (int)
0:39 'e' (int)
0:39 direct index (int)
0:39 t: direct index for structure (4-component vector of int)
0:39 'f' (structure{4-component vector of int t})
0:39 Constant:
0:39 0 (const int)
0:39 Constant:
0:39 1 (const int)
0:45 move second child to first child (float)
0:45 'ret' (float)
0:45 Convert int to float (float)
0:45 Comma (int)
0:45 move second child to first child (int)
0:45 'tempReturn' (int)
0:45 Function Call: foo2(f1;vf3;i1; (int)
0:45 Constant:
0:45 4.000000
0:45 Constant:
0:45 1.000000
0:45 2.000000
0:45 3.000000
0:45 'tempArg' (out int)
0:45 move second child to first child (float)
0:45 'arg' (float)
0:45 Convert int to float (float)
0:45 'tempArg' (out int)
0:45 'tempReturn' (int)
0:46 add second child into first child (int)
0:46 'color' (int)
0:46 Convert float to int (int)
0:46 add (float)
0:46 'ret' (float)
0:46 'arg' (float)
0:48 move second child to first child (4-component vector of float)
0:48 'gl_FragColor' (fragColor 4-component vector of float)
0:48 Construct vec4 (4-component vector of float)
0:48 Convert int to float (float)
0:48 'color' (int)
0:? Linker Objects