Add a new shader-versioning infrastructure capable of handling multiple profiles, desktop/ES, many versions, features coming and going in different versions across different profiles, and extensions.
NB: *Use* of this infrastructure is so far only skeletal. Fixed a few typos and minor issues along the way. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@19951 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
5
Test/run.bat
Normal file
5
Test/run.bat
Normal file
@@ -0,0 +1,5 @@
|
||||
.\StandAlone.exe -i sample.vert > sample.vert.newout
|
||||
diff sample.vert.out sample.vert.newout
|
||||
|
||||
.\StandAlone.exe -i sample.frag > sample.frag.newout
|
||||
diff sample.frag.out sample.frag.newout
|
||||
1
Test/runlist.bat
Normal file
1
Test/runlist.bat
Normal file
@@ -0,0 +1 @@
|
||||
for /F "tokens=*" %%f in (testlist) do .\StandAlone.exe -i %%f
|
||||
40
Test/sample.frag
Normal file
40
Test/sample.frag
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
varying vec3 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(color, 1.0f);
|
||||
}
|
||||
15
Test/sample.frag.out
Normal file
15
Test/sample.frag.out
Normal file
@@ -0,0 +1,15 @@
|
||||
#### BEGIN COMPILER 0 INFO LOG ####
|
||||
0:? Sequence
|
||||
0:37 Function Definition: main( (void)
|
||||
0:37 Function Parameters:
|
||||
0:39 Sequence
|
||||
0:39 move second child to first child (4-component vector of float)
|
||||
0:39 'gl_FragColor' (FragColor 4-component vector of float)
|
||||
0:39 Construct vec4 (4-component vector of float)
|
||||
0:39 'color' (varying in 3-component vector of float)
|
||||
0:39 1.000000 (const float)
|
||||
|
||||
#### END COMPILER 0 INFO LOG ####
|
||||
#### BEGIN LINKER INFO LOG ####
|
||||
|
||||
#### END LINKER INFO LOG ####
|
||||
42
Test/sample.vert
Normal file
42
Test/sample.vert
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
varying vec3 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
color = vec3(1.0, 1.0, 1.0);
|
||||
|
||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||
}
|
||||
20
Test/sample.vert.out
Normal file
20
Test/sample.vert.out
Normal file
@@ -0,0 +1,20 @@
|
||||
#### BEGIN COMPILER 0 INFO LOG ####
|
||||
0:? Sequence
|
||||
0:37 Function Definition: main( (void)
|
||||
0:37 Function Parameters:
|
||||
0:39 Sequence
|
||||
0:39 move second child to first child (3-component vector of float)
|
||||
0:39 'color' (varying out 3-component vector of float)
|
||||
0:39 1.000000 (const float)
|
||||
0:39 1.000000 (const float)
|
||||
0:39 1.000000 (const float)
|
||||
0:41 move second child to first child (4-component vector of float)
|
||||
0:41 'gl_Position' (Position 4-component vector of float)
|
||||
0:41 matrix-times-vector (4-component vector of float)
|
||||
0:41 'gl_ModelViewProjectionMatrix' (uniform 4X4 matrix of float)
|
||||
0:41 'gl_Vertex' (attribute 4-component vector of float)
|
||||
|
||||
#### END COMPILER 0 INFO LOG ####
|
||||
#### BEGIN LINKER INFO LOG ####
|
||||
|
||||
#### END LINKER INFO LOG ####
|
||||
237
Test/specExamples.frag
Normal file
237
Test/specExamples.frag
Normal file
@@ -0,0 +1,237 @@
|
||||
#version 430
|
||||
|
||||
#extension GL_3DL_array_objects : enable
|
||||
|
||||
int a = 0xffffffff; // 32 bits, a gets the value -1
|
||||
//int b = 0xffffffffU; // ERROR: can't convert uint to int
|
||||
uint c = 0xffffffff; // 32 bits, c gets the value 0xFFFFFFFF
|
||||
//uint d = 0xffffffffU; // 32 bits, d gets the value 0xFFFFFFFF
|
||||
int e = -1; // the literal is <20>1<EFBFBD>, then negation is performed,
|
||||
// and the resulting non-literal 32-bit signed
|
||||
// bit pattern of 0xFFFFFFFF is assigned, giving e
|
||||
// the value of -1.
|
||||
//uint f = -1u; // the literal is <20>1u<31>, then negation is performed,
|
||||
// and the resulting non-literal 32-bit unsigned
|
||||
// bit pattern of 0xFFFFFFFF is assigned, giving f
|
||||
// the value of 0xFFFFFFFF.
|
||||
int g = 3000000000; // a signed decimal literal taking 32 bits,
|
||||
// setting the sign bit, g gets -1294967296
|
||||
int h = 0xA0000000; // okay, 32-bit signed hexadecimal
|
||||
//int i = 5000000000; // ERROR: needs more than 32 bits
|
||||
//int j = 0xFFFFFFFFF; // ERROR: needs more that 32 bits
|
||||
int k = 0x80000000; // k gets -2147483648 == 0x80000000
|
||||
int l = 2147483648; // l gets -2147483648 (the literal set the sign bit)
|
||||
|
||||
float fa, fb = 1.5; // single-precision floating-point
|
||||
//double fc, fd = 2.0LF; // double-precision floating-point
|
||||
|
||||
vec2 texcoord1, texcoord2;
|
||||
vec3 position;
|
||||
vec4 myRGBA;
|
||||
ivec2 textureLookup;
|
||||
bvec3 less;
|
||||
|
||||
mat2 mat2D;
|
||||
mat3 optMatrix;
|
||||
mat4 view, projection;
|
||||
mat4x4 view; // an alternate way of declaring a mat4
|
||||
mat3x2 m; // a matrix with 3 columns and 2 rows
|
||||
dmat4 highPrecisionMVP;
|
||||
dmat2x4 dm;
|
||||
|
||||
struct light {
|
||||
float intensity;
|
||||
vec3 position;
|
||||
} lightVar;
|
||||
|
||||
struct S { float f; };
|
||||
|
||||
struct T {
|
||||
//S; // Error: anonymous structures disallowed
|
||||
//struct { ... }; // Error: embedded structures disallowed
|
||||
S s; // Okay: nested structures with name are allowed
|
||||
};
|
||||
|
||||
float frequencies[3];
|
||||
uniform vec4 lightPosition[4];
|
||||
light lights[];
|
||||
const int numLights = 2;
|
||||
light lights[numLights];
|
||||
|
||||
in vec3 normal;
|
||||
centroid in vec2 TexCoord;
|
||||
invariant centroid in vec4 Color;
|
||||
noperspective in float temperature;
|
||||
flat in vec3 myColor;
|
||||
noperspective centroid in vec2 myTexCoord;
|
||||
|
||||
uniform vec4 lightPosition;
|
||||
uniform vec3 color = vec3(0.7, 0.7, 0.2); // value assigned at link time
|
||||
|
||||
in Material {
|
||||
smooth in vec4 Color1; // legal, input inside in block
|
||||
smooth vec4 Color2; // legal, 'in' inherited from 'in Material'
|
||||
vec2 TexCoord; // legal, TexCoord is an input
|
||||
uniform float Atten; // illegal, mismatched storage qualifier
|
||||
|
||||
};
|
||||
|
||||
in Light {
|
||||
vec4 LightPos;
|
||||
vec3 LightColor;
|
||||
};
|
||||
in ColoredTexture {
|
||||
vec4 Color;
|
||||
vec2 TexCoord;
|
||||
} Material; // instance name
|
||||
vec3 Color; // different Color than Material.Color
|
||||
|
||||
in vec4 gl_FragCoord; // redeclaration that changes nothing is allowed
|
||||
|
||||
// All the following are allowed redeclaration that change behavior
|
||||
layout(origin_upper_left) in vec4 gl_FragCoord;
|
||||
layout(pixel_center_integer) in vec4 gl_FragCoord;
|
||||
layout(origin_upper_left, pixel_center_integer) in vec4 gl_FragCoord;
|
||||
|
||||
layout(early_fragment_tests) in;
|
||||
|
||||
// compute shader:
|
||||
layout (local_size_x = 32, local_size_y = 32) in;
|
||||
layout (local_size_x = 8) in;
|
||||
|
||||
layout(location = 3) out vec4 color;
|
||||
layout(location = 3, index = 1) out vec4 factor;
|
||||
layout(location = 2) out vec4 colors[3];
|
||||
|
||||
layout (depth_greater) out float gl_FragDepth;
|
||||
|
||||
// redeclaration that changes nothing is allowed
|
||||
out float gl_FragDepth;
|
||||
|
||||
// assume it may be modified in any way
|
||||
layout (depth_any) out float gl_FragDepth;
|
||||
|
||||
// assume it may be modified such that its value will only increase
|
||||
layout (depth_greater) out float gl_FragDepth;
|
||||
|
||||
// assume it may be modified such that its value will only decrease
|
||||
layout (depth_less) out float gl_FragDepth;
|
||||
|
||||
// assume it will not be modified
|
||||
layout (depth_unchanged) out float gl_FragDepth;
|
||||
|
||||
in vec4 gl_Color; // predeclared by the fragment language
|
||||
flat in vec4 gl_Color; // redeclared by user to be flat
|
||||
|
||||
|
||||
float[5] foo(float[5])
|
||||
{
|
||||
return float[5](3.4, 4.2, 5.0, 5.2, 1.1);
|
||||
}
|
||||
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
precision mediump int;
|
||||
precision highp float;
|
||||
|
||||
void main()
|
||||
{
|
||||
{
|
||||
float a[5] = float[5](3.4, 4.2, 5.0, 5.2, 1.1);
|
||||
}
|
||||
{
|
||||
float a[5] = float[](3.4, 4.2, 5.0, 5.2, 1.1); // same thing
|
||||
}
|
||||
{
|
||||
vec4 a[3][2]; // size-3 array of size-2 array of vec4
|
||||
vec4[2] a1[3]; // size-3 array of size-2 array of vec4
|
||||
vec4[3][2] a2; // size-3 array of size-2 array of vec4
|
||||
vec4 b[2] = vec4[2](vec4(0.0), vec4(0.1));
|
||||
vec4[3][2] a3 = vec4[3][2](b, b, b); // constructor
|
||||
void foo(vec4[3][2]); // prototype with unnamed parameter
|
||||
vec4 a4[3][2] = {vec4[2](vec4(0.0), vec4(1.0)),
|
||||
vec4[2](vec4(0.0), vec4(1.0)),
|
||||
vec4[2](vec4(0.0), vec4(1.0)) };
|
||||
}
|
||||
{
|
||||
float a[5];
|
||||
{
|
||||
float b[] = a; // b is explicitly size 5
|
||||
}
|
||||
{
|
||||
float b[5] = a; // means the same thing
|
||||
}
|
||||
{
|
||||
float b[] = float[](1,2,3,4,5); // also explicitly sizes to 5
|
||||
}
|
||||
a.length(); // returns 5
|
||||
}
|
||||
{
|
||||
vec4 a[3][2];
|
||||
a.length(); // this is 3
|
||||
a[x].length(); // this is 2
|
||||
}
|
||||
// for an array b containing a member array a:
|
||||
b[++x].a.length(); // b is never dereferenced, but <20>++x<> is evaluated
|
||||
|
||||
// for an array s of a shader storage object containing a member array a:
|
||||
s[x].a.length(); // s is dereferenced; x needs to be a valid index
|
||||
//
|
||||
//All of the following declarations result in a compile-time error.
|
||||
//float a[2] = { 3.4, 4.2, 5.0 }; // illegal
|
||||
//vec2 b = { 1.0, 2.0, 3.0 }; // illegal
|
||||
//mat3x3 c = { vec3(0.0), vec3(1.0), vec3(2.0), vec3(3.0) }; // illegal
|
||||
//mat2x2 d = { 1.0, 0.0, 0.0, 1.0 }; // illegal, can't flatten nesting
|
||||
//struct {
|
||||
// float a;
|
||||
// int b;
|
||||
//} e = { 1.2, 2, 3 }; // illegal
|
||||
|
||||
struct {
|
||||
float a;
|
||||
int b;
|
||||
} e = { 1.2, 2 }; // legal, all types match
|
||||
|
||||
struct {
|
||||
float a;
|
||||
int b;
|
||||
} e = { 1, 3 }; // legal, first initializer is converted
|
||||
|
||||
//All of the following declarations result in a compile-time error.
|
||||
//int a = true; // illegal
|
||||
//vec4 b[2] = { vec4(0.0), 1.0 }; // illegal
|
||||
//mat4x2 c = { vec3(0.0), vec3(1.0) }; // illegal
|
||||
|
||||
//struct S1 {
|
||||
// vec4 a;
|
||||
// vec4 b;
|
||||
//};
|
||||
|
||||
//struct {
|
||||
// float s;
|
||||
// float t;
|
||||
//} d[] = { S1(vec4(0.0), vec4(1.1)) }; // illegal
|
||||
|
||||
{
|
||||
float a[] = float[](3.4, 4.2, 5.0, 5.2, 1.1);
|
||||
float b[] = { 3.4, 4.2, 5.0, 5.2, 1.1 };
|
||||
float c[] = a; // c is explicitly size 5
|
||||
float d[5] = b; // means the same thing
|
||||
}
|
||||
{
|
||||
const vec3 zAxis = vec3 (0.0, 0.0, 1.0);
|
||||
const float ceiling = a + b; // a and b not necessarily constants
|
||||
}
|
||||
{
|
||||
in vec4 position;
|
||||
in vec3 normal;
|
||||
in vec2 texCoord[4];
|
||||
}
|
||||
{
|
||||
lowp float color;
|
||||
out mediump vec2 P;
|
||||
lowp ivec2 foo(lowp mat3);
|
||||
highp mat4 m;
|
||||
}
|
||||
|
||||
}
|
||||
196
Test/specExamples.vert
Normal file
196
Test/specExamples.vert
Normal file
@@ -0,0 +1,196 @@
|
||||
#version 110
|
||||
|
||||
#extension GL_3DL_array_objects : enable
|
||||
|
||||
out Vertex {
|
||||
vec4 Position; // API transform/feedback will use <20>Vertex.Position<6F>
|
||||
vec2 Texture;
|
||||
} Coords; // shader will use <20>Coords.Position<6F>
|
||||
|
||||
out Vertex2 {
|
||||
vec4 Color; // API will use <20>Color<6F>
|
||||
};
|
||||
|
||||
uniform Transform { // API uses <20>Transform[2]<5D> to refer to instance 2
|
||||
mat4 ModelViewMatrix;
|
||||
mat4 ModelViewProjectionMatrix;
|
||||
vec4 a[]; // array will get implicitly sized
|
||||
float Deformation;
|
||||
} transforms[4];
|
||||
|
||||
layout(location = 3) in vec4 normal;
|
||||
layout(location = 6) in vec4 colors[3];
|
||||
layout(location = 9) in mat4 transforms[2];
|
||||
|
||||
layout(location = 3) struct S {
|
||||
vec3 a;
|
||||
mat2 b;
|
||||
vec4 c[2];
|
||||
} s;
|
||||
|
||||
layout(triangles, invocations = 6) in;
|
||||
|
||||
layout(lines) in; // legal for Color2, input size is 2, matching Color2
|
||||
|
||||
layout(triangle_strip, max_vertices = 60) out; // order does not matter
|
||||
layout(max_vertices = 60) out; // redeclaration okay
|
||||
layout(triangle_strip) out; // redeclaration okay
|
||||
//layout(points) out; // error, contradicts triangle_strip
|
||||
//layout(max_vertices = 30) out; // error, contradicts 60
|
||||
|
||||
layout(stream = 1) out;
|
||||
|
||||
layout(stream=1) out; // default is now stream 1
|
||||
out vec4 var1; // var1 gets default stream (1)
|
||||
layout(stream=2) out Block1 { // "Block1" belongs to stream 2
|
||||
layout(stream=2) vec4 var2; // redundant block member stream decl
|
||||
layout(stream=3) vec2 var3; // ILLEGAL (must match block stream)
|
||||
vec3 var4; // belongs to stream 2
|
||||
};
|
||||
layout(stream=0) out; // default is now stream 0
|
||||
out vec4 var5; // var5 gets default stream (0)
|
||||
out Block2 { // "Block2" gets default stream (0)
|
||||
vec4 var6;
|
||||
};
|
||||
layout(stream=3) out vec4 var7; // var7 belongs to stream 3
|
||||
|
||||
layout(shared, column_major) uniform;
|
||||
layout(shared, column_major) buffer;
|
||||
|
||||
layout(row_major, column_major)
|
||||
|
||||
layout(shared, row_major) uniform; // default is now shared and row_major
|
||||
|
||||
layout(std140) uniform Transform { // layout of this block is std140
|
||||
mat4 M1; // row_major
|
||||
layout(column_major) mat4 M2; // column major
|
||||
mat3 N1; // row_major
|
||||
};
|
||||
|
||||
layout(column_major) uniform T3 { // shared and column_major
|
||||
mat4 M3; // column_major
|
||||
layout(row_major) mat4 m4; // row major
|
||||
mat3 N2; // column_major
|
||||
};
|
||||
|
||||
// in one compilation unit...
|
||||
layout(binding=3) uniform sampler2D s; // s bound to unit 3
|
||||
|
||||
// in another compilation unit...
|
||||
uniform sampler2D s; // okay, s still bound at 3
|
||||
|
||||
// in another compilation unit...
|
||||
//layout(binding=4) uniform sampler2D s; // ERROR: contradictory bindings
|
||||
|
||||
layout (binding = 2, offset = 4) uniform atomic_uint a;
|
||||
|
||||
layout (binding = 2) uniform atomic_uint bar;
|
||||
|
||||
layout (binding = 2, offset = 4) uniform atomic_uint;
|
||||
|
||||
layout (binding = 2) uniform atomic_uint bar; // offset is 4
|
||||
layout (offset = 8) uniform atomic_uint bar; // error, no default binding
|
||||
|
||||
layout (binding=3, offset=4) uniform atomic_uint a2; // offset = 4
|
||||
layout (binding=2) uniform atomic_uint b2; // offset = 0
|
||||
layout (binding=3) uniform atomic_uint c2; // offset = 8
|
||||
layout (binding=2) uniform atomic_uint d2; // offset = 4
|
||||
|
||||
//layout (offset=4) // error, must include binding
|
||||
layout (binding=1, offset=0) a; // okay
|
||||
layout (binding=2, offset=0) b; // okay
|
||||
//layout (binding=1, offset=0) c; // error, offsets must not be shared
|
||||
// // between a and c
|
||||
//layout (binding=1, offset=2) d; // error, overlaps offset 0 of a
|
||||
|
||||
flat in vec4 gl_FrontColor; // input to geometry shader, no <20>gl_in[]<5D>
|
||||
flat out vec4 gl_FrontColor; // output from geometry shader
|
||||
|
||||
invariant gl_Position; // make existing gl_Position be invariant
|
||||
|
||||
out vec3 Color;
|
||||
invariant Color; // make existing Color be invariant
|
||||
|
||||
invariant centroid out vec3 Color4;
|
||||
precise out vec4 position;
|
||||
|
||||
out vec3 Color5;
|
||||
precise Color5; // make existing Color be precise
|
||||
in vec4 a, b, c, d;
|
||||
precise out vec4 v;
|
||||
|
||||
coherent buffer Block {
|
||||
readonly vec4 member1;
|
||||
vec4 member2;
|
||||
};
|
||||
|
||||
buffer Block {
|
||||
coherent readonly vec4 member1;
|
||||
coherent vec4 member2;
|
||||
};
|
||||
|
||||
shared vec4 shv;
|
||||
|
||||
vec4 funcA(restrict image2D a) { }
|
||||
|
||||
vec4 funcB(image2D a) { }
|
||||
layout(rgba32f) uniform image2D img1;
|
||||
layout(rgba32f) coherent uniform image2D img2;
|
||||
|
||||
float func(float e, float f, float g, float h)
|
||||
{
|
||||
return (e*f) + (g*h); // no constraint on order or
|
||||
// operator consistency
|
||||
}
|
||||
|
||||
float func2(float e, float f, float g, float h)
|
||||
{
|
||||
precise float result = (e*f) + (g*h); // ensures same precision for
|
||||
// the two multiplies
|
||||
return result;
|
||||
}
|
||||
|
||||
float func3(float i, float j, precise out float k)
|
||||
{
|
||||
k = i * i + j; // precise, due to <k> declaration
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 r = vec3(a * b); // precise, used to compute v.xyz
|
||||
vec3 s = vec3(c * d); // precise, used to compute v.xyz
|
||||
v.xyz = r + s; // precise
|
||||
v.w = (a.w * b.w) + (c.w * d.w); // precise
|
||||
v.x = func(a.x, b.x, c.x, d.x); // values computed in func()
|
||||
// are NOT precise
|
||||
v.x = func2(a.x, b.x, c.x, d.x); // precise!
|
||||
func3(a.x * b.x, c.x * d.x, v.x); // precise!
|
||||
|
||||
funcA(img1); // OK, adding "restrict" is allowed
|
||||
funcB(img2); // illegal, stripping "coherent" is not
|
||||
|
||||
{
|
||||
struct light {
|
||||
float intensity;
|
||||
vec3 position;
|
||||
};
|
||||
|
||||
light lightVar = light(3.0, vec3(1.0, 2.0, 3.0));
|
||||
}
|
||||
{
|
||||
const float c[3] = float[3](5.0, 7.2, 1.1);
|
||||
const float d[3] = float[](5.0, 7.2, 1.1);
|
||||
|
||||
float g;
|
||||
float a[5] = float[5](g, 1, g, 2.3, g);
|
||||
float b[3];
|
||||
|
||||
b = float[3](g, g + 1.0, g + 2.0);
|
||||
}
|
||||
{
|
||||
vec4 b[2] = { vec4(1.0), vec4(1.0) };
|
||||
vec4[3][2](b, b, b); // constructor
|
||||
vec4[][2](b, b, b); // constructor, valid, size deduced
|
||||
vec4[3][](b, b, b); // compile-time error, invalid type constructed
|
||||
}
|
||||
}
|
||||
45
Test/versionsClean.frag
Normal file
45
Test/versionsClean.frag
Normal file
@@ -0,0 +1,45 @@
|
||||
//
|
||||
//Copyright (C) 2012 LunarG, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of LunarG Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
#version 300 es
|
||||
|
||||
in vec3 color;
|
||||
out vec4 foo;
|
||||
|
||||
uniform sampler2DRect bar;
|
||||
|
||||
void main()
|
||||
{
|
||||
foo = vec4(color, 142.0f);
|
||||
discard;
|
||||
}
|
||||
43
Test/versionsClean.vert
Normal file
43
Test/versionsClean.vert
Normal file
@@ -0,0 +1,43 @@
|
||||
//
|
||||
//Copyright (C) 2012 LunarG, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of LunarG Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
#version 420 compatibility
|
||||
|
||||
attribute vec3 color;
|
||||
|
||||
uniform sampler2DRect foo;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(color, 142.0f);
|
||||
}
|
||||
46
Test/versionsErrors.frag
Normal file
46
Test/versionsErrors.frag
Normal file
@@ -0,0 +1,46 @@
|
||||
//
|
||||
//Copyright (C) 2012 LunarG, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of LunarG Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
#version 110 es
|
||||
|
||||
#extension GL_ARB_texture_rectangle : disable
|
||||
|
||||
attribute vec3 color;
|
||||
|
||||
uniform sampler2DRect foo;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(color, 142.0f);
|
||||
discard;
|
||||
}
|
||||
46
Test/versionsErrors.vert
Normal file
46
Test/versionsErrors.vert
Normal file
@@ -0,0 +1,46 @@
|
||||
//
|
||||
//Copyright (C) 2012 LunarG, Inc.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of LunarG Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
#version 420 core
|
||||
|
||||
#extension GL_ARB_texture_rectangle : enable
|
||||
|
||||
attribute vec3 color;
|
||||
|
||||
uniform sampler2DRect foo;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(color, 142.0f);
|
||||
discard;
|
||||
}
|
||||
Reference in New Issue
Block a user