1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.0 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief GLES3 shader constant expression tests
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es3fShaderConstExprTests.hpp"
25 
26 #include "glsShaderLibrary.hpp"
27 #include "glsShaderConstExprTests.hpp"
28 
29 #include "tcuStringTemplate.hpp"
30 #include "gluShaderUtil.hpp"
31 
32 #include "deStringUtil.hpp"
33 #include "deMath.h"
34 
35 namespace deqp
36 {
37 namespace gles3
38 {
39 namespace Functional
40 {
41 
42 // builtins
43 class ShaderConstExprBuiltinTests : public TestCaseGroup
44 {
45 public:
ShaderConstExprBuiltinTests(Context & context)46 				ShaderConstExprBuiltinTests		(Context& context) : TestCaseGroup (context, "builtin_functions", "Builtin functions") {}
~ShaderConstExprBuiltinTests(void)47 	virtual		~ShaderConstExprBuiltinTests	(void) {}
48 
49 	void		init							(void);
50 
51 	void		addChildGroup					(const char* name, const char* desc, const gls::ShaderConstExpr::TestParams* cases, int numCases);
52 };
53 
addChildGroup(const char * name,const char * desc,const gls::ShaderConstExpr::TestParams * cases,int numCases)54 void ShaderConstExprBuiltinTests::addChildGroup (const char* name, const char* desc, const gls::ShaderConstExpr::TestParams* cases, int numCases)
55 {
56 	const std::vector<tcu::TestNode*>	children = createTests(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), cases, numCases, glu::GLSL_VERSION_300_ES);
57 	tcu::TestCaseGroup*					group	 = new tcu::TestCaseGroup(m_testCtx, name, desc);
58 
59 	addChild(group);
60 
61 	for (int i = 0; i < (int)children.size(); i++)
62 		group->addChild(children[i]);
63 }
64 
init(void)65 void ShaderConstExprBuiltinTests::init (void)
66 {
67 	using namespace gls::ShaderConstExpr;
68 
69 	// ${T} => final type, ${MT} => final type but with scalar version usable even when T is a vector
70 
71 	// Trigonometry
72 	{
73 		const TestParams cases[] =
74 		{
75 			{"radians",			"radians(${T} (90.0))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatRadians(90.0f)		},
76 			{"degrees",			"degrees(${T} (2.0))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatDegrees(2.0f)		},
77 			{"sin",				"sin(${T} (3.0))",										glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatSin(3.0f)			},
78 			{"cos",				"cos(${T} (3.2))",										glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatCos(3.2f)			},
79 			{"tan",				"tan(${T} (1.5))",										glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatTan(1.5f)			},
80 			{"asin",			"asin(${T} (0.0))",										glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatAsin(0.0f)			},
81 			{"acos",			"acos(${T} (1.0))",										glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatAcos(1.0f)			},
82 			{"atan_separate",	"atan(${T} (-1.0), ${T} (-1.0))",						glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatAtan2(-1.0f, -1.0f)	},
83 			{"atan_combined",	"atan(${T} (2.0))",										glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatAtanOver(2.0f)		},
84 			{"sinh",			"sinh(${T} (1.5))",										glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatSinh(1.5f)			},
85 			{"cosh",			"cosh(${T} (1.5))",										glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatCosh(1.5f)			},
86 			{"tanh",			"tanh(${T} (1.5))",										glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatTanh(1.5f)			},
87 			{"asinh",			"asinh(${T} (2.0))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatAsinh(2.0f)			},
88 			{"acosh",			"acosh(${T} (2.0))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatAcosh(2.0f)			},
89 			{"atanh",			"atanh(${T} (0.8))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatAtanh(0.8f)			},
90 		};
91 
92 		addChildGroup("angle_and_trigonometry", "Angles and Trigonometry", cases, DE_LENGTH_OF_ARRAY(cases));
93 	}
94 	// Exponential
95 	{
96 		const TestParams cases[] =
97 		{
98 			{"pow",				"pow(${T} (1.7), ${T} (3.5))",							glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatPow(1.7f, 3.5f)		},
99 			{"exp",				"exp(${T} (4.2))",										glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatExp(4.2f)			},
100 			{"log",				"log(${T} (42.12))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatLog(42.12f)			},
101 			{"exp2",			"exp2(${T} (6.7))",										glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatExp2(6.7f)			},
102 			{"log2",			"log2(${T} (100.0))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatLog2(100.0f)			},
103 			{"sqrt",			"sqrt(${T} (10.0))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatSqrt(10.0f)			},
104 			{"inversesqrt",		"inversesqrt(${T} (10.0))",								glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatRsq(10.0f)			},
105 		};
106 
107 		addChildGroup("exponential", "Exponential", cases, DE_LENGTH_OF_ARRAY(cases));
108 	}
109 	// Common
110 	{
111 		const TestParams cases[] =
112 		{
113 			{"abs",				"abs(${T} (-42.0))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, 42.0f						},
114 			{"abs",				"abs(${T} (-42))",										glu::TYPE_INT,   1, 4, glu::TYPE_INT,   42.0f						},
115 			{"sign",			"sign(${T} (-18.0))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, -1.0f						},
116 			{"sign",			"sign(${T} (-18))",										glu::TYPE_INT,   1, 4, glu::TYPE_INT,	-1.0f						},
117 			{"floor",			"floor(${T} (37.3))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatFloor(37.3f)			},
118 			{"trunc",			"trunc(${T} (-1.8))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, -1.0f						},
119 			{"round",			"round(${T} (42.7))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, 42.0f						},
120 			{"roundEven",		"roundEven(${T} (1.5))",								glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT,  2.0f						},
121 			{"ceil",			"ceil(${T} (82.2))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatCeil(82.2f)			},
122 			{"fract",			"fract(${T} (17.75))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatFrac(17.75f)			},
123 			{"mod",				"mod(${T} (87.65), ${MT} (3.7))",						glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, deFloatMod(87.65f, 3.7f)	},
124 			// modf cannot be tested due to lacking valid ways of using the 'out' parameter in a constant expression
125 			{"min",				"min(${T} (12.3), ${MT} (32.1))",						glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, 12.3f						},
126 			{"min",				"min(${T} (13), ${MT} (-14))",							glu::TYPE_INT,   1, 4, glu::TYPE_INT,  -14.0f						},
127 			{"min",				"min(${T} (13), ${MT} (14))",							glu::TYPE_UINT,  1, 4, glu::TYPE_UINT,	13.0f						},
128 			{"max",				"max(${T} (12.3), ${MT} (32.1))",						glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, 32.1f						},
129 			{"max",				"max(${T} (13), ${MT} (-14))",							glu::TYPE_INT,   1, 4, glu::TYPE_INT,	13.0f						},
130 			{"max",				"max(${T} (13), ${MT} (14))",							glu::TYPE_UINT,  1, 4, glu::TYPE_UINT,	14.0f						},
131 			{"clamp",			"clamp(${T} (42.1),	${MT} (10.0), ${MT} (15.0))",		glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, 15.0f						},
132 			{"clamp",			"clamp(${T} (42), ${MT} (-10), ${MT} (15))",			glu::TYPE_INT,   1, 4, glu::TYPE_INT,	15.0f						},
133 			{"clamp",			"clamp(${T} (42), ${MT} (10), ${MT} (15))",				glu::TYPE_UINT,  1, 4, glu::TYPE_UINT,	15.0f						},
134 
135 			{"mix",				"mix(${T} (10.0), ${T} (20.0), ${MT}(0.75))",			glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, 17.5f						},
136 			{"mix_float_bool",	"mix(float(10.0), float(20.0), bool(1))",				glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 20.0f						},
137 			{"mix_vec2_bvec2",	"mix(vec2(10.0), vec2(20.0), bvec2(1)).x",				glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 20.0f						},
138 			{"mix_vec3_bvec3",	"mix(vec3(10.0), vec3(20.0), bvec3(1)).x",				glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 20.0f						},
139 			{"mix_vec4_bvec4",	"mix(vec4(10.0), vec4(20.0), bvec4(1)).x",				glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 20.0f						},
140 
141 			{"step",			"step(${MT} (3.2), ${T} (4.2))",						glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, 1.0f						},
142 			{"smoothstep",		"smoothstep(${MT} (3.0), ${MT} (5.0), ${T} (4.0))",		glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, 0.5f						},
143 			{"isnan",			"isnan(${T} (1.3))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_BOOL,  0.0f						},
144 			{"isinf",			"isinf(${T} (1.3))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_BOOL,  0.0f						},
145 			{"floatbits_int",	"intBitsToFloat(floatBitsToInt(42.12))",				glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 42.12f						},
146 			{"floatbits_uint",	"uintBitsToFloat(floatBitsToUint(-14.2))",				glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, -14.2f						},
147 		};
148 
149 		addChildGroup("common", "Common", cases, DE_LENGTH_OF_ARRAY(cases));
150 	}
151 	// Floating point pack & unpack
152 	{
153 		const TestParams cases[] =
154 		{
155 			{"packSnorm2x16",	"packSnorm2x16(vec2(0.7, 0.0))",						glu::TYPE_FLOAT, 1, 1, glu::TYPE_UINT,  22937.0f					},
156 			{"unpackSnorm2x16",	"unpackSnorm2x16(22937u).x",							glu::TYPE_UINT,  1, 1, glu::TYPE_FLOAT, 0.7f						},
157 			{"packUnorm2x16",	"packUnorm2x16(vec2(0.6, -0.3))",						glu::TYPE_FLOAT, 1, 1, glu::TYPE_UINT,	39321.0f					},
158 			{"unpackUnorm2x16",	"unpackUnorm2x16(39321u).x",							glu::TYPE_UINT,  1, 1, glu::TYPE_FLOAT, 0.6f						},
159 			{"packHalf2x16",	"unpackHalf2x16(packHalf2x16(vec2(0.3, 0.1))).x",		glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 0.3f						},
160 			// \todo [2014-01-29 otto] Separate testing of half-precision pack & unpack
161 		};
162 
163 		addChildGroup("float_pack_unpack", "Floating point pack & unpack", cases, DE_LENGTH_OF_ARRAY(cases));
164 	}
165 	// Geometric
166 	{
167 		const TestParams cases[] =
168 		{
169 			{"length_float",	"length(1.0)",											glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 1.0f						},
170 			{"length_vec2",		"length(vec2(1.0))",									glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, deFloatSqrt(2.0f)			},
171 			{"length_vec3",		"length(vec3(1.0))",									glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, deFloatSqrt(3.0f)			},
172 			{"length_vec4",		"length(vec4(1.0))",									glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, deFloatSqrt(4.0f)			},
173 
174 			{"distance_float",	"distance(1.0, 2.0)",									glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 1.0f						},
175 			{"distance_vec2",	"distance(vec2(1.0), vec2(2.0))",						glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, deFloatSqrt(2.0f)			},
176 			{"distance_vec3",	"distance(vec3(1.0), vec3(2.0))",						glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, deFloatSqrt(3.0f)			},
177 			{"distance_vec4",	"distance(vec4(1.0), vec4(2.0))",						glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, deFloatSqrt(4.0f)			},
178 
179 			{"dot_float",		"dot(1.0, 1.0)",										glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 1.0f						},
180 			{"dot_vec2",		"dot(vec2(1.0), vec2(1.0))",							glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 2.0f						},
181 			{"dot_vec3",		"dot(vec3(1.0), vec3(1.0))",							glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 3.0f						},
182 			{"dot_vec4",		"dot(vec4(1.0), vec4(1.0))",							glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 4.0f						},
183 
184 			{"normalize_float",	"normalize(1.0)",										glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 1.0f						},
185 			{"normalize_vec2",	"normalize(vec2(1.0)).x",								glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, deFloatRsq(2.0f)			},
186 			{"normalize_vec3",	"normalize(vec3(1.0)).x",								glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, deFloatRsq(3.0f)			},
187 			{"normalize_vec4",	"normalize(vec4(1.0)).x",								glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, deFloatRsq(4.0f)			},
188 
189 			{"faceforward",		"faceforward(${T} (1.0), ${T} (1.0), ${T} (1.0))",		glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, -1.0f						},
190 
191 			// reflect(I, N) => I - 2*dot(N, I)*N
192 			{"reflect_float",	"reflect(1.0, 1.0)",									glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, -1.0f						},
193 			{"reflect_vec2",	"reflect(vec2(1.0), vec2(1.0, 0.0)).x",					glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, -1.0f						},
194 			{"reflect_vec3",	"reflect(vec3(1.0), vec3(1.0, 0.0, 0.0)).x",			glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, -1.0f						},
195 			{"reflect_vec4",	"reflect(vec4(1.0), vec4(1.0, 0.0, 0.0, 0.0)).x",		glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, -1.0f						},
196 
197 			/*
198 			genType refract(genType I, genType N, float eta) =>
199 				k = 1.0 - (eta^2)*(1.0-dot(N,I)^2)
200 				if k < 0 return 0.0
201 				else return eta*I - (eta*dot(N,I) + sqrt(k))*N
202 			*/
203 			{"refract_float",	"refract(1.0, 1.0, 0.5)",								glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, -1.0f						},
204 			{"refract_vec2",	"refract(vec2(1.0), vec2(1.0, 0.0), 0.5).x",			glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, -1.0f						},
205 			{"refract_vec3",	"refract(vec3(1.0), vec3(1.0, 0.0, 0.0), 0.5).x",		glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, -1.0f						},
206 			{"refract_vec4",	"refract(vec4(1.0), vec4(1.0, 0.0, 0.0, 0.0), 0.5).x",	glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, -1.0f						},
207 		};
208 
209 		addChildGroup("geometric", "Geometric", cases, DE_LENGTH_OF_ARRAY(cases));
210 	}
211 	// Matrix
212 	{
213 		const TestParams cases[] =
214 		{
215 			{"compMult_mat2",	"matrixCompMult(mat2(1.0), mat2(1.0))[0][0]",			glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 1.0f						},
216 			{"compMult_mat3",	"matrixCompMult(mat3(1.0), mat3(1.0))[0][0]",			glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 1.0f						},
217 			{"compMult_mat4",	"matrixCompMult(mat4(1.0), mat4(1.0))[0][0]",			glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 1.0f						},
218 			{"outerProd_mat2",	"outerProduct(vec2(3.0), vec2(3.0))[0][0]",				glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 9.0f						},
219 			{"outerProd_mat3",	"outerProduct(vec3(3.0), vec3(3.0))[0][0]",				glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 9.0f						},
220 			{"outerProd_mat4",	"outerProduct(vec4(3.0), vec4(3.0))[0][0]",				glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 9.0f						},
221 
222 			{"outerProd_mat2x3","outerProduct(vec3(3.0), vec2(3.0))[0][0]",				glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 9.0f						},
223 			{"outerProd_mat3x2","outerProduct(vec2(3.0), vec3(3.0))[0][0]",				glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 9.0f						},
224 			{"outerProd_mat2x4","outerProduct(vec4(3.0), vec2(3.0))[0][0]",				glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 9.0f						},
225 			{"outerProd_mat4x2","outerProduct(vec2(3.0), vec4(3.0))[0][0]",				glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 9.0f						},
226 			{"outerProd_mat3x4","outerProduct(vec4(3.0), vec3(3.0))[0][0]",				glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 9.0f						},
227 			{"outerProd_mat4x3","outerProduct(vec3(3.0), vec4(3.0))[0][0]",				glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 9.0f						},
228 
229 			{"transpose_mat2",	"transpose(mat2(2.0))[0][0]",							glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 2.0f						},
230 			{"transpose_mat3",	"transpose(mat3(2.0))[0][0]",							glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 2.0f						},
231 			{"transpose_mat4",	"transpose(mat4(2.0))[0][0]",							glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 2.0f						},
232 			{"transpose_mat3x2","transpose(mat3x2(2.3))[0][0]",							glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 2.3f						},
233 			{"transpose_mat2x3","transpose(mat2x3(2.3))[0][0]",							glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 2.3f						},
234 			{"transpose_mat4x2","transpose(mat4x2(2.3))[0][0]",							glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 2.3f						},
235 			{"transpose_mat4x3","transpose(mat4x3(2.3))[0][0]",							glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 2.3f						},
236 			{"transpose_mat2x4","transpose(mat2x4(2.3))[0][0]",							glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 2.3f						},
237 			{"transpose_mat3x4","transpose(mat3x4(2.3))[0][0]",							glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 2.3f						},
238 
239 			{"determinant_mat2","determinant(mat2(2.0))",								glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 4.0f						},
240 			{"determinant_mat3","determinant(mat3(2.0))",								glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 8.0f						},
241 			{"determinant_mat4","determinant(mat4(2.0))",								glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 16.0f						},
242 
243 			{"inverse_mat2",	"inverse(mat2(2.0))[0][0]",								glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 0.5f						},
244 			{"inverse_mat3",	"inverse(mat3(2.0))[0][0]",								glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 0.5f						},
245 			{"inverse_mat4",	"inverse(mat4(2.0))[0][0]",								glu::TYPE_FLOAT, 1, 1, glu::TYPE_FLOAT, 0.5f						},
246 		};
247 
248 		addChildGroup("matrix", "Matrix", cases, DE_LENGTH_OF_ARRAY(cases));
249 	}
250 	// Vector relational
251 	{
252 		const TestParams cases[] =
253 		{
254 			{"lessThan",		"lessThan(${T} (1.0), ${T} (2.0))",						glu::TYPE_FLOAT, 2, 4, glu::TYPE_BOOL,  1.0f						},
255 			{"lessThan",		"lessThan(${T} (-1), ${T} (2))",						glu::TYPE_INT,   2, 4, glu::TYPE_BOOL,  1.0f						},
256 			{"lessThan",		"lessThan(${T} (1), ${T} (2))",							glu::TYPE_UINT,  2, 4, glu::TYPE_BOOL,  1.0f						},
257 			{"lessThanEqual",	"lessThanEqual(${T} (1.0), ${T} (1.0))",				glu::TYPE_FLOAT, 2, 4, glu::TYPE_BOOL,  1.0f						},
258 			{"lessThanEqual",	"lessThanEqual(${T} (-1), ${T} (-1))",					glu::TYPE_INT,   2, 4, glu::TYPE_BOOL,  1.0f						},
259 			{"lessThanEqual",	"lessThanEqual(${T} (1), ${T} (1))",					glu::TYPE_UINT,  2, 4, glu::TYPE_BOOL,  1.0f						},
260 			{"greaterThan",		"greaterThan(${T} (1.0), ${T} (2.0))",					glu::TYPE_FLOAT, 2, 4, glu::TYPE_BOOL,  0.0f						},
261 			{"greaterThan",		"greaterThan(${T} (-1), ${T} (2))",						glu::TYPE_INT,   2, 4, glu::TYPE_BOOL,  0.0f						},
262 			{"greaterThan",		"greaterThan(${T} (1), ${T} (2))",						glu::TYPE_UINT,  2, 4, glu::TYPE_BOOL,  0.0f						},
263 			{"greaterThanEqual","greaterThanEqual(${T} (1.0), ${T} (2.0))",				glu::TYPE_FLOAT, 2, 4, glu::TYPE_BOOL,  0.0f						},
264 			{"greaterThanEqual","greaterThanEqual(${T} (-1), ${T} (2))",				glu::TYPE_INT,   2, 4, glu::TYPE_BOOL,  0.0f						},
265 			{"greaterThanEqual","greaterThanEqual(${T} (1), ${T} (2))",					glu::TYPE_UINT,  2, 4, glu::TYPE_BOOL,  0.0f						},
266 			{"equal",			"equal(${T} (1.0), ${T} (1.2))",						glu::TYPE_FLOAT, 2, 4, glu::TYPE_BOOL,  0.0f						},
267 			{"equal",			"equal(${T} (1), ${T} (-2))",							glu::TYPE_INT,   2, 4, glu::TYPE_BOOL,  0.0f						},
268 			{"equal",			"equal(${T} (1), ${T} (2))",							glu::TYPE_UINT,  2, 4, glu::TYPE_BOOL,  0.0f						},
269 			{"equal",			"equal(${T} (true), ${T} (false))",						glu::TYPE_BOOL,  2, 4, glu::TYPE_BOOL,  0.0f						},
270 			{"notEqual",		"notEqual(${T} (1.0), ${T} (1.2))",						glu::TYPE_FLOAT, 2, 4, glu::TYPE_BOOL,  1.0f						},
271 			{"notEqual",		"notEqual(${T} (1), ${T} (-2))",						glu::TYPE_INT,   2, 4, glu::TYPE_BOOL,  1.0f						},
272 			{"notEqual",		"notEqual(${T} (1), ${T} (2))",							glu::TYPE_UINT,  2, 4, glu::TYPE_BOOL,  1.0f						},
273 			{"notEqual",		"notEqual(${T} (true), ${T} (false))",					glu::TYPE_BOOL,  2, 4, glu::TYPE_BOOL,  1.0f						},
274 			{"any_bvec2",		"any(bvec2(true, false))",								glu::TYPE_BOOL,  1, 1, glu::TYPE_BOOL,  1.0f						},
275 			{"any_bvec3",		"any(bvec3(true, false, false))",						glu::TYPE_BOOL,  1, 1, glu::TYPE_BOOL,  1.0f						},
276 			{"any_bvec4",		"any(bvec4(true, false, false, false))",				glu::TYPE_BOOL,  1, 1, glu::TYPE_BOOL,  1.0f						},
277 			{"all_bvec2",		"all(bvec2(true, false))",								glu::TYPE_BOOL,  1, 1, glu::TYPE_BOOL,  0.0f						},
278 			{"all_bvec3",		"all(bvec3(true, false, false))",						glu::TYPE_BOOL,  1, 1, glu::TYPE_BOOL,  0.0f						},
279 			{"all_bvec4",		"all(bvec4(true, false, false, false))",				glu::TYPE_BOOL,  1, 1, glu::TYPE_BOOL,  0.0f						},
280 			{"not",				"not(${T} (false))",									glu::TYPE_BOOL,  2, 4, glu::TYPE_BOOL,  1.0f						},
281 		};
282 
283 		addChildGroup("vector_relational", "Vector relational", cases, DE_LENGTH_OF_ARRAY(cases));
284 	}
285 	// Fragment processing (must return zero when used in initilizer with constexpr arguement)
286 	{
287 		const TestParams cases[] =
288 		{
289 			{"dFdx",			"dFdx(${T} (123.0))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, 0.0							},
290 			{"dFdy",			"dFdx(${T} (234.0))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, 0.0							},
291 			{"fwidth",			"fwidth(${T} (345.0))",									glu::TYPE_FLOAT, 1, 4, glu::TYPE_FLOAT, 0.0							},
292 		};
293 
294 		const std::vector<tcu::TestNode*>	children = createTests(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), cases, DE_LENGTH_OF_ARRAY(cases), glu::GLSL_VERSION_300_ES, SHADER_FRAGMENT);
295 		tcu::TestCaseGroup*					group	 = new tcu::TestCaseGroup(m_testCtx, "fragment_processing", "Fragment processing");
296 
297 		addChild(group);
298 
299 		for (int i = 0; i < (int)children.size(); i++)
300 			group->addChild(children[i]);
301 	}
302 }
303 
304 // all
ShaderConstExprTests(Context & context)305 ShaderConstExprTests::ShaderConstExprTests (Context& context)
306 	: TestCaseGroup	(context, "constant_expressions", "Constant expressions")
307 {
308 }
309 
~ShaderConstExprTests(void)310 ShaderConstExprTests::~ShaderConstExprTests (void)
311 {
312 }
313 
init(void)314 void ShaderConstExprTests::init (void)
315 {
316 	const std::vector<tcu::TestNode*> children = gls::ShaderLibrary(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo()).loadShaderFile("shaders/constant_expressions.test");
317 
318 	for (int i = 0; i < (int)children.size(); i++)
319 		addChild(children[i]);
320 
321 	addChild(new ShaderConstExprBuiltinTests(m_context));
322 }
323 
324 } // Functional
325 } // gles3
326 } // deqp
327