-$ /*\r
-$ Shader test script.\r
-$ \r
-$ Author: Michal Krol\r
-$ \r
-$ Comment line starts with dollar sign and white space.\r
-$ \r
-$ $program <name> starts a new test program section called <name>. Contains all other sections.\r
-$ \r
-$ $attrib <name> starts vertex data input section for attrib called <name>. Each line consists of\r
-$ four values that form single vertex attrib.\r
-$ \r
-$ $vertex starts vertex shader section. Contains $code and &output sections.\r
-$ \r
-$ $code starts source code section. All text in this section gets compiled into appropriate\r
-$ shader object.\r
-$ \r
-$ $output starts shader execution results section. These are compared, value-by-value,\r
-$ with results of executing printMESA() functions within a shader.\r
-$ */\r
-\r
-\r
-$ /*\r
-$ --------------------------------------------------------------------------------------------------\r
-$ Test printMESA() function.\r
-$ */\r
-\r
-$program PRINT TEST\r
-\r
-$vertex\r
-\r
-$code\r
-\r
-void main () {\r
- gl_Position = gl_ModelViewMatrix * gl_Vertex;\r
- gl_FrontColor = vec4 (1.0);\r
-\r
- printMESA (11.1);\r
- printMESA (111);\r
- printMESA (true);\r
-\r
- printMESA (vec2 (22.1, 22.2));\r
- printMESA (vec3 (33.1, 33.2, 33.3));\r
- printMESA (vec4 (44.1, 44.2, 44.3, 44.4));\r
-\r
- printMESA (ivec2 (221, 222));\r
- printMESA (ivec3 (331, 332, 333));\r
- printMESA (ivec4 (441, 442, 443, 444));\r
-\r
- printMESA (bvec2 (false, true));\r
- printMESA (bvec3 (true, true, false));\r
- printMESA (bvec4 (true, false, true, false));\r
-\r
- printMESA (mat2 (55.11, 55.12, 55.21, 55.22));\r
- printMESA (mat3 (66.11, 66.12, 66.13,\r
- 66.21, 66.22, 66.23,\r
- 66.31, 66.32, 66.33));\r
- printMESA (mat4 (77.11, 77.12, 77.13, 77.14,\r
- 77.21, 77.22, 77.23, 77.24,\r
- 77.31, 77.32, 77.33, 77.34,\r
- 77.41, 77.42, 77.43, 77.44));\r
-}\r
-\r
-$output\r
-\r
-11.1\r
-111\r
-true\r
-\r
-22.1\r
-22.2\r
-33.1\r
-33.2\r
-33.3\r
-44.1\r
-44.2\r
-44.3\r
-44.4\r
-\r
-221\r
-222\r
-331\r
-332\r
-333\r
-441\r
-442\r
-443\r
-444\r
-\r
-false\r
-true\r
-true\r
-true\r
-false\r
-true\r
-false\r
-true\r
-false\r
-\r
-55.11\r
-55.12\r
-55.21\r
-55.22\r
-\r
-66.11\r
-66.12\r
-66.13\r
-66.21\r
-66.22\r
-66.23\r
-66.31\r
-66.32\r
-66.33\r
-\r
-77.11\r
-77.12\r
-77.13\r
-77.14\r
-77.21\r
-77.22\r
-77.23\r
-77.24\r
-77.31\r
-77.32\r
-77.33\r
-77.34\r
-77.41\r
-77.42\r
-77.43\r
-77.44\r
-\r
-\r
-$ /*\r
-$ --------------------------------------------------------------------------------------------------\r
-$ Test type casting.\r
-$ */\r
-\r
-$program TYPE CAST TEST\r
-\r
-$attrib gl_Vertex\r
-0.0 0.0 0.0 1.0\r
-\r
-$attrib _Zero\r
-0.0 0.0 0.0 0.0\r
-\r
-$attrib _One\r
-1.1 0.0 0.0 0.0\r
-\r
-$attrib _Two\r
-2.2 0.0 0.0 0.0\r
-\r
-$attrib _MinusThree\r
--3.3 0.0 0.0 0.0\r
-\r
-$vertex\r
-\r
-$code\r
-\r
-attribute float _Zero;\r
-attribute float _One;\r
-attribute float _Two;\r
-attribute float _MinusThree;\r
-\r
-void main () {\r
- gl_Position = gl_ModelViewMatrix * gl_Vertex;\r
- gl_FrontColor = vec4 (1.0);\r
-\r
- printMESA (_Zero);\r
- printMESA (_One);\r
- printMESA (_Two);\r
- printMESA (_MinusThree);\r
-\r
- printMESA (float (_Zero));\r
- printMESA (float (_One));\r
- printMESA (float (_Two));\r
- printMESA (float (_MinusThree));\r
- printMESA (float (45.99));\r
- printMESA (float (-6.17));\r
-\r
- printMESA (bool (_Zero));\r
- printMESA (bool (_One));\r
- printMESA (bool (_Two));\r
- printMESA (bool (_MinusThree));\r
- printMESA (bool (45.99));\r
- printMESA (bool (-6.17));\r
- printMESA (bool (0.0001));\r
- printMESA (bool (0.0));\r
-\r
- printMESA (int (_Zero));\r
- printMESA (int (_One));\r
- printMESA (int (_Two));\r
- printMESA (int (_MinusThree));\r
- printMESA (int (45.99));\r
- printMESA (int (45.22));\r
- printMESA (int (-6.17));\r
- printMESA (int (-6.87));\r
-}\r
-\r
-$output\r
-\r
-0.0\r
-1.1\r
-2.2\r
--3.3\r
-\r
-0.0\r
-1.1\r
-2.2\r
--3.3\r
-45.99\r
--6.17\r
-\r
-false\r
-true\r
-true\r
-true\r
-true\r
-true\r
-true\r
-false\r
-\r
-0\r
-1\r
-2\r
--3\r
-45\r
-45\r
--6\r
--6\r
-\r
-$ /*\r
-$ --------------------------------------------------------------------------------------------------\r
-$ Test vector swizzles.\r
-$ */\r
-\r
-$program SWIZZLE TEST\r
-\r
-$attrib gl_Vertex\r
-0.0 0.0 0.0 1.0\r
-\r
-$attrib _One\r
-1.1 1.2 1.3 1.4\r
-\r
-$attrib _Two\r
-2.1 2.2 2.3 2.4\r
-\r
-$vertex\r
-\r
-$code\r
-\r
-attribute vec4 _One;\r
-attribute vec4 _Two;\r
-\r
-void assign5678 (out vec4 v)\r
-{\r
- v.x = 5.5;\r
- v.y = 6.6;\r
- v.z = 7.7;\r
- v.w = 8.8;\r
-}\r
-\r
-void main () {\r
- gl_Position = gl_ModelViewMatrix * gl_Vertex;\r
- gl_FrontColor = vec4 (1.0);\r
-\r
- printMESA (_One);\r
- printMESA (_Two);\r
-\r
- printMESA (_One.x);\r
- printMESA (_One.y);\r
- printMESA (_One.z);\r
- printMESA (_One.w);\r
-\r
- printMESA (_Two.xy);\r
- printMESA (_Two.yx);\r
- printMESA (_Two.xw);\r
- printMESA (_Two.wx);\r
- printMESA (_Two.yz);\r
- printMESA (_Two.zy);\r
- printMESA (_Two.xz);\r
- printMESA (_Two.zx);\r
- printMESA (_Two.zw);\r
- printMESA (_Two.wz);\r
-\r
- printMESA (_One.xyz);\r
- printMESA (_One.yzx);\r
- printMESA (_One.zxy);\r
- printMESA (_One.xzy);\r
- printMESA (_One.yzw);\r
- printMESA (_One.zwx);\r
-\r
- printMESA (_Two.xyzw);\r
- printMESA (_Two.yzwx);\r
- printMESA (_Two.wzyx);\r
- printMESA (_Two.zwyx);\r
-\r
- printMESA (_One.xx);\r
- printMESA (_One.zz);\r
- printMESA (_One.ww);\r
-\r
- printMESA (_Two.xxx);\r
- printMESA (_Two.yyy);\r
- printMESA (_Two.www);\r
-\r
- printMESA (_One.xxxx);\r
- printMESA (_One.zzzz);\r
-\r
- printMESA (_Two.xxyy);\r
- printMESA (_Two.wwxx);\r
- printMESA (_Two.zxxw);\r
-\r
- vec4 v;\r
-\r
- v.zxwy = vec4 (5.5, 6.6, 7.7, 8.8);\r
- printMESA (v);\r
-\r
- assign5678 (v.ywxz);\r
- printMESA (v);\r
-}\r
-\r
-$output\r
-\r
-1.1\r
-1.2\r
-1.3\r
-1.4\r
-2.1\r
-2.2\r
-2.3\r
-2.4\r
-\r
-1.1\r
-1.2\r
-1.3\r
-1.4\r
-\r
-2.1\r
-2.2\r
-2.2\r
-2.1\r
-2.1\r
-2.4\r
-2.4\r
-2.1\r
-2.2\r
-2.3\r
-2.3\r
-2.2\r
-2.1\r
-2.3\r
-2.3\r
-2.1\r
-2.3\r
-2.4\r
-2.4\r
-2.3\r
-\r
-1.1\r
-1.2\r
-1.3\r
-1.2\r
-1.3\r
-1.1\r
-1.3\r
-1.1\r
-1.2\r
-1.1\r
-1.3\r
-1.2\r
-1.2\r
-1.3\r
-1.4\r
-1.3\r
-1.4\r
-1.1\r
-\r
-2.1\r
-2.2\r
-2.3\r
-2.4\r
-2.2\r
-2.3\r
-2.4\r
-2.1\r
-2.4\r
-2.3\r
-2.2\r
-2.1\r
-2.3\r
-2.4\r
-2.2\r
-2.1\r
-\r
-1.1\r
-1.1\r
-1.3\r
-1.3\r
-1.4\r
-1.4\r
-\r
-2.1\r
-2.1\r
-2.1\r
-2.2\r
-2.2\r
-2.2\r
-2.4\r
-2.4\r
-2.4\r
-\r
-1.1\r
-1.1\r
-1.1\r
-1.1\r
-1.3\r
-1.3\r
-1.3\r
-1.3\r
-\r
-2.1\r
-2.1\r
-2.2\r
-2.2\r
-2.4\r
-2.4\r
-2.1\r
-2.1\r
-2.3\r
-2.1\r
-2.1\r
-2.4\r
-\r
-6.6\r
-8.8\r
-5.5\r
-7.7\r
-\r
-7.7\r
-5.5\r
-8.8\r
-6.6\r
-\r
-\r
-$ /*\r
-$ --------------------------------------------------------------------------------------------------\r
-$ Test relational operators.\r
-$ */\r
-\r
-$program RELATIONAL OPERATOR TEST\r
-\r
-$attrib gl_Vertex\r
-0.0 0.0 0.0 1.0\r
-\r
-$attrib _Two\r
-2.0 0.0 0.0 0.0\r
-\r
-$attrib _Two2\r
-2.0 0.0 0.0 0.0\r
-\r
-$attrib _MinusThree\r
--3.0 0.0 0.0 0.0\r
-\r
-$vertex\r
-\r
-$code\r
-\r
-attribute float _Two;\r
-attribute float _Two2;\r
-attribute float _MinusThree;\r
-\r
-struct foo\r
-{\r
- float f;\r
- vec4 v4;\r
- vec3 v3;\r
- mat4 m4;\r
- int i;\r
- bool b;\r
-};\r
-\r
-void printMESA (const in foo bar)\r
-{\r
- printMESA (bar.f);\r
- printMESA (bar.v4);\r
- printMESA (bar.v3);\r
- printMESA (bar.m4);\r
- printMESA (bar.i);\r
- printMESA (bar.b);\r
-}\r
-\r
-void main () {\r
- gl_Position = gl_ModelViewMatrix * gl_Vertex;\r
- gl_FrontColor = vec4 (1.0);\r
-\r
- int iTwo = int (_Two);\r
- int iTwo2 = int (_Two2);\r
- int iMinusThree = int (_MinusThree);\r
-\r
- printMESA (_Two <= _Two);\r
- printMESA (_Two <= _Two2);\r
- printMESA (_Two <= _MinusThree);\r
- printMESA (_MinusThree <= _Two);\r
- printMESA (iTwo <= iTwo);\r
- printMESA (iTwo <= iTwo2);\r
- printMESA (iTwo <= iMinusThree);\r
- printMESA (iMinusThree <= iTwo);\r
-\r
- printMESA (_Two >= _Two);\r
- printMESA (_Two >= _Two2);\r
- printMESA (_Two >= _MinusThree);\r
- printMESA (_MinusThree >= _Two);\r
- printMESA (iTwo >= iTwo);\r
- printMESA (iTwo >= iTwo2);\r
- printMESA (iTwo >= iMinusThree);\r
- printMESA (iMinusThree >= iTwo);\r
-\r
- printMESA (_Two < _Two);\r
- printMESA (_Two < _Two2);\r
- printMESA (_Two < _MinusThree);\r
- printMESA (_MinusThree < _Two);\r
- printMESA (iTwo < iTwo);\r
- printMESA (iTwo < iTwo2);\r
- printMESA (iTwo < iMinusThree);\r
- printMESA (iMinusThree < iTwo);\r
-\r
- printMESA (_Two > _Two);\r
- printMESA (_Two > _Two2);\r
- printMESA (_Two > _MinusThree);\r
- printMESA (_MinusThree > _Two);\r
- printMESA (iTwo > iTwo);\r
- printMESA (iTwo > iTwo2);\r
- printMESA (iTwo > iMinusThree);\r
- printMESA (iMinusThree > iTwo);\r
-\r
- printMESA (_Two == _Two);\r
- printMESA (_Two == _Two2);\r
- printMESA (_Two == _MinusThree);\r
- printMESA (_MinusThree == _MinusThree);\r
- printMESA (iTwo == iTwo);\r
- printMESA (iTwo == iTwo2);\r
- printMESA (iTwo == iMinusThree);\r
- printMESA (iMinusThree == iMinusThree);\r
-\r
- printMESA (_Two != _Two);\r
- printMESA (_Two != _Two2);\r
- printMESA (_Two != _MinusThree);\r
- printMESA (_MinusThree != _MinusThree);\r
- printMESA (iTwo != iTwo);\r
- printMESA (iTwo != iTwo2);\r
- printMESA (iTwo != iMinusThree);\r
- printMESA (iMinusThree != iMinusThree);\r
-\r
- foo foo1;\r
- foo1.f = 13.31;\r
- foo1.v4 = vec4 (44.11, 44.22, 44.33, 44.44);\r
- foo1.v3 = vec3 (33.11, 33.22, 33.33);\r
- foo1.m4 = mat4 (17.88);\r
- foo1.i = 666;\r
- foo1.b = true;\r
- printMESA (foo1);\r
-\r
- // make foo2 the same as foo1\r
- foo foo2;\r
- foo2.f = 13.31;\r
- foo2.v4 = vec4 (44.11, 44.22, 44.33, 44.44);\r
- foo2.v3 = vec3 (33.11, 33.22, 33.33);\r
- foo2.m4 = mat4 (17.88);\r
- foo2.i = 666;\r
- foo2.b = true;\r
-\r
- printMESA (foo1 == foo2);\r
- printMESA (foo1 != foo2);\r
-\r
- // make them a little bit different\r
- foo2.m4[2].y = 333.333;\r
- printMESA (foo2);\r
-\r
- printMESA (foo1 == foo2);\r
- printMESA (foo1 != foo2);\r
-}\r
-\r
-$output\r
-\r
-true\r
-true\r
-false\r
-true\r
-true\r
-true\r
-false\r
-true\r
-\r
-true\r
-true\r
-true\r
-false\r
-true\r
-true\r
-true\r
-false\r
-\r
-false\r
-false\r
-false\r
-true\r
-false\r
-false\r
-false\r
-true\r
-\r
-false\r
-false\r
-true\r
-false\r
-false\r
-false\r
-true\r
-false\r
-\r
-true\r
-true\r
-false\r
-true\r
-true\r
-true\r
-false\r
-true\r
-\r
-false\r
-false\r
-true\r
-false\r
-false\r
-false\r
-true\r
-false\r
-\r
-13.31\r
-44.11\r
-44.22\r
-44.33\r
-44.44\r
-33.11\r
-33.22\r
-33.33\r
-17.88\r
-0.0\r
-0.0\r
-0.0\r
-0.0\r
-17.88\r
-0.0\r
-0.0\r
-0.0\r
-0.0\r
-17.88\r
-0.0\r
-0.0\r
-0.0\r
-0.0\r
-17.88\r
-666\r
-true\r
-\r
-true\r
-false\r
-\r
-13.31\r
-44.11\r
-44.22\r
-44.33\r
-44.44\r
-33.11\r
-33.22\r
-33.33\r
-17.88\r
-0.0\r
-0.0\r
-0.0\r
-0.0\r
-17.88\r
-0.0\r
-0.0\r
-0.0\r
-333.333\r
-17.88\r
-0.0\r
-0.0\r
-0.0\r
-0.0\r
-17.88\r
-666\r
-true\r
-\r
-false\r
-true\r
-\r
-\r
-$ /*\r
-$ --------------------------------------------------------------------------------------------------\r
-$ Test logical operators.\r
-$ */\r
-\r
-$program LOGICAL OPERATOR TEST\r
-\r
-$attrib gl_Vertex\r
-0.0 0.0 0.0 1.0\r
-\r
-$attrib _False\r
-0.0 0.0 0.0 0.0\r
-\r
-$attrib _True\r
-1.0 0.0 0.0 0.0\r
-\r
-$attrib _False2\r
-0.0 0.0 0.0 0.0\r
-\r
-$attrib _True2\r
-1.0 0.0 0.0 0.0\r
-\r
-$vertex\r
-\r
-$code\r
-\r
-attribute float _False;\r
-attribute float _True;\r
-attribute float _False2;\r
-attribute float _True2;\r
-\r
-void main () {\r
- gl_Position = gl_ModelViewMatrix * gl_Vertex;\r
- gl_FrontColor = vec4 (1.0);\r
-\r
- printMESA (_False);\r
- printMESA (_True);\r
- printMESA (_False2);\r
- printMESA (_True2);\r
-\r
- bool False = bool (_False);\r
- bool True = bool (_True);\r
- bool False2 = bool (_False2);\r
- bool True2 = bool (_True2);\r
-\r
- //\r
- // It is important to test each operator with the following argument types:\r
- // * Both arguments are different variables, even if they have the same values.\r
- // False and False2 are distinct attributes, but are the same in value.\r
- // * Both arguments may be the same variables. This case tests possible\r
- // optimizations, e.g. X && X --> X.\r
- // * Both arguments are constant. This tests constant folding.\r
- //\r
-\r
- printMESA (!False);\r
- printMESA (!True);\r
- printMESA (!false);\r
- printMESA (!true);\r
-\r
- printMESA (False ^^ False2);\r
- printMESA (False ^^ True2);\r
- printMESA (True ^^ False2);\r
- printMESA (True ^^ True2);\r
- printMESA (False ^^ False);\r
- printMESA (False ^^ True);\r
- printMESA (True ^^ False);\r
- printMESA (True ^^ True);\r
- printMESA (false ^^ false);\r
- printMESA (false ^^ true);\r
- printMESA (true ^^ false);\r
- printMESA (true ^^ true);\r
-\r
- printMESA (False && False2);\r
- printMESA (False && True2);\r
- printMESA (True && False2);\r
- printMESA (True && True2);\r
- printMESA (False && False);\r
- printMESA (False && True);\r
- printMESA (True && False);\r
- printMESA (True && True);\r
- printMESA (false && false);\r
- printMESA (false && true);\r
- printMESA (true && false);\r
- printMESA (true && true);\r
-\r
- printMESA (False || False2);\r
- printMESA (False || True2);\r
- printMESA (True || False2);\r
- printMESA (True || True2);\r
- printMESA (False || False);\r
- printMESA (False || True);\r
- printMESA (True || False);\r
- printMESA (True || True);\r
- printMESA (false || false);\r
- printMESA (false || true);\r
- printMESA (true || false);\r
- printMESA (true || true);\r
-\r
- //\r
- // Test short-circuit evaluation of && and ||. The right expression evaluation depends\r
- // on the value of the left expression. If the right expression has side effects, we\r
- // can easily test if it happened.\r
- //\r
-\r
- bool x;\r
-\r
- x = false;\r
- printMESA (x);\r
- printMESA (False && (x = true));\r
- printMESA (x);\r
-\r
- x = false;\r
- printMESA (x);\r
- printMESA (false && (x = true));\r
- printMESA (x);\r
-\r
- x = true;\r
- printMESA (x);\r
- printMESA (True || (x = false));\r
- printMESA (x);\r
-\r
- x = true;\r
- printMESA (x);\r
- printMESA (true || (x = false));\r
- printMESA (x);\r
-}\r
-\r
-$output\r
-\r
-0.0\r
-1.0\r
-0.0\r
-1.0\r
-\r
-true\r
-false\r
-true\r
-false\r
-\r
-false\r
-true\r
-true\r
-false\r
-false\r
-true\r
-true\r
-false\r
-false\r
-true\r
-true\r
-false\r
-\r
-false\r
-false\r
-false\r
-true\r
-false\r
-false\r
-false\r
-true\r
-false\r
-false\r
-false\r
-true\r
-\r
-false\r
-true\r
-true\r
-true\r
-false\r
-true\r
-true\r
-true\r
-false\r
-true\r
-true\r
-true\r
-\r
-false\r
-false\r
-false\r
-\r
-false\r
-false\r
-false\r
-\r
-true\r
-true\r
-true\r
-\r
-true\r
-true\r
-true\r
-\r
-\r
-$ /*\r
-$ --------------------------------------------------------------------------------------------------\r
-$ Test subscript operator/array access.\r
-$ */\r
-\r
-$program ARRAY ACCESS TEST\r
-\r
-$attrib gl_Vertex\r
-0.0 0.0 0.0 1.0\r
-\r
-$attrib _Zero\r
-0.0 0.0 0.0 0.0\r
-\r
-$attrib _One\r
-1.1 0.0 0.0 0.0\r
-\r
-$attrib _Two\r
-2.9 0.0 0.0 0.0\r
-\r
-$attrib _Vec\r
-11.11 22.22 33.33 44.44\r
-\r
-$vertex\r
-\r
-$code\r
-\r
-attribute float _Zero;\r
-attribute float _One;\r
-attribute float _Two;\r
-attribute vec4 _Vec;\r
-\r
-void main () {\r
- gl_Position = gl_ModelViewMatrix * gl_Vertex;\r
- gl_FrontColor = vec4 (1.0);\r
-\r
- printMESA (_Zero);\r
- printMESA (_One);\r
- printMESA (_Two);\r
- printMESA (_Vec);\r
-\r
- printMESA (_Vec[0]);\r
- printMESA (_Vec[1]);\r
- printMESA (_Vec[2]);\r
- printMESA (_Vec[3]);\r
-\r
- printMESA (_Vec[int (_Zero)]);\r
- printMESA (_Vec[int (_One)]);\r
- printMESA (_Vec[int (_Two)]);\r
-}\r
-\r
-$output\r
-\r
-0.0\r
-1.1\r
-2.9\r
-11.11\r
-22.22\r
-33.33\r
-44.44\r
-\r
-11.11\r
-22.22\r
-33.33\r
-44.44\r
-\r
-11.11\r
-22.22\r
-33.33\r
-\r
-\r
-$ /*\r
-$ --------------------------------------------------------------------------------------------------\r
-$ Test pre/post-increment/decrement operators.\r
-$ Note: assumes relational operators being correct.\r
-$ */\r
-\r
-$program PRE/POST-INC/DEC OPERATOR TEST\r
-\r
-$attrib gl_Vertex\r
-0.0 0.0 0.0 1.0\r
-\r
-$attrib _Zero\r
-0.0 0.0 0.0 0.0\r
-\r
-$attrib _One\r
-1.1 0.0 0.0 0.0\r
-\r
-$attrib _Two4\r
-2.1 2.2 2.3 2.4\r
-\r
-$vertex\r
-\r
-$code\r
-\r
-attribute float _Zero;\r
-attribute float _One;\r
-attribute vec4 _Two4;\r
-\r
-float fZero, fOne;\r
-vec4 fTwo4;\r
-int iZero, iOne;\r
-ivec4 iTwo4;\r
-\r
-void reset () {\r
- fZero = _Zero;\r
- fOne = _One;\r
- fTwo4 = _Two4;\r
- iZero = int (_Zero);\r
- iOne = int (_One);\r
- iTwo4 = ivec4 (_Two4);\r
-}\r
-\r
-void main () {\r
- gl_Position = gl_ModelViewMatrix * gl_Vertex;\r
- gl_FrontColor = vec4 (1.0);\r
-\r
- printMESA (_Zero);\r
- printMESA (_One);\r
- printMESA (_Two4);\r
-\r
- // pre-increment\r
- reset ();\r
- printMESA (++fZero);\r
- printMESA (++fOne);\r
- printMESA (++iZero);\r
- printMESA (++iOne);\r
- printMESA (fZero);\r
- printMESA (fOne);\r
- printMESA (iZero);\r
- printMESA (iOne);\r
- printMESA (++fTwo4 == _Two4 + 1.0);\r
- printMESA (++iTwo4 == ivec4 (_Two4) + 1);\r
-\r
- // pre-decrement\r
- reset ();\r
- printMESA (--fZero);\r
- printMESA (--fOne);\r
- printMESA (--iZero);\r
- printMESA (--iOne);\r
- printMESA (fZero);\r
- printMESA (fOne);\r
- printMESA (iZero);\r
- printMESA (iOne);\r
- printMESA (--fTwo4 == _Two4 - 1.0);\r
- printMESA (--iTwo4 == ivec4 (_Two4) - 1);\r
-\r
- // post-increment\r
- reset ();\r
- printMESA (fZero++);\r
- printMESA (fOne++);\r
- printMESA (iZero++);\r
- printMESA (iOne++);\r
- printMESA (fZero);\r
- printMESA (fOne);\r
- printMESA (iZero);\r
- printMESA (iOne);\r
- printMESA (fTwo4++ == _Two4);\r
- printMESA (iTwo4++ == ivec4 (_Two4));\r
-\r
- // post-decrement\r
- reset ();\r
- printMESA (fZero--);\r
- printMESA (fOne--);\r
- printMESA (iZero--);\r
- printMESA (iOne--);\r
- printMESA (fZero);\r
- printMESA (fOne);\r
- printMESA (iZero);\r
- printMESA (iOne);\r
- printMESA (fTwo4-- == _Two4);\r
- printMESA (iTwo4-- == ivec4 (_Two4));\r
-}\r
-\r
-$output\r
-\r
-0.0\r
-1.1\r
-2.1\r
-2.2\r
-2.3\r
-2.4\r
-\r
-1.0\r
-2.1\r
-1\r
-2\r
-1.0\r
-2.1\r
-1\r
-2\r
-true\r
-true\r
-\r
--1.0\r
-0.1\r
--1\r
-0\r
--1.0\r
-0.1\r
--1\r
-0\r
-true\r
-true\r
-\r
-0.0\r
-1.1\r
-0\r
-1\r
-1.0\r
-2.1\r
-1\r
-2\r
-true\r
-true\r
-\r
-0.0\r
-1.1\r
-0\r
-1\r
--1.0\r
-0.1\r
--1\r
-0\r
-true\r
-true\r
-\r
-\r
-$ /*\r
-$ --------------------------------------------------------------------------------------------------\r
-$ Test arithmetical operators.\r
-$ */\r
-\r
-$program ARITHMETICAL OPERATOR TEST\r
-\r
-$attrib gl_Vertex\r
-0.0 0.0 0.0 1.0\r
-\r
-$attrib _Zero\r
-0.0 0.0 0.0 0.0\r
-\r
-$attrib _One\r
-1.1 0.0 0.0 0.0\r
-\r
-$attrib _Two4\r
-2.1 2.2 2.3 2.4\r
-\r
-$vertex\r
-\r
-$code\r
-\r
-attribute float _Zero;\r
-attribute float _One;\r
-attribute vec4 _Two4;\r
-\r
-void main () {\r
- gl_Position = gl_ModelViewMatrix * gl_Vertex;\r
- gl_FrontColor = vec4 (1.0);\r
-\r
- printMESA (_Zero);\r
- printMESA (_One);\r
- printMESA (_Two4);\r
-\r
- int iZero = int (_Zero);\r
- int iOne = int (_One);\r
- ivec4 iTwo4 = ivec4 (_Two4);\r
-\r
- printMESA (-_Zero);\r
- printMESA (-_One);\r
- printMESA (-_Two4);\r
- printMESA (-_Two4.z);\r
-\r
- printMESA (_Zero + 0.0);\r
- printMESA (_One + 0.0);\r
- printMESA (_Two4 + 0.0);\r
- printMESA (_Two4.y + 0.0);\r
-\r
- printMESA (_Zero + _Zero);\r
- printMESA (_Zero + _One);\r
- printMESA (_Zero + _Two4);\r
- printMESA (_One + _Zero);\r
- printMESA (_One + _Two4);\r
- printMESA (_Two4 + _Two4);\r
-\r
- printMESA (_Zero - 0.0);\r
- printMESA (_One - 0.0);\r
- printMESA (_Two4 - 0.0);\r
- printMESA (_Two4.y - 0.0);\r
-\r
- printMESA (_Zero - _Zero);\r
- printMESA (_Zero - _One);\r
- printMESA (_Zero - _Two4);\r
- printMESA (_One - _Zero);\r
- printMESA (_One - _Two4);\r
- printMESA (_Two4 - _Two4);\r
-\r
- printMESA (_Zero * 1.0);\r
- printMESA (_One * 1.0);\r
- printMESA (_Two4 * 1.0);\r
- printMESA (_Two4.x * 1.0);\r
-\r
- printMESA (_Zero * _Zero);\r
- printMESA (_Zero * _One);\r
- printMESA (_Zero * _Two4);\r
- printMESA (_One * _Zero);\r
- printMESA (_One * _One);\r
- printMESA (_One * _Two4);\r
- printMESA (_Two4 * _Two4);\r
-\r
- printMESA (_Zero / 1.0);\r
- printMESA (_One / 1.0);\r
- printMESA (_Two4 / 1.0);\r
- printMESA (_Two4.x / 1.0);\r
-\r
- printMESA (_Zero / _One);\r
- printMESA (_Zero / _Two4);\r
- printMESA (_One / _One);\r
- printMESA (_One / _Two4);\r
- printMESA (_Two4 / _Two4);\r
-}\r
-\r
-$output\r
-\r
-0.0\r
-1.1\r
-2.1\r
-2.2\r
-2.3\r
-2.4\r
-\r
-0.0\r
--1.1\r
--2.1\r
--2.2\r
--2.3\r
--2.4\r
--2.3\r
-\r
-0.0\r
-1.1\r
-2.1\r
-2.2\r
-2.3\r
-2.4\r
-2.2\r
-\r
-0.0\r
-1.1\r
-2.1\r
-2.2\r
-2.3\r
-2.4\r
-1.1\r
-3.2\r
-3.3\r
-3.4\r
-3.5\r
-4.2\r
-4.4\r
-4.6\r
-4.8\r
-\r
-0.0\r
-1.1\r
-2.1\r
-2.2\r
-2.3\r
-2.4\r
-2.2\r
-\r
-0.0\r
--1.1\r
--2.1\r
--2.2\r
--2.3\r
--2.4\r
-1.1\r
--1.0\r
--1.1\r
--1.2\r
--1.3\r
-0.0\r
-0.0\r
-0.0\r
-0.0\r
-\r
-0.0\r
-1.1\r
-2.1\r
-2.2\r
-2.3\r
-2.4\r
-2.1\r
-\r
-0.0\r
-0.0\r
-0.0\r
-0.0\r
-0.0\r
-0.0\r
-0.0\r
-1.21\r
-2.31\r
-2.42\r
-2.53\r
-2.64\r
-4.41\r
-4.84\r
-5.29\r
-5.76\r
-\r
-0.0\r
-1.1\r
-2.1\r
-2.2\r
-2.3\r
-2.4\r
-2.1\r
-\r
-0.0\r
-0.0\r
-0.0\r
-0.0\r
-0.0\r
-1.0\r
-0.52381\r
-0.5\r
-0.47826\r
-0.45833\r
-1.0\r
-1.0\r
-1.0\r
-1.0\r
-\r
-\r
-$ /*\r
-$ --------------------------------------------------------------------------------------------------\r
-$ Test matrix operations.\r
-$ Note: assumes relational operators being correct.\r
-$ */\r
-\r
-$program MATRIX TEST\r
-\r
-$attrib gl_Vertex\r
-0.0 0.0 0.0 1.0\r
-\r
-$attrib _Zero\r
-0.0 0.0 0.0 0.0\r
-\r
-$attrib _One\r
-1.0 1.0 1.0 1.0\r
-\r
-$attrib _Two\r
-2.0 2.0 2.0 2.0\r
-\r
-$vertex\r
-\r
-$code\r
-\r
-attribute vec4 _Zero;\r
-attribute vec4 _One;\r
-attribute vec4 _Two;\r
-\r
-void main () {\r
- gl_Position = gl_ModelViewMatrix * gl_Vertex;\r
- gl_FrontColor = vec4 (1.0);\r
-\r
- printMESA (_Zero);\r
- printMESA (_One);\r
- printMESA (_Two);\r
-\r
- mat4 Identity = mat4 (_One.x);\r
-\r
- printMESA (Identity == mat4 (1.0, 0.0, 0.0, 0.0,\r
- 0.0, 1.0, 0.0, 0.0,\r
- 0.0, 0.0, 1.0, 0.0,\r
- 0.0, 0.0, 0.0, 1.0));\r
- printMESA (Identity * _Two == _Two);\r
-\r
- mat4 Matrix = mat4 (1.1, 1.2, 1.3, 1.4,\r
- 2.1, 2.2, 2.3, 2.4,\r
- 3.1, 3.2, 3.3, 3.4,\r
- 4.1, 4.2, 4.3, 4.4);\r
-\r
- printMESA (Matrix[2].y);\r
- printMESA (Matrix[1]);\r
-}\r
-\r
-$output\r
-\r
-0.0\r
-0.0\r
-0.0\r
-0.0\r
-1.0\r
-1.0\r
-1.0\r
-1.0\r
-2.0\r
-2.0\r
-2.0\r
-2.0\r
-true\r
-true\r
-3.2\r
-2.1\r
-2.2\r
-2.3\r
-2.4\r
-\r
+$ /*
+$ 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
+