• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2015 The Khronos Group Inc.
6  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7  * Copyright (c) 2016 The Android Open Source Project
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief Common built-in function tests.
24  *//*--------------------------------------------------------------------*/
25 
26 #include "vktShaderCommonFunctionTests.hpp"
27 #include "vktShaderExecutor.hpp"
28 #include "vkQueryUtil.hpp"
29 #include "gluContextInfo.hpp"
30 #include "tcuTestLog.hpp"
31 #include "tcuFormatUtil.hpp"
32 #include "tcuFloat.hpp"
33 #include "tcuInterval.hpp"
34 #include "tcuFloatFormat.hpp"
35 #include "tcuVectorUtil.hpp"
36 #include "deRandom.hpp"
37 #include "deMath.h"
38 #include "deString.h"
39 #include "deArrayUtil.hpp"
40 #include "deSharedPtr.hpp"
41 #include <algorithm>
42 
43 namespace vkt
44 {
45 
46 namespace shaderexecutor
47 {
48 
49 
50 using std::vector;
51 using std::string;
52 using tcu::TestLog;
53 
54 using tcu::Vec2;
55 using tcu::Vec3;
56 using tcu::Vec4;
57 using tcu::IVec2;
58 using tcu::IVec3;
59 using tcu::IVec4;
60 
61 namespace
62 {
63 
64 // Utilities
65 
66 template<typename T, int Size>
67 struct VecArrayAccess
68 {
69 public:
VecArrayAccessvkt::shaderexecutor::__anon4b662c020111::VecArrayAccess70 									VecArrayAccess	(const void* ptr) : m_array((tcu::Vector<T, Size>*)ptr) {}
~VecArrayAccessvkt::shaderexecutor::__anon4b662c020111::VecArrayAccess71 									~VecArrayAccess	(void) {}
72 
operator []vkt::shaderexecutor::__anon4b662c020111::VecArrayAccess73 	const tcu::Vector<T, Size>&		operator[]		(size_t offset) const	{ return m_array[offset];	}
operator []vkt::shaderexecutor::__anon4b662c020111::VecArrayAccess74 	tcu::Vector<T, Size>&			operator[]		(size_t offset)			{ return m_array[offset];	}
75 
76 private:
77 	tcu::Vector<T, Size>*			m_array;
78 };
79 
80 template<typename T, int Size>
fillRandomVectors(de::Random & rnd,const tcu::Vector<T,Size> & minValue,const tcu::Vector<T,Size> & maxValue,void * dst,int numValues,int offset=0)81 static void fillRandomVectors (de::Random& rnd, const tcu::Vector<T, Size>& minValue, const tcu::Vector<T, Size>& maxValue, void* dst, int numValues, int offset = 0)
82 {
83 	VecArrayAccess<T, Size> access(dst);
84 	for (int ndx = 0; ndx < numValues; ndx++)
85 		access[offset + ndx] = tcu::randomVector<T, Size>(rnd, minValue, maxValue);
86 }
87 
88 template<typename T>
fillRandomScalars(de::Random & rnd,T minValue,T maxValue,void * dst,int numValues,int offset=0)89 static void fillRandomScalars (de::Random& rnd, T minValue, T maxValue, void* dst, int numValues, int offset = 0)
90 {
91 	T* typedPtr = (T*)dst;
92 	for (int ndx = 0; ndx < numValues; ndx++)
93 		typedPtr[offset + ndx] = de::randomScalar<T>(rnd, minValue, maxValue);
94 }
95 
getUlpDiff(float a,float b)96 inline deUint32 getUlpDiff (float a, float b)
97 {
98 	const deUint32	aBits	= tcu::Float32(a).bits();
99 	const deUint32	bBits	= tcu::Float32(b).bits();
100 	return aBits > bBits ? aBits - bBits : bBits - aBits;
101 }
102 
getUlpDiffIgnoreZeroSign(float a,float b)103 inline deUint32 getUlpDiffIgnoreZeroSign (float a, float b)
104 {
105 	if (tcu::Float32(a).isZero())
106 		return getUlpDiff(tcu::Float32::construct(tcu::Float32(b).sign(), 0, 0).asFloat(), b);
107 	else if (tcu::Float32(b).isZero())
108 		return getUlpDiff(a, tcu::Float32::construct(tcu::Float32(a).sign(), 0, 0).asFloat());
109 	else
110 		return getUlpDiff(a, b);
111 }
112 
getMaxUlpDiffFromBits(int numAccurateBits,int numTotalBits)113 inline deUint64 getMaxUlpDiffFromBits (int numAccurateBits, int numTotalBits)
114 {
115 	const int		numGarbageBits	= numTotalBits-numAccurateBits;
116 	const deUint64	mask			= (1ull<<numGarbageBits)-1ull;
117 
118 	return mask;
119 }
120 
getNumMantissaBits(glu::DataType type)121 static int getNumMantissaBits (glu::DataType type)
122 {
123 	DE_ASSERT(glu::isDataTypeFloatOrVec(type) || glu::isDataTypeDoubleOrDVec(type));
124 	return (glu::isDataTypeFloatOrVec(type) ? 23 : 52);
125 }
126 
getMinMantissaBits(glu::DataType type,glu::Precision precision)127 static int getMinMantissaBits (glu::DataType type, glu::Precision precision)
128 {
129 	if (glu::isDataTypeDoubleOrDVec(type))
130 	{
131 		return tcu::Float64::MANTISSA_BITS;
132 	}
133 
134 	// Float case.
135 	const int bits[] =
136 	{
137 		7,								// lowp
138 		tcu::Float16::MANTISSA_BITS,	// mediump
139 		tcu::Float32::MANTISSA_BITS,	// highp
140 	};
141 	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(bits) == glu::PRECISION_LAST);
142 	DE_ASSERT(de::inBounds<int>(precision, 0, DE_LENGTH_OF_ARRAY(bits)));
143 	return bits[precision];
144 }
145 
getExponentBits(glu::DataType type)146 static int getExponentBits (glu::DataType type)
147 {
148 	DE_ASSERT(glu::isDataTypeFloatOrVec(type) || glu::isDataTypeDoubleOrDVec(type));
149 	return (glu::isDataTypeFloatOrVec(type) ? static_cast<int>(tcu::Float32::EXPONENT_BITS) : static_cast<int>(tcu::Float64::EXPONENT_BITS));
150 }
151 
getExponentMask(int exponentBits)152 static deUint32 getExponentMask (int exponentBits)
153 {
154 	DE_ASSERT(exponentBits > 0);
155 	return ((1u<<exponentBits) - 1u);
156 }
157 
getComponentByteSize(glu::DataType type)158 static int getComponentByteSize (glu::DataType type)
159 {
160 	const glu::DataType scalarType = glu::getDataTypeScalarType(type);
161 
162 	DE_ASSERT(	scalarType == glu::TYPE_FLOAT	||
163 				scalarType == glu::TYPE_FLOAT16	||
164 				scalarType == glu::TYPE_DOUBLE	||
165 				scalarType == glu::TYPE_INT		||
166 				scalarType == glu::TYPE_UINT	||
167 				scalarType == glu::TYPE_INT8	||
168 				scalarType == glu::TYPE_UINT8	||
169 				scalarType == glu::TYPE_INT16	||
170 				scalarType == glu::TYPE_UINT16	||
171 				scalarType == glu::TYPE_BOOL	);
172 
173 	switch (scalarType)
174 	{
175 	case glu::TYPE_INT8:
176 	case glu::TYPE_UINT8:
177 		return 1;
178 	case glu::TYPE_INT16:
179 	case glu::TYPE_UINT16:
180 	case glu::TYPE_FLOAT16:
181 		return 2;
182 	case glu::TYPE_BOOL:
183 	case glu::TYPE_INT:
184 	case glu::TYPE_UINT:
185 	case glu::TYPE_FLOAT:
186 		return 4;
187 	case glu::TYPE_DOUBLE:
188 		return 8;
189 	default:
190 		DE_ASSERT(false); break;
191 	}
192 	// Unreachable.
193 	return 0;
194 }
195 
getScalarSizes(const vector<Symbol> & symbols)196 static vector<int> getScalarSizes (const vector<Symbol>& symbols)
197 {
198 	vector<int> sizes(symbols.size());
199 	for (int ndx = 0; ndx < (int)symbols.size(); ++ndx)
200 		sizes[ndx] = symbols[ndx].varType.getScalarSize();
201 	return sizes;
202 }
203 
getComponentByteSizes(const vector<Symbol> & symbols)204 static vector<int> getComponentByteSizes (const vector<Symbol>& symbols)
205 {
206 	vector<int> sizes;
207 	sizes.reserve(symbols.size());
208 	for (const auto& sym : symbols)
209 		sizes.push_back(getComponentByteSize(sym.varType.getBasicType()));
210 	return sizes;
211 }
212 
computeTotalByteSize(const vector<Symbol> & symbols)213 static int computeTotalByteSize (const vector<Symbol>& symbols)
214 {
215 	int totalSize = 0;
216 	for (const auto& sym : symbols)
217 		totalSize += getComponentByteSize(sym.varType.getBasicType()) * sym.varType.getScalarSize();
218 	return totalSize;
219 }
220 
getInputOutputPointers(const vector<Symbol> & symbols,vector<deUint8> & data,const int numValues)221 static vector<void*> getInputOutputPointers (const vector<Symbol>& symbols, vector<deUint8>& data, const int numValues)
222 {
223 	vector<void*>	pointers		(symbols.size());
224 	int				curScalarOffset	= 0;
225 
226 	for (int varNdx = 0; varNdx < (int)symbols.size(); ++varNdx)
227 	{
228 		const Symbol&	var				= symbols[varNdx];
229 		const int		scalarSize		= var.varType.getScalarSize();
230 		const auto		componentBytes	= getComponentByteSize(var.varType.getBasicType());
231 
232 		// Uses planar layout as input/output specs do not support strides.
233 		pointers[varNdx] = &data[curScalarOffset];
234 		curScalarOffset += scalarSize*numValues*componentBytes;
235 	}
236 
237 	DE_ASSERT(curScalarOffset == (int)data.size());
238 
239 	return pointers;
240 }
241 
checkTypeSupport(Context & context,glu::DataType dataType)242 void checkTypeSupport (Context& context, glu::DataType dataType)
243 {
244 	if (glu::isDataTypeDoubleOrDVec(dataType))
245 	{
246 		const auto&	vki				= context.getInstanceInterface();
247 		const auto	physicalDevice	= context.getPhysicalDevice();
248 
249 		const auto features = vk::getPhysicalDeviceFeatures(vki, physicalDevice);
250 		if (!features.shaderFloat64)
251 			TCU_THROW(NotSupportedError, "64-bit floats not supported by the implementation");
252 	}
253 }
254 
255 // \todo [2013-08-08 pyry] Make generic utility and move to glu?
256 
257 struct HexFloat
258 {
259 	const float value;
HexFloatvkt::shaderexecutor::__anon4b662c020111::HexFloat260 	HexFloat (const float value_) : value(value_) {}
261 };
262 
operator <<(std::ostream & str,const HexFloat & v)263 std::ostream& operator<< (std::ostream& str, const HexFloat& v)
264 {
265 	return str << v.value << " / " << tcu::toHex(tcu::Float32(v.value).bits());
266 }
267 
268 struct HexDouble
269 {
270 	const double value;
HexDoublevkt::shaderexecutor::__anon4b662c020111::HexDouble271 	HexDouble (const double value_) : value(value_) {}
272 };
273 
operator <<(std::ostream & str,const HexDouble & v)274 std::ostream& operator<< (std::ostream& str, const HexDouble& v)
275 {
276 	return str << v.value << " / " << tcu::toHex(tcu::Float64(v.value).bits());
277 }
278 
279 struct HexBool
280 {
281 	const deUint32 value;
HexBoolvkt::shaderexecutor::__anon4b662c020111::HexBool282 	HexBool (const deUint32 value_) : value(value_) {}
283 };
284 
operator <<(std::ostream & str,const HexBool & v)285 std::ostream& operator<< (std::ostream& str, const HexBool& v)
286 {
287 	return str << (v.value ? "true" : "false") << " / " << tcu::toHex(v.value);
288 }
289 
290 struct VarValue
291 {
292 	const glu::VarType&	type;
293 	const void*			value;
294 
VarValuevkt::shaderexecutor::__anon4b662c020111::VarValue295 	VarValue (const glu::VarType& type_, const void* value_) : type(type_), value(value_) {}
296 };
297 
operator <<(std::ostream & str,const VarValue & varValue)298 std::ostream& operator<< (std::ostream& str, const VarValue& varValue)
299 {
300 	DE_ASSERT(varValue.type.isBasicType());
301 
302 	const glu::DataType		basicType		= varValue.type.getBasicType();
303 	const glu::DataType		scalarType		= glu::getDataTypeScalarType(basicType);
304 	const int				numComponents	= glu::getDataTypeScalarSize(basicType);
305 
306 	if (numComponents > 1)
307 		str << glu::getDataTypeName(basicType) << "(";
308 
309 	for (int compNdx = 0; compNdx < numComponents; compNdx++)
310 	{
311 		if (compNdx != 0)
312 			str << ", ";
313 
314 		switch (scalarType)
315 		{
316 			case glu::TYPE_FLOAT:	str << HexFloat(((const float*)varValue.value)[compNdx]);			break;
317 			case glu::TYPE_INT:		str << ((const deInt32*)varValue.value)[compNdx];					break;
318 			case glu::TYPE_UINT:	str << tcu::toHex(((const deUint32*)varValue.value)[compNdx]);		break;
319 			case glu::TYPE_BOOL:	str << HexBool(((const deUint32*)varValue.value)[compNdx]);			break;
320 			case glu::TYPE_DOUBLE:	str << HexDouble(((const double*)varValue.value)[compNdx]);			break;
321 
322 			default:
323 				DE_ASSERT(false);
324 		}
325 	}
326 
327 	if (numComponents > 1)
328 		str << ")";
329 
330 	return str;
331 }
332 
getCommonFuncCaseName(glu::DataType baseType,glu::Precision precision)333 static std::string getCommonFuncCaseName (glu::DataType baseType, glu::Precision precision)
334 {
335 	const bool isDouble = glu::isDataTypeDoubleOrDVec(baseType);
336 	return string(glu::getDataTypeName(baseType)) + (isDouble ? "" : getPrecisionPostfix(precision)) + "_compute";
337 }
338 
339 template<class TestClass>
addFunctionCases(tcu::TestCaseGroup * parent,const char * functionName,const std::vector<glu::DataType> & scalarTypes)340 static void addFunctionCases (tcu::TestCaseGroup* parent, const char* functionName, const std::vector<glu::DataType>& scalarTypes)
341 {
342 	tcu::TestCaseGroup* group = new tcu::TestCaseGroup(parent->getTestContext(), functionName, functionName);
343 	parent->addChild(group);
344 
345 	for (const auto scalarType : scalarTypes)
346 	{
347 		const bool	isDouble	= glu::isDataTypeDoubleOrDVec(scalarType);
348 		const int	lowestPrec	= (isDouble ? glu::PRECISION_LAST : glu::PRECISION_MEDIUMP);
349 		const int	highestPrec	= (isDouble ? glu::PRECISION_LAST : glu::PRECISION_HIGHP);
350 
351 		for (int vecSize = 1; vecSize <= 4; vecSize++)
352 		{
353 			for (int prec = lowestPrec; prec <= highestPrec; prec++)
354 			{
355 				group->addChild(new TestClass(parent->getTestContext(), glu::DataType(scalarType + vecSize - 1), glu::Precision(prec)));
356 			}
357 		}
358 	}
359 }
360 
361 // CommonFunctionCase
362 
363 class CommonFunctionCase : public TestCase
364 {
365 public:
366 										CommonFunctionCase			(tcu::TestContext& testCtx, const char* name, const char* description);
367 										~CommonFunctionCase			(void);
initPrograms(vk::SourceCollections & programCollection) const368 	virtual	void						initPrograms				(vk::SourceCollections& programCollection) const
369 										{
370 											generateSources(glu::SHADERTYPE_COMPUTE, m_spec, programCollection);
371 										}
372 
373 	virtual TestInstance*				createInstance				(Context& context) const = 0;
374 
375 protected:
376 										CommonFunctionCase			(const CommonFunctionCase&);
377 	CommonFunctionCase&					operator=					(const CommonFunctionCase&);
378 
379 	ShaderSpec							m_spec;
380 	const int							m_numValues;
381 };
382 
CommonFunctionCase(tcu::TestContext & testCtx,const char * name,const char * description)383 CommonFunctionCase::CommonFunctionCase (tcu::TestContext& testCtx, const char* name, const char* description)
384 	: TestCase		(testCtx, name, description)
385 	, m_numValues	(100)
386 {
387 }
388 
~CommonFunctionCase(void)389 CommonFunctionCase::~CommonFunctionCase (void)
390 {
391 }
392 
393 // CommonFunctionTestInstance
394 
395 class CommonFunctionTestInstance : public TestInstance
396 {
397 public:
CommonFunctionTestInstance(Context & context,const ShaderSpec & spec,int numValues,const char * name)398 										CommonFunctionTestInstance	(Context& context, const ShaderSpec& spec, int numValues, const char* name)
399 											: TestInstance	(context)
400 											, m_spec		(spec)
401 											, m_numValues	(numValues)
402 											, m_name		(name)
403 											, m_executor	(createExecutor(context, glu::SHADERTYPE_COMPUTE, spec))
404 										{
405 										}
406 	virtual tcu::TestStatus				iterate						(void);
407 
408 protected:
409 	virtual void						getInputValues				(int numValues, void* const* values) const = 0;
410 	virtual bool						compare						(const void* const* inputs, const void* const* outputs) = 0;
411 
412 	const ShaderSpec					m_spec;
413 	const int							m_numValues;
414 
415 	// \todo [2017-03-07 pyry] Hack used to generate seeds for test cases - get rid of this.
416 	const char*							m_name;
417 
418 	std::ostringstream					m_failMsg;					//!< Comparison failure help message.
419 
420 	de::UniquePtr<ShaderExecutor>		m_executor;
421 };
422 
iterate(void)423 tcu::TestStatus CommonFunctionTestInstance::iterate (void)
424 {
425 	const int				numInputBytes			= computeTotalByteSize(m_spec.inputs);
426 	const int				numOutputBytes			= computeTotalByteSize(m_spec.outputs);
427 	vector<deUint8>			inputData				(numInputBytes * m_numValues);
428 	vector<deUint8>			outputData				(numOutputBytes * m_numValues);
429 	const vector<void*>		inputPointers			= getInputOutputPointers(m_spec.inputs, inputData, m_numValues);
430 	const vector<void*>		outputPointers			= getInputOutputPointers(m_spec.outputs, outputData, m_numValues);
431 
432 	// Initialize input data.
433 	getInputValues(m_numValues, &inputPointers[0]);
434 
435 	// Execute shader.
436 	m_executor->execute(m_numValues, &inputPointers[0], &outputPointers[0]);
437 
438 	// Compare results.
439 	{
440 		const vector<int>		inScalarSizes		= getScalarSizes(m_spec.inputs);
441 		const vector<int>		outScalarSizes		= getScalarSizes(m_spec.outputs);
442 		const vector<int>		inCompByteSizes		= getComponentByteSizes(m_spec.inputs);
443 		const vector<int>		outCompByteSizes	= getComponentByteSizes(m_spec.outputs);
444 		vector<void*>			curInputPtr			(inputPointers.size());
445 		vector<void*>			curOutputPtr		(outputPointers.size());
446 		int						numFailed			= 0;
447 		tcu::TestContext&		testCtx				= m_context.getTestContext();
448 
449 		for (int valNdx = 0; valNdx < m_numValues; valNdx++)
450 		{
451 			// Set up pointers for comparison.
452 			for (int inNdx = 0; inNdx < (int)curInputPtr.size(); ++inNdx)
453 				curInputPtr[inNdx] = (deUint8*)inputPointers[inNdx] + inScalarSizes[inNdx]*inCompByteSizes[inNdx]*valNdx;
454 
455 			for (int outNdx = 0; outNdx < (int)curOutputPtr.size(); ++outNdx)
456 				curOutputPtr[outNdx] = (deUint8*)outputPointers[outNdx] + outScalarSizes[outNdx]*outCompByteSizes[outNdx]*valNdx;
457 
458 			if (!compare(&curInputPtr[0], &curOutputPtr[0]))
459 			{
460 				// \todo [2013-08-08 pyry] We probably want to log reference value as well?
461 
462 				testCtx.getLog() << TestLog::Message << "ERROR: comparison failed for value " << valNdx << ":\n  " << m_failMsg.str() << TestLog::EndMessage;
463 
464 				testCtx.getLog() << TestLog::Message << "  inputs:" << TestLog::EndMessage;
465 				for (int inNdx = 0; inNdx < (int)curInputPtr.size(); inNdx++)
466 					testCtx.getLog() << TestLog::Message << "    " << m_spec.inputs[inNdx].name << " = "
467 														   << VarValue(m_spec.inputs[inNdx].varType, curInputPtr[inNdx])
468 									   << TestLog::EndMessage;
469 
470 				testCtx.getLog() << TestLog::Message << "  outputs:" << TestLog::EndMessage;
471 				for (int outNdx = 0; outNdx < (int)curOutputPtr.size(); outNdx++)
472 					testCtx.getLog() << TestLog::Message << "    " << m_spec.outputs[outNdx].name << " = "
473 														   << VarValue(m_spec.outputs[outNdx].varType, curOutputPtr[outNdx])
474 									   << TestLog::EndMessage;
475 
476 				m_failMsg.str("");
477 				m_failMsg.clear();
478 				numFailed += 1;
479 			}
480 		}
481 
482 		testCtx.getLog() << TestLog::Message << (m_numValues - numFailed) << " / " << m_numValues << " values passed" << TestLog::EndMessage;
483 
484 		if (numFailed == 0)
485 			return tcu::TestStatus::pass("Pass");
486 		else
487 			return tcu::TestStatus::fail("Result comparison failed");
488 	}
489 }
490 
491 // Test cases
492 
493 class AbsCaseInstance : public CommonFunctionTestInstance
494 {
495 public:
AbsCaseInstance(Context & context,const ShaderSpec & spec,int numValues,const char * name)496 	AbsCaseInstance (Context& context, const ShaderSpec& spec, int numValues, const char* name)
497 		: CommonFunctionTestInstance	(context, spec, numValues, name)
498 	{
499 	}
500 
getInputValues(int numValues,void * const * values) const501 	void getInputValues (int numValues, void* const* values) const
502 	{
503 		const IVec2 intRanges[] =
504 		{
505 			IVec2(-(1<<7)+1,	(1<<7)-1),
506 			IVec2(-(1<<15)+1,	(1<<15)-1),
507 			IVec2(0x80000001,	0x7fffffff)
508 		};
509 
510 		de::Random				rnd			(deStringHash(m_name) ^ 0x235facu);
511 		const glu::DataType		type		= m_spec.inputs[0].varType.getBasicType();
512 		const glu::Precision	precision	= m_spec.inputs[0].varType.getPrecision();
513 		const int				scalarSize	= glu::getDataTypeScalarSize(type);
514 
515 		DE_ASSERT(!glu::isDataTypeFloatOrVec(type));
516 
517 		fillRandomScalars(rnd, intRanges[precision].x(), intRanges[precision].y(), values[0], numValues*scalarSize);
518 	}
519 
compare(const void * const * inputs,const void * const * outputs)520 	bool compare (const void* const* inputs, const void* const* outputs)
521 	{
522 		const glu::DataType		type			= m_spec.inputs[0].varType.getBasicType();
523 		const int				scalarSize		= glu::getDataTypeScalarSize(type);
524 
525 		DE_ASSERT(!glu::isDataTypeFloatOrVec(type));
526 
527 		for (int compNdx = 0; compNdx < scalarSize; compNdx++)
528 		{
529 			const int	in0		= ((const int*)inputs[0])[compNdx];
530 			const int	out0	= ((const int*)outputs[0])[compNdx];
531 			const int	ref0	= de::abs(in0);
532 
533 			if (out0 != ref0)
534 			{
535 				m_failMsg << "Expected [" << compNdx << "] = " << ref0;
536 				return false;
537 			}
538 		}
539 
540 		return true;
541 	}
542 };
543 
544 class AbsCase : public CommonFunctionCase
545 {
546 public:
AbsCase(tcu::TestContext & testCtx,glu::DataType baseType,glu::Precision precision)547 	AbsCase (tcu::TestContext& testCtx, glu::DataType baseType, glu::Precision precision)
548 		: CommonFunctionCase	(testCtx, getCommonFuncCaseName(baseType, precision).c_str(), "abs")
549 	{
550 		m_spec.inputs.push_back(Symbol("in0", glu::VarType(baseType, precision)));
551 		m_spec.outputs.push_back(Symbol("out0", glu::VarType(baseType, precision)));
552 		m_spec.source = "out0 = abs(in0);";
553 	}
554 
createInstance(Context & ctx) const555 	TestInstance* createInstance (Context& ctx) const
556 	{
557 		return new AbsCaseInstance(ctx, m_spec, m_numValues, getName());
558 	}
559 };
560 
561 class SignCaseInstance : public CommonFunctionTestInstance
562 {
563 public:
SignCaseInstance(Context & context,const ShaderSpec & spec,int numValues,const char * name)564 	SignCaseInstance (Context& context, const ShaderSpec& spec, int numValues, const char* name)
565 		: CommonFunctionTestInstance	(context, spec, numValues, name)
566 	{
567 	}
568 
getInputValues(int numValues,void * const * values) const569 	void getInputValues (int numValues, void* const* values) const
570 	{
571 		const IVec2 intRanges[] =
572 		{
573 			IVec2(-(1<<7),		(1<<7)-1),
574 			IVec2(-(1<<15),		(1<<15)-1),
575 			IVec2(0x80000000,	0x7fffffff)
576 		};
577 
578 		de::Random				rnd			(deStringHash(m_name) ^ 0x324u);
579 		const glu::DataType		type		= m_spec.inputs[0].varType.getBasicType();
580 		const glu::Precision	precision	= m_spec.inputs[0].varType.getPrecision();
581 		const int				scalarSize	= glu::getDataTypeScalarSize(type);
582 
583 		DE_ASSERT(!glu::isDataTypeFloatOrVec(type));
584 
585 		std::fill((int*)values[0] + scalarSize*0, (int*)values[0] + scalarSize*1, +1);
586 		std::fill((int*)values[0] + scalarSize*1, (int*)values[0] + scalarSize*2, -1);
587 		std::fill((int*)values[0] + scalarSize*2, (int*)values[0] + scalarSize*3,  0);
588 		fillRandomScalars(rnd, intRanges[precision].x(), intRanges[precision].y(), (int*)values[0] + scalarSize*3, (numValues-3)*scalarSize);
589 	}
590 
compare(const void * const * inputs,const void * const * outputs)591 	bool compare (const void* const* inputs, const void* const* outputs)
592 	{
593 		const glu::DataType		type			= m_spec.inputs[0].varType.getBasicType();
594 		const int				scalarSize		= glu::getDataTypeScalarSize(type);
595 
596 		DE_ASSERT(!glu::isDataTypeFloatOrVec(type));
597 
598 		for (int compNdx = 0; compNdx < scalarSize; compNdx++)
599 		{
600 			const int	in0		= ((const int*)inputs[0])[compNdx];
601 			const int	out0	= ((const int*)outputs[0])[compNdx];
602 			const int	ref0	= in0 < 0 ? -1 :
603 								  in0 > 0 ? +1 : 0;
604 
605 			if (out0 != ref0)
606 			{
607 				m_failMsg << "Expected [" << compNdx << "] = " << ref0;
608 				return false;
609 			}
610 		}
611 
612 		return true;
613 	}
614 };
615 
616 class SignCase : public CommonFunctionCase
617 {
618 public:
SignCase(tcu::TestContext & testCtx,glu::DataType baseType,glu::Precision precision)619 	SignCase (tcu::TestContext& testCtx, glu::DataType baseType, glu::Precision precision)
620 		: CommonFunctionCase	(testCtx, getCommonFuncCaseName(baseType, precision).c_str(), "sign")
621 	{
622 		m_spec.inputs.push_back(Symbol("in0", glu::VarType(baseType, precision)));
623 		m_spec.outputs.push_back(Symbol("out0", glu::VarType(baseType, precision)));
624 		m_spec.source = "out0 = sign(in0);";
625 	}
626 
createInstance(Context & ctx) const627 	TestInstance* createInstance (Context& ctx) const
628 	{
629 		return new SignCaseInstance(ctx, m_spec, m_numValues, getName());
630 	}
631 };
632 
infNanRandomFloats(int numValues,void * const * values,const char * name,const ShaderSpec & spec)633 static void infNanRandomFloats(int numValues, void* const* values, const char *name, const ShaderSpec& spec)
634 {
635 	constexpr deUint64		kOne			= 1;
636 	de::Random				rnd				(deStringHash(name) ^ 0xc2a39fu);
637 	const glu::DataType		type			= spec.inputs[0].varType.getBasicType();
638 	const glu::Precision	precision		= spec.inputs[0].varType.getPrecision();
639 	const int				scalarSize		= glu::getDataTypeScalarSize(type);
640 	const int				minMantissaBits	= getMinMantissaBits(type, precision);
641 	const int				numMantissaBits	= getNumMantissaBits(type);
642 	const deUint64			mantissaMask	= ~getMaxUlpDiffFromBits(minMantissaBits, numMantissaBits) & ((kOne<<numMantissaBits)-kOne);
643 	const int				exponentBits	= getExponentBits(type);
644 	const deUint32			exponentMask	= getExponentMask(exponentBits);
645 	const bool				isDouble		= glu::isDataTypeDoubleOrDVec(type);
646 	const deUint64			exponentBias	= (isDouble ? static_cast<deUint64>(tcu::Float64::EXPONENT_BIAS) : static_cast<deUint64>(tcu::Float32::EXPONENT_BIAS));
647 
648 	for (int valNdx = 0; valNdx < numValues*scalarSize; valNdx++)
649 	{
650 		// Roughly 25% chance of each of Inf and NaN
651 		const bool		isInf		= rnd.getFloat() > 0.75f;
652 		const bool		isNan		= !isInf && rnd.getFloat() > 0.66f;
653 		const deUint64	m			= rnd.getUint64() & mantissaMask;
654 		const deUint64	e			= static_cast<deUint64>(rnd.getUint32() & exponentMask);
655 		const deUint64	sign		= static_cast<deUint64>(rnd.getUint32() & 0x1u);
656 		// Ensure the 'quiet' bit is set on NaNs (also ensures we don't generate inf by mistake)
657 		const deUint64	mantissa	= isInf ? 0 : (isNan ? ((kOne<<(numMantissaBits-1)) | m) : m);
658 		const deUint64	exp			= (isNan || isInf) ? exponentMask : std::min(e, exponentBias);
659 		const deUint64	value		= (sign << (numMantissaBits + exponentBits)) | (exp << numMantissaBits) | static_cast<deUint32>(mantissa);
660 
661 		if (isDouble)
662 		{
663 			DE_ASSERT(tcu::Float64(value).isInf() == isInf && tcu::Float64(value).isNaN() == isNan);
664 			((deUint64*)values[0])[valNdx] = value;
665 		}
666 		else
667 		{
668 			const auto value32 = static_cast<deUint32>(value);
669 			DE_ASSERT(tcu::Float32(value32).isInf() == isInf && tcu::Float32(value32).isNaN() == isNan);
670 			((deUint32*)values[0])[valNdx] = value32;
671 		}
672 	}
673 }
674 
675 class IsnanCaseInstance : public CommonFunctionTestInstance
676 {
677 public:
IsnanCaseInstance(Context & context,const ShaderSpec & spec,int numValues,const char * name)678 	IsnanCaseInstance (Context& context, const ShaderSpec& spec, int numValues, const char* name)
679 		: CommonFunctionTestInstance	(context, spec, numValues, name)
680 	{
681 	}
682 
getInputValues(int numValues,void * const * values) const683 	void getInputValues (int numValues, void* const* values) const
684 	{
685 		infNanRandomFloats(numValues, values, m_name, m_spec);
686 	}
687 
compare(const void * const * inputs,const void * const * outputs)688 	bool compare (const void* const* inputs, const void* const* outputs)
689 	{
690 		const glu::DataType		type			= m_spec.inputs[0].varType.getBasicType();
691 		const glu::Precision	precision		= m_spec.inputs[0].varType.getPrecision();
692 		const int				scalarSize		= glu::getDataTypeScalarSize(type);
693 		const bool				isDouble		= glu::isDataTypeDoubleOrDVec(type);
694 
695 		for (int compNdx = 0; compNdx < scalarSize; compNdx++)
696 		{
697 			const bool	out0	= reinterpret_cast<const deUint32*>(outputs[0])[compNdx] != 0;
698 			bool		ok;
699 			bool		ref;
700 
701 			if (isDouble)
702 			{
703 				const double in0 = reinterpret_cast<const double*>(inputs[0])[compNdx];
704 				ref	= tcu::Float64(in0).isNaN();
705 				ok = (out0 == ref);
706 			}
707 			else
708 			{
709 				const float	in0	= reinterpret_cast<const float*>(inputs[0])[compNdx];
710 				ref	= tcu::Float32(in0).isNaN();
711 
712 				// NaN support only required for highp. Otherwise just check for false positives.
713 				if (precision == glu::PRECISION_HIGHP)
714 					ok = (out0 == ref);
715 				else
716 					ok = ref || !out0;
717 			}
718 
719 			if (!ok)
720 			{
721 				m_failMsg << "Expected [" << compNdx << "] = " << (ref ? "true" : "false");
722 				return false;
723 			}
724 		}
725 
726 		return true;
727 	}
728 };
729 
730 class IsnanCase : public CommonFunctionCase
731 {
732 public:
IsnanCase(tcu::TestContext & testCtx,glu::DataType baseType,glu::Precision precision)733 	IsnanCase (tcu::TestContext& testCtx, glu::DataType baseType, glu::Precision precision)
734 		: CommonFunctionCase	(testCtx, getCommonFuncCaseName(baseType, precision).c_str(), "isnan")
735 	{
736 		DE_ASSERT(glu::isDataTypeFloatOrVec(baseType) || glu::isDataTypeDoubleOrDVec(baseType));
737 
738 		const int			vecSize		= glu::getDataTypeScalarSize(baseType);
739 		const glu::DataType	boolType	= vecSize > 1 ? glu::getDataTypeBoolVec(vecSize) : glu::TYPE_BOOL;
740 
741 		m_spec.inputs.push_back(Symbol("in0", glu::VarType(baseType, precision)));
742 		m_spec.outputs.push_back(Symbol("out0", glu::VarType(boolType, glu::PRECISION_LAST)));
743 		m_spec.source = "out0 = isnan(in0);";
744 	}
745 
checkSupport(Context & context) const746 	void checkSupport (Context& context) const
747 	{
748 		checkTypeSupport(context, m_spec.inputs[0].varType.getBasicType());
749 	}
750 
createInstance(Context & ctx) const751 	TestInstance* createInstance (Context& ctx) const
752 	{
753 		return new IsnanCaseInstance(ctx, m_spec, m_numValues, getName());
754 	}
755 };
756 
757 class IsinfCaseInstance : public CommonFunctionTestInstance
758 {
759 public:
IsinfCaseInstance(Context & context,const ShaderSpec & spec,int numValues,const char * name)760 	IsinfCaseInstance (Context& context, const ShaderSpec& spec, int numValues, const char* name)
761 		: CommonFunctionTestInstance(context, spec, numValues, name)
762 	{
763 	}
764 
getInputValues(int numValues,void * const * values) const765 	void getInputValues (int numValues, void* const* values) const
766 	{
767 		infNanRandomFloats(numValues, values, m_name, m_spec);
768 	}
769 
compare(const void * const * inputs,const void * const * outputs)770 	bool compare (const void* const* inputs, const void* const* outputs)
771 	{
772 		const glu::DataType		type			= m_spec.inputs[0].varType.getBasicType();
773 		const glu::Precision	precision		= m_spec.inputs[0].varType.getPrecision();
774 		const int				scalarSize		= glu::getDataTypeScalarSize(type);
775 		const bool				isDouble		= glu::isDataTypeDoubleOrDVec(type);
776 
777 		for (int compNdx = 0; compNdx < scalarSize; compNdx++)
778 		{
779 			const bool	out0 = reinterpret_cast<const deUint32*>(outputs[0])[compNdx] != 0;
780 			bool		ref;
781 			bool		ok;
782 
783 			if (isDouble)
784 			{
785 				const double in0 = reinterpret_cast<const double*>(inputs[0])[compNdx];
786 				ref = tcu::Float64(in0).isInf();
787 				ok = (out0 == ref);
788 			}
789 			else
790 			{
791 				const float in0 = reinterpret_cast<const float*>(inputs[0])[compNdx];
792 				if (precision == glu::PRECISION_HIGHP)
793 				{
794 					// Only highp is required to support inf/nan
795 					ref = tcu::Float32(in0).isInf();
796 					ok = (out0 == ref);
797 				}
798 				else
799 				{
800 					// Inf support is optional, check that inputs that are not Inf in mediump don't result in true.
801 					ref = tcu::Float16(in0).isInf();
802 					ok = (out0 || !ref);
803 				}
804 			}
805 
806 			if (!ok)
807 			{
808 				m_failMsg << "Expected [" << compNdx << "] = " << HexBool(ref);
809 				return false;
810 			}
811 		}
812 
813 		return true;
814 	}
815 };
816 
817 class IsinfCase : public CommonFunctionCase
818 {
819 public:
IsinfCase(tcu::TestContext & testCtx,glu::DataType baseType,glu::Precision precision)820 	IsinfCase (tcu::TestContext& testCtx, glu::DataType baseType, glu::Precision precision)
821 		: CommonFunctionCase	(testCtx, getCommonFuncCaseName(baseType, precision).c_str(), "isinf")
822 	{
823 		DE_ASSERT(glu::isDataTypeFloatOrVec(baseType) || glu::isDataTypeDoubleOrDVec(baseType));
824 
825 		const int			vecSize		= glu::getDataTypeScalarSize(baseType);
826 		const glu::DataType	boolType	= vecSize > 1 ? glu::getDataTypeBoolVec(vecSize) : glu::TYPE_BOOL;
827 
828 		m_spec.inputs.push_back(Symbol("in0", glu::VarType(baseType, precision)));
829 		m_spec.outputs.push_back(Symbol("out0", glu::VarType(boolType, glu::PRECISION_LAST)));
830 		m_spec.source = "out0 = isinf(in0);";
831 	}
832 
checkSupport(Context & context) const833 	void checkSupport (Context& context) const
834 	{
835 		checkTypeSupport(context, m_spec.inputs[0].varType.getBasicType());
836 	}
837 
createInstance(Context & ctx) const838 	TestInstance* createInstance (Context& ctx) const
839 	{
840 		return new IsinfCaseInstance(ctx, m_spec, m_numValues, getName());
841 	}
842 };
843 
844 class FloatBitsToUintIntCaseInstance : public CommonFunctionTestInstance
845 {
846 public:
FloatBitsToUintIntCaseInstance(Context & context,const ShaderSpec & spec,int numValues,const char * name)847 	FloatBitsToUintIntCaseInstance (Context& context, const ShaderSpec& spec, int numValues, const char* name)
848 		: CommonFunctionTestInstance	(context, spec, numValues, name)
849 	{
850 	}
851 
getInputValues(int numValues,void * const * values) const852 	void getInputValues (int numValues, void* const* values) const
853 	{
854 		const Vec2 ranges[] =
855 		{
856 			Vec2(-2.0f,		2.0f),	// lowp
857 			Vec2(-1e3f,		1e3f),	// mediump
858 			Vec2(-1e7f,		1e7f)	// highp
859 		};
860 
861 		de::Random				rnd			(deStringHash(m_name) ^ 0x2790au);
862 		const glu::DataType		type		= m_spec.inputs[0].varType.getBasicType();
863 		const glu::Precision	precision	= m_spec.inputs[0].varType.getPrecision();
864 		const int				scalarSize	= glu::getDataTypeScalarSize(type);
865 
866 		fillRandomScalars(rnd, ranges[precision].x(), ranges[precision].y(), values[0], numValues*scalarSize);
867 	}
868 
compare(const void * const * inputs,const void * const * outputs)869 	bool compare (const void* const* inputs, const void* const* outputs)
870 	{
871 		const glu::DataType		type			= m_spec.inputs[0].varType.getBasicType();
872 		const glu::Precision	precision		= m_spec.inputs[0].varType.getPrecision();
873 		const int				scalarSize		= glu::getDataTypeScalarSize(type);
874 
875 		const int				minMantissaBits	= getMinMantissaBits(type, precision);
876 		const int				numMantissaBits	= getNumMantissaBits(type);
877 		const int				maxUlpDiff		= static_cast<int>(getMaxUlpDiffFromBits(minMantissaBits, numMantissaBits));
878 
879 		for (int compNdx = 0; compNdx < scalarSize; compNdx++)
880 		{
881 			const float		in0			= ((const float*)inputs[0])[compNdx];
882 			const deUint32	out0		= ((const deUint32*)outputs[0])[compNdx];
883 			const deUint32	refOut0		= tcu::Float32(in0).bits();
884 			const int		ulpDiff		= de::abs((int)out0 - (int)refOut0);
885 
886 			if (ulpDiff > maxUlpDiff)
887 			{
888 				m_failMsg << "Expected [" << compNdx << "] = " << tcu::toHex(refOut0) << " with threshold "
889 							<< tcu::toHex(maxUlpDiff) << ", got diff " << tcu::toHex(ulpDiff);
890 				return false;
891 			}
892 		}
893 
894 		return true;
895 	}
896 };
897 
898 class FloatBitsToUintIntCase : public CommonFunctionCase
899 {
900 public:
FloatBitsToUintIntCase(tcu::TestContext & testCtx,glu::DataType baseType,glu::Precision precision,bool outIsSigned)901 	FloatBitsToUintIntCase (tcu::TestContext& testCtx, glu::DataType baseType, glu::Precision precision, bool outIsSigned)
902 		: CommonFunctionCase	(testCtx, getCommonFuncCaseName(baseType, precision).c_str(), outIsSigned ? "floatBitsToInt" : "floatBitsToUint")
903 	{
904 		const int			vecSize		= glu::getDataTypeScalarSize(baseType);
905 		const glu::DataType	intType		= outIsSigned ? (vecSize > 1 ? glu::getDataTypeIntVec(vecSize) : glu::TYPE_INT)
906 													  : (vecSize > 1 ? glu::getDataTypeUintVec(vecSize) : glu::TYPE_UINT);
907 
908 		m_spec.inputs.push_back(Symbol("in0", glu::VarType(baseType, precision)));
909 		m_spec.outputs.push_back(Symbol("out0", glu::VarType(intType, glu::PRECISION_HIGHP)));
910 		m_spec.source = outIsSigned ? "out0 = floatBitsToInt(in0);" : "out0 = floatBitsToUint(in0);";
911 	}
912 
createInstance(Context & ctx) const913 	TestInstance* createInstance (Context& ctx) const
914 	{
915 		return new FloatBitsToUintIntCaseInstance(ctx, m_spec, m_numValues, getName());
916 	}
917 };
918 
919 class FloatBitsToIntCase : public FloatBitsToUintIntCase
920 {
921 public:
FloatBitsToIntCase(tcu::TestContext & testCtx,glu::DataType baseType,glu::Precision precision)922 	FloatBitsToIntCase (tcu::TestContext& testCtx, glu::DataType baseType, glu::Precision precision)
923 		: FloatBitsToUintIntCase	(testCtx, baseType, precision, true)
924 	{
925 	}
926 
927 };
928 
929 class FloatBitsToUintCase : public FloatBitsToUintIntCase
930 {
931 public:
FloatBitsToUintCase(tcu::TestContext & testCtx,glu::DataType baseType,glu::Precision precision)932 	FloatBitsToUintCase (tcu::TestContext& testCtx, glu::DataType baseType, glu::Precision precision)
933 		: FloatBitsToUintIntCase	(testCtx, baseType, precision, false)
934 	{
935 	}
936 };
937 
938 class BitsToFloatCaseInstance : public CommonFunctionTestInstance
939 {
940 public:
BitsToFloatCaseInstance(Context & context,const ShaderSpec & spec,int numValues,const char * name)941 	BitsToFloatCaseInstance (Context& context, const ShaderSpec& spec, int numValues, const char* name)
942 		: CommonFunctionTestInstance	(context, spec, numValues, name)
943 	{
944 	}
945 
getInputValues(int numValues,void * const * values) const946 	void getInputValues (int numValues, void* const* values) const
947 	{
948 		de::Random				rnd			(deStringHash(m_name) ^ 0xbbb225u);
949 		const glu::DataType		type		= m_spec.inputs[0].varType.getBasicType();
950 		const int				scalarSize	= glu::getDataTypeScalarSize(type);
951 		const Vec2				range		(-1e8f, +1e8f);
952 
953 		// \note Filled as floats.
954 		fillRandomScalars(rnd, range.x(), range.y(), values[0], numValues*scalarSize);
955 	}
956 
compare(const void * const * inputs,const void * const * outputs)957 	bool compare (const void* const* inputs, const void* const* outputs)
958 	{
959 		const glu::DataType		type			= m_spec.inputs[0].varType.getBasicType();
960 		const int				scalarSize		= glu::getDataTypeScalarSize(type);
961 		const deUint32			maxUlpDiff		= 0;
962 
963 		for (int compNdx = 0; compNdx < scalarSize; compNdx++)
964 		{
965 			const float		in0			= ((const float*)inputs[0])[compNdx];
966 			const float		out0		= ((const float*)outputs[0])[compNdx];
967 			const deUint32	ulpDiff		= getUlpDiffIgnoreZeroSign(in0, out0);
968 
969 			if (ulpDiff > maxUlpDiff)
970 			{
971 				m_failMsg << "Expected [" << compNdx << "] = " << tcu::toHex(tcu::Float32(in0).bits()) << " with ULP threshold "
972 							<< tcu::toHex(maxUlpDiff) << ", got ULP diff " << tcu::toHex(ulpDiff);
973 				return false;
974 			}
975 		}
976 
977 		return true;
978 	}
979 };
980 
981 class BitsToFloatCase : public CommonFunctionCase
982 {
983 public:
BitsToFloatCase(tcu::TestContext & testCtx,glu::DataType baseType)984 	BitsToFloatCase (tcu::TestContext& testCtx, glu::DataType baseType)
985 		: CommonFunctionCase	(testCtx, getCommonFuncCaseName(baseType, glu::PRECISION_HIGHP).c_str(), glu::isDataTypeIntOrIVec(baseType) ? "intBitsToFloat" : "uintBitsToFloat")
986 	{
987 		const bool			inIsSigned	= glu::isDataTypeIntOrIVec(baseType);
988 		const int			vecSize		= glu::getDataTypeScalarSize(baseType);
989 		const glu::DataType	floatType	= vecSize > 1 ? glu::getDataTypeFloatVec(vecSize) : glu::TYPE_FLOAT;
990 
991 		m_spec.inputs.push_back(Symbol("in0", glu::VarType(baseType, glu::PRECISION_HIGHP)));
992 		m_spec.outputs.push_back(Symbol("out0", glu::VarType(floatType, glu::PRECISION_HIGHP)));
993 		m_spec.source = inIsSigned ? "out0 = intBitsToFloat(in0);" : "out0 = uintBitsToFloat(in0);";
994 	}
995 
createInstance(Context & ctx) const996 	TestInstance* createInstance (Context& ctx) const
997 	{
998 		return new BitsToFloatCaseInstance(ctx, m_spec, m_numValues, getName());
999 	}
1000 };
1001 
1002 } // anonymous
1003 
ShaderCommonFunctionTests(tcu::TestContext & testCtx)1004 ShaderCommonFunctionTests::ShaderCommonFunctionTests (tcu::TestContext& testCtx)
1005 	: tcu::TestCaseGroup	(testCtx, "common", "Common function tests")
1006 {
1007 }
1008 
~ShaderCommonFunctionTests(void)1009 ShaderCommonFunctionTests::~ShaderCommonFunctionTests (void)
1010 {
1011 }
1012 
init(void)1013 void ShaderCommonFunctionTests::init (void)
1014 {
1015 	static const std::vector<glu::DataType>	kIntOnly		(1u, glu::TYPE_INT);
1016 	static const std::vector<glu::DataType>	kFloatOnly		(1u, glu::TYPE_FLOAT);
1017 	static const std::vector<glu::DataType>	kFloatAndDouble	{glu::TYPE_FLOAT, glu::TYPE_DOUBLE};
1018 
1019 	addFunctionCases<AbsCase>				(this,	"abs",				kIntOnly);
1020 	addFunctionCases<SignCase>				(this,	"sign",				kIntOnly);
1021 	addFunctionCases<IsnanCase>				(this,	"isnan",			kFloatAndDouble);
1022 	addFunctionCases<IsinfCase>				(this,	"isinf",			kFloatAndDouble);
1023 	addFunctionCases<FloatBitsToIntCase>	(this,	"floatbitstoint",	kFloatOnly);
1024 	addFunctionCases<FloatBitsToUintCase>	(this,	"floatbitstouint",	kFloatOnly);
1025 
1026 	// (u)intBitsToFloat()
1027 	{
1028 		tcu::TestCaseGroup* intGroup	= new tcu::TestCaseGroup(m_testCtx, "intbitstofloat",	"intBitsToFloat() Tests");
1029 		tcu::TestCaseGroup* uintGroup	= new tcu::TestCaseGroup(m_testCtx, "uintbitstofloat",	"uintBitsToFloat() Tests");
1030 
1031 		addChild(intGroup);
1032 		addChild(uintGroup);
1033 
1034 		for (int vecSize = 1; vecSize < 4; vecSize++)
1035 		{
1036 			const glu::DataType		intType		= vecSize > 1 ? glu::getDataTypeIntVec(vecSize) : glu::TYPE_INT;
1037 			const glu::DataType		uintType	= vecSize > 1 ? glu::getDataTypeUintVec(vecSize) : glu::TYPE_UINT;
1038 
1039 			intGroup->addChild(new BitsToFloatCase(getTestContext(), intType));
1040 			uintGroup->addChild(new BitsToFloatCase(getTestContext(), uintType));
1041 		}
1042 	}
1043 }
1044 
1045 } // shaderexecutor
1046 } // vkt
1047