Change infrastructure to support constant folding across built-in functions, as required by 1.2 semantics. Partially fleshed out with min/max and some trig functions. Still have to complete all operations.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@20806 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich
2013-03-07 19:22:07 +00:00
parent 3f3e0ad3ad
commit 53fb465729
14 changed files with 737 additions and 481 deletions

View File

@@ -18,5 +18,5 @@ void main()
vec4 e[constInt + uniformInt]; // error
vec4 f[uniformInt + constInt]; // error
vec4 g[sin(3.2)]; // okay
vec4 g[int(sin(0.3)) + 1]; // okay
}

29
Test/constFold.frag Normal file
View File

@@ -0,0 +1,29 @@
#version 430
const int a = 1;
const int b = 2;
const int c = a + b; // 3
const int d = c - a; // 2
const float e = float(d); // 2.0
const float f = e * float(c); // 6.0
const float g = f / float(d); // 3.0
in vec4 inv;
out vec4 FragColor;
void main()
{
vec4 dx = dFdx(inv);
const ivec4 v = ivec4(a, b, c, d);
vec4 array2[v.y]; // 2
const ivec4 u = ~v;
const float h = degrees(g); // 171.88
FragColor = vec4(e, f, g, h); // 2, 6, 3, 171.88
vec4 array3[c]; // 3
vec4 arrayMax[int(max(float(array2.length()), float(array3.length())))];
vec4 arrayMin[int(min(float(array2.length()), float(array3.length())))];
FragColor = vec4(arrayMax.length(), arrayMin.length(), sin(3.14), cos(3.14)); // 3, 2, .00159, -.999
}

View File

@@ -26,4 +26,5 @@ comment.frag
330.frag
330comp.frag
constErrors.frag
constFold.frag
errors.frag