• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * OpenGL Conformance Test Suite
3  * -----------------------------
4  *
5  * Copyright (c) 2014-2016 The Khronos Group Inc.
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
22  */ /*-------------------------------------------------------------------*/
23 
24 #include "es31cShaderBitfieldOperationTests.hpp"
25 #include "deMath.h"
26 #include "deRandom.hpp"
27 #include "deString.h"
28 #include "deStringUtil.hpp"
29 #include "deFloat16.h"
30 #include "gluContextInfo.hpp"
31 #include "gluDrawUtil.hpp"
32 #include "gluPixelTransfer.hpp"
33 #include "gluShaderProgram.hpp"
34 #include "glw.h"
35 #include "glwFunctions.hpp"
36 #include "tcuCommandLine.hpp"
37 #include "tcuStringTemplate.hpp"
38 #include "tcuSurface.hpp"
39 #include "tcuTestLog.hpp"
40 
41 namespace glcts
42 {
43 
44 using tcu::TestLog;
45 using std::string;
46 using std::vector;
47 using glcts::Context;
48 
specializeVersion(const std::string & source,glu::GLSLVersion version,const char * testStatement)49 static std::string specializeVersion(const std::string& source, glu::GLSLVersion version, const char* testStatement)
50 {
51 	DE_ASSERT(version == glu::GLSL_VERSION_310_ES || version >= glu::GLSL_VERSION_430);
52 	std::map<std::string, std::string> args;
53 	args["VERSION_DECL"]   = glu::getGLSLVersionDeclaration(version);
54 	args["TEST_STATEMENT"] = testStatement;
55 	return tcu::StringTemplate(source.c_str()).specialize(args);
56 }
57 
58 struct Data
59 {
Dataglcts::Data60 	Data()
61 	{
62 		memset(this, 0, sizeof *this);
63 	}
Dataglcts::Data64 	Data(Data const& init)
65 	{
66 		memcpy(this, &init, sizeof *this);
67 	}
68 
69 	GLuint  inUvec4[4];
70 	GLint   inIvec4[4];
71 	GLfloat inVec4[4];
72 
73 	GLuint  in2Uvec4[4];
74 	GLint   in2Ivec4[4];
75 	GLfloat in2Vec4[4];
76 
77 	GLint offset;
78 	GLint bits;
79 	GLint padding[2];
80 
81 	GLuint  outUvec4[4];
82 	GLint   outIvec4[4];
83 	GLfloat outVec4[4];
84 
85 	GLuint  out2Uvec4[4];
86 	GLint   out2Ivec4[4];
87 	GLfloat out2Vec4[4];
88 };
89 
90 struct Uvec4 : public Data
91 {
Uvec4glcts::Uvec492 	Uvec4(GLuint x = 0, GLuint y = 0, GLuint z = 0, GLuint w = 0)
93 	{
94 		inUvec4[0] = x;
95 		inUvec4[1] = y;
96 		inUvec4[2] = z;
97 		inUvec4[3] = w;
98 	}
99 };
100 
101 struct Ivec4 : public Data
102 {
Ivec4glcts::Ivec4103 	Ivec4(GLint x = 0, GLint y = 0, GLint z = 0, GLint w = 0)
104 	{
105 		inIvec4[0] = x;
106 		inIvec4[1] = y;
107 		inIvec4[2] = z;
108 		inIvec4[3] = w;
109 	}
110 };
111 
112 struct Vec4 : public Data
113 {
Vec4glcts::Vec4114 	Vec4(GLfloat x = 0.0f, GLfloat y = 0.0f, GLfloat z = 0.0f, GLfloat w = 0.0f)
115 	{
116 		inVec4[0] = x;
117 		inVec4[1] = y;
118 		inVec4[2] = z;
119 		inVec4[3] = w;
120 	}
121 };
122 
123 class ShaderBitfieldOperationCase : public TestCase
124 {
125 public:
126 	ShaderBitfieldOperationCase(Context& context, const char* name, const char* description,
127 								glu::GLSLVersion glslVersion, Data const& data, char const* testStatement);
128 	~ShaderBitfieldOperationCase();
129 
130 	IterateResult iterate();
131 
132 protected:
133 	glu::GLSLVersion m_glslVersion;
134 	Data			 m_data;
135 	std::string		 m_testStatement;
136 
137 	virtual bool test(Data const* data) = 0;
138 };
139 
ShaderBitfieldOperationCase(Context & context,const char * name,const char * description,glu::GLSLVersion glslVersion,Data const & data,char const * testStatement)140 ShaderBitfieldOperationCase::ShaderBitfieldOperationCase(Context& context, const char* name, const char* description,
141 														 glu::GLSLVersion glslVersion, Data const& data,
142 														 char const* testStatement)
143 	: TestCase(context, name, description), m_glslVersion(glslVersion), m_data(data), m_testStatement(testStatement)
144 {
145 	DE_ASSERT(glslVersion == glu::GLSL_VERSION_310_ES || glslVersion >= glu::GLSL_VERSION_430);
146 }
147 
~ShaderBitfieldOperationCase()148 ShaderBitfieldOperationCase::~ShaderBitfieldOperationCase()
149 {
150 }
151 
iterate()152 ShaderBitfieldOperationCase::IterateResult ShaderBitfieldOperationCase::iterate()
153 {
154 	const glw::Functions& gl   = m_context.getRenderContext().getFunctions();
155 	bool				  isOk = true;
156 
157 	GLuint data;
158 	gl.genBuffers(1, &data);
159 	gl.bindBuffer(GL_SHADER_STORAGE_BUFFER, data);
160 	gl.bufferData(GL_SHADER_STORAGE_BUFFER, sizeof(Data), &m_data, GL_STATIC_DRAW);
161 	gl.bindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, data);
162 
163 	char const* css = "${VERSION_DECL}\n"
164 					  "\n"
165 					  "layout(local_size_x = 1) in;\n"
166 					  "\n"
167 					  "layout(binding = 0, std430) buffer Data {\n"
168 					  "    uvec4 inUvec4;\n"
169 					  "    ivec4 inIvec4;\n"
170 					  "    vec4 inVec4;\n"
171 					  "\n"
172 					  "    uvec4 in2Uvec4;\n"
173 					  "    ivec4 in2Ivec4;\n"
174 					  "    vec4 in2Vec4;\n"
175 					  "\n"
176 					  "    int offset;\n"
177 					  "    int bits;\n"
178 					  "\n"
179 					  "    uvec4 outUvec4;\n"
180 					  "    ivec4 outIvec4;\n"
181 					  "    vec4 outVec4;\n"
182 					  "\n"
183 					  "    uvec4 out2Uvec4;\n"
184 					  "    ivec4 out2Ivec4;\n"
185 					  "    vec4 out2Vec4;\n"
186 					  "};\n"
187 					  "\n"
188 					  "void main()\n"
189 					  "{\n"
190 					  "    ${TEST_STATEMENT};\n"
191 					  "}\n";
192 
193 	GLuint		cs		   = gl.createShader(GL_COMPUTE_SHADER);
194 	std::string csString   = specializeVersion(css, m_glslVersion, m_testStatement.c_str());
195 	char const* strings[1] = { csString.c_str() };
196 	gl.shaderSource(cs, 1, strings, 0);
197 	gl.compileShader(cs);
198 	GLint compileSuccess = 0;
199 	gl.getShaderiv(cs, GL_COMPILE_STATUS, &compileSuccess);
200 	if (!compileSuccess)
201 	{
202 		TCU_FAIL("Compile failed");
203 	}
204 
205 	GLuint pgm = gl.createProgram();
206 	gl.attachShader(pgm, cs);
207 	gl.linkProgram(pgm);
208 	GLint linkSuccess = 0;
209 	gl.getProgramiv(pgm, GL_LINK_STATUS, &linkSuccess);
210 	if (!linkSuccess)
211 	{
212 		gl.deleteShader(cs);
213 		TCU_FAIL("Link failed");
214 	}
215 
216 	gl.useProgram(pgm);
217 
218 	gl.dispatchCompute(1, 1, 1);
219 
220 	Data const* results = (Data const*)gl.mapBufferRange(GL_SHADER_STORAGE_BUFFER, 0, sizeof(Data), GL_MAP_READ_BIT);
221 	isOk				= test(results);
222 	gl.unmapBuffer(GL_SHADER_STORAGE_BUFFER);
223 
224 	gl.useProgram(0);
225 	gl.deleteProgram(pgm);
226 	gl.deleteShader(cs);
227 
228 	gl.deleteBuffers(1, &data);
229 
230 	m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL, isOk ? "Pass" : "Fail");
231 	return STOP;
232 }
233 
234 class ShaderBitfieldOperationCaseFrexp : public ShaderBitfieldOperationCase
235 {
236 public:
ShaderBitfieldOperationCaseFrexp(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,int components,char const * testStatement)237 	ShaderBitfieldOperationCaseFrexp(Context& context, const char* name, glu::GLSLVersion glslVersion, Data const& data,
238 									 int components, char const* testStatement)
239 		: ShaderBitfieldOperationCase(context, name, "", glslVersion, data, testStatement), m_components(components)
240 	{
241 	}
242 
243 private:
244 	int m_components;
245 
test(Data const * data)246 	virtual bool test(Data const* data)
247 	{
248 		for (int i = 0; i < m_components; ++i)
249 		{
250 			if (data->inVec4[i] == 0.0)
251 			{
252 				if (data->outVec4[i] != 0.0 || data->outIvec4[i] != 0)
253 				{
254 					return false;
255 				}
256 			}
257 			else if (deFloatAbs(data->outVec4[i]) < 0.5 || deFloatAbs(data->outVec4[i]) >= 1.0)
258 			{
259 				return false;
260 			}
261 
262 			float result = data->outVec4[i] * deFloatPow(2.0, (float)data->outIvec4[i]);
263 			if (deFloatAbs(result - data->inVec4[i]) > 0.0001f)
264 			{
265 				return false;
266 			}
267 		}
268 		return true;
269 	}
270 };
271 
272 class ShaderBitfieldOperationCaseFrexpFloat : public ShaderBitfieldOperationCaseFrexp
273 {
274 public:
ShaderBitfieldOperationCaseFrexpFloat(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data)275 	ShaderBitfieldOperationCaseFrexpFloat(Context& context, const char* name, glu::GLSLVersion glslVersion,
276 										  Data const& data)
277 		: ShaderBitfieldOperationCaseFrexp(context, name, glslVersion, data, 1,
278 										   "outVec4.x = frexp(inVec4.x, outIvec4.x)")
279 	{
280 	}
281 };
282 
283 class ShaderBitfieldOperationCaseFrexpVec2 : public ShaderBitfieldOperationCaseFrexp
284 {
285 public:
ShaderBitfieldOperationCaseFrexpVec2(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data)286 	ShaderBitfieldOperationCaseFrexpVec2(Context& context, const char* name, glu::GLSLVersion glslVersion,
287 										 Data const& data)
288 		: ShaderBitfieldOperationCaseFrexp(context, name, glslVersion, data, 2,
289 										   "outVec4.xy = frexp(inVec4.xy, outIvec4.xy)")
290 	{
291 	}
292 };
293 
294 class ShaderBitfieldOperationCaseFrexpVec3 : public ShaderBitfieldOperationCaseFrexp
295 {
296 public:
ShaderBitfieldOperationCaseFrexpVec3(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data)297 	ShaderBitfieldOperationCaseFrexpVec3(Context& context, const char* name, glu::GLSLVersion glslVersion,
298 										 Data const& data)
299 		: ShaderBitfieldOperationCaseFrexp(context, name, glslVersion, data, 3,
300 										   "outVec4.xyz = frexp(inVec4.xyz, outIvec4.xyz)")
301 	{
302 	}
303 };
304 
305 class ShaderBitfieldOperationCaseFrexpVec4 : public ShaderBitfieldOperationCaseFrexp
306 {
307 public:
ShaderBitfieldOperationCaseFrexpVec4(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data)308 	ShaderBitfieldOperationCaseFrexpVec4(Context& context, const char* name, glu::GLSLVersion glslVersion,
309 										 Data const& data)
310 		: ShaderBitfieldOperationCaseFrexp(context, name, glslVersion, data, 4, "outVec4 = frexp(inVec4, outIvec4)")
311 	{
312 	}
313 };
314 
315 class ShaderBitfieldOperationCaseLdexp : public ShaderBitfieldOperationCase
316 {
317 public:
ShaderBitfieldOperationCaseLdexp(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,int components,char const * testStatement)318 	ShaderBitfieldOperationCaseLdexp(Context& context, const char* name, glu::GLSLVersion glslVersion, Data const& data,
319 									 int components, char const* testStatement)
320 		: ShaderBitfieldOperationCase(context, name, "", glslVersion, data, testStatement), m_components(components)
321 	{
322 	}
323 
324 private:
325 	int m_components;
326 
test(Data const * data)327 	virtual bool test(Data const* data)
328 	{
329 		for (int i = 0; i < m_components; ++i)
330 		{
331 			float expected = deFloatLdExp(data->inVec4[i], data->inIvec4[i]);
332 			if (deFloatAbs(expected - data->outVec4[i]) > 0.0001f)
333 			{
334 				return false;
335 			}
336 		}
337 		return true;
338 	}
339 };
340 
341 class ShaderBitfieldOperationCaseLdexpFloat : public ShaderBitfieldOperationCaseLdexp
342 {
343 public:
ShaderBitfieldOperationCaseLdexpFloat(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,Data const & exp)344 	ShaderBitfieldOperationCaseLdexpFloat(Context& context, const char* name, glu::GLSLVersion glslVersion,
345 										  Data const& data, Data const& exp)
346 		: ShaderBitfieldOperationCaseLdexp(context, name, glslVersion, data, 1,
347 										   "outVec4.x = ldexp(inVec4.x, inIvec4.x)")
348 	{
349 		m_data.inIvec4[0] = exp.inIvec4[0];
350 	}
351 };
352 
353 class ShaderBitfieldOperationCaseLdexpVec2 : public ShaderBitfieldOperationCaseLdexp
354 {
355 public:
ShaderBitfieldOperationCaseLdexpVec2(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,Data const & exp)356 	ShaderBitfieldOperationCaseLdexpVec2(Context& context, const char* name, glu::GLSLVersion glslVersion,
357 										 Data const& data, Data const& exp)
358 		: ShaderBitfieldOperationCaseLdexp(context, name, glslVersion, data, 2,
359 										   "outVec4.xy = ldexp(inVec4.xy, inIvec4.xy)")
360 	{
361 		m_data.inIvec4[0] = exp.inIvec4[0];
362 		m_data.inIvec4[1] = exp.inIvec4[1];
363 	}
364 };
365 
366 class ShaderBitfieldOperationCaseLdexpVec3 : public ShaderBitfieldOperationCaseLdexp
367 {
368 public:
ShaderBitfieldOperationCaseLdexpVec3(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,Data const & exp)369 	ShaderBitfieldOperationCaseLdexpVec3(Context& context, const char* name, glu::GLSLVersion glslVersion,
370 										 Data const& data, Data const& exp)
371 		: ShaderBitfieldOperationCaseLdexp(context, name, glslVersion, data, 3,
372 										   "outVec4.xyz = ldexp(inVec4.xyz, inIvec4.xyz)")
373 	{
374 		m_data.inIvec4[0] = exp.inIvec4[0];
375 		m_data.inIvec4[1] = exp.inIvec4[1];
376 		m_data.inIvec4[2] = exp.inIvec4[2];
377 	}
378 };
379 
380 class ShaderBitfieldOperationCaseLdexpVec4 : public ShaderBitfieldOperationCaseLdexp
381 {
382 public:
ShaderBitfieldOperationCaseLdexpVec4(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,Data const & exp)383 	ShaderBitfieldOperationCaseLdexpVec4(Context& context, const char* name, glu::GLSLVersion glslVersion,
384 										 Data const& data, Data const& exp)
385 		: ShaderBitfieldOperationCaseLdexp(context, name, glslVersion, data, 4, "outVec4 = ldexp(inVec4, inIvec4)")
386 	{
387 		m_data.inIvec4[0] = exp.inIvec4[0];
388 		m_data.inIvec4[1] = exp.inIvec4[1];
389 		m_data.inIvec4[2] = exp.inIvec4[2];
390 		m_data.inIvec4[3] = exp.inIvec4[3];
391 	}
392 };
393 
reduce32PrecisionTo16(float f)394 static float reduce32PrecisionTo16(float f)
395 {
396 	return deFloat16To32(deFloat32To16(f));
397 }
398 
pack(float x,float y,float z,float w,float range)399 static GLuint pack(float x, float y, float z, float w, float range)
400 {
401 	return ((int(deFloatFloor(x * range + 0.5f)) & 0xFF) << 0) |
402 			((int(deFloatFloor(y * range + 0.5f)) & 0xFF) << 8) |
403 			((int(deFloatFloor(z * range + 0.5f)) & 0xFF) << 16)|
404 			((int(deFloatFloor(w * range + 0.5f)) & 0xFF) << 24);
405 }
406 
checkOutData(GLuint result,const GLfloat input[4],float range)407 static bool checkOutData(GLuint result, const GLfloat input[4], float range)
408 {
409 	GLuint expected = pack(input[0], input[1], input[2], input[3], range);
410 
411 	GLuint expected_mp = pack(reduce32PrecisionTo16(input[0]),
412 									reduce32PrecisionTo16(input[1]),
413 									reduce32PrecisionTo16(input[2]),
414 									reduce32PrecisionTo16(input[3]),
415 									range);
416 
417 	return (expected == result || expected_mp == result);
418 }
419 
420 class ShaderBitfieldOperationCasePackUnorm : public ShaderBitfieldOperationCase
421 {
422 public:
ShaderBitfieldOperationCasePackUnorm(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data)423 	ShaderBitfieldOperationCasePackUnorm(Context& context, const char* name, glu::GLSLVersion glslVersion,
424 										 Data const& data)
425 		: ShaderBitfieldOperationCase(context, name, "", glslVersion, data, "outUvec4.x = packUnorm4x8(inVec4)")
426 	{
427 	}
428 
429 private:
test(Data const * data)430 	virtual bool test(Data const* data)
431 	{
432 					return checkOutData(data->outUvec4[0], data->inVec4, 255.0f);
433 	}
434 };
435 
436 class ShaderBitfieldOperationCasePackSnorm : public ShaderBitfieldOperationCase
437 {
438 public:
ShaderBitfieldOperationCasePackSnorm(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data)439 	ShaderBitfieldOperationCasePackSnorm(Context& context, const char* name, glu::GLSLVersion glslVersion,
440 										 Data const& data)
441 		: ShaderBitfieldOperationCase(context, name, "", glslVersion, data, "outUvec4.x = packSnorm4x8(inVec4)")
442 	{
443 	}
444 
445 private:
test(Data const * data)446 	virtual bool test(Data const* data)
447 	{
448 					return checkOutData(data->outUvec4[0], data->inVec4, 127.0f);
449 	}
450 };
451 
452 class ShaderBitfieldOperationCaseUnpackUnorm : public ShaderBitfieldOperationCase
453 {
454 public:
ShaderBitfieldOperationCaseUnpackUnorm(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data)455 	ShaderBitfieldOperationCaseUnpackUnorm(Context& context, const char* name, glu::GLSLVersion glslVersion,
456 										   Data const& data)
457 		: ShaderBitfieldOperationCase(context, name, "", glslVersion, data, "outVec4 = unpackUnorm4x8(inUvec4.x)")
458 	{
459 	}
460 
461 private:
test(Data const * data)462 	virtual bool test(Data const* data)
463 	{
464 		GLfloat x = float((data->inUvec4[0] >> 0) & 0xFF) / 255.0f;
465 		if (deFloatAbs(data->outVec4[0] - x) > 0.0001f)
466 		{
467 			return false;
468 		}
469 		GLfloat y = float((data->inUvec4[0] >> 8) & 0xFF) / 255.0f;
470 		if (deFloatAbs(data->outVec4[1] - y) > 0.0001f)
471 		{
472 			return false;
473 		}
474 		GLfloat z = float((data->inUvec4[0] >> 16) & 0xFF) / 255.0f;
475 		if (deFloatAbs(data->outVec4[2] - z) > 0.0001f)
476 		{
477 			return false;
478 		}
479 		GLfloat w = float((data->inUvec4[0] >> 24) & 0xFF) / 255.0f;
480 		if (deFloatAbs(data->outVec4[3] - w) > 0.0001f)
481 		{
482 			return false;
483 		}
484 
485 		return true;
486 	}
487 };
488 
489 class ShaderBitfieldOperationCaseUnpackSnorm : public ShaderBitfieldOperationCase
490 {
491 public:
ShaderBitfieldOperationCaseUnpackSnorm(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data)492 	ShaderBitfieldOperationCaseUnpackSnorm(Context& context, const char* name, glu::GLSLVersion glslVersion,
493 										   Data const& data)
494 		: ShaderBitfieldOperationCase(context, name, "", glslVersion, data, "outVec4 = unpackSnorm4x8(inUvec4.x)")
495 	{
496 	}
497 
498 private:
test(Data const * data)499 	virtual bool test(Data const* data)
500 	{
501 		GLfloat x = float((signed char)((data->inUvec4[0] >> 0) & 0xFF)) / 127.0f;
502 		x		  = de::clamp<GLfloat>(x, -1.0f, 1.0f);
503 		if (deFloatAbs(data->outVec4[0] - x) > 0.0001f)
504 		{
505 			return false;
506 		}
507 		GLfloat y = float((signed char)((data->inUvec4[0] >> 8) & 0xFF)) / 127.0f;
508 		y		  = de::clamp<GLfloat>(y, -1.0f, 1.0f);
509 		if (deFloatAbs(data->outVec4[1] - y) > 0.0001f)
510 		{
511 			return false;
512 		}
513 		GLfloat z = float((signed char)((data->inUvec4[0] >> 16) & 0xFF)) / 127.0f;
514 		z		  = de::clamp<GLfloat>(z, -1.0f, 1.0f);
515 		if (deFloatAbs(data->outVec4[2] - z) > 0.0001f)
516 		{
517 			return false;
518 		}
519 		GLfloat w = float((signed char)((data->inUvec4[0] >> 24) & 0xFF)) / 127.0f;
520 		w		  = de::clamp<GLfloat>(w, -1.0f, 1.0f);
521 		if (deFloatAbs(data->outVec4[3] - w) > 0.0001f)
522 		{
523 			return false;
524 		}
525 
526 		return true;
527 	}
528 };
529 
530 class ShaderBitfieldOperationCaseBitfieldExtractUint : public ShaderBitfieldOperationCase
531 {
532 public:
ShaderBitfieldOperationCaseBitfieldExtractUint(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,int offset,int bits,int components,char const * testStatement)533 	ShaderBitfieldOperationCaseBitfieldExtractUint(Context& context, const char* name, glu::GLSLVersion glslVersion,
534 												   Data const& data, int offset, int bits, int components,
535 												   char const* testStatement)
536 		: ShaderBitfieldOperationCase(context, name, "", glslVersion, data, testStatement), m_components(components)
537 	{
538 		if (offset + bits > 32)
539 		{
540 			offset -= (offset + bits) - 32;
541 		}
542 		m_data.offset = offset;
543 		m_data.bits   = bits;
544 	}
545 
546 private:
547 	int m_components;
548 
test(Data const * data)549 	virtual bool test(Data const* data)
550 	{
551 		for (int i = 0; i < m_components; ++i)
552 		{
553 			GLuint expected =
554 				(data->inUvec4[i] >> data->offset) & (data->bits == 32 ? 0xFFFFFFFF : ((1u << data->bits) - 1));
555 			if (data->outUvec4[i] != expected)
556 			{
557 				return false;
558 			}
559 		}
560 		return true;
561 	}
562 };
563 
564 class ShaderBitfieldOperationCaseBitfieldExtractUint1 : public ShaderBitfieldOperationCaseBitfieldExtractUint
565 {
566 public:
ShaderBitfieldOperationCaseBitfieldExtractUint1(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,int offset,int bits)567 	ShaderBitfieldOperationCaseBitfieldExtractUint1(Context& context, const char* name, glu::GLSLVersion glslVersion,
568 													Data const& data, int offset, int bits)
569 		: ShaderBitfieldOperationCaseBitfieldExtractUint(context, name, glslVersion, data, offset, bits, 1,
570 														 "outUvec4.x = bitfieldExtract(inUvec4.x, offset, bits)")
571 	{
572 	}
573 };
574 
575 class ShaderBitfieldOperationCaseBitfieldExtractUint2 : public ShaderBitfieldOperationCaseBitfieldExtractUint
576 {
577 public:
ShaderBitfieldOperationCaseBitfieldExtractUint2(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,int offset,int bits)578 	ShaderBitfieldOperationCaseBitfieldExtractUint2(Context& context, const char* name, glu::GLSLVersion glslVersion,
579 													Data const& data, int offset, int bits)
580 		: ShaderBitfieldOperationCaseBitfieldExtractUint(context, name, glslVersion, data, offset, bits, 2,
581 														 "outUvec4.xy = bitfieldExtract(inUvec4.xy, offset, bits)")
582 	{
583 	}
584 };
585 
586 class ShaderBitfieldOperationCaseBitfieldExtractUint3 : public ShaderBitfieldOperationCaseBitfieldExtractUint
587 {
588 public:
ShaderBitfieldOperationCaseBitfieldExtractUint3(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,int offset,int bits)589 	ShaderBitfieldOperationCaseBitfieldExtractUint3(Context& context, const char* name, glu::GLSLVersion glslVersion,
590 													Data const& data, int offset, int bits)
591 		: ShaderBitfieldOperationCaseBitfieldExtractUint(context, name, glslVersion, data, offset, bits, 3,
592 														 "outUvec4.xyz = bitfieldExtract(inUvec4.xyz, offset, bits)")
593 	{
594 	}
595 };
596 
597 class ShaderBitfieldOperationCaseBitfieldExtractUint4 : public ShaderBitfieldOperationCaseBitfieldExtractUint
598 {
599 public:
ShaderBitfieldOperationCaseBitfieldExtractUint4(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,int offset,int bits)600 	ShaderBitfieldOperationCaseBitfieldExtractUint4(Context& context, const char* name, glu::GLSLVersion glslVersion,
601 													Data const& data, int offset, int bits)
602 		: ShaderBitfieldOperationCaseBitfieldExtractUint(context, name, glslVersion, data, offset, bits, 4,
603 														 "outUvec4 = bitfieldExtract(inUvec4, offset, bits)")
604 	{
605 	}
606 };
607 
608 class ShaderBitfieldOperationCaseBitfieldExtractInt : public ShaderBitfieldOperationCase
609 {
610 public:
ShaderBitfieldOperationCaseBitfieldExtractInt(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,int offset,int bits,int components,char const * testStatement)611 	ShaderBitfieldOperationCaseBitfieldExtractInt(Context& context, const char* name, glu::GLSLVersion glslVersion,
612 												  Data const& data, int offset, int bits, int components,
613 												  char const* testStatement)
614 		: ShaderBitfieldOperationCase(context, name, "", glslVersion, data, testStatement), m_components(components)
615 	{
616 		if (offset + bits > 32)
617 		{
618 			offset -= (offset + bits) - 32;
619 		}
620 		m_data.offset = offset;
621 		m_data.bits   = bits;
622 	}
623 
624 private:
625 	int m_components;
626 
test(Data const * data)627 	virtual bool test(Data const* data)
628 	{
629 		for (int i = 0; i < m_components; ++i)
630 		{
631 			GLint expected = data->inIvec4[i] << (32 - (data->offset + data->bits));
632 			expected >>= 32 - data->bits;
633 			if (data->outIvec4[i] != expected)
634 			{
635 				return false;
636 			}
637 		}
638 		return true;
639 	}
640 };
641 
642 class ShaderBitfieldOperationCaseBitfieldExtractInt1 : public ShaderBitfieldOperationCaseBitfieldExtractInt
643 {
644 public:
ShaderBitfieldOperationCaseBitfieldExtractInt1(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,int offset,int bits)645 	ShaderBitfieldOperationCaseBitfieldExtractInt1(Context& context, const char* name, glu::GLSLVersion glslVersion,
646 												   Data const& data, int offset, int bits)
647 		: ShaderBitfieldOperationCaseBitfieldExtractInt(context, name, glslVersion, data, offset, bits, 1,
648 														"outIvec4.x = bitfieldExtract(inIvec4.x, offset, bits)")
649 	{
650 	}
651 };
652 
653 class ShaderBitfieldOperationCaseBitfieldExtractInt2 : public ShaderBitfieldOperationCaseBitfieldExtractInt
654 {
655 public:
ShaderBitfieldOperationCaseBitfieldExtractInt2(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,int offset,int bits)656 	ShaderBitfieldOperationCaseBitfieldExtractInt2(Context& context, const char* name, glu::GLSLVersion glslVersion,
657 												   Data const& data, int offset, int bits)
658 		: ShaderBitfieldOperationCaseBitfieldExtractInt(context, name, glslVersion, data, offset, bits, 2,
659 														"outIvec4.xy = bitfieldExtract(inIvec4.xy, offset, bits)")
660 	{
661 	}
662 };
663 
664 class ShaderBitfieldOperationCaseBitfieldExtractInt3 : public ShaderBitfieldOperationCaseBitfieldExtractInt
665 {
666 public:
ShaderBitfieldOperationCaseBitfieldExtractInt3(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,int offset,int bits)667 	ShaderBitfieldOperationCaseBitfieldExtractInt3(Context& context, const char* name, glu::GLSLVersion glslVersion,
668 												   Data const& data, int offset, int bits)
669 		: ShaderBitfieldOperationCaseBitfieldExtractInt(context, name, glslVersion, data, offset, bits, 3,
670 														"outIvec4.xyz = bitfieldExtract(inIvec4.xyz, offset, bits)")
671 	{
672 	}
673 };
674 
675 class ShaderBitfieldOperationCaseBitfieldExtractInt4 : public ShaderBitfieldOperationCaseBitfieldExtractInt
676 {
677 public:
ShaderBitfieldOperationCaseBitfieldExtractInt4(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,int offset,int bits)678 	ShaderBitfieldOperationCaseBitfieldExtractInt4(Context& context, const char* name, glu::GLSLVersion glslVersion,
679 												   Data const& data, int offset, int bits)
680 		: ShaderBitfieldOperationCaseBitfieldExtractInt(context, name, glslVersion, data, offset, bits, 4,
681 														"outIvec4 = bitfieldExtract(inIvec4, offset, bits)")
682 	{
683 	}
684 };
685 
686 class ShaderBitfieldOperationCaseBitfieldInsertUint : public ShaderBitfieldOperationCase
687 {
688 public:
ShaderBitfieldOperationCaseBitfieldInsertUint(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,Data const & insert,int offset,int bits,int components,char const * testStatement)689 	ShaderBitfieldOperationCaseBitfieldInsertUint(Context& context, const char* name, glu::GLSLVersion glslVersion,
690 												  Data const& data, Data const& insert, int offset, int bits,
691 												  int components, char const* testStatement)
692 		: ShaderBitfieldOperationCase(context, name, "", glslVersion, data, testStatement), m_components(components)
693 	{
694 		for (int i = 0; i < components; ++i)
695 		{
696 			m_data.in2Uvec4[i] = insert.inUvec4[i];
697 		}
698 		if (offset + bits > 32)
699 		{
700 			offset -= (offset + bits) - 32;
701 		}
702 		m_data.offset = offset;
703 		m_data.bits   = bits;
704 	}
705 
706 private:
707 	int m_components;
708 
test(Data const * data)709 	virtual bool test(Data const* data)
710 	{
711 		for (int i = 0; i < m_components; ++i)
712 		{
713 			GLuint mask = (data->bits == 32) ? ~0u : (1 << data->bits) - 1;
714 			GLuint expected =
715 				(data->inUvec4[i] & ~(mask << data->offset)) | ((data->in2Uvec4[i] & mask) << data->offset);
716 			if (data->outUvec4[i] != expected)
717 			{
718 				return false;
719 			}
720 		}
721 		return true;
722 	}
723 };
724 
725 class ShaderBitfieldOperationCaseBitfieldInsertUint1 : public ShaderBitfieldOperationCaseBitfieldInsertUint
726 {
727 public:
ShaderBitfieldOperationCaseBitfieldInsertUint1(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,Data const & insert,int offset,int bits)728 	ShaderBitfieldOperationCaseBitfieldInsertUint1(Context& context, const char* name, glu::GLSLVersion glslVersion,
729 												   Data const& data, Data const& insert, int offset, int bits)
730 		: ShaderBitfieldOperationCaseBitfieldInsertUint(
731 			  context, name, glslVersion, data, insert, offset, bits, 1,
732 			  "outUvec4.x = bitfieldInsert(inUvec4.x, in2Uvec4.x, offset, bits)")
733 	{
734 	}
735 };
736 
737 class ShaderBitfieldOperationCaseBitfieldInsertUint2 : public ShaderBitfieldOperationCaseBitfieldInsertUint
738 {
739 public:
ShaderBitfieldOperationCaseBitfieldInsertUint2(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,Data const & insert,int offset,int bits)740 	ShaderBitfieldOperationCaseBitfieldInsertUint2(Context& context, const char* name, glu::GLSLVersion glslVersion,
741 												   Data const& data, Data const& insert, int offset, int bits)
742 		: ShaderBitfieldOperationCaseBitfieldInsertUint(
743 			  context, name, glslVersion, data, insert, offset, bits, 2,
744 			  "outUvec4.xy = bitfieldInsert(inUvec4.xy, in2Uvec4.xy, offset, bits)")
745 	{
746 	}
747 };
748 
749 class ShaderBitfieldOperationCaseBitfieldInsertUint3 : public ShaderBitfieldOperationCaseBitfieldInsertUint
750 {
751 public:
ShaderBitfieldOperationCaseBitfieldInsertUint3(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,Data const & insert,int offset,int bits)752 	ShaderBitfieldOperationCaseBitfieldInsertUint3(Context& context, const char* name, glu::GLSLVersion glslVersion,
753 												   Data const& data, Data const& insert, int offset, int bits)
754 		: ShaderBitfieldOperationCaseBitfieldInsertUint(
755 			  context, name, glslVersion, data, insert, offset, bits, 3,
756 			  "outUvec4.xyz = bitfieldInsert(inUvec4.xyz, in2Uvec4.xyz, offset, bits)")
757 	{
758 	}
759 };
760 
761 class ShaderBitfieldOperationCaseBitfieldInsertUint4 : public ShaderBitfieldOperationCaseBitfieldInsertUint
762 {
763 public:
ShaderBitfieldOperationCaseBitfieldInsertUint4(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,Data const & insert,int offset,int bits)764 	ShaderBitfieldOperationCaseBitfieldInsertUint4(Context& context, const char* name, glu::GLSLVersion glslVersion,
765 												   Data const& data, Data const& insert, int offset, int bits)
766 		: ShaderBitfieldOperationCaseBitfieldInsertUint(context, name, glslVersion, data, insert, offset, bits, 4,
767 														"outUvec4 = bitfieldInsert(inUvec4, in2Uvec4, offset, bits)")
768 	{
769 	}
770 };
771 
772 class ShaderBitfieldOperationCaseBitfieldInsertInt : public ShaderBitfieldOperationCase
773 {
774 public:
ShaderBitfieldOperationCaseBitfieldInsertInt(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,Data const & insert,int offset,int bits,int components,char const * testStatement)775 	ShaderBitfieldOperationCaseBitfieldInsertInt(Context& context, const char* name, glu::GLSLVersion glslVersion,
776 												 Data const& data, Data const& insert, int offset, int bits,
777 												 int components, char const* testStatement)
778 		: ShaderBitfieldOperationCase(context, name, "", glslVersion, data, testStatement), m_components(components)
779 	{
780 		for (int i = 0; i < components; ++i)
781 		{
782 			m_data.in2Ivec4[i] = insert.inIvec4[i];
783 		}
784 		if (offset + bits > 32)
785 		{
786 			offset -= (offset + bits) - 32;
787 		}
788 		m_data.offset = offset;
789 		m_data.bits   = bits;
790 	}
791 
792 private:
793 	int m_components;
794 
test(Data const * data)795 	virtual bool test(Data const* data)
796 	{
797 		for (int i = 0; i < m_components; ++i)
798 		{
799 			GLuint mask = (data->bits == 32) ? ~0u : (1 << data->bits) - 1;
800 			GLint  expected =
801 				(data->inIvec4[i] & ~(mask << data->offset)) | ((data->in2Ivec4[i] & mask) << data->offset);
802 			if (data->outIvec4[i] != expected)
803 			{
804 				return false;
805 			}
806 		}
807 		return true;
808 	}
809 };
810 
811 class ShaderBitfieldOperationCaseBitfieldInsertInt1 : public ShaderBitfieldOperationCaseBitfieldInsertInt
812 {
813 public:
ShaderBitfieldOperationCaseBitfieldInsertInt1(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,Data const & insert,int offset,int bits)814 	ShaderBitfieldOperationCaseBitfieldInsertInt1(Context& context, const char* name, glu::GLSLVersion glslVersion,
815 												  Data const& data, Data const& insert, int offset, int bits)
816 		: ShaderBitfieldOperationCaseBitfieldInsertInt(
817 			  context, name, glslVersion, data, insert, offset, bits, 1,
818 			  "outIvec4.x = bitfieldInsert(inIvec4.x, in2Ivec4.x, offset, bits)")
819 	{
820 	}
821 };
822 
823 class ShaderBitfieldOperationCaseBitfieldInsertInt2 : public ShaderBitfieldOperationCaseBitfieldInsertInt
824 {
825 public:
ShaderBitfieldOperationCaseBitfieldInsertInt2(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,Data const & insert,int offset,int bits)826 	ShaderBitfieldOperationCaseBitfieldInsertInt2(Context& context, const char* name, glu::GLSLVersion glslVersion,
827 												  Data const& data, Data const& insert, int offset, int bits)
828 		: ShaderBitfieldOperationCaseBitfieldInsertInt(
829 			  context, name, glslVersion, data, insert, offset, bits, 2,
830 			  "outIvec4.xy = bitfieldInsert(inIvec4.xy, in2Ivec4.xy, offset, bits)")
831 	{
832 	}
833 };
834 
835 class ShaderBitfieldOperationCaseBitfieldInsertInt3 : public ShaderBitfieldOperationCaseBitfieldInsertInt
836 {
837 public:
ShaderBitfieldOperationCaseBitfieldInsertInt3(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,Data const & insert,int offset,int bits)838 	ShaderBitfieldOperationCaseBitfieldInsertInt3(Context& context, const char* name, glu::GLSLVersion glslVersion,
839 												  Data const& data, Data const& insert, int offset, int bits)
840 		: ShaderBitfieldOperationCaseBitfieldInsertInt(
841 			  context, name, glslVersion, data, insert, offset, bits, 3,
842 			  "outIvec4.xyz = bitfieldInsert(inIvec4.xyz, in2Ivec4.xyz, offset, bits)")
843 	{
844 	}
845 };
846 
847 class ShaderBitfieldOperationCaseBitfieldInsertInt4 : public ShaderBitfieldOperationCaseBitfieldInsertInt
848 {
849 public:
ShaderBitfieldOperationCaseBitfieldInsertInt4(Context & context,const char * name,glu::GLSLVersion glslVersion,Data const & data,Data const & insert,int offset,int bits)850 	ShaderBitfieldOperationCaseBitfieldInsertInt4(Context& context, const char* name, glu::GLSLVersion glslVersion,
851 												  Data const& data, Data const& insert, int offset, int bits)
852 		: ShaderBitfieldOperationCaseBitfieldInsertInt(context, name, glslVersion, data, insert, offset, bits, 4,
853 													   "outIvec4 = bitfieldInsert(inIvec4, in2Ivec4, offset, bits)")
854 	{
855 	}
856 };
857 
858 typedef GLuint (*UnaryUFunc)(GLuint input);
859 typedef GLint (*UnaryIFunc)(GLint input);
860 
bitfieldReverse(GLuint input)861 static GLuint bitfieldReverse(GLuint input)
862 {
863 	GLuint result = 0;
864 	for (int i = 0; i < 32; ++i)
865 	{
866 		result >>= 1;
867 		result |= (input & 0x80000000);
868 		input <<= 1;
869 	}
870 	return result;
871 }
872 
bitCount(GLuint input)873 static GLuint bitCount(GLuint input)
874 {
875 	GLuint result = 0;
876 	while (input)
877 	{
878 		if (input & 1)
879 		{
880 			result += 1;
881 		}
882 		input >>= 1;
883 	}
884 	return result;
885 }
886 
findLSB(GLuint input)887 static GLuint findLSB(GLuint input)
888 {
889 	if (!input)
890 	{
891 		return -1;
892 	}
893 	for (GLuint result = 0;; ++result)
894 	{
895 		if (input & 1)
896 		{
897 			return result;
898 		}
899 		input >>= 1;
900 	}
901 }
902 
findMSBU(GLuint input)903 static GLuint findMSBU(GLuint input)
904 {
905 	if (!input)
906 	{
907 		return -1;
908 	}
909 	for (GLuint result = 31;; --result)
910 	{
911 		if (input & 0x80000000)
912 		{
913 			return result;
914 		}
915 		input <<= 1;
916 	}
917 }
918 
findMSBI(GLint input)919 static GLint findMSBI(GLint input)
920 {
921 	if (input == 0 || input == -1)
922 	{
923 		return -1;
924 	}
925 	else if (input > 0)
926 	{
927 		for (GLuint result = 31;; --result)
928 		{
929 			if (input & 0x80000000)
930 			{
931 				return result;
932 			}
933 			input <<= 1;
934 		}
935 	}
936 	else
937 	{
938 		for (GLuint result = 31;; --result)
939 		{
940 			if (!(input & 0x80000000))
941 			{
942 				return result;
943 			}
944 			input <<= 1;
945 		}
946 	}
947 }
948 
949 class ShaderBitfieldOperationCaseUnaryUint : public ShaderBitfieldOperationCase
950 {
951 public:
ShaderBitfieldOperationCaseUnaryUint(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * funcName,UnaryUFunc func,Data const & data,int components,char const * testStatement)952 	ShaderBitfieldOperationCaseUnaryUint(Context& context, const char* name, glu::GLSLVersion glslVersion,
953 										 char const* funcName, UnaryUFunc func, Data const& data, int components,
954 										 char const* testStatement)
955 		: ShaderBitfieldOperationCase(context, name, "", glslVersion, data, testStatement)
956 		, m_components(components)
957 		, m_func(func)
958 	{
959 		size_t pos = m_testStatement.find("func");
960 		m_testStatement.replace(pos, 4, funcName);
961 	}
962 
963 private:
964 	int		   m_components;
965 	UnaryUFunc m_func;
966 
test(Data const * data)967 	virtual bool test(Data const* data)
968 	{
969 		for (int i = 0; i < m_components; ++i)
970 		{
971 			GLuint expected = m_func(data->inUvec4[i]);
972 			GLuint output   = data->outUvec4[i];
973 			if (m_func == (UnaryUFunc)glcts::bitCount || m_func == (UnaryUFunc)glcts::findLSB ||
974 				m_func == (UnaryUFunc)glcts::findMSBU || m_func == (UnaryUFunc)glcts::findMSBI)
975 			{
976 				/* The built-in bitCount, findLSB and findMSB functions
977 				 * return a lowp int, which can be encoded with as little
978 				 * as 9 bits. Since findLSB and findMSB can return negative
979 				 * values (namely, -1), we cannot compare the value directly
980 				 * against a (32-bit) GLuint.
981 				 */
982 				GLuint output_9bits = output & 0x1ff;
983 				GLuint sign_extend  = output_9bits & 0x100 ? 0xfffffe00 : 0;
984 				output				= output_9bits | sign_extend;
985 			}
986 
987 			if (output != expected)
988 			{
989 				return false;
990 			}
991 		}
992 		return true;
993 	}
994 };
995 
996 class ShaderBitfieldOperationCaseUnaryUint1 : public ShaderBitfieldOperationCaseUnaryUint
997 {
998 public:
ShaderBitfieldOperationCaseUnaryUint1(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * funcName,UnaryUFunc func,Data const & data)999 	ShaderBitfieldOperationCaseUnaryUint1(Context& context, const char* name, glu::GLSLVersion glslVersion,
1000 										  char const* funcName, UnaryUFunc func, Data const& data)
1001 		: ShaderBitfieldOperationCaseUnaryUint(context, name, glslVersion, funcName, func, data, 1,
1002 											   "outUvec4.x = uint(func(inUvec4.x))")
1003 	{
1004 	}
1005 };
1006 
1007 class ShaderBitfieldOperationCaseUnaryUint2 : public ShaderBitfieldOperationCaseUnaryUint
1008 {
1009 public:
ShaderBitfieldOperationCaseUnaryUint2(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * funcName,UnaryUFunc func,Data const & data)1010 	ShaderBitfieldOperationCaseUnaryUint2(Context& context, const char* name, glu::GLSLVersion glslVersion,
1011 										  char const* funcName, UnaryUFunc func, Data const& data)
1012 		: ShaderBitfieldOperationCaseUnaryUint(context, name, glslVersion, funcName, func, data, 2,
1013 											   "outUvec4.xy = uvec2(func(inUvec4.xy))")
1014 	{
1015 	}
1016 };
1017 
1018 class ShaderBitfieldOperationCaseUnaryUint3 : public ShaderBitfieldOperationCaseUnaryUint
1019 {
1020 public:
ShaderBitfieldOperationCaseUnaryUint3(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * funcName,UnaryUFunc func,Data const & data)1021 	ShaderBitfieldOperationCaseUnaryUint3(Context& context, const char* name, glu::GLSLVersion glslVersion,
1022 										  char const* funcName, UnaryUFunc func, Data const& data)
1023 		: ShaderBitfieldOperationCaseUnaryUint(context, name, glslVersion, funcName, func, data, 3,
1024 											   "outUvec4.xyz = uvec3(func(inUvec4.xyz))")
1025 	{
1026 	}
1027 };
1028 
1029 class ShaderBitfieldOperationCaseUnaryUint4 : public ShaderBitfieldOperationCaseUnaryUint
1030 {
1031 public:
ShaderBitfieldOperationCaseUnaryUint4(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * funcName,UnaryUFunc func,Data const & data)1032 	ShaderBitfieldOperationCaseUnaryUint4(Context& context, const char* name, glu::GLSLVersion glslVersion,
1033 										  char const* funcName, UnaryUFunc func, Data const& data)
1034 		: ShaderBitfieldOperationCaseUnaryUint(context, name, glslVersion, funcName, func, data, 4,
1035 											   "outUvec4 = uvec4(func(inUvec4))")
1036 	{
1037 	}
1038 };
1039 
1040 class ShaderBitfieldOperationCaseUnaryInt : public ShaderBitfieldOperationCase
1041 {
1042 public:
ShaderBitfieldOperationCaseUnaryInt(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * funcName,UnaryIFunc func,Data const & data,int components,char const * testStatement)1043 	ShaderBitfieldOperationCaseUnaryInt(Context& context, const char* name, glu::GLSLVersion glslVersion,
1044 										char const* funcName, UnaryIFunc func, Data const& data, int components,
1045 										char const* testStatement)
1046 		: ShaderBitfieldOperationCase(context, name, "", glslVersion, data, testStatement)
1047 		, m_components(components)
1048 		, m_func(func)
1049 	{
1050 		size_t pos = m_testStatement.find("func");
1051 		m_testStatement.replace(pos, 4, funcName);
1052 	}
1053 
1054 private:
1055 	int		   m_components;
1056 	UnaryIFunc m_func;
1057 
test(Data const * data)1058 	virtual bool test(Data const* data)
1059 	{
1060 		for (int i = 0; i < m_components; ++i)
1061 		{
1062 			GLint expected = m_func(data->inIvec4[i]);
1063 			if (data->outIvec4[i] != expected)
1064 			{
1065 				return false;
1066 			}
1067 		}
1068 		return true;
1069 	}
1070 };
1071 
1072 class ShaderBitfieldOperationCaseUnaryInt1 : public ShaderBitfieldOperationCaseUnaryInt
1073 {
1074 public:
ShaderBitfieldOperationCaseUnaryInt1(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * funcName,UnaryIFunc func,Data const & data)1075 	ShaderBitfieldOperationCaseUnaryInt1(Context& context, const char* name, glu::GLSLVersion glslVersion,
1076 										 char const* funcName, UnaryIFunc func, Data const& data)
1077 		: ShaderBitfieldOperationCaseUnaryInt(context, name, glslVersion, funcName, func, data, 1,
1078 											  "outIvec4.x = func(inIvec4.x)")
1079 	{
1080 	}
1081 };
1082 
1083 class ShaderBitfieldOperationCaseUnaryInt2 : public ShaderBitfieldOperationCaseUnaryInt
1084 {
1085 public:
ShaderBitfieldOperationCaseUnaryInt2(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * funcName,UnaryIFunc func,Data const & data)1086 	ShaderBitfieldOperationCaseUnaryInt2(Context& context, const char* name, glu::GLSLVersion glslVersion,
1087 										 char const* funcName, UnaryIFunc func, Data const& data)
1088 		: ShaderBitfieldOperationCaseUnaryInt(context, name, glslVersion, funcName, func, data, 2,
1089 											  "outIvec4.xy = func(inIvec4.xy)")
1090 	{
1091 	}
1092 };
1093 
1094 class ShaderBitfieldOperationCaseUnaryInt3 : public ShaderBitfieldOperationCaseUnaryInt
1095 {
1096 public:
ShaderBitfieldOperationCaseUnaryInt3(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * funcName,UnaryIFunc func,Data const & data)1097 	ShaderBitfieldOperationCaseUnaryInt3(Context& context, const char* name, glu::GLSLVersion glslVersion,
1098 										 char const* funcName, UnaryIFunc func, Data const& data)
1099 		: ShaderBitfieldOperationCaseUnaryInt(context, name, glslVersion, funcName, func, data, 3,
1100 											  "outIvec4.xyz = func(inIvec4.xyz)")
1101 	{
1102 	}
1103 };
1104 
1105 class ShaderBitfieldOperationCaseUnaryInt4 : public ShaderBitfieldOperationCaseUnaryInt
1106 {
1107 public:
ShaderBitfieldOperationCaseUnaryInt4(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * funcName,UnaryIFunc func,Data const & data)1108 	ShaderBitfieldOperationCaseUnaryInt4(Context& context, const char* name, glu::GLSLVersion glslVersion,
1109 										 char const* funcName, UnaryIFunc func, Data const& data)
1110 		: ShaderBitfieldOperationCaseUnaryInt(context, name, glslVersion, funcName, func, data, 4,
1111 											  "outIvec4 = func(inIvec4)")
1112 	{
1113 	}
1114 };
1115 
1116 typedef GLuint (*BinaryUFunc)(GLuint input, GLuint input2, GLuint& output2);
1117 typedef GLint (*BinaryIFunc)(GLint input, GLint input2, GLint& output2);
1118 
uaddCarry(GLuint input,GLuint input2,GLuint & output2)1119 static GLuint uaddCarry(GLuint input, GLuint input2, GLuint& output2)
1120 {
1121 	GLuint result = input + input2;
1122 	output2		  = (input > result) ? 1 : 0;
1123 	return result;
1124 }
1125 
usubBorrow(GLuint input,GLuint input2,GLuint & output2)1126 static GLuint usubBorrow(GLuint input, GLuint input2, GLuint& output2)
1127 {
1128 	output2 = (input2 > input) ? 1 : 0;
1129 	return input - input2;
1130 }
1131 
umulExtended(GLuint input,GLuint input2,GLuint & output2)1132 static GLuint umulExtended(GLuint input, GLuint input2, GLuint& output2)
1133 {
1134 	GLuint64 result = static_cast<GLuint64>(input) * static_cast<GLuint64>(input2);
1135 	output2			= GLuint(result & 0xFFFFFFFF);
1136 	return GLuint(result >> 32);
1137 }
1138 
imulExtended(GLint input,GLint input2,GLint & output2)1139 static GLint imulExtended(GLint input, GLint input2, GLint& output2)
1140 {
1141 	GLint64 result = static_cast<GLint64>(input) * static_cast<GLint64>(input2);
1142 	output2		   = GLint(result & 0xFFFFFFFF);
1143 	return GLint(result >> 32);
1144 }
1145 
1146 class ShaderBitfieldOperationCaseBinaryUint : public ShaderBitfieldOperationCase
1147 {
1148 public:
ShaderBitfieldOperationCaseBinaryUint(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * testStatement,BinaryUFunc func,Data const & input,Data const & input2,int components)1149 	ShaderBitfieldOperationCaseBinaryUint(Context& context, const char* name, glu::GLSLVersion glslVersion,
1150 										  char const* testStatement, BinaryUFunc func, Data const& input,
1151 										  Data const& input2, int components)
1152 		: ShaderBitfieldOperationCase(context, name, "", glslVersion, input, testStatement)
1153 		, m_components(components)
1154 		, m_func(func)
1155 	{
1156 		for (int i = 0; i < components; ++i)
1157 		{
1158 			m_data.in2Uvec4[i] = input2.inUvec4[i];
1159 		}
1160 	}
1161 
1162 private:
1163 	int			m_components;
1164 	BinaryUFunc m_func;
1165 
test(Data const * data)1166 	virtual bool test(Data const* data)
1167 	{
1168 		for (int i = 0; i < m_components; ++i)
1169 		{
1170 			GLuint expected2 = 0;
1171 			GLuint expected  = m_func(data->inUvec4[i], data->in2Uvec4[i], expected2);
1172 			if (data->outUvec4[i] != expected || data->out2Uvec4[i] != expected2)
1173 			{
1174 				return false;
1175 			}
1176 		}
1177 		return true;
1178 	}
1179 };
1180 
1181 class ShaderBitfieldOperationCaseBinaryUint1 : public ShaderBitfieldOperationCaseBinaryUint
1182 {
1183 public:
ShaderBitfieldOperationCaseBinaryUint1(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * testStatement,BinaryUFunc func,Data const & input,Data const & input2)1184 	ShaderBitfieldOperationCaseBinaryUint1(Context& context, const char* name, glu::GLSLVersion glslVersion,
1185 										   char const* testStatement, BinaryUFunc func, Data const& input,
1186 										   Data const& input2)
1187 		: ShaderBitfieldOperationCaseBinaryUint(context, name, glslVersion, testStatement, func, input, input2, 1)
1188 	{
1189 	}
1190 };
1191 
1192 class ShaderBitfieldOperationCaseBinaryUint2 : public ShaderBitfieldOperationCaseBinaryUint
1193 {
1194 public:
ShaderBitfieldOperationCaseBinaryUint2(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * testStatement,BinaryUFunc func,Data const & input,Data const & input2)1195 	ShaderBitfieldOperationCaseBinaryUint2(Context& context, const char* name, glu::GLSLVersion glslVersion,
1196 										   char const* testStatement, BinaryUFunc func, Data const& input,
1197 										   Data const& input2)
1198 		: ShaderBitfieldOperationCaseBinaryUint(context, name, glslVersion, testStatement, func, input, input2, 2)
1199 	{
1200 	}
1201 };
1202 
1203 class ShaderBitfieldOperationCaseBinaryUint3 : public ShaderBitfieldOperationCaseBinaryUint
1204 {
1205 public:
ShaderBitfieldOperationCaseBinaryUint3(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * testStatement,BinaryUFunc func,Data const & input,Data const & input2)1206 	ShaderBitfieldOperationCaseBinaryUint3(Context& context, const char* name, glu::GLSLVersion glslVersion,
1207 										   char const* testStatement, BinaryUFunc func, Data const& input,
1208 										   Data const& input2)
1209 		: ShaderBitfieldOperationCaseBinaryUint(context, name, glslVersion, testStatement, func, input, input2, 3)
1210 	{
1211 	}
1212 };
1213 
1214 class ShaderBitfieldOperationCaseBinaryUint4 : public ShaderBitfieldOperationCaseBinaryUint
1215 {
1216 public:
ShaderBitfieldOperationCaseBinaryUint4(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * testStatement,BinaryUFunc func,Data const & input,Data const & input2)1217 	ShaderBitfieldOperationCaseBinaryUint4(Context& context, const char* name, glu::GLSLVersion glslVersion,
1218 										   char const* testStatement, BinaryUFunc func, Data const& input,
1219 										   Data const& input2)
1220 		: ShaderBitfieldOperationCaseBinaryUint(context, name, glslVersion, testStatement, func, input, input2, 4)
1221 	{
1222 	}
1223 };
1224 
1225 class ShaderBitfieldOperationCaseBinaryInt : public ShaderBitfieldOperationCase
1226 {
1227 public:
ShaderBitfieldOperationCaseBinaryInt(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * testStatement,BinaryIFunc func,Data const & input,Data const & input2,int components)1228 	ShaderBitfieldOperationCaseBinaryInt(Context& context, const char* name, glu::GLSLVersion glslVersion,
1229 										 char const* testStatement, BinaryIFunc func, Data const& input,
1230 										 Data const& input2, int components)
1231 		: ShaderBitfieldOperationCase(context, name, "", glslVersion, input, testStatement)
1232 		, m_components(components)
1233 		, m_func(func)
1234 	{
1235 		for (int i = 0; i < components; ++i)
1236 		{
1237 			m_data.in2Ivec4[i] = input2.inIvec4[i];
1238 		}
1239 	}
1240 
1241 private:
1242 	int			m_components;
1243 	BinaryIFunc m_func;
1244 
test(Data const * data)1245 	virtual bool test(Data const* data)
1246 	{
1247 		for (int i = 0; i < m_components; ++i)
1248 		{
1249 			GLint expected2 = 0;
1250 			GLint expected  = m_func(data->inIvec4[i], data->in2Ivec4[i], expected2);
1251 			if (data->outIvec4[i] != expected || data->out2Ivec4[i] != expected2)
1252 			{
1253 				return false;
1254 			}
1255 		}
1256 		return true;
1257 	}
1258 };
1259 
1260 class ShaderBitfieldOperationCaseBinaryInt1 : public ShaderBitfieldOperationCaseBinaryInt
1261 {
1262 public:
ShaderBitfieldOperationCaseBinaryInt1(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * testStatement,BinaryIFunc func,Data const & input,Data const & input2)1263 	ShaderBitfieldOperationCaseBinaryInt1(Context& context, const char* name, glu::GLSLVersion glslVersion,
1264 										  char const* testStatement, BinaryIFunc func, Data const& input,
1265 										  Data const& input2)
1266 		: ShaderBitfieldOperationCaseBinaryInt(context, name, glslVersion, testStatement, func, input, input2, 1)
1267 	{
1268 	}
1269 };
1270 
1271 class ShaderBitfieldOperationCaseBinaryInt2 : public ShaderBitfieldOperationCaseBinaryInt
1272 {
1273 public:
ShaderBitfieldOperationCaseBinaryInt2(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * testStatement,BinaryIFunc func,Data const & input,Data const & input2)1274 	ShaderBitfieldOperationCaseBinaryInt2(Context& context, const char* name, glu::GLSLVersion glslVersion,
1275 										  char const* testStatement, BinaryIFunc func, Data const& input,
1276 										  Data const& input2)
1277 		: ShaderBitfieldOperationCaseBinaryInt(context, name, glslVersion, testStatement, func, input, input2, 2)
1278 	{
1279 	}
1280 };
1281 
1282 class ShaderBitfieldOperationCaseBinaryInt3 : public ShaderBitfieldOperationCaseBinaryInt
1283 {
1284 public:
ShaderBitfieldOperationCaseBinaryInt3(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * testStatement,BinaryIFunc func,Data const & input,Data const & input2)1285 	ShaderBitfieldOperationCaseBinaryInt3(Context& context, const char* name, glu::GLSLVersion glslVersion,
1286 										  char const* testStatement, BinaryIFunc func, Data const& input,
1287 										  Data const& input2)
1288 		: ShaderBitfieldOperationCaseBinaryInt(context, name, glslVersion, testStatement, func, input, input2, 3)
1289 	{
1290 	}
1291 };
1292 
1293 class ShaderBitfieldOperationCaseBinaryInt4 : public ShaderBitfieldOperationCaseBinaryInt
1294 {
1295 public:
ShaderBitfieldOperationCaseBinaryInt4(Context & context,const char * name,glu::GLSLVersion glslVersion,char const * testStatement,BinaryIFunc func,Data const & input,Data const & input2)1296 	ShaderBitfieldOperationCaseBinaryInt4(Context& context, const char* name, glu::GLSLVersion glslVersion,
1297 										  char const* testStatement, BinaryIFunc func, Data const& input,
1298 										  Data const& input2)
1299 		: ShaderBitfieldOperationCaseBinaryInt(context, name, glslVersion, testStatement, func, input, input2, 4)
1300 	{
1301 	}
1302 };
1303 
ShaderBitfieldOperationTests(Context & context,glu::GLSLVersion glslVersion)1304 ShaderBitfieldOperationTests::ShaderBitfieldOperationTests(Context& context, glu::GLSLVersion glslVersion)
1305 	: TestCaseGroup(context, "shader_bitfield_operation", "Shader Bitfield Operation tests"), m_glslVersion(glslVersion)
1306 {
1307 }
1308 
~ShaderBitfieldOperationTests(void)1309 ShaderBitfieldOperationTests::~ShaderBitfieldOperationTests(void)
1310 {
1311 }
1312 
init(void)1313 void ShaderBitfieldOperationTests::init(void)
1314 {
1315 	de::Random rnd(m_context.getTestContext().getCommandLine().getBaseSeed());
1316 
1317 	// shader_bitfield_operation.frexp
1318 	tcu::TestCaseGroup* frexpGroup = new tcu::TestCaseGroup(m_testCtx, "frexp", "");
1319 	addChild(frexpGroup);
1320 	frexpGroup->addChild(new ShaderBitfieldOperationCaseFrexpFloat(m_context, "float_zero", m_glslVersion, Vec4(0.0)));
1321 	for (int i = 0; i < ITERATIONS; ++i)
1322 	{
1323 		std::stringstream ss;
1324 		ss << "float_" << i;
1325 		frexpGroup->addChild(new ShaderBitfieldOperationCaseFrexpFloat(m_context, ss.str().c_str(), m_glslVersion,
1326 																	   Vec4(rnd.getFloat())));
1327 	}
1328 	frexpGroup->addChild(
1329 		new ShaderBitfieldOperationCaseFrexpVec2(m_context, "vec2_zero", m_glslVersion, Vec4(0.0, 0.0)));
1330 	for (int i = 0; i < ITERATIONS; ++i)
1331 	{
1332 		std::stringstream ss;
1333 		ss << "vec2_" << i;
1334 		frexpGroup->addChild(new ShaderBitfieldOperationCaseFrexpVec2(m_context, ss.str().c_str(), m_glslVersion,
1335 																	  Vec4(rnd.getFloat(), -rnd.getFloat())));
1336 	}
1337 	frexpGroup->addChild(
1338 		new ShaderBitfieldOperationCaseFrexpVec3(m_context, "vec3_zero", m_glslVersion, Vec4(0.0, 0.0, 0.0)));
1339 	for (int i = 0; i < ITERATIONS; ++i)
1340 	{
1341 		std::stringstream ss;
1342 		ss << "vec3_" << i;
1343 		frexpGroup->addChild(new ShaderBitfieldOperationCaseFrexpVec3(
1344 			m_context, ss.str().c_str(), m_glslVersion, Vec4(rnd.getFloat(), -rnd.getFloat(), rnd.getFloat())));
1345 	}
1346 	frexpGroup->addChild(
1347 		new ShaderBitfieldOperationCaseFrexpVec4(m_context, "vec4_zero", m_glslVersion, Vec4(0.0, 0.0, 0.0, 0.0)));
1348 	for (int i = 0; i < ITERATIONS; ++i)
1349 	{
1350 		std::stringstream ss;
1351 		ss << "vec4_" << i;
1352 		frexpGroup->addChild(new ShaderBitfieldOperationCaseFrexpVec4(
1353 			m_context, ss.str().c_str(), m_glslVersion,
1354 			Vec4(rnd.getFloat(), -rnd.getFloat(), rnd.getFloat(), -rnd.getFloat())));
1355 	}
1356 
1357 	// shader_bitfield_operation.ldexp
1358 	tcu::TestCaseGroup* ldexpGroup = new tcu::TestCaseGroup(m_testCtx, "ldexp", "");
1359 	addChild(ldexpGroup);
1360 	ldexpGroup->addChild(
1361 		new ShaderBitfieldOperationCaseLdexpFloat(m_context, "float_zero", m_glslVersion, Vec4(0.0), Ivec4(0)));
1362 	for (int i = 0; i < ITERATIONS; ++i)
1363 	{
1364 		std::stringstream ss;
1365 		ss << "float_" << i;
1366 		ldexpGroup->addChild(new ShaderBitfieldOperationCaseLdexpFloat(m_context, ss.str().c_str(), m_glslVersion,
1367 																	   Vec4(rnd.getFloat()), Ivec4(rnd.getInt(-8, 8))));
1368 	}
1369 	ldexpGroup->addChild(
1370 		new ShaderBitfieldOperationCaseLdexpVec2(m_context, "vec2_zero", m_glslVersion, Vec4(0.0, 0.0), Ivec4(0, 0)));
1371 	for (int i = 0; i < ITERATIONS; ++i)
1372 	{
1373 		std::stringstream ss;
1374 		ss << "vec2_" << i;
1375 		ldexpGroup->addChild(new ShaderBitfieldOperationCaseLdexpVec2(m_context, ss.str().c_str(), m_glslVersion,
1376 																	  Vec4(rnd.getFloat(), -rnd.getFloat()),
1377 																	  Ivec4(rnd.getInt(-8, 8), rnd.getInt(-8, 8))));
1378 	}
1379 	ldexpGroup->addChild(new ShaderBitfieldOperationCaseLdexpVec3(m_context, "vec3_zero", m_glslVersion,
1380 																  Vec4(0.0, 0.0, 0.0), Ivec4(0, 0, 0)));
1381 	for (int i = 0; i < ITERATIONS; ++i)
1382 	{
1383 		std::stringstream ss;
1384 		ss << "vec3_" << i;
1385 		ldexpGroup->addChild(new ShaderBitfieldOperationCaseLdexpVec3(
1386 			m_context, ss.str().c_str(), m_glslVersion, Vec4(rnd.getFloat(), -rnd.getFloat(), rnd.getFloat()),
1387 			Ivec4(rnd.getInt(-8, 8), rnd.getInt(-8, 8), rnd.getInt(-8, 8))));
1388 	}
1389 	ldexpGroup->addChild(new ShaderBitfieldOperationCaseLdexpVec4(m_context, "vec4_zero", m_glslVersion,
1390 																  Vec4(0.0, 0.0, 0.0, 0.0), Ivec4(0, 0, 0, 0)));
1391 	for (int i = 0; i < ITERATIONS; ++i)
1392 	{
1393 		std::stringstream ss;
1394 		ss << "vec4_" << i;
1395 		ldexpGroup->addChild(new ShaderBitfieldOperationCaseLdexpVec4(
1396 			m_context, ss.str().c_str(), m_glslVersion,
1397 			Vec4(rnd.getFloat(), -rnd.getFloat(), rnd.getFloat(), -rnd.getFloat()),
1398 			Ivec4(rnd.getInt(-8, 8), rnd.getInt(-8, 8), rnd.getInt(-8, 8), rnd.getInt(-8, 8))));
1399 	}
1400 
1401 	// shader_bitfield_operation.packUnorm4x8
1402 	tcu::TestCaseGroup* packUnormGroup = new tcu::TestCaseGroup(m_testCtx, "packUnorm4x8", "");
1403 	addChild(packUnormGroup);
1404 	for (int i = 0; i < ITERATIONS; ++i)
1405 	{
1406 		std::stringstream ss;
1407 		ss << i;
1408 		packUnormGroup->addChild(new ShaderBitfieldOperationCasePackUnorm(
1409 			m_context, ss.str().c_str(), m_glslVersion,
1410 			Vec4(rnd.getFloat(), rnd.getFloat(), rnd.getFloat(), rnd.getFloat())));
1411 	}
1412 
1413 	// shader_bitfield_operation.packSnorm4x8
1414 	tcu::TestCaseGroup* packSnormGroup = new tcu::TestCaseGroup(m_testCtx, "packSnorm4x8", "");
1415 	addChild(packSnormGroup);
1416 	for (int i = 0; i < ITERATIONS; ++i)
1417 	{
1418 		std::stringstream ss;
1419 		ss << i;
1420 		packSnormGroup->addChild(new ShaderBitfieldOperationCasePackSnorm(
1421 			m_context, ss.str().c_str(), m_glslVersion,
1422 			Vec4(rnd.getFloat(), -rnd.getFloat(), rnd.getFloat(), -rnd.getFloat())));
1423 	}
1424 
1425 	// shader_bitfield_operation.unpackUnorm4x8
1426 	tcu::TestCaseGroup* unpackUnormGroup = new tcu::TestCaseGroup(m_testCtx, "unpackUnorm4x8", "");
1427 	addChild(unpackUnormGroup);
1428 	for (int i = 0; i < ITERATIONS; ++i)
1429 	{
1430 		std::stringstream ss;
1431 		ss << i;
1432 		unpackUnormGroup->addChild(new ShaderBitfieldOperationCaseUnpackUnorm(m_context, ss.str().c_str(),
1433 																			  m_glslVersion, Uvec4(rnd.getUint32())));
1434 	}
1435 
1436 	// shader_bitfield_operation.unpackSnorm4x8
1437 	tcu::TestCaseGroup* unpackSnormGroup = new tcu::TestCaseGroup(m_testCtx, "unpackSnorm4x8", "");
1438 	addChild(unpackSnormGroup);
1439 	for (int i = 0; i < ITERATIONS; ++i)
1440 	{
1441 		std::stringstream ss;
1442 		ss << i;
1443 		unpackSnormGroup->addChild(new ShaderBitfieldOperationCaseUnpackSnorm(m_context, ss.str().c_str(),
1444 																			  m_glslVersion, Uvec4(rnd.getUint32())));
1445 	}
1446 
1447 	// shader_bitfield_operation.bitfieldExtract
1448 	tcu::TestCaseGroup* bitfieldExtractGroup = new tcu::TestCaseGroup(m_testCtx, "bitfieldExtract", "");
1449 	addChild(bitfieldExtractGroup);
1450 	for (int i = 0; i < ITERATIONS; ++i)
1451 	{
1452 		std::stringstream ss;
1453 		ss << "uint_" << i;
1454 		bitfieldExtractGroup->addChild(new ShaderBitfieldOperationCaseBitfieldExtractUint1(
1455 			m_context, ss.str().c_str(), m_glslVersion, Uvec4(rnd.getUint32()), rnd.getInt(0, 31), rnd.getInt(1, 32)));
1456 	}
1457 	for (int i = 0; i < ITERATIONS; ++i)
1458 	{
1459 		std::stringstream ss;
1460 		ss << "uvec2_" << i;
1461 		bitfieldExtractGroup->addChild(new ShaderBitfieldOperationCaseBitfieldExtractUint2(
1462 			m_context, ss.str().c_str(), m_glslVersion, Uvec4(rnd.getUint32(), rnd.getUint32()), rnd.getInt(0, 31),
1463 			rnd.getInt(1, 32)));
1464 	}
1465 	for (int i = 0; i < ITERATIONS; ++i)
1466 	{
1467 		std::stringstream ss;
1468 		ss << "uvec3_" << i;
1469 		bitfieldExtractGroup->addChild(new ShaderBitfieldOperationCaseBitfieldExtractUint3(
1470 			m_context, ss.str().c_str(), m_glslVersion, Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32()),
1471 			rnd.getInt(0, 31), rnd.getInt(1, 32)));
1472 	}
1473 	for (int i = 0; i < ITERATIONS; ++i)
1474 	{
1475 		std::stringstream ss;
1476 		ss << "uvec4_" << i;
1477 		bitfieldExtractGroup->addChild(new ShaderBitfieldOperationCaseBitfieldExtractUint4(
1478 			m_context, ss.str().c_str(), m_glslVersion,
1479 			Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32(), rnd.getUint32()), rnd.getInt(0, 31),
1480 			rnd.getInt(1, 32)));
1481 	}
1482 
1483 	for (int i = 0; i < ITERATIONS; ++i)
1484 	{
1485 		std::stringstream ss;
1486 		ss << "int_" << i;
1487 		bitfieldExtractGroup->addChild(new ShaderBitfieldOperationCaseBitfieldExtractInt1(
1488 			m_context, ss.str().c_str(), m_glslVersion, Ivec4(rnd.getUint32()), rnd.getInt(0, 31), rnd.getInt(1, 32)));
1489 	}
1490 	for (int i = 0; i < ITERATIONS; ++i)
1491 	{
1492 		std::stringstream ss;
1493 		ss << "ivec2_" << i;
1494 		bitfieldExtractGroup->addChild(new ShaderBitfieldOperationCaseBitfieldExtractInt2(
1495 			m_context, ss.str().c_str(), m_glslVersion, Ivec4(rnd.getUint32(), rnd.getUint32()), rnd.getInt(0, 31),
1496 			rnd.getInt(1, 32)));
1497 	}
1498 	for (int i = 0; i < ITERATIONS; ++i)
1499 	{
1500 		std::stringstream ss;
1501 		ss << "ivec3_" << i;
1502 		bitfieldExtractGroup->addChild(new ShaderBitfieldOperationCaseBitfieldExtractInt3(
1503 			m_context, ss.str().c_str(), m_glslVersion, Ivec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32()),
1504 			rnd.getInt(0, 31), rnd.getInt(1, 32)));
1505 	}
1506 	for (int i = 0; i < ITERATIONS; ++i)
1507 	{
1508 		std::stringstream ss;
1509 		ss << "ivec4_" << i;
1510 		bitfieldExtractGroup->addChild(new ShaderBitfieldOperationCaseBitfieldExtractInt4(
1511 			m_context, ss.str().c_str(), m_glslVersion,
1512 			Ivec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32(), rnd.getUint32()), rnd.getInt(0, 31),
1513 			rnd.getInt(1, 32)));
1514 	}
1515 
1516 	// shader_bitfield_operation.bitfieldInsert
1517 	tcu::TestCaseGroup* bitfieldInsertGroup = new tcu::TestCaseGroup(m_testCtx, "bitfieldInsert", "");
1518 	addChild(bitfieldInsertGroup);
1519 	for (int i = 0; i < ITERATIONS; ++i)
1520 	{
1521 		std::stringstream ss;
1522 		ss << "uint_" << i;
1523 		bitfieldInsertGroup->addChild(new ShaderBitfieldOperationCaseBitfieldInsertUint1(
1524 			m_context, ss.str().c_str(), m_glslVersion, Uvec4(rnd.getUint32()), Uvec4(rnd.getUint32()),
1525 			rnd.getInt(0, 31), rnd.getInt(1, 32)));
1526 	}
1527 	for (int i = 0; i < ITERATIONS; ++i)
1528 	{
1529 		std::stringstream ss;
1530 		ss << "uvec2_" << i;
1531 		bitfieldInsertGroup->addChild(new ShaderBitfieldOperationCaseBitfieldInsertUint2(
1532 			m_context, ss.str().c_str(), m_glslVersion, Uvec4(rnd.getUint32(), rnd.getUint32()),
1533 			Uvec4(rnd.getUint32(), rnd.getUint32()), rnd.getInt(0, 31), rnd.getInt(1, 32)));
1534 	}
1535 	for (int i = 0; i < ITERATIONS; ++i)
1536 	{
1537 		std::stringstream ss;
1538 		ss << "uvec3_" << i;
1539 		bitfieldInsertGroup->addChild(new ShaderBitfieldOperationCaseBitfieldInsertUint3(
1540 			m_context, ss.str().c_str(), m_glslVersion, Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32()),
1541 			Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32()), rnd.getInt(0, 31), rnd.getInt(1, 32)));
1542 	}
1543 	for (int i = 0; i < ITERATIONS; ++i)
1544 	{
1545 		std::stringstream ss;
1546 		ss << "uvec4_" << i;
1547 		bitfieldInsertGroup->addChild(new ShaderBitfieldOperationCaseBitfieldInsertUint4(
1548 			m_context, ss.str().c_str(), m_glslVersion,
1549 			Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32(), rnd.getUint32()),
1550 			Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32(), rnd.getUint32()), rnd.getInt(0, 31),
1551 			rnd.getInt(1, 32)));
1552 	}
1553 
1554 	for (int i = 0; i < ITERATIONS; ++i)
1555 	{
1556 		std::stringstream ss;
1557 		ss << "int_" << i;
1558 		bitfieldInsertGroup->addChild(new ShaderBitfieldOperationCaseBitfieldInsertInt1(
1559 			m_context, ss.str().c_str(), m_glslVersion, Ivec4(rnd.getUint32()), Ivec4(rnd.getUint32()),
1560 			rnd.getInt(0, 31), rnd.getInt(1, 32)));
1561 	}
1562 	for (int i = 0; i < ITERATIONS; ++i)
1563 	{
1564 		std::stringstream ss;
1565 		ss << "ivec2_" << i;
1566 		bitfieldInsertGroup->addChild(new ShaderBitfieldOperationCaseBitfieldInsertInt2(
1567 			m_context, ss.str().c_str(), m_glslVersion, Ivec4(rnd.getUint32(), rnd.getUint32()),
1568 			Ivec4(rnd.getUint32(), rnd.getUint32()), rnd.getInt(0, 31), rnd.getInt(1, 32)));
1569 	}
1570 	for (int i = 0; i < ITERATIONS; ++i)
1571 	{
1572 		std::stringstream ss;
1573 		ss << "ivec3_" << i;
1574 		bitfieldInsertGroup->addChild(new ShaderBitfieldOperationCaseBitfieldInsertInt3(
1575 			m_context, ss.str().c_str(), m_glslVersion, Ivec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32()),
1576 			Ivec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32()), rnd.getInt(0, 31), rnd.getInt(1, 32)));
1577 	}
1578 	for (int i = 0; i < ITERATIONS; ++i)
1579 	{
1580 		std::stringstream ss;
1581 		ss << "ivec4_" << i;
1582 		bitfieldInsertGroup->addChild(new ShaderBitfieldOperationCaseBitfieldInsertInt4(
1583 			m_context, ss.str().c_str(), m_glslVersion,
1584 			Ivec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32(), rnd.getUint32()),
1585 			Ivec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32(), rnd.getUint32()), rnd.getInt(0, 31),
1586 			rnd.getInt(1, 32)));
1587 	}
1588 
1589 	struct UnaryTest
1590 	{
1591 		char const* funcName;
1592 		UnaryUFunc  funcU;
1593 		UnaryIFunc  funcI;
1594 	} commonTests[] = {
1595 		{ "bitfieldReverse", bitfieldReverse,
1596 		  reinterpret_cast<UnaryIFunc>(bitfieldReverse) },				  // shader_bitfield_operation.bitfieldReverse
1597 		{ "bitCount", bitCount, reinterpret_cast<UnaryIFunc>(bitCount) }, // shader_bitfield_operation.bitCount
1598 		{ "findLSB", findLSB, reinterpret_cast<UnaryIFunc>(findLSB) },	// shader_bitfield_operation.findLSB
1599 		{ "findMSB", findMSBU, findMSBI },								  // shader_bitfield_operation.findMSB
1600 	};
1601 	for (int test = 0; test < DE_LENGTH_OF_ARRAY(commonTests); ++test)
1602 	{
1603 		tcu::TestCaseGroup* commonGroup = new tcu::TestCaseGroup(m_testCtx, commonTests[test].funcName, "");
1604 		addChild(commonGroup);
1605 		commonGroup->addChild(new ShaderBitfieldOperationCaseUnaryUint1(
1606 			m_context, "uint_zero", m_glslVersion, commonTests[test].funcName, commonTests[test].funcU, Uvec4(0)));
1607 		for (int i = 0; i < ITERATIONS; ++i)
1608 		{
1609 			std::stringstream ss;
1610 			ss << "uint_" << i;
1611 			commonGroup->addChild(new ShaderBitfieldOperationCaseUnaryUint1(
1612 				m_context, ss.str().c_str(), m_glslVersion, commonTests[test].funcName, commonTests[test].funcU,
1613 				Uvec4(rnd.getUint32())));
1614 		}
1615 		for (int i = 0; i < ITERATIONS; ++i)
1616 		{
1617 			std::stringstream ss;
1618 			ss << "uvec2_" << i;
1619 			commonGroup->addChild(new ShaderBitfieldOperationCaseUnaryUint2(
1620 				m_context, ss.str().c_str(), m_glslVersion, commonTests[test].funcName, commonTests[test].funcU,
1621 				Uvec4(rnd.getUint32(), rnd.getUint32())));
1622 		}
1623 		for (int i = 0; i < ITERATIONS; ++i)
1624 		{
1625 			std::stringstream ss;
1626 			ss << "uvec3_" << i;
1627 			commonGroup->addChild(new ShaderBitfieldOperationCaseUnaryUint3(
1628 				m_context, ss.str().c_str(), m_glslVersion, commonTests[test].funcName, commonTests[test].funcU,
1629 				Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32())));
1630 		}
1631 		for (int i = 0; i < ITERATIONS; ++i)
1632 		{
1633 			std::stringstream ss;
1634 			ss << "uvec4_" << i;
1635 			commonGroup->addChild(new ShaderBitfieldOperationCaseUnaryUint4(
1636 				m_context, ss.str().c_str(), m_glslVersion, commonTests[test].funcName, commonTests[test].funcU,
1637 				Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32(), rnd.getUint32())));
1638 		}
1639 
1640 		commonGroup->addChild(new ShaderBitfieldOperationCaseUnaryInt1(
1641 			m_context, "int_zero", m_glslVersion, commonTests[test].funcName, commonTests[test].funcI, Ivec4(0)));
1642 		commonGroup->addChild(new ShaderBitfieldOperationCaseUnaryInt1(
1643 			m_context, "int_minus_one", m_glslVersion, commonTests[test].funcName, commonTests[test].funcI, Ivec4(-1)));
1644 		for (int i = 0; i < ITERATIONS; ++i)
1645 		{
1646 			std::stringstream ss;
1647 			ss << "int_" << i;
1648 			commonGroup->addChild(new ShaderBitfieldOperationCaseUnaryInt1(
1649 				m_context, ss.str().c_str(), m_glslVersion, commonTests[test].funcName, commonTests[test].funcI,
1650 				Ivec4(rnd.getUint32())));
1651 		}
1652 		for (int i = 0; i < ITERATIONS; ++i)
1653 		{
1654 			std::stringstream ss;
1655 			ss << "ivec2_" << i;
1656 			commonGroup->addChild(new ShaderBitfieldOperationCaseUnaryInt2(
1657 				m_context, ss.str().c_str(), m_glslVersion, commonTests[test].funcName, commonTests[test].funcI,
1658 				Ivec4(rnd.getUint32(), rnd.getUint32())));
1659 		}
1660 		for (int i = 0; i < ITERATIONS; ++i)
1661 		{
1662 			std::stringstream ss;
1663 			ss << "ivec3_" << i;
1664 			commonGroup->addChild(new ShaderBitfieldOperationCaseUnaryInt3(
1665 				m_context, ss.str().c_str(), m_glslVersion, commonTests[test].funcName, commonTests[test].funcI,
1666 				Ivec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32())));
1667 		}
1668 		for (int i = 0; i < ITERATIONS; ++i)
1669 		{
1670 			std::stringstream ss;
1671 			ss << "ivec4_" << i;
1672 			commonGroup->addChild(new ShaderBitfieldOperationCaseUnaryInt4(
1673 				m_context, ss.str().c_str(), m_glslVersion, commonTests[test].funcName, commonTests[test].funcI,
1674 				Ivec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32(), rnd.getUint32())));
1675 		}
1676 	}
1677 
1678 	// shader_bitfield_operation.uaddCarry
1679 	tcu::TestCaseGroup* uaddCarryGroup = new tcu::TestCaseGroup(m_testCtx, "uaddCarry", "");
1680 	addChild(uaddCarryGroup);
1681 	for (int i = 0; i < ITERATIONS; ++i)
1682 	{
1683 		std::stringstream ss;
1684 		ss << "uint_" << i;
1685 		uaddCarryGroup->addChild(new ShaderBitfieldOperationCaseBinaryUint1(
1686 			m_context, ss.str().c_str(), m_glslVersion, "outUvec4.x = uaddCarry(inUvec4.x, in2Uvec4.x, out2Uvec4.x);",
1687 			uaddCarry, Uvec4(rnd.getUint32()), Uvec4(rnd.getUint32())));
1688 	}
1689 	for (int i = 0; i < ITERATIONS; ++i)
1690 	{
1691 		std::stringstream ss;
1692 		ss << "uvec2_" << i;
1693 		uaddCarryGroup->addChild(new ShaderBitfieldOperationCaseBinaryUint2(
1694 			m_context, ss.str().c_str(), m_glslVersion,
1695 			"outUvec4.xy = uaddCarry(inUvec4.xy, in2Uvec4.xy, out2Uvec4.xy);", uaddCarry,
1696 			Uvec4(rnd.getUint32(), rnd.getUint32()), Uvec4(rnd.getUint32(), rnd.getUint32())));
1697 	}
1698 	for (int i = 0; i < ITERATIONS; ++i)
1699 	{
1700 		std::stringstream ss;
1701 		ss << "uvec3_" << i;
1702 		uaddCarryGroup->addChild(new ShaderBitfieldOperationCaseBinaryUint3(
1703 			m_context, ss.str().c_str(), m_glslVersion,
1704 			"outUvec4.xyz = uaddCarry(inUvec4.xyz, in2Uvec4.xyz, out2Uvec4.xyz);", uaddCarry,
1705 			Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32()),
1706 			Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32())));
1707 	}
1708 	for (int i = 0; i < ITERATIONS; ++i)
1709 	{
1710 		std::stringstream ss;
1711 		ss << "uvec4_" << i;
1712 		uaddCarryGroup->addChild(new ShaderBitfieldOperationCaseBinaryUint4(
1713 			m_context, ss.str().c_str(), m_glslVersion, "outUvec4 = uaddCarry(inUvec4, in2Uvec4, out2Uvec4);",
1714 			uaddCarry, Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32(), rnd.getUint32()),
1715 			Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32(), rnd.getUint32())));
1716 	}
1717 
1718 	// shader_bitfield_operation.usubBorrow
1719 	tcu::TestCaseGroup* usubBorrowGroup = new tcu::TestCaseGroup(m_testCtx, "usubBorrow", "");
1720 	addChild(usubBorrowGroup);
1721 	for (int i = 0; i < ITERATIONS; ++i)
1722 	{
1723 		std::stringstream ss;
1724 		ss << "uint_" << i;
1725 		usubBorrowGroup->addChild(new ShaderBitfieldOperationCaseBinaryUint1(
1726 			m_context, ss.str().c_str(), m_glslVersion, "outUvec4.x = usubBorrow(inUvec4.x, in2Uvec4.x, out2Uvec4.x);",
1727 			usubBorrow, Uvec4(rnd.getUint32()), Uvec4(rnd.getUint32())));
1728 	}
1729 	for (int i = 0; i < ITERATIONS; ++i)
1730 	{
1731 		std::stringstream ss;
1732 		ss << "uvec2_" << i;
1733 		usubBorrowGroup->addChild(new ShaderBitfieldOperationCaseBinaryUint2(
1734 			m_context, ss.str().c_str(), m_glslVersion,
1735 			"outUvec4.xy = usubBorrow(inUvec4.xy, in2Uvec4.xy, out2Uvec4.xy);", usubBorrow,
1736 			Uvec4(rnd.getUint32(), rnd.getUint32()), Uvec4(rnd.getUint32(), rnd.getUint32())));
1737 	}
1738 	for (int i = 0; i < ITERATIONS; ++i)
1739 	{
1740 		std::stringstream ss;
1741 		ss << "uvec3_" << i;
1742 		usubBorrowGroup->addChild(new ShaderBitfieldOperationCaseBinaryUint3(
1743 			m_context, ss.str().c_str(), m_glslVersion,
1744 			"outUvec4.xyz = usubBorrow(inUvec4.xyz, in2Uvec4.xyz, out2Uvec4.xyz);", usubBorrow,
1745 			Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32()),
1746 			Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32())));
1747 	}
1748 	for (int i = 0; i < ITERATIONS; ++i)
1749 	{
1750 		std::stringstream ss;
1751 		ss << "uvec4_" << i;
1752 		usubBorrowGroup->addChild(new ShaderBitfieldOperationCaseBinaryUint4(
1753 			m_context, ss.str().c_str(), m_glslVersion, "outUvec4 = usubBorrow(inUvec4, in2Uvec4, out2Uvec4);",
1754 			usubBorrow, Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32(), rnd.getUint32()),
1755 			Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32(), rnd.getUint32())));
1756 	}
1757 
1758 	// shader_bitfield_operation.umulExtended
1759 	tcu::TestCaseGroup* umulExtendedGroup = new tcu::TestCaseGroup(m_testCtx, "umulExtended", "");
1760 	addChild(umulExtendedGroup);
1761 	for (int i = 0; i < ITERATIONS; ++i)
1762 	{
1763 		std::stringstream ss;
1764 		ss << "uint_" << i;
1765 		umulExtendedGroup->addChild(new ShaderBitfieldOperationCaseBinaryUint1(
1766 			m_context, ss.str().c_str(), m_glslVersion, "umulExtended(inUvec4.x, in2Uvec4.x, outUvec4.x, out2Uvec4.x);",
1767 			umulExtended, Uvec4(rnd.getUint32()), Uvec4(rnd.getUint32())));
1768 	}
1769 	for (int i = 0; i < ITERATIONS; ++i)
1770 	{
1771 		std::stringstream ss;
1772 		ss << "uvec2_" << i;
1773 		umulExtendedGroup->addChild(new ShaderBitfieldOperationCaseBinaryUint2(
1774 			m_context, ss.str().c_str(), m_glslVersion,
1775 			"umulExtended(inUvec4.xy, in2Uvec4.xy, outUvec4.xy, out2Uvec4.xy);", umulExtended,
1776 			Uvec4(rnd.getUint32(), rnd.getUint32()), Uvec4(rnd.getUint32(), rnd.getUint32())));
1777 	}
1778 	for (int i = 0; i < ITERATIONS; ++i)
1779 	{
1780 		std::stringstream ss;
1781 		ss << "uvec3_" << i;
1782 		umulExtendedGroup->addChild(new ShaderBitfieldOperationCaseBinaryUint3(
1783 			m_context, ss.str().c_str(), m_glslVersion,
1784 			"umulExtended(inUvec4.xyz, in2Uvec4.xyz, outUvec4.xyz, out2Uvec4.xyz);", umulExtended,
1785 			Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32()),
1786 			Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32())));
1787 	}
1788 	for (int i = 0; i < ITERATIONS; ++i)
1789 	{
1790 		std::stringstream ss;
1791 		ss << "uvec4_" << i;
1792 		umulExtendedGroup->addChild(new ShaderBitfieldOperationCaseBinaryUint4(
1793 			m_context, ss.str().c_str(), m_glslVersion, "umulExtended(inUvec4, in2Uvec4, outUvec4, out2Uvec4);",
1794 			umulExtended, Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32(), rnd.getUint32()),
1795 			Uvec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32(), rnd.getUint32())));
1796 	}
1797 
1798 	// shader_bitfield_operation.imulExtended
1799 	tcu::TestCaseGroup* imulExtendedGroup = new tcu::TestCaseGroup(m_testCtx, "imulExtended", "");
1800 	addChild(imulExtendedGroup);
1801 	for (int i = 0; i < ITERATIONS; ++i)
1802 	{
1803 		std::stringstream ss;
1804 		ss << "int_" << i;
1805 		imulExtendedGroup->addChild(new ShaderBitfieldOperationCaseBinaryInt1(
1806 			m_context, ss.str().c_str(), m_glslVersion, "imulExtended(inIvec4.x, in2Ivec4.x, outIvec4.x, out2Ivec4.x);",
1807 			imulExtended, Ivec4(rnd.getUint32()), Ivec4(rnd.getUint32())));
1808 	}
1809 	for (int i = 0; i < ITERATIONS; ++i)
1810 	{
1811 		std::stringstream ss;
1812 		ss << "ivec2_" << i;
1813 		imulExtendedGroup->addChild(new ShaderBitfieldOperationCaseBinaryInt2(
1814 			m_context, ss.str().c_str(), m_glslVersion,
1815 			"imulExtended(inIvec4.xy, in2Ivec4.xy, outIvec4.xy, out2Ivec4.xy);", imulExtended,
1816 			Ivec4(rnd.getUint32(), rnd.getUint32()), Ivec4(rnd.getUint32(), rnd.getUint32())));
1817 	}
1818 	for (int i = 0; i < ITERATIONS; ++i)
1819 	{
1820 		std::stringstream ss;
1821 		ss << "ivec3_" << i;
1822 		imulExtendedGroup->addChild(new ShaderBitfieldOperationCaseBinaryInt3(
1823 			m_context, ss.str().c_str(), m_glslVersion,
1824 			"imulExtended(inIvec4.xyz, in2Ivec4.xyz, outIvec4.xyz, out2Ivec4.xyz);", imulExtended,
1825 			Ivec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32()),
1826 			Ivec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32())));
1827 	}
1828 	for (int i = 0; i < ITERATIONS; ++i)
1829 	{
1830 		std::stringstream ss;
1831 		ss << "ivec4_" << i;
1832 		imulExtendedGroup->addChild(new ShaderBitfieldOperationCaseBinaryInt4(
1833 			m_context, ss.str().c_str(), m_glslVersion, "imulExtended(inIvec4, in2Ivec4, outIvec4, out2Ivec4);",
1834 			imulExtended, Ivec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32(), rnd.getUint32()),
1835 			Ivec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32(), rnd.getUint32())));
1836 	}
1837 }
1838 
1839 } // glcts
1840