summaryrefslogtreecommitdiff
path: root/progs
diff options
context:
space:
mode:
Diffstat (limited to 'progs')
-rw-r--r--progs/slang/Makefile67
-rw-r--r--progs/slang/README7
-rw-r--r--progs/slang/cltest.c6
-rw-r--r--progs/slang/cltest.txt2804
-rw-r--r--progs/slang/framework.c7
-rw-r--r--progs/slang/framework.h9
-rw-r--r--progs/slang/vstest.c4
-rw-r--r--progs/slang/vstest.txt136
8 files changed, 1559 insertions, 1481 deletions
diff --git a/progs/slang/Makefile b/progs/slang/Makefile
new file mode 100644
index 0000000000..90debd186a
--- /dev/null
+++ b/progs/slang/Makefile
@@ -0,0 +1,67 @@
+# progs/slang/Makefile
+
+TOP = ../..
+
+include $(TOP)/configs/current
+
+INCDIR = $(TOP)/include
+
+LIB_DEP = $(LIB_DIR)/$(GL_LIB_NAME)
+
+#
+# targets
+#
+
+.PHONY: default tests clean
+
+default: cltest sotest vstest
+
+tests: default
+ ! ./sotest 2> /dev/null | (grep -e ^[*][*][*])
+ ! ./vstest 2> /dev/null | (grep -e ^[*][*][*])
+ ! ./cltest 2> /dev/null | (grep -e ^[*][*][*])
+
+clean:
+ rm -f cltest.o sotest.o vstest.o framework.o cltest sotest vstest
+
+#
+# executables
+#
+
+cltest: cltest.o framework.o $(LIB_DEP)
+ $(CC) cltest.o framework.o $(APP_LIB_DEPS) -o cltest
+
+sotest: sotest.o framework.o $(LIB_DEP)
+ $(CC) sotest.o framework.o $(APP_LIB_DEPS) -o sotest
+
+vstest: vstest.o framework.o $(LIB_DEP)
+ $(CC) vstest.o framework.o $(APP_LIB_DEPS) -o vstest
+
+#
+# objects
+#
+
+framework.o: framework.c
+ $(CC) -c -I$(INCDIR) framework.c -o framework.o
+
+cltest.o: cltest.c
+ $(CC) -c -I$(INCDIR) cltest.c -o cltest.o
+
+sotest.o: sotest.c
+ $(CC) -c -I$(INCDIR) sotest.c -o sotest.o
+
+vstest.o: vstest.c
+ $(CC) -c -I$(INCDIR) vstest.c -o vstest.o
+
+#
+# sources
+#
+
+framework.c: framework.h
+
+cltest.c: framework.h
+
+sotest.c: framework.h
+
+vstest.c: framework.h
+
diff --git a/progs/slang/README b/progs/slang/README
new file mode 100644
index 0000000000..13a6aaad34
--- /dev/null
+++ b/progs/slang/README
@@ -0,0 +1,7 @@
+GLSL regression tests.
+
+Type "make" to build all test apps.
+
+Type "make tests" to build and run all test apps. If any
+error is detected, a line starting with *** is output.
+
diff --git a/progs/slang/cltest.c b/progs/slang/cltest.c
index 5736f3eab1..2753f59f85 100644
--- a/progs/slang/cltest.c
+++ b/progs/slang/cltest.c
@@ -76,8 +76,8 @@ static void load_test_file (const char *filename, struct PROGRAM **program)
struct PROGRAM **currprog = program;
FILE *f;
char line[256];
- enum PROGRAM_LOAD_STATE pls;
- enum SHADER_LOAD_STATE sls;
+ enum PROGRAM_LOAD_STATE pls = PLS_NONE;
+ enum SHADER_LOAD_STATE sls = SLS_NONE;
f = fopen (filename, "r");
if (f == NULL)
@@ -174,7 +174,7 @@ void RenderScene (void)
exit (0);
code = program->vertex.code;
- glShaderSourceARB (vert, 1, &code, NULL);
+ glShaderSourceARB (vert, 1, (const GLcharARB **) (&code), NULL);
glCompileShaderARB (vert);
CheckObjectStatus (vert);
diff --git a/progs/slang/cltest.txt b/progs/slang/cltest.txt
index 7d87e74a11..8ca1dd40f9 100644
--- a/progs/slang/cltest.txt
+++ b/progs/slang/cltest.txt
@@ -1,1402 +1,1402 @@
-$ /*
-$ Shader test script.
-$
-$ Author: Michal Krol
-$
-$ Comment line starts with dollar sign and white space.
-$
-$ $program <name> starts a new test program section called <name>. Contains all other sections.
-$
-$ $attrib <name> starts vertex data input section for attrib called <name>. Each line consists of
-$ four values that form single vertex attrib.
-$
-$ $vertex starts vertex shader section. Contains $code and &output sections.
-$
-$ $code starts source code section. All text in this section gets compiled into appropriate
-$ shader object.
-$
-$ $output starts shader execution results section. These are compared, value-by-value,
-$ with results of executing printMESA() functions within a shader.
-$ */
-
-
-$ /*
-$ --------------------------------------------------------------------------------------------------
-$ Test printMESA() function.
-$ */
-
-$program PRINT TEST
-
-$vertex
-
-$code
-
-void main () {
- gl_Position = gl_ModelViewMatrix * gl_Vertex;
- gl_FrontColor = vec4 (1.0);
-
- printMESA (11.1);
- printMESA (111);
- printMESA (true);
-
- printMESA (vec2 (22.1, 22.2));
- printMESA (vec3 (33.1, 33.2, 33.3));
- printMESA (vec4 (44.1, 44.2, 44.3, 44.4));
-
- printMESA (ivec2 (221, 222));
- printMESA (ivec3 (331, 332, 333));
- printMESA (ivec4 (441, 442, 443, 444));
-
- printMESA (bvec2 (false, true));
- printMESA (bvec3 (true, true, false));
- printMESA (bvec4 (true, false, true, false));
-
- printMESA (mat2 (55.11, 55.12, 55.21, 55.22));
- printMESA (mat3 (66.11, 66.12, 66.13,
- 66.21, 66.22, 66.23,
- 66.31, 66.32, 66.33));
- printMESA (mat4 (77.11, 77.12, 77.13, 77.14,
- 77.21, 77.22, 77.23, 77.24,
- 77.31, 77.32, 77.33, 77.34,
- 77.41, 77.42, 77.43, 77.44));
-}
-
-$output
-
-11.1
-111
-true
-
-22.1
-22.2
-33.1
-33.2
-33.3
-44.1
-44.2
-44.3
-44.4
-
-221
-222
-331
-332
-333
-441
-442
-443
-444
-
-false
-true
-true
-true
-false
-true
-false
-true
-false
-
-55.11
-55.12
-55.21
-55.22
-
-66.11
-66.12
-66.13
-66.21
-66.22
-66.23
-66.31
-66.32
-66.33
-
-77.11
-77.12
-77.13
-77.14
-77.21
-77.22
-77.23
-77.24
-77.31
-77.32
-77.33
-77.34
-77.41
-77.42
-77.43
-77.44
-
-
-$ /*
-$ --------------------------------------------------------------------------------------------------
-$ Test type casting.
-$ */
-
-$program TYPE CAST TEST
-
-$attrib gl_Vertex
-0.0 0.0 0.0 1.0
-
-$attrib _Zero
-0.0 0.0 0.0 0.0
-
-$attrib _One
-1.1 0.0 0.0 0.0
-
-$attrib _Two
-2.2 0.0 0.0 0.0
-
-$attrib _MinusThree
--3.3 0.0 0.0 0.0
-
-$vertex
-
-$code
-
-attribute float _Zero;
-attribute float _One;
-attribute float _Two;
-attribute float _MinusThree;
-
-void main () {
- gl_Position = gl_ModelViewMatrix * gl_Vertex;
- gl_FrontColor = vec4 (1.0);
-
- printMESA (_Zero);
- printMESA (_One);
- printMESA (_Two);
- printMESA (_MinusThree);
-
- printMESA (float (_Zero));
- printMESA (float (_One));
- printMESA (float (_Two));
- printMESA (float (_MinusThree));
- printMESA (float (45.99));
- printMESA (float (-6.17));
-
- printMESA (bool (_Zero));
- printMESA (bool (_One));
- printMESA (bool (_Two));
- printMESA (bool (_MinusThree));
- printMESA (bool (45.99));
- printMESA (bool (-6.17));
- printMESA (bool (0.0001));
- printMESA (bool (0.0));
-
- printMESA (int (_Zero));
- printMESA (int (_One));
- printMESA (int (_Two));
- printMESA (int (_MinusThree));
- printMESA (int (45.99));
- printMESA (int (45.22));
- printMESA (int (-6.17));
- printMESA (int (-6.87));
-}
-
-$output
-
-0.0
-1.1
-2.2
--3.3
-
-0.0
-1.1
-2.2
--3.3
-45.99
--6.17
-
-false
-true
-true
-true
-true
-true
-true
-false
-
-0
-1
-2
--3
-45
-45
--6
--6
-
-$ /*
-$ --------------------------------------------------------------------------------------------------
-$ Test vector swizzles.
-$ */
-
-$program SWIZZLE TEST
-
-$attrib gl_Vertex
-0.0 0.0 0.0 1.0
-
-$attrib _One
-1.1 1.2 1.3 1.4
-
-$attrib _Two
-2.1 2.2 2.3 2.4
-
-$vertex
-
-$code
-
-attribute vec4 _One;
-attribute vec4 _Two;
-
-void assign5678 (out vec4 v)
-{
- v.x = 5.5;
- v.y = 6.6;
- v.z = 7.7;
- v.w = 8.8;
-}
-
-void main () {
- gl_Position = gl_ModelViewMatrix * gl_Vertex;
- gl_FrontColor = vec4 (1.0);
-
- printMESA (_One);
- printMESA (_Two);
-
- printMESA (_One.x);
- printMESA (_One.y);
- printMESA (_One.z);
- printMESA (_One.w);
-
- printMESA (_Two.xy);
- printMESA (_Two.yx);
- printMESA (_Two.xw);
- printMESA (_Two.wx);
- printMESA (_Two.yz);
- printMESA (_Two.zy);
- printMESA (_Two.xz);
- printMESA (_Two.zx);
- printMESA (_Two.zw);
- printMESA (_Two.wz);
-
- printMESA (_One.xyz);
- printMESA (_One.yzx);
- printMESA (_One.zxy);
- printMESA (_One.xzy);
- printMESA (_One.yzw);
- printMESA (_One.zwx);
-
- printMESA (_Two.xyzw);
- printMESA (_Two.yzwx);
- printMESA (_Two.wzyx);
- printMESA (_Two.zwyx);
-
- printMESA (_One.xx);
- printMESA (_One.zz);
- printMESA (_One.ww);
-
- printMESA (_Two.xxx);
- printMESA (_Two.yyy);
- printMESA (_Two.www);
-
- printMESA (_One.xxxx);
- printMESA (_One.zzzz);
-
- printMESA (_Two.xxyy);
- printMESA (_Two.wwxx);
- printMESA (_Two.zxxw);
-
- vec4 v;
-
- v.zxwy = vec4 (5.5, 6.6, 7.7, 8.8);
- printMESA (v);
-
- assign5678 (v.ywxz);
- printMESA (v);
-}
-
-$output
-
-1.1
-1.2
-1.3
-1.4
-2.1
-2.2
-2.3
-2.4
-
-1.1
-1.2
-1.3
-1.4
-
-2.1
-2.2
-2.2
-2.1
-2.1
-2.4
-2.4
-2.1
-2.2
-2.3
-2.3
-2.2
-2.1
-2.3
-2.3
-2.1
-2.3
-2.4
-2.4
-2.3
-
-1.1
-1.2
-1.3
-1.2
-1.3
-1.1
-1.3
-1.1
-1.2
-1.1
-1.3
-1.2
-1.2
-1.3
-1.4
-1.3
-1.4
-1.1
-
-2.1
-2.2
-2.3
-2.4
-2.2
-2.3
-2.4
-2.1
-2.4
-2.3
-2.2
-2.1
-2.3
-2.4
-2.2
-2.1
-
-1.1
-1.1
-1.3
-1.3
-1.4
-1.4
-
-2.1
-2.1
-2.1
-2.2
-2.2
-2.2
-2.4
-2.4
-2.4
-
-1.1
-1.1
-1.1
-1.1
-1.3
-1.3
-1.3
-1.3
-
-2.1
-2.1
-2.2
-2.2
-2.4
-2.4
-2.1
-2.1
-2.3
-2.1
-2.1
-2.4
-
-6.6
-8.8
-5.5
-7.7
-
-7.7
-5.5
-8.8
-6.6
-
-
-$ /*
-$ --------------------------------------------------------------------------------------------------
-$ Test relational operators.
-$ */
-
-$program RELATIONAL OPERATOR TEST
-
-$attrib gl_Vertex
-0.0 0.0 0.0 1.0
-
-$attrib _Two
-2.0 0.0 0.0 0.0
-
-$attrib _Two2
-2.0 0.0 0.0 0.0
-
-$attrib _MinusThree
--3.0 0.0 0.0 0.0
-
-$vertex
-
-$code
-
-attribute float _Two;
-attribute float _Two2;
-attribute float _MinusThree;
-
-struct foo
-{
- float f;
- vec4 v4;
- vec3 v3;
- mat4 m4;
- int i;
- bool b;
-};
-
-void printMESA (const in foo bar)
-{
- printMESA (bar.f);
- printMESA (bar.v4);
- printMESA (bar.v3);
- printMESA (bar.m4);
- printMESA (bar.i);
- printMESA (bar.b);
-}
-
-void main () {
- gl_Position = gl_ModelViewMatrix * gl_Vertex;
- gl_FrontColor = vec4 (1.0);
-
- int iTwo = int (_Two);
- int iTwo2 = int (_Two2);
- int iMinusThree = int (_MinusThree);
-
- printMESA (_Two <= _Two);
- printMESA (_Two <= _Two2);
- printMESA (_Two <= _MinusThree);
- printMESA (_MinusThree <= _Two);
- printMESA (iTwo <= iTwo);
- printMESA (iTwo <= iTwo2);
- printMESA (iTwo <= iMinusThree);
- printMESA (iMinusThree <= iTwo);
-
- printMESA (_Two >= _Two);
- printMESA (_Two >= _Two2);
- printMESA (_Two >= _MinusThree);
- printMESA (_MinusThree >= _Two);
- printMESA (iTwo >= iTwo);
- printMESA (iTwo >= iTwo2);
- printMESA (iTwo >= iMinusThree);
- printMESA (iMinusThree >= iTwo);
-
- printMESA (_Two < _Two);
- printMESA (_Two < _Two2);
- printMESA (_Two < _MinusThree);
- printMESA (_MinusThree < _Two);
- printMESA (iTwo < iTwo);
- printMESA (iTwo < iTwo2);
- printMESA (iTwo < iMinusThree);
- printMESA (iMinusThree < iTwo);
-
- printMESA (_Two > _Two);
- printMESA (_Two > _Two2);
- printMESA (_Two > _MinusThree);
- printMESA (_MinusThree > _Two);
- printMESA (iTwo > iTwo);
- printMESA (iTwo > iTwo2);
- printMESA (iTwo > iMinusThree);
- printMESA (iMinusThree > iTwo);
-
- printMESA (_Two == _Two);
- printMESA (_Two == _Two2);
- printMESA (_Two == _MinusThree);
- printMESA (_MinusThree == _MinusThree);
- printMESA (iTwo == iTwo);
- printMESA (iTwo == iTwo2);
- printMESA (iTwo == iMinusThree);
- printMESA (iMinusThree == iMinusThree);
-
- printMESA (_Two != _Two);
- printMESA (_Two != _Two2);
- printMESA (_Two != _MinusThree);
- printMESA (_MinusThree != _MinusThree);
- printMESA (iTwo != iTwo);
- printMESA (iTwo != iTwo2);
- printMESA (iTwo != iMinusThree);
- printMESA (iMinusThree != iMinusThree);
-
- foo foo1;
- foo1.f = 13.31;
- foo1.v4 = vec4 (44.11, 44.22, 44.33, 44.44);
- foo1.v3 = vec3 (33.11, 33.22, 33.33);
- foo1.m4 = mat4 (17.88);
- foo1.i = 666;
- foo1.b = true;
- printMESA (foo1);
-
- // make foo2 the same as foo1
- foo foo2;
- foo2.f = 13.31;
- foo2.v4 = vec4 (44.11, 44.22, 44.33, 44.44);
- foo2.v3 = vec3 (33.11, 33.22, 33.33);
- foo2.m4 = mat4 (17.88);
- foo2.i = 666;
- foo2.b = true;
-
- printMESA (foo1 == foo2);
- printMESA (foo1 != foo2);
-
- // make them a little bit different
- foo2.m4[2].y = 333.333;
- printMESA (foo2);
-
- printMESA (foo1 == foo2);
- printMESA (foo1 != foo2);
-}
-
-$output
-
-true
-true
-false
-true
-true
-true
-false
-true
-
-true
-true
-true
-false
-true
-true
-true
-false
-
-false
-false
-false
-true
-false
-false
-false
-true
-
-false
-false
-true
-false
-false
-false
-true
-false
-
-true
-true
-false
-true
-true
-true
-false
-true
-
-false
-false
-true
-false
-false
-false
-true
-false
-
-13.31
-44.11
-44.22
-44.33
-44.44
-33.11
-33.22
-33.33
-17.88
-0.0
-0.0
-0.0
-0.0
-17.88
-0.0
-0.0
-0.0
-0.0
-17.88
-0.0
-0.0
-0.0
-0.0
-17.88
-666
-true
-
-true
-false
-
-13.31
-44.11
-44.22
-44.33
-44.44
-33.11
-33.22
-33.33
-17.88
-0.0
-0.0
-0.0
-0.0
-17.88
-0.0
-0.0
-0.0
-333.333
-17.88
-0.0
-0.0
-0.0
-0.0
-17.88
-666
-true
-
-false
-true
-
-
-$ /*
-$ --------------------------------------------------------------------------------------------------
-$ Test logical operators.
-$ */
-
-$program LOGICAL OPERATOR TEST
-
-$attrib gl_Vertex
-0.0 0.0 0.0 1.0
-
-$attrib _False
-0.0 0.0 0.0 0.0
-
-$attrib _True
-1.0 0.0 0.0 0.0
-
-$attrib _False2
-0.0 0.0 0.0 0.0
-
-$attrib _True2
-1.0 0.0 0.0 0.0
-
-$vertex
-
-$code
-
-attribute float _False;
-attribute float _True;
-attribute float _False2;
-attribute float _True2;
-
-void main () {
- gl_Position = gl_ModelViewMatrix * gl_Vertex;
- gl_FrontColor = vec4 (1.0);
-
- printMESA (_False);
- printMESA (_True);
- printMESA (_False2);
- printMESA (_True2);
-
- bool False = bool (_False);
- bool True = bool (_True);
- bool False2 = bool (_False2);
- bool True2 = bool (_True2);
-
- //
- // It is important to test each operator with the following argument types:
- // * Both arguments are different variables, even if they have the same values.
- // False and False2 are distinct attributes, but are the same in value.
- // * Both arguments may be the same variables. This case tests possible
- // optimizations, e.g. X && X --> X.
- // * Both arguments are constant. This tests constant folding.
- //
-
- printMESA (!False);
- printMESA (!True);
- printMESA (!false);
- printMESA (!true);
-
- printMESA (False ^^ False2);
- printMESA (False ^^ True2);
- printMESA (True ^^ False2);
- printMESA (True ^^ True2);
- printMESA (False ^^ False);
- printMESA (False ^^ True);
- printMESA (True ^^ False);
- printMESA (True ^^ True);
- printMESA (false ^^ false);
- printMESA (false ^^ true);
- printMESA (true ^^ false);
- printMESA (true ^^ true);
-
- printMESA (False && False2);
- printMESA (False && True2);
- printMESA (True && False2);
- printMESA (True && True2);
- printMESA (False && False);
- printMESA (False && True);
- printMESA (True && False);
- printMESA (True && True);
- printMESA (false && false);
- printMESA (false && true);
- printMESA (true && false);
- printMESA (true && true);
-
- printMESA (False || False2);
- printMESA (False || True2);
- printMESA (True || False2);
- printMESA (True || True2);
- printMESA (False || False);
- printMESA (False || True);
- printMESA (True || False);
- printMESA (True || True);
- printMESA (false || false);
- printMESA (false || true);
- printMESA (true || false);
- printMESA (true || true);
-
- //
- // Test short-circuit evaluation of && and ||. The right expression evaluation depends
- // on the value of the left expression. If the right expression has side effects, we
- // can easily test if it happened.
- //
-
- bool x;
-
- x = false;
- printMESA (x);
- printMESA (False && (x = true));
- printMESA (x);
-
- x = false;
- printMESA (x);
- printMESA (false && (x = true));
- printMESA (x);
-
- x = true;
- printMESA (x);
- printMESA (True || (x = false));
- printMESA (x);
-
- x = true;
- printMESA (x);
- printMESA (true || (x = false));
- printMESA (x);
-}
-
-$output
-
-0.0
-1.0
-0.0
-1.0
-
-true
-false
-true
-false
-
-false
-true
-true
-false
-false
-true
-true
-false
-false
-true
-true
-false
-
-false
-false
-false
-true
-false
-false
-false
-true
-false
-false
-false
-true
-
-false
-true
-true
-true
-false
-true
-true
-true
-false
-true
-true
-true
-
-false
-false
-false
-
-false
-false
-false
-
-true
-true
-true
-
-true
-true
-true
-
-
-$ /*
-$ --------------------------------------------------------------------------------------------------
-$ Test subscript operator/array access.
-$ */
-
-$program ARRAY ACCESS TEST
-
-$attrib gl_Vertex
-0.0 0.0 0.0 1.0
-
-$attrib _Zero
-0.0 0.0 0.0 0.0
-
-$attrib _One
-1.1 0.0 0.0 0.0
-
-$attrib _Two
-2.9 0.0 0.0 0.0
-
-$attrib _Vec
-11.11 22.22 33.33 44.44
-
-$vertex
-
-$code
-
-attribute float _Zero;
-attribute float _One;
-attribute float _Two;
-attribute vec4 _Vec;
-
-void main () {
- gl_Position = gl_ModelViewMatrix * gl_Vertex;
- gl_FrontColor = vec4 (1.0);
-
- printMESA (_Zero);
- printMESA (_One);
- printMESA (_Two);
- printMESA (_Vec);
-
- printMESA (_Vec[0]);
- printMESA (_Vec[1]);
- printMESA (_Vec[2]);
- printMESA (_Vec[3]);
-
- printMESA (_Vec[int (_Zero)]);
- printMESA (_Vec[int (_One)]);
- printMESA (_Vec[int (_Two)]);
-}
-
-$output
-
-0.0
-1.1
-2.9
-11.11
-22.22
-33.33
-44.44
-
-11.11
-22.22
-33.33
-44.44
-
-11.11
-22.22
-33.33
-
-
-$ /*
-$ --------------------------------------------------------------------------------------------------
-$ Test pre/post-increment/decrement operators.
-$ Note: assumes relational operators being correct.
-$ */
-
-$program PRE/POST-INC/DEC OPERATOR TEST
-
-$attrib gl_Vertex
-0.0 0.0 0.0 1.0
-
-$attrib _Zero
-0.0 0.0 0.0 0.0
-
-$attrib _One
-1.1 0.0 0.0 0.0
-
-$attrib _Two4
-2.1 2.2 2.3 2.4
-
-$vertex
-
-$code
-
-attribute float _Zero;
-attribute float _One;
-attribute vec4 _Two4;
-
-float fZero, fOne;
-vec4 fTwo4;
-int iZero, iOne;
-ivec4 iTwo4;
-
-void reset () {
- fZero = _Zero;
- fOne = _One;
- fTwo4 = _Two4;
- iZero = int (_Zero);
- iOne = int (_One);
- iTwo4 = ivec4 (_Two4);
-}
-
-void main () {
- gl_Position = gl_ModelViewMatrix * gl_Vertex;
- gl_FrontColor = vec4 (1.0);
-
- printMESA (_Zero);
- printMESA (_One);
- printMESA (_Two4);
-
- // pre-increment
- reset ();
- printMESA (++fZero);
- printMESA (++fOne);
- printMESA (++iZero);
- printMESA (++iOne);
- printMESA (fZero);
- printMESA (fOne);
- printMESA (iZero);
- printMESA (iOne);
- printMESA (++fTwo4 == _Two4 + 1.0);
- printMESA (++iTwo4 == ivec4 (_Two4) + 1);
-
- // pre-decrement
- reset ();
- printMESA (--fZero);
- printMESA (--fOne);
- printMESA (--iZero);
- printMESA (--iOne);
- printMESA (fZero);
- printMESA (fOne);
- printMESA (iZero);
- printMESA (iOne);
- printMESA (--fTwo4 == _Two4 - 1.0);
- printMESA (--iTwo4 == ivec4 (_Two4) - 1);
-
- // post-increment
- reset ();
- printMESA (fZero++);
- printMESA (fOne++);
- printMESA (iZero++);
- printMESA (iOne++);
- printMESA (fZero);
- printMESA (fOne);
- printMESA (iZero);
- printMESA (iOne);
- printMESA (fTwo4++ == _Two4);
- printMESA (iTwo4++ == ivec4 (_Two4));
-
- // post-decrement
- reset ();
- printMESA (fZero--);
- printMESA (fOne--);
- printMESA (iZero--);
- printMESA (iOne--);
- printMESA (fZero);
- printMESA (fOne);
- printMESA (iZero);
- printMESA (iOne);
- printMESA (fTwo4-- == _Two4);
- printMESA (iTwo4-- == ivec4 (_Two4));
-}
-
-$output
-
-0.0
-1.1
-2.1
-2.2
-2.3
-2.4
-
-1.0
-2.1
-1
-2
-1.0
-2.1
-1
-2
-true
-true
-
--1.0
-0.1
--1
-0
--1.0
-0.1
--1
-0
-true
-true
-
-0.0
-1.1
-0
-1
-1.0
-2.1
-1
-2
-true
-true
-
-0.0
-1.1
-0
-1
--1.0
-0.1
--1
-0
-true
-true
-
-
-$ /*
-$ --------------------------------------------------------------------------------------------------
-$ Test arithmetical operators.
-$ */
-
-$program ARITHMETICAL OPERATOR TEST
-
-$attrib gl_Vertex
-0.0 0.0 0.0 1.0
-
-$attrib _Zero
-0.0 0.0 0.0 0.0
-
-$attrib _One
-1.1 0.0 0.0 0.0
-
-$attrib _Two4
-2.1 2.2 2.3 2.4
-
-$vertex
-
-$code
-
-attribute float _Zero;
-attribute float _One;
-attribute vec4 _Two4;
-
-void main () {
- gl_Position = gl_ModelViewMatrix * gl_Vertex;
- gl_FrontColor = vec4 (1.0);
-
- printMESA (_Zero);
- printMESA (_One);
- printMESA (_Two4);
-
- int iZero = int (_Zero);
- int iOne = int (_One);
- ivec4 iTwo4 = ivec4 (_Two4);
-
- printMESA (-_Zero);
- printMESA (-_One);
- printMESA (-_Two4);
- printMESA (-_Two4.z);
-
- printMESA (_Zero + 0.0);
- printMESA (_One + 0.0);
- printMESA (_Two4 + 0.0);
- printMESA (_Two4.y + 0.0);
-
- printMESA (_Zero + _Zero);
- printMESA (_Zero + _One);
- printMESA (_Zero + _Two4);
- printMESA (_One + _Zero);
- printMESA (_One + _Two4);
- printMESA (_Two4 + _Two4);
-
- printMESA (_Zero - 0.0);
- printMESA (_One - 0.0);
- printMESA (_Two4 - 0.0);
- printMESA (_Two4.y - 0.0);
-
- printMESA (_Zero - _Zero);
- printMESA (_Zero - _One);
- printMESA (_Zero - _Two4);
- printMESA (_One - _Zero);
- printMESA (_One - _Two4);
- printMESA (_Two4 - _Two4);
-
- printMESA (_Zero * 1.0);
- printMESA (_One * 1.0);
- printMESA (_Two4 * 1.0);
- printMESA (_Two4.x * 1.0);
-
- printMESA (_Zero * _Zero);
- printMESA (_Zero * _One);
- printMESA (_Zero * _Two4);
- printMESA (_One * _Zero);
- printMESA (_One * _One);
- printMESA (_One * _Two4);
- printMESA (_Two4 * _Two4);
-
- printMESA (_Zero / 1.0);
- printMESA (_One / 1.0);
- printMESA (_Two4 / 1.0);
- printMESA (_Two4.x / 1.0);
-
- printMESA (_Zero / _One);
- printMESA (_Zero / _Two4);
- printMESA (_One / _One);
- printMESA (_One / _Two4);
- printMESA (_Two4 / _Two4);
-}
-
-$output
-
-0.0
-1.1
-2.1
-2.2
-2.3
-2.4
-
-0.0
--1.1
--2.1
--2.2
--2.3
--2.4
--2.3
-
-0.0
-1.1
-2.1
-2.2
-2.3
-2.4
-2.2
-
-0.0
-1.1
-2.1
-2.2
-2.3
-2.4
-1.1
-3.2
-3.3
-3.4
-3.5
-4.2
-4.4
-4.6
-4.8
-
-0.0
-1.1
-2.1
-2.2
-2.3
-2.4
-2.2
-
-0.0
--1.1
--2.1
--2.2
--2.3
--2.4
-1.1
--1.0
--1.1
--1.2
--1.3
-0.0
-0.0
-0.0
-0.0
-
-0.0
-1.1
-2.1
-2.2
-2.3
-2.4
-2.1
-
-0.0
-0.0
-0.0
-0.0
-0.0
-0.0
-0.0
-1.21
-2.31
-2.42
-2.53
-2.64
-4.41
-4.84
-5.29
-5.76
-
-0.0
-1.1
-2.1
-2.2
-2.3
-2.4
-2.1
-
-0.0
-0.0
-0.0
-0.0
-0.0
-1.0
-0.52381
-0.5
-0.47826
-0.45833
-1.0
-1.0
-1.0
-1.0
-
-
-$ /*
-$ --------------------------------------------------------------------------------------------------
-$ Test matrix operations.
-$ Note: assumes relational operators being correct.
-$ */
-
-$program MATRIX TEST
-
-$attrib gl_Vertex
-0.0 0.0 0.0 1.0
-
-$attrib _Zero
-0.0 0.0 0.0 0.0
-
-$attrib _One
-1.0 1.0 1.0 1.0
-
-$attrib _Two
-2.0 2.0 2.0 2.0
-
-$vertex
-
-$code
-
-attribute vec4 _Zero;
-attribute vec4 _One;
-attribute vec4 _Two;
-
-void main () {
- gl_Position = gl_ModelViewMatrix * gl_Vertex;
- gl_FrontColor = vec4 (1.0);
-
- printMESA (_Zero);
- printMESA (_One);
- printMESA (_Two);
-
- mat4 Identity = mat4 (_One.x);
-
- printMESA (Identity == mat4 (1.0, 0.0, 0.0, 0.0,
- 0.0, 1.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0));
- printMESA (Identity * _Two == _Two);
-
- mat4 Matrix = mat4 (1.1, 1.2, 1.3, 1.4,
- 2.1, 2.2, 2.3, 2.4,
- 3.1, 3.2, 3.3, 3.4,
- 4.1, 4.2, 4.3, 4.4);
-
- printMESA (Matrix[2].y);
- printMESA (Matrix[1]);
-}
-
-$output
-
-0.0
-0.0
-0.0
-0.0
-1.0
-1.0
-1.0
-1.0
-2.0
-2.0
-2.0
-2.0
-true
-true
-3.2
-2.1
-2.2
-2.3
-2.4
-
+$ /*
+$ Shader test script.
+$
+$ Author: Michal Krol
+$
+$ Comment line starts with dollar sign and white space.
+$
+$ $program <name> starts a new test program section called <name>. Contains all other sections.
+$
+$ $attrib <name> starts vertex data input section for attrib called <name>. Each line consists of
+$ four values that form single vertex attrib.
+$
+$ $vertex starts vertex shader section. Contains $code and &output sections.
+$
+$ $code starts source code section. All text in this section gets compiled into appropriate
+$ shader object.
+$
+$ $output starts shader execution results section. These are compared, value-by-value,
+$ with results of executing printMESA() functions within a shader.
+$ */
+
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test printMESA() function.
+$ */
+
+$program PRINT TEST
+
+$vertex
+
+$code
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ printMESA (11.1);
+ printMESA (111);
+ printMESA (true);
+
+ printMESA (vec2 (22.1, 22.2));
+ printMESA (vec3 (33.1, 33.2, 33.3));
+ printMESA (vec4 (44.1, 44.2, 44.3, 44.4));
+
+ printMESA (ivec2 (221, 222));
+ printMESA (ivec3 (331, 332, 333));
+ printMESA (ivec4 (441, 442, 443, 444));
+
+ printMESA (bvec2 (false, true));
+ printMESA (bvec3 (true, true, false));
+ printMESA (bvec4 (true, false, true, false));
+
+ printMESA (mat2 (55.11, 55.12, 55.21, 55.22));
+ printMESA (mat3 (66.11, 66.12, 66.13,
+ 66.21, 66.22, 66.23,
+ 66.31, 66.32, 66.33));
+ printMESA (mat4 (77.11, 77.12, 77.13, 77.14,
+ 77.21, 77.22, 77.23, 77.24,
+ 77.31, 77.32, 77.33, 77.34,
+ 77.41, 77.42, 77.43, 77.44));
+}
+
+$output
+
+11.1
+111
+true
+
+22.1
+22.2
+33.1
+33.2
+33.3
+44.1
+44.2
+44.3
+44.4
+
+221
+222
+331
+332
+333
+441
+442
+443
+444
+
+false
+true
+true
+true
+false
+true
+false
+true
+false
+
+55.11
+55.12
+55.21
+55.22
+
+66.11
+66.12
+66.13
+66.21
+66.22
+66.23
+66.31
+66.32
+66.33
+
+77.11
+77.12
+77.13
+77.14
+77.21
+77.22
+77.23
+77.24
+77.31
+77.32
+77.33
+77.34
+77.41
+77.42
+77.43
+77.44
+
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test type casting.
+$ */
+
+$program TYPE CAST TEST
+
+$attrib gl_Vertex
+0.0 0.0 0.0 1.0
+
+$attrib _Zero
+0.0 0.0 0.0 0.0
+
+$attrib _One
+1.1 0.0 0.0 0.0
+
+$attrib _Two
+2.2 0.0 0.0 0.0
+
+$attrib _MinusThree
+-3.3 0.0 0.0 0.0
+
+$vertex
+
+$code
+
+attribute float _Zero;
+attribute float _One;
+attribute float _Two;
+attribute float _MinusThree;
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ printMESA (_Zero);
+ printMESA (_One);
+ printMESA (_Two);
+ printMESA (_MinusThree);
+
+ printMESA (float (_Zero));
+ printMESA (float (_One));
+ printMESA (float (_Two));
+ printMESA (float (_MinusThree));
+ printMESA (float (45.99));
+ printMESA (float (-6.17));
+
+ printMESA (bool (_Zero));
+ printMESA (bool (_One));
+ printMESA (bool (_Two));
+ printMESA (bool (_MinusThree));
+ printMESA (bool (45.99));
+ printMESA (bool (-6.17));
+ printMESA (bool (0.0001));
+ printMESA (bool (0.0));
+
+ printMESA (int (_Zero));
+ printMESA (int (_One));
+ printMESA (int (_Two));
+ printMESA (int (_MinusThree));
+ printMESA (int (45.99));
+ printMESA (int (45.22));
+ printMESA (int (-6.17));
+ printMESA (int (-6.87));
+}
+
+$output
+
+0.0
+1.1
+2.2
+-3.3
+
+0.0
+1.1
+2.2
+-3.3
+45.99
+-6.17
+
+false
+true
+true
+true
+true
+true
+true
+false
+
+0
+1
+2
+-3
+45
+45
+-6
+-6
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test vector swizzles.
+$ */
+
+$program SWIZZLE TEST
+
+$attrib gl_Vertex
+0.0 0.0 0.0 1.0
+
+$attrib _One
+1.1 1.2 1.3 1.4
+
+$attrib _Two
+2.1 2.2 2.3 2.4
+
+$vertex
+
+$code
+
+attribute vec4 _One;
+attribute vec4 _Two;
+
+void assign5678 (out vec4 v)
+{
+ v.x = 5.5;
+ v.y = 6.6;
+ v.z = 7.7;
+ v.w = 8.8;
+}
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ printMESA (_One);
+ printMESA (_Two);
+
+ printMESA (_One.x);
+ printMESA (_One.y);
+ printMESA (_One.z);
+ printMESA (_One.w);
+
+ printMESA (_Two.xy);
+ printMESA (_Two.yx);
+ printMESA (_Two.xw);
+ printMESA (_Two.wx);
+ printMESA (_Two.yz);
+ printMESA (_Two.zy);
+ printMESA (_Two.xz);
+ printMESA (_Two.zx);
+ printMESA (_Two.zw);
+ printMESA (_Two.wz);
+
+ printMESA (_One.xyz);
+ printMESA (_One.yzx);
+ printMESA (_One.zxy);
+ printMESA (_One.xzy);
+ printMESA (_One.yzw);
+ printMESA (_One.zwx);
+
+ printMESA (_Two.xyzw);
+ printMESA (_Two.yzwx);
+ printMESA (_Two.wzyx);
+ printMESA (_Two.zwyx);
+
+ printMESA (_One.xx);
+ printMESA (_One.zz);
+ printMESA (_One.ww);
+
+ printMESA (_Two.xxx);
+ printMESA (_Two.yyy);
+ printMESA (_Two.www);
+
+ printMESA (_One.xxxx);
+ printMESA (_One.zzzz);
+
+ printMESA (_Two.xxyy);
+ printMESA (_Two.wwxx);
+ printMESA (_Two.zxxw);
+
+ vec4 v;
+
+ v.zxwy = vec4 (5.5, 6.6, 7.7, 8.8);
+ printMESA (v);
+
+ assign5678 (v.ywxz);
+ printMESA (v);
+}
+
+$output
+
+1.1
+1.2
+1.3
+1.4
+2.1
+2.2
+2.3
+2.4
+
+1.1
+1.2
+1.3
+1.4
+
+2.1
+2.2
+2.2
+2.1
+2.1
+2.4
+2.4
+2.1
+2.2
+2.3
+2.3
+2.2
+2.1
+2.3
+2.3
+2.1
+2.3
+2.4
+2.4
+2.3
+
+1.1
+1.2
+1.3
+1.2
+1.3
+1.1
+1.3
+1.1
+1.2
+1.1
+1.3
+1.2
+1.2
+1.3
+1.4
+1.3
+1.4
+1.1
+
+2.1
+2.2
+2.3
+2.4
+2.2
+2.3
+2.4
+2.1
+2.4
+2.3
+2.2
+2.1
+2.3
+2.4
+2.2
+2.1
+
+1.1
+1.1
+1.3
+1.3
+1.4
+1.4
+
+2.1
+2.1
+2.1
+2.2
+2.2
+2.2
+2.4
+2.4
+2.4
+
+1.1
+1.1
+1.1
+1.1
+1.3
+1.3
+1.3
+1.3
+
+2.1
+2.1
+2.2
+2.2
+2.4
+2.4
+2.1
+2.1
+2.3
+2.1
+2.1
+2.4
+
+6.6
+8.8
+5.5
+7.7
+
+7.7
+5.5
+8.8
+6.6
+
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test relational operators.
+$ */
+
+$program RELATIONAL OPERATOR TEST
+
+$attrib gl_Vertex
+0.0 0.0 0.0 1.0
+
+$attrib _Two
+2.0 0.0 0.0 0.0
+
+$attrib _Two2
+2.0 0.0 0.0 0.0
+
+$attrib _MinusThree
+-3.0 0.0 0.0 0.0
+
+$vertex
+
+$code
+
+attribute float _Two;
+attribute float _Two2;
+attribute float _MinusThree;
+
+struct foo
+{
+ float f;
+ vec4 v4;
+ vec3 v3;
+ mat4 m4;
+ int i;
+ bool b;
+};
+
+void printMESA (const in foo bar)
+{
+ printMESA (bar.f);
+ printMESA (bar.v4);
+ printMESA (bar.v3);
+ printMESA (bar.m4);
+ printMESA (bar.i);
+ printMESA (bar.b);
+}
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ int iTwo = int (_Two);
+ int iTwo2 = int (_Two2);
+ int iMinusThree = int (_MinusThree);
+
+ printMESA (_Two <= _Two);
+ printMESA (_Two <= _Two2);
+ printMESA (_Two <= _MinusThree);
+ printMESA (_MinusThree <= _Two);
+ printMESA (iTwo <= iTwo);
+ printMESA (iTwo <= iTwo2);
+ printMESA (iTwo <= iMinusThree);
+ printMESA (iMinusThree <= iTwo);
+
+ printMESA (_Two >= _Two);
+ printMESA (_Two >= _Two2);
+ printMESA (_Two >= _MinusThree);
+ printMESA (_MinusThree >= _Two);
+ printMESA (iTwo >= iTwo);
+ printMESA (iTwo >= iTwo2);
+ printMESA (iTwo >= iMinusThree);
+ printMESA (iMinusThree >= iTwo);
+
+ printMESA (_Two < _Two);
+ printMESA (_Two < _Two2);
+ printMESA (_Two < _MinusThree);
+ printMESA (_MinusThree < _Two);
+ printMESA (iTwo < iTwo);
+ printMESA (iTwo < iTwo2);
+ printMESA (iTwo < iMinusThree);
+ printMESA (iMinusThree < iTwo);
+
+ printMESA (_Two > _Two);
+ printMESA (_Two > _Two2);
+ printMESA (_Two > _MinusThree);
+ printMESA (_MinusThree > _Two);
+ printMESA (iTwo > iTwo);
+ printMESA (iTwo > iTwo2);
+ printMESA (iTwo > iMinusThree);
+ printMESA (iMinusThree > iTwo);
+
+ printMESA (_Two == _Two);
+ printMESA (_Two == _Two2);
+ printMESA (_Two == _MinusThree);
+ printMESA (_MinusThree == _MinusThree);
+ printMESA (iTwo == iTwo);
+ printMESA (iTwo == iTwo2);
+ printMESA (iTwo == iMinusThree);
+ printMESA (iMinusThree == iMinusThree);
+
+ printMESA (_Two != _Two);
+ printMESA (_Two != _Two2);
+ printMESA (_Two != _MinusThree);
+ printMESA (_MinusThree != _MinusThree);
+ printMESA (iTwo != iTwo);
+ printMESA (iTwo != iTwo2);
+ printMESA (iTwo != iMinusThree);
+ printMESA (iMinusThree != iMinusThree);
+
+ foo foo1;
+ foo1.f = 13.31;
+ foo1.v4 = vec4 (44.11, 44.22, 44.33, 44.44);
+ foo1.v3 = vec3 (33.11, 33.22, 33.33);
+ foo1.m4 = mat4 (17.88);
+ foo1.i = 666;
+ foo1.b = true;
+ printMESA (foo1);
+
+ // make foo2 the same as foo1
+ foo foo2;
+ foo2.f = 13.31;
+ foo2.v4 = vec4 (44.11, 44.22, 44.33, 44.44);
+ foo2.v3 = vec3 (33.11, 33.22, 33.33);
+ foo2.m4 = mat4 (17.88);
+ foo2.i = 666;
+ foo2.b = true;
+
+ printMESA (foo1 == foo2);
+ printMESA (foo1 != foo2);
+
+ // make them a little bit different
+ foo2.m4[2].y = 333.333;
+ printMESA (foo2);
+
+ printMESA (foo1 == foo2);
+ printMESA (foo1 != foo2);
+}
+
+$output
+
+true
+true
+false
+true
+true
+true
+false
+true
+
+true
+true
+true
+false
+true
+true
+true
+false
+
+false
+false
+false
+true
+false
+false
+false
+true
+
+false
+false
+true
+false
+false
+false
+true
+false
+
+true
+true
+false
+true
+true
+true
+false
+true
+
+false
+false
+true
+false
+false
+false
+true
+false
+
+13.31
+44.11
+44.22
+44.33
+44.44
+33.11
+33.22
+33.33
+17.88
+0.0
+0.0
+0.0
+0.0
+17.88
+0.0
+0.0
+0.0
+0.0
+17.88
+0.0
+0.0
+0.0
+0.0
+17.88
+666
+true
+
+true
+false
+
+13.31
+44.11
+44.22
+44.33
+44.44
+33.11
+33.22
+33.33
+17.88
+0.0
+0.0
+0.0
+0.0
+17.88
+0.0
+0.0
+0.0
+333.333
+17.88
+0.0
+0.0
+0.0
+0.0
+17.88
+666
+true
+
+false
+true
+
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test logical operators.
+$ */
+
+$program LOGICAL OPERATOR TEST
+
+$attrib gl_Vertex
+0.0 0.0 0.0 1.0
+
+$attrib _False
+0.0 0.0 0.0 0.0
+
+$attrib _True
+1.0 0.0 0.0 0.0
+
+$attrib _False2
+0.0 0.0 0.0 0.0
+
+$attrib _True2
+1.0 0.0 0.0 0.0
+
+$vertex
+
+$code
+
+attribute float _False;
+attribute float _True;
+attribute float _False2;
+attribute float _True2;
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ printMESA (_False);
+ printMESA (_True);
+ printMESA (_False2);
+ printMESA (_True2);
+
+ bool False = bool (_False);
+ bool True = bool (_True);
+ bool False2 = bool (_False2);
+ bool True2 = bool (_True2);
+
+ //
+ // It is important to test each operator with the following argument types:
+ // * Both arguments are different variables, even if they have the same values.
+ // False and False2 are distinct attributes, but are the same in value.
+ // * Both arguments may be the same variables. This case tests possible
+ // optimizations, e.g. X && X --> X.
+ // * Both arguments are constant. This tests constant folding.
+ //
+
+ printMESA (!False);
+ printMESA (!True);
+ printMESA (!false);
+ printMESA (!true);
+
+ printMESA (False ^^ False2);
+ printMESA (False ^^ True2);
+ printMESA (True ^^ False2);
+ printMESA (True ^^ True2);
+ printMESA (False ^^ False);
+ printMESA (False ^^ True);
+ printMESA (True ^^ False);
+ printMESA (True ^^ True);
+ printMESA (false ^^ false);
+ printMESA (false ^^ true);
+ printMESA (true ^^ false);
+ printMESA (true ^^ true);
+
+ printMESA (False && False2);
+ printMESA (False && True2);
+ printMESA (True && False2);
+ printMESA (True && True2);
+ printMESA (False && False);
+ printMESA (False && True);
+ printMESA (True && False);
+ printMESA (True && True);
+ printMESA (false && false);
+ printMESA (false && true);
+ printMESA (true && false);
+ printMESA (true && true);
+
+ printMESA (False || False2);
+ printMESA (False || True2);
+ printMESA (True || False2);
+ printMESA (True || True2);
+ printMESA (False || False);
+ printMESA (False || True);
+ printMESA (True || False);
+ printMESA (True || True);
+ printMESA (false || false);
+ printMESA (false || true);
+ printMESA (true || false);
+ printMESA (true || true);
+
+ //
+ // Test short-circuit evaluation of && and ||. The right expression evaluation depends
+ // on the value of the left expression. If the right expression has side effects, we
+ // can easily test if it happened.
+ //
+
+ bool x;
+
+ x = false;
+ printMESA (x);
+ printMESA (False && (x = true));
+ printMESA (x);
+
+ x = false;
+ printMESA (x);
+ printMESA (false && (x = true));
+ printMESA (x);
+
+ x = true;
+ printMESA (x);
+ printMESA (True || (x = false));
+ printMESA (x);
+
+ x = true;
+ printMESA (x);
+ printMESA (true || (x = false));
+ printMESA (x);
+}
+
+$output
+
+0.0
+1.0
+0.0
+1.0
+
+true
+false
+true
+false
+
+false
+true
+true
+false
+false
+true
+true
+false
+false
+true
+true
+false
+
+false
+false
+false
+true
+false
+false
+false
+true
+false
+false
+false
+true
+
+false
+true
+true
+true
+false
+true
+true
+true
+false
+true
+true
+true
+
+false
+false
+false
+
+false
+false
+false
+
+true
+true
+true
+
+true
+true
+true
+
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test subscript operator/array access.
+$ */
+
+$program ARRAY ACCESS TEST
+
+$attrib gl_Vertex
+0.0 0.0 0.0 1.0
+
+$attrib _Zero
+0.0 0.0 0.0 0.0
+
+$attrib _One
+1.1 0.0 0.0 0.0
+
+$attrib _Two
+2.9 0.0 0.0 0.0
+
+$attrib _Vec
+11.11 22.22 33.33 44.44
+
+$vertex
+
+$code
+
+attribute float _Zero;
+attribute float _One;
+attribute float _Two;
+attribute vec4 _Vec;
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ printMESA (_Zero);
+ printMESA (_One);
+ printMESA (_Two);
+ printMESA (_Vec);
+
+ printMESA (_Vec[0]);
+ printMESA (_Vec[1]);
+ printMESA (_Vec[2]);
+ printMESA (_Vec[3]);
+
+ printMESA (_Vec[int (_Zero)]);
+ printMESA (_Vec[int (_One)]);
+ printMESA (_Vec[int (_Two)]);
+}
+
+$output
+
+0.0
+1.1
+2.9
+11.11
+22.22
+33.33
+44.44
+
+11.11
+22.22
+33.33
+44.44
+
+11.11
+22.22
+33.33
+
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test pre/post-increment/decrement operators.
+$ Note: assumes relational operators being correct.
+$ */
+
+$program PRE/POST-INC/DEC OPERATOR TEST
+
+$attrib gl_Vertex
+0.0 0.0 0.0 1.0
+
+$attrib _Zero
+0.0 0.0 0.0 0.0
+
+$attrib _One
+1.1 0.0 0.0 0.0
+
+$attrib _Two4
+2.1 2.2 2.3 2.4
+
+$vertex
+
+$code
+
+attribute float _Zero;
+attribute float _One;
+attribute vec4 _Two4;
+
+float fZero, fOne;
+vec4 fTwo4;
+int iZero, iOne;
+ivec4 iTwo4;
+
+void reset () {
+ fZero = _Zero;
+ fOne = _One;
+ fTwo4 = _Two4;
+ iZero = int (_Zero);
+ iOne = int (_One);
+ iTwo4 = ivec4 (_Two4);
+}
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ printMESA (_Zero);
+ printMESA (_One);
+ printMESA (_Two4);
+
+ // pre-increment
+ reset ();
+ printMESA (++fZero);
+ printMESA (++fOne);
+ printMESA (++iZero);
+ printMESA (++iOne);
+ printMESA (fZero);
+ printMESA (fOne);
+ printMESA (iZero);
+ printMESA (iOne);
+ printMESA (++fTwo4 == _Two4 + 1.0);
+ printMESA (++iTwo4 == ivec4 (_Two4) + 1);
+
+ // pre-decrement
+ reset ();
+ printMESA (--fZero);
+ printMESA (--fOne);
+ printMESA (--iZero);
+ printMESA (--iOne);
+ printMESA (fZero);
+ printMESA (fOne);
+ printMESA (iZero);
+ printMESA (iOne);
+ printMESA (--fTwo4 == _Two4 - 1.0);
+ printMESA (--iTwo4 == ivec4 (_Two4) - 1);
+
+ // post-increment
+ reset ();
+ printMESA (fZero++);
+ printMESA (fOne++);
+ printMESA (iZero++);
+ printMESA (iOne++);
+ printMESA (fZero);
+ printMESA (fOne);
+ printMESA (iZero);
+ printMESA (iOne);
+ printMESA (fTwo4++ == _Two4);
+ printMESA (iTwo4++ == ivec4 (_Two4));
+
+ // post-decrement
+ reset ();
+ printMESA (fZero--);
+ printMESA (fOne--);
+ printMESA (iZero--);
+ printMESA (iOne--);
+ printMESA (fZero);
+ printMESA (fOne);
+ printMESA (iZero);
+ printMESA (iOne);
+ printMESA (fTwo4-- == _Two4);
+ printMESA (iTwo4-- == ivec4 (_Two4));
+}
+
+$output
+
+0.0
+1.1
+2.1
+2.2
+2.3
+2.4
+
+1.0
+2.1
+1
+2
+1.0
+2.1
+1
+2
+true
+true
+
+-1.0
+0.1
+-1
+0
+-1.0
+0.1
+-1
+0
+true
+true
+
+0.0
+1.1
+0
+1
+1.0
+2.1
+1
+2
+true
+true
+
+0.0
+1.1
+0
+1
+-1.0
+0.1
+-1
+0
+true
+true
+
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test arithmetical operators.
+$ */
+
+$program ARITHMETICAL OPERATOR TEST
+
+$attrib gl_Vertex
+0.0 0.0 0.0 1.0
+
+$attrib _Zero
+0.0 0.0 0.0 0.0
+
+$attrib _One
+1.1 0.0 0.0 0.0
+
+$attrib _Two4
+2.1 2.2 2.3 2.4
+
+$vertex
+
+$code
+
+attribute float _Zero;
+attribute float _One;
+attribute vec4 _Two4;
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ printMESA (_Zero);
+ printMESA (_One);
+ printMESA (_Two4);
+
+ int iZero = int (_Zero);
+ int iOne = int (_One);
+ ivec4 iTwo4 = ivec4 (_Two4);
+
+ printMESA (-_Zero);
+ printMESA (-_One);
+ printMESA (-_Two4);
+ printMESA (-_Two4.z);
+
+ printMESA (_Zero + 0.0);
+ printMESA (_One + 0.0);
+ printMESA (_Two4 + 0.0);
+ printMESA (_Two4.y + 0.0);
+
+ printMESA (_Zero + _Zero);
+ printMESA (_Zero + _One);
+ printMESA (_Zero + _Two4);
+ printMESA (_One + _Zero);
+ printMESA (_One + _Two4);
+ printMESA (_Two4 + _Two4);
+
+ printMESA (_Zero - 0.0);
+ printMESA (_One - 0.0);
+ printMESA (_Two4 - 0.0);
+ printMESA (_Two4.y - 0.0);
+
+ printMESA (_Zero - _Zero);
+ printMESA (_Zero - _One);
+ printMESA (_Zero - _Two4);
+ printMESA (_One - _Zero);
+ printMESA (_One - _Two4);
+ printMESA (_Two4 - _Two4);
+
+ printMESA (_Zero * 1.0);
+ printMESA (_One * 1.0);
+ printMESA (_Two4 * 1.0);
+ printMESA (_Two4.x * 1.0);
+
+ printMESA (_Zero * _Zero);
+ printMESA (_Zero * _One);
+ printMESA (_Zero * _Two4);
+ printMESA (_One * _Zero);
+ printMESA (_One * _One);
+ printMESA (_One * _Two4);
+ printMESA (_Two4 * _Two4);
+
+ printMESA (_Zero / 1.0);
+ printMESA (_One / 1.0);
+ printMESA (_Two4 / 1.0);
+ printMESA (_Two4.x / 1.0);
+
+ printMESA (_Zero / _One);
+ printMESA (_Zero / _Two4);
+ printMESA (_One / _One);
+ printMESA (_One / _Two4);
+ printMESA (_Two4 / _Two4);
+}
+
+$output
+
+0.0
+1.1
+2.1
+2.2
+2.3
+2.4
+
+0.0
+-1.1
+-2.1
+-2.2
+-2.3
+-2.4
+-2.3
+
+0.0
+1.1
+2.1
+2.2
+2.3
+2.4
+2.2
+
+0.0
+1.1
+2.1
+2.2
+2.3
+2.4
+1.1
+3.2
+3.3
+3.4
+3.5
+4.2
+4.4
+4.6
+4.8
+
+0.0
+1.1
+2.1
+2.2
+2.3
+2.4
+2.2
+
+0.0
+-1.1
+-2.1
+-2.2
+-2.3
+-2.4
+1.1
+-1.0
+-1.1
+-1.2
+-1.3
+0.0
+0.0
+0.0
+0.0
+
+0.0
+1.1
+2.1
+2.2
+2.3
+2.4
+2.1
+
+0.0
+0.0
+0.0
+0.0
+0.0
+0.0
+0.0
+1.21
+2.31
+2.42
+2.53
+2.64
+4.41
+4.84
+5.29
+5.76
+
+0.0
+1.1
+2.1
+2.2
+2.3
+2.4
+2.1
+
+0.0
+0.0
+0.0
+0.0
+0.0
+1.0
+0.52381
+0.5
+0.47826
+0.45833
+1.0
+1.0
+1.0
+1.0
+
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test matrix operations.
+$ Note: assumes relational operators being correct.
+$ */
+
+$program MATRIX TEST
+
+$attrib gl_Vertex
+0.0 0.0 0.0 1.0
+
+$attrib _Zero
+0.0 0.0 0.0 0.0
+
+$attrib _One
+1.0 1.0 1.0 1.0
+
+$attrib _Two
+2.0 2.0 2.0 2.0
+
+$vertex
+
+$code
+
+attribute vec4 _Zero;
+attribute vec4 _One;
+attribute vec4 _Two;
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ printMESA (_Zero);
+ printMESA (_One);
+ printMESA (_Two);
+
+ mat4 Identity = mat4 (_One.x);
+
+ printMESA (Identity == mat4 (1.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0));
+ printMESA (Identity * _Two == _Two);
+
+ mat4 Matrix = mat4 (1.1, 1.2, 1.3, 1.4,
+ 2.1, 2.2, 2.3, 2.4,
+ 3.1, 3.2, 3.3, 3.4,
+ 4.1, 4.2, 4.3, 4.4);
+
+ printMESA (Matrix[2].y);
+ printMESA (Matrix[1]);
+}
+
+$output
+
+0.0
+0.0
+0.0
+0.0
+1.0
+1.0
+1.0
+1.0
+2.0
+2.0
+2.0
+2.0
+true
+true
+3.2
+2.1
+2.2
+2.3
+2.4
+
diff --git a/progs/slang/framework.c b/progs/slang/framework.c
index 80ee37f637..692cef9c8c 100644
--- a/progs/slang/framework.c
+++ b/progs/slang/framework.c
@@ -3,8 +3,10 @@
/*
* GL_ARB_multitexture
*/
+#ifndef GL_ARB_multitexture
PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB;
PFNGLMULTITEXCOORD4FVARBPROC glMultiTexCoord4fvARB;
+#endif
/*
* GL_ARB_shader_objects
@@ -65,8 +67,10 @@ void InitFramework (int *argc, char *argv[])
glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow (argv[0]);
+#ifndef GL_ARB_multitexture
GETPROCADDR(glClientActiveTextureARB, PFNGLCLIENTACTIVETEXTUREARBPROC);
GETPROCADDR(glMultiTexCoord4fvARB, PFNGLMULTITEXCOORD4FVARBPROC);
+#endif
GETPROCADDR(glDeleteObjectARB, PFNGLDELETEOBJECTARBPROC);
GETPROCADDR(glGetHandleARB, PFNGLGETHANDLEARBPROC);
@@ -100,9 +104,6 @@ void InitFramework (int *argc, char *argv[])
InitScene ();
- /*glutReshapeFunc (Reshape);
- glutKeyboardFunc (Key);
- glutSpecialFunc (SpecialKey);*/
glutDisplayFunc (Display);
glutIdleFunc (Idle);
glutMainLoop ();
diff --git a/progs/slang/framework.h b/progs/slang/framework.h
index fe1c4cbd38..e023f7da8a 100644
--- a/progs/slang/framework.h
+++ b/progs/slang/framework.h
@@ -6,9 +6,10 @@
#include <windows.h>
#endif
-#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
+#include <assert.h>
#include <math.h>
#include <GL/gl.h>
#include <GL/glut.h>
@@ -25,8 +26,10 @@
/*
* GL_ARB_multitexture
*/
+#ifndef GL_ARB_multitexture
extern PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB;
extern PFNGLMULTITEXCOORD4FVARBPROC glMultiTexCoord4fvARB;
+#endif
/*
* GL_ARB_shader_objects
@@ -68,12 +71,12 @@ extern PFNGLFOGCOORDPOINTEREXTPROC glFogCoordPointerEXT;
extern PFNGLSECONDARYCOLOR3FVEXTPROC glSecondaryColor3fvEXT;
extern PFNGLSECONDARYCOLORPOINTEREXTPROC glSecondaryColorPointerEXT;
-void InitFramework (int *argc, char *argv[]);
+extern void InitFramework (int *argc, char *argv[]);
extern void InitScene (void);
extern void RenderScene (void);
-GLboolean CheckObjectStatus (GLhandleARB);
+extern GLboolean CheckObjectStatus (GLhandleARB);
#endif
diff --git a/progs/slang/vstest.c b/progs/slang/vstest.c
index 95d2ed6b83..e31f3b16df 100644
--- a/progs/slang/vstest.c
+++ b/progs/slang/vstest.c
@@ -210,7 +210,7 @@ static void dl_end ()
static void load_test_file (const char *filename)
{
FILE *f;
- long size;
+ GLint size;
char *code;
GLint i;
@@ -230,7 +230,7 @@ static void load_test_file (const char *filename)
size = fread (code, 1, size, f);
fclose (f);
- glShaderSourceARB (vert, 1, &code, &size);
+ glShaderSourceARB (vert, 1, (const GLcharARB **) (&code), &size);
glCompileShaderARB (vert);
if (!CheckObjectStatus (vert))
exit (0);
diff --git a/progs/slang/vstest.txt b/progs/slang/vstest.txt
index ac4fceb1c6..b049f4206f 100644
--- a/progs/slang/vstest.txt
+++ b/progs/slang/vstest.txt
@@ -1,68 +1,68 @@
-/*
- * Vertex shader test.
- * Uses all conventional attributes and 15 generic attributes to print
- * their values, using printMESA() extension function, to the debugger
- * to compare them with the actual passed-in values.
- * Use different types for generic attributes to check matrix handling.
- *
- * Author: Michal Krol
- */
-
-#version 110
-
-//#extension MESA_shader_debug: require
-
-attribute vec4 Attribute1;
-attribute vec4 Attribute2;
-attribute vec4 Attribute3;
-attribute float Attribute4;
-attribute vec2 Attribute5;
-attribute vec3 Attribute6;
-attribute mat2 Attribute7;
-attribute mat3 Attribute9;
-attribute mat4 Attribute12;
-
-void main ()
-{
- //
- // Do some legal stuff.
- //
- gl_Position = gl_ModelViewMatrix * gl_Vertex;
- gl_FrontColor = vec4 (1.0);
-
- //
- // Conventional attributes - except for gl_Vertex.
- //
- printMESA (gl_Color);
- printMESA (gl_SecondaryColor);
- printMESA (gl_Normal);
- printMESA (gl_MultiTexCoord0);
- printMESA (gl_MultiTexCoord1);
- printMESA (gl_MultiTexCoord2);
- printMESA (gl_MultiTexCoord3);
- printMESA (gl_MultiTexCoord4);
- printMESA (gl_MultiTexCoord5);
- printMESA (gl_MultiTexCoord6);
- printMESA (gl_MultiTexCoord7);
- printMESA (gl_FogCoord);
-
- //
- // Generic attributes - attrib with index 0 is not used because it would
- // alias with gl_Vertex, which is not allowed.
- //
- printMESA (Attribute1);
- printMESA (Attribute2);
- printMESA (Attribute3);
- printMESA (Attribute4);
- printMESA (Attribute5);
- printMESA (Attribute6);
- printMESA (Attribute7);
- printMESA (Attribute9);
- printMESA (Attribute12);
-
- //
- // Vertex position goes last.
- //
- printMESA (gl_Vertex);
-}
-
+/*
+ * Vertex shader test.
+ * Uses all conventional attributes and 15 generic attributes to print
+ * their values, using printMESA() extension function, to the debugger
+ * to compare them with the actual passed-in values.
+ * Use different types for generic attributes to check matrix handling.
+ *
+ * Author: Michal Krol
+ */
+
+#version 110
+
+//#extension MESA_shader_debug: require
+
+attribute vec4 Attribute1;
+attribute vec4 Attribute2;
+attribute vec4 Attribute3;
+attribute float Attribute4;
+attribute vec2 Attribute5;
+attribute vec3 Attribute6;
+attribute mat2 Attribute7;
+attribute mat3 Attribute9;
+attribute mat4 Attribute12;
+
+void main ()
+{
+ //
+ // Do some legal stuff.
+ //
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ //
+ // Conventional attributes - except for gl_Vertex.
+ //
+ printMESA (gl_Color);
+ printMESA (gl_SecondaryColor);
+ printMESA (gl_Normal);
+ printMESA (gl_MultiTexCoord0);
+ printMESA (gl_MultiTexCoord1);
+ printMESA (gl_MultiTexCoord2);
+ printMESA (gl_MultiTexCoord3);
+ printMESA (gl_MultiTexCoord4);
+ printMESA (gl_MultiTexCoord5);
+ printMESA (gl_MultiTexCoord6);
+ printMESA (gl_MultiTexCoord7);
+ printMESA (gl_FogCoord);
+
+ //
+ // Generic attributes - attrib with index 0 is not used because it would
+ // alias with gl_Vertex, which is not allowed.
+ //
+ printMESA (Attribute1);
+ printMESA (Attribute2);
+ printMESA (Attribute3);
+ printMESA (Attribute4);
+ printMESA (Attribute5);
+ printMESA (Attribute6);
+ printMESA (Attribute7);
+ printMESA (Attribute9);
+ printMESA (Attribute12);
+
+ //
+ // Vertex position goes last.
+ //
+ printMESA (gl_Vertex);
+}
+