$ /*
$ 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
#version 110
#extension MESA_shader_debug: require
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
#version 110
#extension MESA_shader_debug: require
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
#version 110
#extension MESA_shader_debug: require
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
#version 110
#extension MESA_shader_debug: require
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);
评论0