1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
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
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 * \brief Shader operators tests.
24 *//*--------------------------------------------------------------------*/
26 #include "vktShaderRenderOperatorTests.hpp"
27 #include "vktShaderRender.hpp"
28 #include "tcuVectorUtil.hpp"
29 #include "deStringUtil.hpp"
51 // \note VS2013 gets confused without these
59 inline bool logicalAnd (bool a, bool b) { return (a && b); }
60 inline bool logicalOr (bool a, bool b) { return (a || b); }
61 inline bool logicalXor (bool a, bool b) { return (a != b); }
63 // \note stdlib.h defines div() that is not compatible with the macros.
64 template<typename T> inline T div (T a, T b) { return a / b; }
66 template<typename T> inline T leftShift (T value, int amount) { return value << amount; }
68 inline deUint32 rightShift (deUint32 value, int amount) { return value >> amount; }
69 inline int rightShift (int value, int amount) { return (value >> amount) | (value >= 0 ? 0 : ~(~0U >> amount)); } // \note Arithmetic shift.
71 template<typename T, int Size> Vector<T, Size> leftShift (const Vector<T, Size>& value, const Vector<int, Size>& amount)
73 Vector<T, Size> result;
74 for (int i = 0; i < Size; i++)
75 result[i] = leftShift(value[i], amount[i]);
79 template<typename T, int Size> Vector<T, Size> rightShift (const Vector<T, Size>& value, const Vector<int, Size>& amount)
81 Vector<T, Size> result;
82 for (int i = 0; i < Size; i++)
83 result[i] = rightShift(value[i], amount[i]);
87 template<typename T, int Size> Vector<T, Size> leftShiftVecScalar (const Vector<T, Size>& value, int amount) { return leftShift(value, Vector<int, Size>(amount)); }
88 template<typename T, int Size> Vector<T, Size> rightShiftVecScalar (const Vector<T, Size>& value, int amount) { return rightShift(value, Vector<int, Size>(amount)); }
90 template<typename T, int Size>
91 inline Vector<T, Size> minVecScalar (const Vector<T, Size>& v, T s)
94 for (int i = 0; i < Size; i++)
95 res[i] = min(v[i], s);
99 template<typename T, int Size>
100 inline Vector<T, Size> maxVecScalar (const Vector<T, Size>& v, T s)
103 for (int i = 0; i < Size; i++)
104 res[i] = max(v[i], s);
108 template<typename T, int Size>
109 inline Vector<T, Size> clampVecScalarScalar (const Vector<T, Size>& v, T s0, T s1)
112 for (int i = 0; i < Size; i++)
113 res[i] = clamp(v[i], s0, s1);
117 template<typename T, int Size>
118 inline Vector<T, Size> mixVecVecScalar (const Vector<T, Size>& v0, const Vector<T, Size>& v1, T s)
121 for (int i = 0; i < Size; i++)
122 res[i] = mix(v0[i], v1[i], s);
126 template<typename T, int Size>
127 inline Vector<T, Size> stepScalarVec (T s, const Vector<T, Size>& v)
130 for (int i = 0; i < Size; i++)
131 res[i] = step(s, v[i]);
135 template<typename T, int Size>
136 inline Vector<T, Size> smoothStepScalarScalarVec (T s0, T s1, const Vector<T, Size>& v)
139 for (int i = 0; i < Size; i++)
140 res[i] = smoothStep(s0, s1, v[i]);
144 inline int addOne (int v) { return v + 1; };
145 inline int subOne (int v) { return v - 1; };
146 inline deUint32 addOne (deUint32 v) { return v + 1; };
147 inline deUint32 subOne (deUint32 v) { return v - 1; };
149 template<int Size> inline Vector<float, Size> addOne (const Vector<float, Size>& v) { return v + 1.0f; };
150 template<int Size> inline Vector<float, Size> subOne (const Vector<float, Size>& v) { return v - 1.0f; };
151 template<int Size> inline Vector<int, Size> addOne (const Vector<int, Size>& v) { return v + 1; };
152 template<int Size> inline Vector<int, Size> subOne (const Vector<int, Size>& v) { return v - 1; };
153 template<int Size> inline Vector<deUint32, Size> addOne (const Vector<deUint32, Size>& v) { return v + 1U; };
154 template<int Size> inline Vector<deUint32, Size> subOne (const Vector<deUint32, Size>& v) { return (v.asInt() - 1).asUint(); };
156 template<typename T> inline T selection (bool cond, T a, T b) { return cond ? a : b; };
158 // Vec-scalar and scalar-vec binary operators.
160 // \note This one is done separately due to how the overloaded minus operator is implemented for vector-scalar operands.
161 template<int Size> inline Vector<deUint32, Size> subVecScalar (const Vector<deUint32, Size>& v, deUint32 s) { return (v.asInt() - (int)s).asUint(); };
163 template<typename T, int Size> inline Vector<T, Size> addVecScalar (const Vector<T, Size>& v, T s) { return v + s; };
164 template<typename T, int Size> inline Vector<T, Size> subVecScalar (const Vector<T, Size>& v, T s) { return v - s; };
165 template<typename T, int Size> inline Vector<T, Size> mulVecScalar (const Vector<T, Size>& v, T s) { return v * s; };
166 template<typename T, int Size> inline Vector<T, Size> divVecScalar (const Vector<T, Size>& v, T s) { return v / s; };
167 template<typename T, int Size> inline Vector<T, Size> modVecScalar (const Vector<T, Size>& v, T s) { return mod(v, Vector<T, Size>(s)); };
168 template<typename T, int Size> inline Vector<T, Size> bitwiseAndVecScalar (const Vector<T, Size>& v, T s) { return bitwiseAnd(v, Vector<T, Size>(s)); };
169 template<typename T, int Size> inline Vector<T, Size> bitwiseOrVecScalar (const Vector<T, Size>& v, T s) { return bitwiseOr(v, Vector<T, Size>(s)); };
170 template<typename T, int Size> inline Vector<T, Size> bitwiseXorVecScalar (const Vector<T, Size>& v, T s) { return bitwiseXor(v, Vector<T, Size>(s)); };
172 template<typename T, int Size> inline Vector<T, Size> addScalarVec (T s, const Vector<T, Size>& v) { return s + v; };
173 template<typename T, int Size> inline Vector<T, Size> subScalarVec (T s, const Vector<T, Size>& v) { return s - v; };
174 template<typename T, int Size> inline Vector<T, Size> mulScalarVec (T s, const Vector<T, Size>& v) { return s * v; };
175 template<typename T, int Size> inline Vector<T, Size> divScalarVec (T s, const Vector<T, Size>& v) { return s / v; };
176 template<typename T, int Size> inline Vector<T, Size> modScalarVec (T s, const Vector<T, Size>& v) { return mod(Vector<T, Size>(s), v); };
177 template<typename T, int Size> inline Vector<T, Size> bitwiseAndScalarVec (T s, const Vector<T, Size>& v) { return bitwiseAnd(Vector<T, Size>(s), v); };
178 template<typename T, int Size> inline Vector<T, Size> bitwiseOrScalarVec (T s, const Vector<T, Size>& v) { return bitwiseOr(Vector<T, Size>(s), v); };
179 template<typename T, int Size> inline Vector<T, Size> bitwiseXorScalarVec (T s, const Vector<T, Size>& v) { return bitwiseXor(Vector<T, Size>(s), v); };
181 // Reference functions for specific sequence operations for the sequence operator tests.
183 // Reference for expression "in0, in2 + in1, in1 + in0"
184 inline Vec4 sequenceNoSideEffCase0 (const Vec4& in0, const Vec4& in1, const Vec4& in2) { DE_UNREF(in2); return in1 + in0; }
185 // Reference for expression "in0, in2 + in1, in1 + in0"
186 inline deUint32 sequenceNoSideEffCase1 (float in0, deUint32 in1, float in2) { DE_UNREF(in0); DE_UNREF(in2); return in1 + in1; }
187 // Reference for expression "in0 && in1, in0, ivec2(vec2(in0) + in2)"
188 inline IVec2 sequenceNoSideEffCase2 (bool in0, bool in1, const Vec2& in2) { DE_UNREF(in1); return IVec2((int)((float)in0 + in2.x()), (int)((float)in0 + in2.y())); }
189 // Reference for expression "in0 + vec4(in1), in2, in1"
190 inline IVec4 sequenceNoSideEffCase3 (const Vec4& in0, const IVec4& in1, const BVec4& in2) { DE_UNREF(in0); DE_UNREF(in2); return in1; }
191 // Reference for expression "in0++, in1 = in0 + in2, in2 = in1"
192 inline Vec4 sequenceSideEffCase0 (const Vec4& in0, const Vec4& in1, const Vec4& in2) { DE_UNREF(in1); return in0 + 1.0f + in2; }
193 // Reference for expression "in1++, in0 = float(in1), in1 = uint(in0 + in2)"
194 inline deUint32 sequenceSideEffCase1 (float in0, deUint32 in1, float in2) { DE_UNREF(in0); return (deUint32)(float(in1) + 1.0f + in2); }
195 // Reference for expression "in1 = in0, in2++, in2 = in2 + vec2(in1), ivec2(in2)"
196 inline IVec2 sequenceSideEffCase2 (bool in0, bool in1, const Vec2& in2) { DE_UNREF(in1); return (in2 + Vec2(1.0f) + Vec2((float)in0)).asInt(); }
197 // Reference for expression "in0 = in0 + vec4(in2), in1 = in1 + ivec4(in0), in1++"
198 inline IVec4 sequenceSideEffCase3 (const Vec4& in0, const IVec4& in1, const BVec4& in2) { return in1 + (in0 + Vec4((float)in2.x(), (float)in2.y(), (float)in2.z(), (float)in2.w())).asInt(); }
200 // ShaderEvalFunc-type wrappers for the above functions.
201 void evalSequenceNoSideEffCase0 (ShaderEvalContext& ctx) { ctx.color = sequenceNoSideEffCase0 (ctx.in[0].swizzle(1, 2, 3, 0), ctx.in[1].swizzle(3, 2, 1, 0), ctx.in[2].swizzle(0, 3, 2, 1)); }
202 void evalSequenceNoSideEffCase1 (ShaderEvalContext& ctx) { ctx.color.x() = (float)sequenceNoSideEffCase1 (ctx.in[0].z(), (deUint32)ctx.in[1].x(), ctx.in[2].y()); }
203 void evalSequenceNoSideEffCase2 (ShaderEvalContext& ctx) { ctx.color.yz() = sequenceNoSideEffCase2 (ctx.in[0].z() > 0.0f, ctx.in[1].x() > 0.0f, ctx.in[2].swizzle(2, 1)).asFloat(); }
204 void evalSequenceNoSideEffCase3 (ShaderEvalContext& ctx) { ctx.color = sequenceNoSideEffCase3 (ctx.in[0].swizzle(1, 2, 3, 0), ctx.in[1].swizzle(3, 2, 1, 0).asInt(), greaterThan(ctx.in[2].swizzle(0, 3, 2, 1), Vec4(0.0f, 0.0f, 0.0f, 0.0f))).asFloat(); }
205 void evalSequenceSideEffCase0 (ShaderEvalContext& ctx) { ctx.color = sequenceSideEffCase0 (ctx.in[0].swizzle(1, 2, 3, 0), ctx.in[1].swizzle(3, 2, 1, 0), ctx.in[2].swizzle(0, 3, 2, 1)); }
206 void evalSequenceSideEffCase1 (ShaderEvalContext& ctx) { ctx.color.x() = (float)sequenceSideEffCase1 (ctx.in[0].z(), (deUint32)ctx.in[1].x(), ctx.in[2].y()); }
207 void evalSequenceSideEffCase2 (ShaderEvalContext& ctx) { ctx.color.yz() = sequenceSideEffCase2 (ctx.in[0].z() > 0.0f, ctx.in[1].x() > 0.0f, ctx.in[2].swizzle(2, 1)).asFloat(); }
208 void evalSequenceSideEffCase3 (ShaderEvalContext& ctx) { ctx.color = sequenceSideEffCase3 (ctx.in[0].swizzle(1, 2, 3, 0), ctx.in[1].swizzle(3, 2, 1, 0).asInt(), greaterThan(ctx.in[2].swizzle(0, 3, 2, 1), Vec4(0.0f, 0.0f, 0.0f, 0.0f))).asFloat(); }
210 static std::string stringJoin (const std::vector<std::string>& elems, const std::string& delim)
213 for (int i = 0; i < (int)elems.size(); i++)
214 result += (i > 0 ? delim : "") + elems[i];
218 static std::string twoValuedVec4 (const std::string& first, const std::string& second, const BVec4& firstMask)
220 std::vector<std::string> elems(4);
221 for (int i = 0; i < 4; i++)
222 elems[i] = firstMask[i] ? first : second;
224 return "vec4(" + stringJoin(elems, ", ") + ")";
234 PRECMASK_NA = 0, //!< Precision not applicable (booleans)
235 PRECMASK_MEDIUMP = (1<<PRECISION_MEDIUMP),
236 PRECMASK_HIGHP = (1<<PRECISION_HIGHP),
238 PRECMASK_ALL = PRECMASK_MEDIUMP | PRECMASK_HIGHP
244 VALUE_FLOAT = (1<<0), // float scalar
245 VALUE_FLOAT_VEC = (1<<1), // float vector
246 VALUE_FLOAT_GENTYPE = (1<<2), // float scalar/vector
247 VALUE_VEC3 = (1<<3), // vec3 only
248 VALUE_MATRIX = (1<<4), // matrix
249 VALUE_BOOL = (1<<5), // boolean scalar
250 VALUE_BOOL_VEC = (1<<6), // boolean vector
251 VALUE_BOOL_GENTYPE = (1<<7), // boolean scalar/vector
252 VALUE_INT = (1<<8), // int scalar
253 VALUE_INT_VEC = (1<<9), // int vector
254 VALUE_INT_GENTYPE = (1<<10), // int scalar/vector
255 VALUE_UINT = (1<<11), // uint scalar
256 VALUE_UINT_VEC = (1<<12), // uint vector
257 VALUE_UINT_GENTYPE = (1<<13), // uint scalar/vector
261 FV = VALUE_FLOAT_VEC,
262 GT = VALUE_FLOAT_GENTYPE,
267 BGT = VALUE_BOOL_GENTYPE,
270 IGT = VALUE_INT_GENTYPE,
273 UGT = VALUE_UINT_GENTYPE
276 static inline bool isScalarType (ValueType type)
278 return type == VALUE_FLOAT || type == VALUE_BOOL || type == VALUE_INT || type == VALUE_UINT;
281 static inline bool isFloatType (ValueType type)
283 return (type & (VALUE_FLOAT | VALUE_FLOAT_VEC | VALUE_FLOAT_GENTYPE)) != 0;
286 static inline bool isIntType (ValueType type)
288 return (type & (VALUE_INT | VALUE_INT_VEC | VALUE_INT_GENTYPE)) != 0;
291 static inline bool isUintType (ValueType type)
293 return (type & (VALUE_UINT | VALUE_UINT_VEC | VALUE_UINT_GENTYPE)) != 0;
296 static inline bool isBoolType (ValueType type)
298 return (type & (VALUE_BOOL | VALUE_BOOL_VEC | VALUE_BOOL_GENTYPE)) != 0;
303 Value (ValueType valueType_, const float rangeMin_, const float rangeMax_)
304 : valueType (valueType_)
305 , rangeMin (rangeMin_)
306 , rangeMax (rangeMax_)
319 SIDE_EFFECT_OPERATOR // Test the side-effect (as opposed to the result) of a side-effect operator.
322 struct BuiltinFuncInfo
324 BuiltinFuncInfo (const char* caseName_,
325 const char* shaderFuncName_,
327 Value input0_, Value input1_,
329 const float resultScale_,
330 const float resultBias_,
331 deUint32 precisionMask_,
332 ShaderEvalFunc evalFuncScalar_,
333 ShaderEvalFunc evalFuncVec2_,
334 ShaderEvalFunc evalFuncVec3_,
335 ShaderEvalFunc evalFuncVec4_,
336 OperationType type_=FUNCTION,
337 bool isUnaryPrefix_=true)
338 : caseName (caseName_)
339 , shaderFuncName (shaderFuncName_)
340 , outValue (outValue_)
344 , resultScale (resultScale_)
345 , resultBias (resultBias_)
346 , referenceScale (resultScale_)
347 , referenceBias (resultBias_)
348 , precisionMask (precisionMask_)
349 , evalFuncScalar (evalFuncScalar_)
350 , evalFuncVec2 (evalFuncVec2_)
351 , evalFuncVec3 (evalFuncVec3_)
352 , evalFuncVec4 (evalFuncVec4_)
354 , isUnaryPrefix (isUnaryPrefix_)
358 BuiltinFuncInfo (const char* caseName_,
359 const char* shaderFuncName_,
364 const float resultScale_,
365 const float resultBias_,
366 const float referenceScale_,
367 const float referenceBias_,
368 deUint32 precisionMask_,
369 ShaderEvalFunc evalFuncScalar_,
370 ShaderEvalFunc evalFuncVec2_,
371 ShaderEvalFunc evalFuncVec3_,
372 ShaderEvalFunc evalFuncVec4_,
373 OperationType type_=FUNCTION,
374 bool isUnaryPrefix_=true)
375 : caseName (caseName_)
376 , shaderFuncName (shaderFuncName_)
377 , outValue (outValue_)
381 , resultScale (resultScale_)
382 , resultBias (resultBias_)
383 , referenceScale (referenceScale_)
384 , referenceBias (referenceBias_)
385 , precisionMask (precisionMask_)
386 , evalFuncScalar (evalFuncScalar_)
387 , evalFuncVec2 (evalFuncVec2_)
388 , evalFuncVec3 (evalFuncVec3_)
389 , evalFuncVec4 (evalFuncVec4_)
391 , isUnaryPrefix (isUnaryPrefix_)
395 const char* caseName; //!< Name of case.
396 const char* shaderFuncName; //!< Name in shading language.
403 float referenceScale;
405 deUint32 precisionMask;
406 ShaderEvalFunc evalFuncScalar;
407 ShaderEvalFunc evalFuncVec2;
408 ShaderEvalFunc evalFuncVec3;
409 ShaderEvalFunc evalFuncVec4;
411 bool isUnaryPrefix; //!< Whether a unary operator is a prefix operator; redundant unless unary.
414 static inline BuiltinFuncInfo BuiltinOperInfo (const char* caseName_, const char* shaderFuncName_, ValueType outValue_, Value input0_, Value input1_, Value input2_, const float resultScale_, const float resultBias_, deUint32 precisionMask_, ShaderEvalFunc evalFuncScalar_, ShaderEvalFunc evalFuncVec2_, ShaderEvalFunc evalFuncVec3_, ShaderEvalFunc evalFuncVec4_)
416 return BuiltinFuncInfo(caseName_, shaderFuncName_, outValue_, input0_, input1_, input2_, resultScale_, resultBias_, resultScale_, resultBias_, precisionMask_, evalFuncScalar_, evalFuncVec2_, evalFuncVec3_, evalFuncVec4_, OPERATOR);
419 // For postfix (unary) operators.
420 static inline BuiltinFuncInfo BuiltinPostOperInfo (const char* caseName_, const char* shaderFuncName_, ValueType outValue_, Value input0_, Value input1_, Value input2_, const float resultScale_, const float resultBias_, deUint32 precisionMask_, ShaderEvalFunc evalFuncScalar_, ShaderEvalFunc evalFuncVec2_, ShaderEvalFunc evalFuncVec3_, ShaderEvalFunc evalFuncVec4_)
422 return BuiltinFuncInfo(caseName_, shaderFuncName_, outValue_, input0_, input1_, input2_, resultScale_, resultBias_, resultScale_, resultBias_, precisionMask_, evalFuncScalar_, evalFuncVec2_, evalFuncVec3_, evalFuncVec4_, OPERATOR, false);
425 static inline BuiltinFuncInfo BuiltinSideEffOperInfo (const char* caseName_, const char* shaderFuncName_, ValueType outValue_, Value input0_, Value input1_, Value input2_, const float resultScale_, const float resultBias_, deUint32 precisionMask_, ShaderEvalFunc evalFuncScalar_, ShaderEvalFunc evalFuncVec2_, ShaderEvalFunc evalFuncVec3_, ShaderEvalFunc evalFuncVec4_)
427 return BuiltinFuncInfo(caseName_, shaderFuncName_, outValue_, input0_, input1_, input2_, resultScale_, resultBias_, resultScale_, resultBias_, precisionMask_, evalFuncScalar_, evalFuncVec2_, evalFuncVec3_, evalFuncVec4_, SIDE_EFFECT_OPERATOR);
430 // For postfix (unary) operators, testing side-effect.
431 static inline BuiltinFuncInfo BuiltinPostSideEffOperInfo (const char* caseName_, const char* shaderFuncName_, ValueType outValue_, Value input0_, Value input1_, Value input2_, const float resultScale_, const float resultBias_, deUint32 precisionMask_, ShaderEvalFunc evalFuncScalar_, ShaderEvalFunc evalFuncVec2_, ShaderEvalFunc evalFuncVec3_, ShaderEvalFunc evalFuncVec4_)
433 return BuiltinFuncInfo(caseName_, shaderFuncName_, outValue_, input0_, input1_, input2_, resultScale_, resultBias_, resultScale_, resultBias_, precisionMask_, evalFuncScalar_, evalFuncVec2_, evalFuncVec3_, evalFuncVec4_, SIDE_EFFECT_OPERATOR, false);
438 struct BuiltinFuncGroup
440 BuiltinFuncGroup (const char* name_, const char* description_) : name(name_), description(description_) {}
441 BuiltinFuncGroup& operator<< (const BuiltinFuncInfo& info) { funcInfos.push_back(info); return *this; }
444 const char* description;
445 std::vector<BuiltinFuncInfo> funcInfos;
448 static const char* s_inSwizzles[MAX_INPUTS][4] =
450 { "z", "wy", "zxy", "yzwx" },
451 { "x", "yx", "yzx", "wzyx" },
452 { "y", "zy", "wyz", "xwzy" }
455 static const char* s_outSwizzles[] = { "x", "yz", "xyz", "xyzw" };
457 static const BVec4 s_outSwizzleChannelMasks[] =
459 BVec4(true, false, false, false),
460 BVec4(false, true, true, false),
461 BVec4(true, true, true, false),
462 BVec4(true, true, true, true )
465 // OperatorShaderEvaluator
467 class OperatorShaderEvaluator : public ShaderEvaluator
470 OperatorShaderEvaluator (const ShaderEvalFunc evalFunc, const float scale, const float bias, int resultScalarSize)
471 : m_evalFunc (evalFunc)
472 , m_resultScalarSize (resultScalarSize)
473 , m_evaluatedScale (scale)
474 , m_evaluatedBias (bias)
476 DE_ASSERT(de::inRange(resultScalarSize, 1, 4));
479 virtual ~OperatorShaderEvaluator (void)
483 virtual void evaluate (ShaderEvalContext& ctx) const
487 for (int channelNdx = 0; channelNdx < 4; channelNdx++)
488 if (s_outSwizzleChannelMasks[m_resultScalarSize - 1][channelNdx])
489 ctx.color[channelNdx] = ctx.color[channelNdx] * m_evaluatedScale + m_evaluatedBias;
493 const ShaderEvalFunc m_evalFunc;
494 const int m_resultScalarSize;
496 const float m_evaluatedScale;
497 const float m_evaluatedBias;
504 ShaderValue (DataType type_, const float rangeMin_, const float rangeMax_)
506 , rangeMin (rangeMin_)
507 , rangeMax (rangeMax_)
523 struct ShaderDataSpec
525 ShaderDataSpec (void)
528 , referenceScale (1.0f)
529 , referenceBias (0.0f)
530 , precision (PRECISION_LAST)
538 float referenceScale;
543 ShaderValue inputs[MAX_INPUTS];
546 // ShaderOperatorInstance
548 class ShaderOperatorCaseInstance : public ShaderRenderCaseInstance
551 ShaderOperatorCaseInstance (Context& context,
552 const bool isVertexCase,
553 const ShaderEvaluator& evaluator,
554 const UniformSetup& uniformSetup,
555 const ShaderDataSpec spec);
556 virtual ~ShaderOperatorCaseInstance (void);
559 const ShaderDataSpec m_spec;
562 ShaderOperatorCaseInstance::ShaderOperatorCaseInstance (Context& context,
563 const bool isVertexCase,
564 const ShaderEvaluator& evaluator,
565 const UniformSetup& uniformSetup,
566 const ShaderDataSpec spec)
567 : ShaderRenderCaseInstance (context, isVertexCase, evaluator, uniformSetup, DE_NULL)
570 // Setup the user attributes.
571 m_userAttribTransforms.resize(m_spec.numInputs);
572 for (int inputNdx = 0; inputNdx < m_spec.numInputs; inputNdx++)
574 const ShaderValue& v = m_spec.inputs[inputNdx];
575 DE_ASSERT(v.type != TYPE_LAST);
577 const float rangeMin = v.rangeMin;
578 const float rangeMax = v.rangeMax;
579 const float scale = rangeMax - rangeMin;
580 const float minBias = rangeMin;
581 const float maxBias = rangeMax;
584 for (int rowNdx = 0; rowNdx < 4; rowNdx++)
588 switch ((rowNdx + inputNdx) % 4)
590 case 0: row = Vec4(scale, 0.0f, 0.0f, minBias); break;
591 case 1: row = Vec4(0.0f, scale, 0.0f, minBias); break;
592 case 2: row = Vec4(-scale, 0.0f, 0.0f, maxBias); break;
593 case 3: row = Vec4(0.0f, -scale, 0.0f, maxBias); break;
594 default: DE_ASSERT(false);
597 attribMatrix.setRow(rowNdx, row);
600 m_userAttribTransforms[inputNdx] = attribMatrix;
602 const deUint32 location = 4u + inputNdx;
605 case 0: useAttribute(location, A_IN0); break;
606 case 1: useAttribute(location, A_IN1); break;
607 case 2: useAttribute(location, A_IN2); break;
608 case 3: useAttribute(location, A_IN3); break;
609 default: DE_ASSERT(false);
614 ShaderOperatorCaseInstance::~ShaderOperatorCaseInstance (void)
618 // ShaderOperatorCase
620 class ShaderOperatorCase : public ShaderRenderCase
623 ShaderOperatorCase (tcu::TestContext& testCtx,
624 const char* caseName,
625 const char* description,
626 const bool isVertexCase,
627 const ShaderEvalFunc evalFunc,
628 const std::string& shaderOp,
629 const ShaderDataSpec& spec);
630 virtual ~ShaderOperatorCase (void);
632 virtual TestInstance* createInstance (Context& context) const;
635 void setupShaderData (void);
638 ShaderOperatorCase (const ShaderOperatorCase&); // not allowed!
639 ShaderOperatorCase& operator= (const ShaderOperatorCase&); // not allowed!
641 const ShaderDataSpec m_spec;
642 const std::string m_shaderOp;
645 ShaderOperatorCase::ShaderOperatorCase (tcu::TestContext& testCtx,
646 const char* caseName,
647 const char* description,
648 const bool isVertexCase,
649 const ShaderEvalFunc evalFunc,
650 const std::string& shaderOp,
651 const ShaderDataSpec& spec)
652 : ShaderRenderCase (testCtx,
656 new OperatorShaderEvaluator(evalFunc, spec.referenceScale, spec.referenceBias, getDataTypeScalarSize(spec.output)),
660 , m_shaderOp (shaderOp)
665 TestInstance* ShaderOperatorCase::createInstance (Context& context) const
667 DE_ASSERT(m_evaluator != DE_NULL);
668 DE_ASSERT(m_uniformSetup != DE_NULL);
669 return new ShaderOperatorCaseInstance(context, m_isVertexCase, *m_evaluator, *m_uniformSetup, m_spec);
673 void ShaderOperatorCase::setupShaderData (void)
675 const char* precision = m_spec.precision != PRECISION_LAST ? getPrecisionName(m_spec.precision) : DE_NULL;
676 const char* inputPrecision[MAX_INPUTS];
678 std::ostringstream vtx;
679 std::ostringstream frag;
680 std::ostringstream& op = m_isVertexCase ? vtx : frag;
688 // Compute precision for inputs.
689 for (int inputNdx = 0; inputNdx < m_spec.numInputs; inputNdx++)
691 const bool isBoolVal = de::inRange<int>(m_spec.inputs[inputNdx].type, TYPE_BOOL, TYPE_BOOL_VEC4);
692 const bool isIntVal = de::inRange<int>(m_spec.inputs[inputNdx].type, TYPE_INT, TYPE_INT_VEC4);
693 const bool isUintVal = de::inRange<int>(m_spec.inputs[inputNdx].type, TYPE_UINT, TYPE_UINT_VEC4);
694 // \note Mediump interpolators are used for booleans, and highp for integers.
695 const Precision prec = isBoolVal ? PRECISION_MEDIUMP
696 : isIntVal || isUintVal ? PRECISION_HIGHP
698 inputPrecision[inputNdx] = getPrecisionName(prec);
702 vtx << "layout(location = 0) in highp vec4 a_position;\n";
703 for (int inputNdx = 0; inputNdx < m_spec.numInputs; inputNdx++)
704 vtx << "layout(location = " << 4 + inputNdx << ") in " << inputPrecision[inputNdx] << " vec4 a_in" << inputNdx << ";\n";
707 frag << "layout(location = 0) out mediump vec4 o_color;\n";
711 vtx << "layout(location = 0) out mediump vec4 v_color;\n";
712 frag << "layout(location = 0) in mediump vec4 v_color;\n";
716 for (int inputNdx = 0; inputNdx < m_spec.numInputs; inputNdx++)
718 vtx << "layout(location = " << inputNdx + 1 << ") out " << inputPrecision[inputNdx] << " vec4 v_in" << inputNdx << ";\n";
719 frag << "layout(location = " << inputNdx + 1 << ") in " << inputPrecision[inputNdx] << " vec4 v_in" << inputNdx << ";\n";
724 vtx << "void main()\n";
726 vtx << " gl_Position = a_position;\n";
729 frag << "void main()\n";
732 // Expression inputs.
733 const std::string prefix = m_isVertexCase ? "a_" : "v_";
734 for (int inputNdx = 0; inputNdx < m_spec.numInputs; inputNdx++)
736 const DataType inType = m_spec.inputs[inputNdx].type;
737 const int inSize = getDataTypeScalarSize(inType);
738 const bool isInt = de::inRange<int>(inType, TYPE_INT, TYPE_INT_VEC4);
739 const bool isUint = de::inRange<int>(inType, TYPE_UINT, TYPE_UINT_VEC4);
740 const bool isBool = de::inRange<int>(inType, TYPE_BOOL, TYPE_BOOL_VEC4);
741 const char* typeName = getDataTypeName(inType);
742 const char* swizzle = s_inSwizzles[inputNdx][inSize - 1];
745 if (precision && !isBool) op << precision << " ";
747 op << typeName << " in" << inputNdx << " = ";
751 if (inSize == 1) op << "(";
752 else op << "greaterThan(";
754 else if (isInt || isUint)
755 op << typeName << "(";
757 op << prefix << "in" << inputNdx << "." << swizzle;
761 if (inSize == 1) op << " > 0.0)";
762 else op << ", vec" << inSize << "(0.0))";
764 else if (isInt || isUint)
772 const char* outTypeName = getDataTypeName(m_spec.output);
773 const bool isBoolOut = de::inRange<int>(m_spec.output, TYPE_BOOL, TYPE_BOOL_VEC4);
776 if (precision && !isBoolOut) op << precision << " ";
777 op << outTypeName << " res = " << outTypeName << "(0.0);\n\n";
781 op << "\t" << m_shaderOp << "\n\n";
784 const bool isResFloatVec = de::inRange<int>(m_spec.output, TYPE_FLOAT, TYPE_FLOAT_VEC4);
785 const int outScalarSize = getDataTypeScalarSize(m_spec.output);
787 op << "\thighp vec4 color = vec4(0.0, 0.0, 0.0, 1.0);\n";
788 op << "\tcolor." << s_outSwizzles[outScalarSize-1] << " = ";
790 if (!isResFloatVec && outScalarSize == 1)
792 else if (!isResFloatVec)
793 op << "vec" << outScalarSize << "(res)";
800 const float resultScale = m_spec.resultScale;
801 const float resultBias = m_spec.resultBias;
802 if ((resultScale != 1.0f) || (resultBias != 0.0f))
804 op << "\tcolor = color";
805 if (resultScale != 1.0f) op << " * " << twoValuedVec4(de::toString(resultScale), "1.0", s_outSwizzleChannelMasks[outScalarSize - 1]);
806 if (resultBias != 0.0f) op << " + " << twoValuedVec4(de::floatToString(resultBias, 2), "0.0", s_outSwizzleChannelMasks[outScalarSize - 1]);
813 vtx << " v_color = color;\n";
814 frag << " o_color = v_color;\n";
818 for (int inputNdx = 0; inputNdx < m_spec.numInputs; inputNdx++)
819 vtx << " v_in" << inputNdx << " = a_in" << inputNdx << ";\n";
820 frag << " o_color = color;\n";
826 m_vertShaderSource = vtx.str();
827 m_fragShaderSource = frag.str();
830 ShaderOperatorCase::~ShaderOperatorCase (void)
834 // Vector math functions.
835 template<typename T> inline T nop (T f) { return f; }
837 template <typename T, int Size>
838 Vector<T, Size> nop (const Vector<T, Size>& v) { return v; }
840 #define DECLARE_UNARY_GENTYPE_FUNCS(FUNC_NAME) \
841 void eval_##FUNC_NAME##_float (ShaderEvalContext& c) { c.color.x() = FUNC_NAME(c.in[0].swizzle(2)).x(); } \
842 void eval_##FUNC_NAME##_vec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1)); } \
843 void eval_##FUNC_NAME##_vec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1)); } \
844 void eval_##FUNC_NAME##_vec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0)); }
846 #define DECLARE_BINARY_GENTYPE_FUNCS(FUNC_NAME) \
847 void eval_##FUNC_NAME##_float (ShaderEvalContext& c) { c.color.x() = FUNC_NAME(c.in[0].swizzle(2), c.in[1].swizzle(0)).x(); } \
848 void eval_##FUNC_NAME##_vec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1), c.in[1].swizzle(1, 0)); } \
849 void eval_##FUNC_NAME##_vec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1), c.in[1].swizzle(1, 2, 0)); } \
850 void eval_##FUNC_NAME##_vec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0), c.in[1].swizzle(3, 2, 1, 0)); }
852 #define DECLARE_TERNARY_GENTYPE_FUNCS(FUNC_NAME) \
853 void eval_##FUNC_NAME##_float (ShaderEvalContext& c) { c.color.x() = FUNC_NAME(c.in[0].swizzle(2), c.in[1].swizzle(0), c.in[2].swizzle(1)).x(); } \
854 void eval_##FUNC_NAME##_vec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1), c.in[1].swizzle(1, 0), c.in[2].swizzle(2, 1)); } \
855 void eval_##FUNC_NAME##_vec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1), c.in[1].swizzle(1, 2, 0), c.in[2].swizzle(3, 1, 2)); } \
856 void eval_##FUNC_NAME##_vec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0), c.in[1].swizzle(3, 2, 1, 0), c.in[2].swizzle(0, 3, 2, 1)); }
858 #define DECLARE_UNARY_SCALAR_GENTYPE_FUNCS(FUNC_NAME) \
859 void eval_##FUNC_NAME##_float (ShaderEvalContext& c) { c.color.x() = FUNC_NAME(c.in[0].swizzle(2)); } \
860 void eval_##FUNC_NAME##_vec2 (ShaderEvalContext& c) { c.color.x() = FUNC_NAME(c.in[0].swizzle(3, 1)); } \
861 void eval_##FUNC_NAME##_vec3 (ShaderEvalContext& c) { c.color.x() = FUNC_NAME(c.in[0].swizzle(2, 0, 1)); } \
862 void eval_##FUNC_NAME##_vec4 (ShaderEvalContext& c) { c.color.x() = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0)); }
864 #define DECLARE_BINARY_SCALAR_GENTYPE_FUNCS(FUNC_NAME) \
865 void eval_##FUNC_NAME##_float (ShaderEvalContext& c) { c.color.x() = FUNC_NAME(c.in[0].swizzle(2), c.in[1].swizzle(0)); } \
866 void eval_##FUNC_NAME##_vec2 (ShaderEvalContext& c) { c.color.x() = FUNC_NAME(c.in[0].swizzle(3, 1), c.in[1].swizzle(1, 0)); } \
867 void eval_##FUNC_NAME##_vec3 (ShaderEvalContext& c) { c.color.x() = FUNC_NAME(c.in[0].swizzle(2, 0, 1), c.in[1].swizzle(1, 2, 0)); } \
868 void eval_##FUNC_NAME##_vec4 (ShaderEvalContext& c) { c.color.x() = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0), c.in[1].swizzle(3, 2, 1, 0)); }
870 #define DECLARE_BINARY_BOOL_FUNCS(FUNC_NAME) \
871 void eval_##FUNC_NAME##_bool (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(c.in[0].z() > 0.0f, c.in[1].x() > 0.0f); }
873 #define DECLARE_UNARY_BOOL_GENTYPE_FUNCS(FUNC_NAME) \
874 void eval_##FUNC_NAME##_bool (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(c.in[0].z() > 0.0f); } \
875 void eval_##FUNC_NAME##_bvec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(greaterThan(c.in[0].swizzle(3, 1), Vec2(0.0f))).asFloat(); } \
876 void eval_##FUNC_NAME##_bvec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(greaterThan(c.in[0].swizzle(2, 0, 1), Vec3(0.0f))).asFloat(); } \
877 void eval_##FUNC_NAME##_bvec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(greaterThan(c.in[0].swizzle(1, 2, 3, 0), Vec4(0.0f))).asFloat(); }
879 #define DECLARE_TERNARY_BOOL_GENTYPE_FUNCS(FUNC_NAME) \
880 void eval_##FUNC_NAME##_bool (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(c.in[0].z() > 0.0f, c.in[1].x() > 0.0f, c.in[2].y() > 0.0f); } \
881 void eval_##FUNC_NAME##_bvec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(greaterThan(c.in[0].swizzle(3, 1), Vec2(0.0f)), greaterThan(c.in[1].swizzle(1, 0), Vec2(0.0f)), greaterThan(c.in[2].swizzle(2, 1), Vec2(0.0f))).asFloat(); } \
882 void eval_##FUNC_NAME##_bvec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(greaterThan(c.in[0].swizzle(2, 0, 1), Vec3(0.0f)), greaterThan(c.in[1].swizzle(1, 2, 0), Vec3(0.0f)), greaterThan(c.in[2].swizzle(3, 1, 2), Vec3(0.0f))).asFloat(); } \
883 void eval_##FUNC_NAME##_bvec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(greaterThan(c.in[0].swizzle(1, 2, 3, 0), Vec4(0.0f)), greaterThan(c.in[1].swizzle(3, 2, 1, 0), Vec4(0.0f)), greaterThan(c.in[2].swizzle(0, 3, 2, 1), Vec4(0.0f))).asFloat(); }
885 #define DECLARE_UNARY_INT_GENTYPE_FUNCS(FUNC_NAME) \
886 void eval_##FUNC_NAME##_int (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME((int)c.in[0].z()); } \
887 void eval_##FUNC_NAME##_ivec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1).asInt()).asFloat(); } \
888 void eval_##FUNC_NAME##_ivec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1).asInt()).asFloat(); } \
889 void eval_##FUNC_NAME##_ivec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0).asInt()).asFloat(); }
891 #define DECLARE_BINARY_INT_GENTYPE_FUNCS(FUNC_NAME) \
892 void eval_##FUNC_NAME##_int (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME((int)c.in[0].z(), (int)c.in[1].x()); } \
893 void eval_##FUNC_NAME##_ivec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1).asInt(), c.in[1].swizzle(1, 0).asInt()).asFloat(); } \
894 void eval_##FUNC_NAME##_ivec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1).asInt(), c.in[1].swizzle(1, 2, 0).asInt()).asFloat(); } \
895 void eval_##FUNC_NAME##_ivec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0).asInt(), c.in[1].swizzle(3, 2, 1, 0).asInt()).asFloat(); }
897 #define DECLARE_UNARY_UINT_GENTYPE_FUNCS(FUNC_NAME) \
898 void eval_##FUNC_NAME##_uint (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME((deUint32)c.in[0].z()); } \
899 void eval_##FUNC_NAME##_uvec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1).asUint()).asFloat(); } \
900 void eval_##FUNC_NAME##_uvec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1).asUint()).asFloat(); } \
901 void eval_##FUNC_NAME##_uvec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0).asUint()).asFloat(); }
903 #define DECLARE_BINARY_UINT_GENTYPE_FUNCS(FUNC_NAME) \
904 void eval_##FUNC_NAME##_uint (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME((deUint32)c.in[0].z(), (deUint32)c.in[1].x()); } \
905 void eval_##FUNC_NAME##_uvec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1).asUint(), c.in[1].swizzle(1, 0).asUint()).asFloat(); } \
906 void eval_##FUNC_NAME##_uvec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1).asUint(), c.in[1].swizzle(1, 2, 0).asUint()).asFloat(); } \
907 void eval_##FUNC_NAME##_uvec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0).asUint(), c.in[1].swizzle(3, 2, 1, 0).asUint()).asFloat(); }
909 #define DECLARE_TERNARY_INT_GENTYPE_FUNCS(FUNC_NAME) \
910 void eval_##FUNC_NAME##_int (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME((int)c.in[0].z(), (int)c.in[1].x(), (int)c.in[2].y()); } \
911 void eval_##FUNC_NAME##_ivec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1).asInt(), c.in[1].swizzle(1, 0).asInt(), c.in[2].swizzle(2, 1).asInt()).asFloat(); } \
912 void eval_##FUNC_NAME##_ivec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1).asInt(), c.in[1].swizzle(1, 2, 0).asInt(), c.in[2].swizzle(3, 1, 2).asInt()).asFloat(); } \
913 void eval_##FUNC_NAME##_ivec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0).asInt(), c.in[1].swizzle(3, 2, 1, 0).asInt(), c.in[2].swizzle(0, 3, 2, 1).asInt()).asFloat(); }
915 #define DECLARE_TERNARY_UINT_GENTYPE_FUNCS(FUNC_NAME) \
916 void eval_##FUNC_NAME##_uint (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME((deUint32)c.in[0].z(), (deUint32)c.in[1].x(), (deUint32)c.in[2].y()); } \
917 void eval_##FUNC_NAME##_uvec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1).asUint(), c.in[1].swizzle(1, 0).asUint(), c.in[2].swizzle(2, 1).asUint()).asFloat(); } \
918 void eval_##FUNC_NAME##_uvec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1).asUint(), c.in[1].swizzle(1, 2, 0).asUint(), c.in[2].swizzle(3, 1, 2).asUint()).asFloat(); } \
919 void eval_##FUNC_NAME##_uvec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0).asUint(), c.in[1].swizzle(3, 2, 1, 0).asUint(), c.in[2].swizzle(0, 3, 2, 1).asUint()).asFloat(); }
921 #define DECLARE_VEC_FLOAT_FUNCS(FUNC_NAME) \
922 void eval_##FUNC_NAME##_vec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1), c.in[1].x()); } \
923 void eval_##FUNC_NAME##_vec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1), c.in[1].x()); } \
924 void eval_##FUNC_NAME##_vec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0), c.in[1].x()); }
926 #define DECLARE_VEC_FLOAT_FLOAT_FUNCS(FUNC_NAME) \
927 void eval_##FUNC_NAME##_vec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1), c.in[1].x(), c.in[2].y()); } \
928 void eval_##FUNC_NAME##_vec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1), c.in[1].x(), c.in[2].y()); } \
929 void eval_##FUNC_NAME##_vec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0), c.in[1].x(), c.in[2].y()); }
931 #define DECLARE_VEC_VEC_FLOAT_FUNCS(FUNC_NAME) \
932 void eval_##FUNC_NAME##_vec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1), c.in[1].swizzle(1, 0), c.in[2].y()); } \
933 void eval_##FUNC_NAME##_vec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1), c.in[1].swizzle(1, 2, 0), c.in[2].y()); } \
934 void eval_##FUNC_NAME##_vec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0), c.in[1].swizzle(3, 2, 1, 0), c.in[2].y()); }
936 #define DECLARE_FLOAT_FLOAT_VEC_FUNCS(FUNC_NAME) \
937 void eval_##FUNC_NAME##_vec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].z(), c.in[1].x(), c.in[2].swizzle(2, 1)); } \
938 void eval_##FUNC_NAME##_vec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].z(), c.in[1].x(), c.in[2].swizzle(3, 1, 2)); } \
939 void eval_##FUNC_NAME##_vec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].z(), c.in[1].x(), c.in[2].swizzle(0, 3, 2, 1)); }
941 #define DECLARE_FLOAT_VEC_FUNCS(FUNC_NAME) \
942 void eval_##FUNC_NAME##_vec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].z(), c.in[1].swizzle(1, 0)); } \
943 void eval_##FUNC_NAME##_vec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].z(), c.in[1].swizzle(1, 2, 0)); } \
944 void eval_##FUNC_NAME##_vec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].z(), c.in[1].swizzle(3, 2, 1, 0)); }
946 #define DECLARE_IVEC_INT_FUNCS(FUNC_NAME) \
947 void eval_##FUNC_NAME##_ivec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1).asInt(), (int)c.in[1].x()).asFloat(); } \
948 void eval_##FUNC_NAME##_ivec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1).asInt(), (int)c.in[1].x()).asFloat(); } \
949 void eval_##FUNC_NAME##_ivec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0).asInt(), (int)c.in[1].x()).asFloat(); }
951 #define DECLARE_IVEC_INT_INT_FUNCS(FUNC_NAME) \
952 void eval_##FUNC_NAME##_ivec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1).asInt(), (int)c.in[1].x(), (int)c.in[2].y()).asFloat(); } \
953 void eval_##FUNC_NAME##_ivec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1).asInt(), (int)c.in[1].x(), (int)c.in[2].y()).asFloat(); } \
954 void eval_##FUNC_NAME##_ivec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0).asInt(), (int)c.in[1].x(), (int)c.in[2].y()).asFloat(); }
956 #define DECLARE_INT_IVEC_FUNCS(FUNC_NAME) \
957 void eval_##FUNC_NAME##_ivec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME((int)c.in[0].z(), c.in[1].swizzle(1, 0).asInt()).asFloat(); } \
958 void eval_##FUNC_NAME##_ivec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME((int)c.in[0].z(), c.in[1].swizzle(1, 2, 0).asInt()).asFloat(); } \
959 void eval_##FUNC_NAME##_ivec4 (ShaderEvalContext& c) { c.color = FUNC_NAME((int)c.in[0].z(), c.in[1].swizzle(3, 2, 1, 0).asInt()).asFloat(); }
961 #define DECLARE_UVEC_UINT_FUNCS(FUNC_NAME) \
962 void eval_##FUNC_NAME##_uvec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1).asUint(), (deUint32)c.in[1].x()).asFloat(); } \
963 void eval_##FUNC_NAME##_uvec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1).asUint(), (deUint32)c.in[1].x()).asFloat(); } \
964 void eval_##FUNC_NAME##_uvec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0).asUint(), (deUint32)c.in[1].x()).asFloat(); }
966 #define DECLARE_UVEC_UINT_UINT_FUNCS(FUNC_NAME) \
967 void eval_##FUNC_NAME##_uvec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1).asUint(), (deUint32)c.in[1].x(), (deUint32)c.in[2].y()).asFloat(); } \
968 void eval_##FUNC_NAME##_uvec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1).asUint(), (deUint32)c.in[1].x(), (deUint32)c.in[2].y()).asFloat(); } \
969 void eval_##FUNC_NAME##_uvec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0).asUint(), (deUint32)c.in[1].x(), (deUint32)c.in[2].y()).asFloat(); }
971 #define DECLARE_UINT_UVEC_FUNCS(FUNC_NAME) \
972 void eval_##FUNC_NAME##_uvec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME((deUint32)c.in[0].z(), c.in[1].swizzle(1, 0).asUint()).asFloat(); } \
973 void eval_##FUNC_NAME##_uvec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME((deUint32)c.in[0].z(), c.in[1].swizzle(1, 2, 0).asUint()).asFloat(); } \
974 void eval_##FUNC_NAME##_uvec4 (ShaderEvalContext& c) { c.color = FUNC_NAME((deUint32)c.in[0].z(), c.in[1].swizzle(3, 2, 1, 0).asUint()).asFloat(); }
976 #define DECLARE_BINARY_INT_VEC_FUNCS(FUNC_NAME) \
977 void eval_##FUNC_NAME##_ivec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1).asInt(), c.in[1].swizzle(1, 0).asInt()).asFloat(); } \
978 void eval_##FUNC_NAME##_ivec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1).asInt(), c.in[1].swizzle(1, 2, 0).asInt()).asFloat(); } \
979 void eval_##FUNC_NAME##_ivec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0).asInt(), c.in[1].swizzle(3, 2, 1, 0).asInt()).asFloat(); }
981 #define DECLARE_BINARY_UINT_VEC_FUNCS(FUNC_NAME) \
982 void eval_##FUNC_NAME##_uvec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1).asUint(), c.in[1].swizzle(1, 0).asUint()).asFloat(); } \
983 void eval_##FUNC_NAME##_uvec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1).asUint(), c.in[1].swizzle(1, 2, 0).asUint()).asFloat(); } \
984 void eval_##FUNC_NAME##_uvec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0).asUint(), c.in[1].swizzle(3, 2, 1, 0).asUint()).asFloat(); }
986 #define DECLARE_UINT_INT_GENTYPE_FUNCS(FUNC_NAME) \
987 void eval_##FUNC_NAME##_uint (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME((deUint32)c.in[0].z(), (int)c.in[1].x()); } \
988 void eval_##FUNC_NAME##_uvec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1).asUint(), c.in[1].swizzle(1, 0).asInt()).asFloat(); } \
989 void eval_##FUNC_NAME##_uvec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1).asUint(), c.in[1].swizzle(1, 2, 0).asInt()).asFloat(); } \
990 void eval_##FUNC_NAME##_uvec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0).asUint(), c.in[1].swizzle(3, 2, 1, 0).asInt()).asFloat(); }
992 #define DECLARE_UVEC_INT_FUNCS(FUNC_NAME) \
993 void eval_##FUNC_NAME##_uvec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1).asUint(), (int)c.in[1].x()).asFloat(); } \
994 void eval_##FUNC_NAME##_uvec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1).asUint(), (int)c.in[1].x()).asFloat(); } \
995 void eval_##FUNC_NAME##_uvec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0).asUint(), (int)c.in[1].x()).asFloat(); }
1000 DECLARE_UNARY_GENTYPE_FUNCS(nop)
1001 DECLARE_UNARY_GENTYPE_FUNCS(negate)
1002 DECLARE_UNARY_GENTYPE_FUNCS(addOne)
1003 DECLARE_UNARY_GENTYPE_FUNCS(subOne)
1004 DECLARE_BINARY_GENTYPE_FUNCS(add)
1005 DECLARE_BINARY_GENTYPE_FUNCS(sub)
1006 DECLARE_BINARY_GENTYPE_FUNCS(mul)
1007 DECLARE_BINARY_GENTYPE_FUNCS(div)
1009 void eval_selection_float (ShaderEvalContext& c) { c.color.x() = selection(c.in[0].z() > 0.0f, c.in[1].x(), c.in[2].y()); }
1010 void eval_selection_vec2 (ShaderEvalContext& c) { c.color.yz() = selection(c.in[0].z() > 0.0f, c.in[1].swizzle(1, 0), c.in[2].swizzle(2, 1)); }
1011 void eval_selection_vec3 (ShaderEvalContext& c) { c.color.xyz() = selection(c.in[0].z() > 0.0f, c.in[1].swizzle(1, 2, 0), c.in[2].swizzle(3, 1, 2)); }
1012 void eval_selection_vec4 (ShaderEvalContext& c) { c.color = selection(c.in[0].z() > 0.0f, c.in[1].swizzle(3, 2, 1, 0), c.in[2].swizzle(0, 3, 2, 1)); }
1014 DECLARE_UNARY_INT_GENTYPE_FUNCS(nop)
1015 DECLARE_UNARY_INT_GENTYPE_FUNCS(negate)
1016 DECLARE_UNARY_INT_GENTYPE_FUNCS(addOne)
1017 DECLARE_UNARY_INT_GENTYPE_FUNCS(subOne)
1018 DECLARE_UNARY_INT_GENTYPE_FUNCS(bitwiseNot)
1019 DECLARE_BINARY_INT_GENTYPE_FUNCS(add)
1020 DECLARE_BINARY_INT_GENTYPE_FUNCS(sub)
1021 DECLARE_BINARY_INT_GENTYPE_FUNCS(mul)
1022 DECLARE_BINARY_INT_GENTYPE_FUNCS(div)
1023 DECLARE_BINARY_INT_GENTYPE_FUNCS(mod)
1024 DECLARE_BINARY_INT_GENTYPE_FUNCS(bitwiseAnd)
1025 DECLARE_BINARY_INT_GENTYPE_FUNCS(bitwiseOr)
1026 DECLARE_BINARY_INT_GENTYPE_FUNCS(bitwiseXor)
1028 void eval_leftShift_int (ShaderEvalContext& c) { c.color.x() = (float)leftShift((int)c.in[0].z(), (int)c.in[1].x()); }
1029 DECLARE_BINARY_INT_VEC_FUNCS(leftShift)
1030 void eval_rightShift_int (ShaderEvalContext& c) { c.color.x() = (float)rightShift((int)c.in[0].z(), (int)c.in[1].x()); }
1031 DECLARE_BINARY_INT_VEC_FUNCS(rightShift)
1032 DECLARE_IVEC_INT_FUNCS(leftShiftVecScalar)
1033 DECLARE_IVEC_INT_FUNCS(rightShiftVecScalar)
1035 void eval_selection_int (ShaderEvalContext& c) { c.color.x() = (float)selection(c.in[0].z() > 0.0f, (int)c.in[1].x(), (int)c.in[2].y()); }
1036 void eval_selection_ivec2 (ShaderEvalContext& c) { c.color.yz() = selection(c.in[0].z() > 0.0f, c.in[1].swizzle(1, 0).asInt(), c.in[2].swizzle(2, 1).asInt()).asFloat(); }
1037 void eval_selection_ivec3 (ShaderEvalContext& c) { c.color.xyz() = selection(c.in[0].z() > 0.0f, c.in[1].swizzle(1, 2, 0).asInt(), c.in[2].swizzle(3, 1, 2).asInt()).asFloat(); }
1038 void eval_selection_ivec4 (ShaderEvalContext& c) { c.color = selection(c.in[0].z() > 0.0f, c.in[1].swizzle(3, 2, 1, 0).asInt(), c.in[2].swizzle(0, 3, 2, 1).asInt()).asFloat(); }
1040 DECLARE_UNARY_UINT_GENTYPE_FUNCS(nop)
1041 DECLARE_UNARY_UINT_GENTYPE_FUNCS(negate)
1042 DECLARE_UNARY_UINT_GENTYPE_FUNCS(bitwiseNot)
1043 DECLARE_UNARY_UINT_GENTYPE_FUNCS(addOne)
1044 DECLARE_UNARY_UINT_GENTYPE_FUNCS(subOne)
1045 DECLARE_BINARY_UINT_GENTYPE_FUNCS(add)
1046 DECLARE_BINARY_UINT_GENTYPE_FUNCS(sub)
1047 DECLARE_BINARY_UINT_GENTYPE_FUNCS(mul)
1048 DECLARE_BINARY_UINT_GENTYPE_FUNCS(div)
1049 DECLARE_BINARY_UINT_GENTYPE_FUNCS(mod)
1050 DECLARE_BINARY_UINT_GENTYPE_FUNCS(bitwiseAnd)
1051 DECLARE_BINARY_UINT_GENTYPE_FUNCS(bitwiseOr)
1052 DECLARE_BINARY_UINT_GENTYPE_FUNCS(bitwiseXor)
1054 DECLARE_UINT_INT_GENTYPE_FUNCS(leftShift)
1055 DECLARE_UINT_INT_GENTYPE_FUNCS(rightShift)
1056 DECLARE_UVEC_INT_FUNCS(leftShiftVecScalar)
1057 DECLARE_UVEC_INT_FUNCS(rightShiftVecScalar)
1059 void eval_selection_uint (ShaderEvalContext& c) { c.color.x() = (float)selection(c.in[0].z() > 0.0f, (deUint32)c.in[1].x(), (deUint32)c.in[2].y()); }
1060 void eval_selection_uvec2 (ShaderEvalContext& c) { c.color.yz() = selection(c.in[0].z() > 0.0f, c.in[1].swizzle(1, 0).asUint(), c.in[2].swizzle(2, 1).asUint()).asFloat(); }
1061 void eval_selection_uvec3 (ShaderEvalContext& c) { c.color.xyz() = selection(c.in[0].z() > 0.0f, c.in[1].swizzle(1, 2, 0).asUint(), c.in[2].swizzle(3, 1, 2).asUint()).asFloat(); }
1062 void eval_selection_uvec4 (ShaderEvalContext& c) { c.color = selection(c.in[0].z() > 0.0f, c.in[1].swizzle(3, 2, 1, 0).asUint(), c.in[2].swizzle(0, 3, 2, 1).asUint()).asFloat(); }
1064 DECLARE_UNARY_BOOL_GENTYPE_FUNCS(boolNot)
1065 DECLARE_BINARY_BOOL_FUNCS(logicalAnd)
1066 DECLARE_BINARY_BOOL_FUNCS(logicalOr)
1067 DECLARE_BINARY_BOOL_FUNCS(logicalXor)
1069 void eval_selection_bool (ShaderEvalContext& c) { c.color.x() = (float)selection(c.in[0].z() > 0.0f, c.in[1].x() > 0.0f, c.in[2].y() > 0.0f); }
1070 void eval_selection_bvec2 (ShaderEvalContext& c) { c.color.yz() = selection(c.in[0].z() > 0.0f, greaterThan(c.in[1].swizzle(1, 0), Vec2(0.0f, 0.0f)), greaterThan(c.in[2].swizzle(2, 1), Vec2(0.0f, 0.0f))).asFloat(); }
1071 void eval_selection_bvec3 (ShaderEvalContext& c) { c.color.xyz() = selection(c.in[0].z() > 0.0f, greaterThan(c.in[1].swizzle(1, 2, 0), Vec3(0.0f, 0.0f, 0.0f)), greaterThan(c.in[2].swizzle(3, 1, 2), Vec3(0.0f, 0.0f, 0.0f))).asFloat(); }
1072 void eval_selection_bvec4 (ShaderEvalContext& c) { c.color = selection(c.in[0].z() > 0.0f, greaterThan(c.in[1].swizzle(3, 2, 1, 0), Vec4(0.0f, 0.0f, 0.0f, 0.0f)), greaterThan(c.in[2].swizzle(0, 3, 2, 1), Vec4(0.0f, 0.0f, 0.0f, 0.0f))).asFloat(); }
1074 DECLARE_VEC_FLOAT_FUNCS(addVecScalar)
1075 DECLARE_VEC_FLOAT_FUNCS(subVecScalar)
1076 DECLARE_VEC_FLOAT_FUNCS(mulVecScalar)
1077 DECLARE_VEC_FLOAT_FUNCS(divVecScalar)
1079 DECLARE_FLOAT_VEC_FUNCS(addScalarVec)
1080 DECLARE_FLOAT_VEC_FUNCS(subScalarVec)
1081 DECLARE_FLOAT_VEC_FUNCS(mulScalarVec)
1082 DECLARE_FLOAT_VEC_FUNCS(divScalarVec)
1084 DECLARE_IVEC_INT_FUNCS(addVecScalar)
1085 DECLARE_IVEC_INT_FUNCS(subVecScalar)
1086 DECLARE_IVEC_INT_FUNCS(mulVecScalar)
1087 DECLARE_IVEC_INT_FUNCS(divVecScalar)
1088 DECLARE_IVEC_INT_FUNCS(modVecScalar)
1089 DECLARE_IVEC_INT_FUNCS(bitwiseAndVecScalar)
1090 DECLARE_IVEC_INT_FUNCS(bitwiseOrVecScalar)
1091 DECLARE_IVEC_INT_FUNCS(bitwiseXorVecScalar)
1093 DECLARE_INT_IVEC_FUNCS(addScalarVec)
1094 DECLARE_INT_IVEC_FUNCS(subScalarVec)
1095 DECLARE_INT_IVEC_FUNCS(mulScalarVec)
1096 DECLARE_INT_IVEC_FUNCS(divScalarVec)
1097 DECLARE_INT_IVEC_FUNCS(modScalarVec)
1098 DECLARE_INT_IVEC_FUNCS(bitwiseAndScalarVec)
1099 DECLARE_INT_IVEC_FUNCS(bitwiseOrScalarVec)
1100 DECLARE_INT_IVEC_FUNCS(bitwiseXorScalarVec)
1102 DECLARE_UVEC_UINT_FUNCS(addVecScalar)
1103 DECLARE_UVEC_UINT_FUNCS(subVecScalar)
1104 DECLARE_UVEC_UINT_FUNCS(mulVecScalar)
1105 DECLARE_UVEC_UINT_FUNCS(divVecScalar)
1106 DECLARE_UVEC_UINT_FUNCS(modVecScalar)
1107 DECLARE_UVEC_UINT_FUNCS(bitwiseAndVecScalar)
1108 DECLARE_UVEC_UINT_FUNCS(bitwiseOrVecScalar)
1109 DECLARE_UVEC_UINT_FUNCS(bitwiseXorVecScalar)
1111 DECLARE_UINT_UVEC_FUNCS(addScalarVec)
1112 DECLARE_UINT_UVEC_FUNCS(subScalarVec)
1113 DECLARE_UINT_UVEC_FUNCS(mulScalarVec)
1114 DECLARE_UINT_UVEC_FUNCS(divScalarVec)
1115 DECLARE_UINT_UVEC_FUNCS(modScalarVec)
1116 DECLARE_UINT_UVEC_FUNCS(bitwiseAndScalarVec)
1117 DECLARE_UINT_UVEC_FUNCS(bitwiseOrScalarVec)
1118 DECLARE_UINT_UVEC_FUNCS(bitwiseXorScalarVec)
1120 // Built-in functions.
1122 DECLARE_UNARY_GENTYPE_FUNCS(radians)
1123 DECLARE_UNARY_GENTYPE_FUNCS(degrees)
1124 DECLARE_UNARY_GENTYPE_FUNCS(sin)
1125 DECLARE_UNARY_GENTYPE_FUNCS(cos)
1126 DECLARE_UNARY_GENTYPE_FUNCS(tan)
1127 DECLARE_UNARY_GENTYPE_FUNCS(asin)
1128 DECLARE_UNARY_GENTYPE_FUNCS(acos)
1129 DECLARE_UNARY_GENTYPE_FUNCS(atan)
1130 DECLARE_BINARY_GENTYPE_FUNCS(atan2)
1131 DECLARE_UNARY_GENTYPE_FUNCS(sinh)
1132 DECLARE_UNARY_GENTYPE_FUNCS(cosh)
1133 DECLARE_UNARY_GENTYPE_FUNCS(tanh)
1134 DECLARE_UNARY_GENTYPE_FUNCS(asinh)
1135 DECLARE_UNARY_GENTYPE_FUNCS(acosh)
1136 DECLARE_UNARY_GENTYPE_FUNCS(atanh)
1138 DECLARE_BINARY_GENTYPE_FUNCS(pow)
1139 DECLARE_UNARY_GENTYPE_FUNCS(exp)
1140 DECLARE_UNARY_GENTYPE_FUNCS(log)
1141 DECLARE_UNARY_GENTYPE_FUNCS(exp2)
1142 DECLARE_UNARY_GENTYPE_FUNCS(log2)
1143 DECLARE_UNARY_GENTYPE_FUNCS(sqrt)
1144 DECLARE_UNARY_GENTYPE_FUNCS(inverseSqrt)
1146 DECLARE_UNARY_GENTYPE_FUNCS(abs)
1147 DECLARE_UNARY_GENTYPE_FUNCS(sign)
1148 DECLARE_UNARY_GENTYPE_FUNCS(floor)
1149 DECLARE_UNARY_GENTYPE_FUNCS(trunc)
1150 DECLARE_UNARY_GENTYPE_FUNCS(roundToEven)
1151 DECLARE_UNARY_GENTYPE_FUNCS(ceil)
1152 DECLARE_UNARY_GENTYPE_FUNCS(fract)
1153 DECLARE_BINARY_GENTYPE_FUNCS(mod)
1154 DECLARE_VEC_FLOAT_FUNCS(modVecScalar)
1155 DECLARE_BINARY_GENTYPE_FUNCS(min)
1156 DECLARE_VEC_FLOAT_FUNCS(minVecScalar)
1157 DECLARE_BINARY_INT_GENTYPE_FUNCS(min)
1158 DECLARE_IVEC_INT_FUNCS(minVecScalar)
1159 DECLARE_BINARY_UINT_GENTYPE_FUNCS(min)
1160 DECLARE_UVEC_UINT_FUNCS(minVecScalar)
1161 DECLARE_BINARY_GENTYPE_FUNCS(max)
1162 DECLARE_VEC_FLOAT_FUNCS(maxVecScalar)
1163 DECLARE_BINARY_INT_GENTYPE_FUNCS(max)
1164 DECLARE_IVEC_INT_FUNCS(maxVecScalar)
1165 DECLARE_BINARY_UINT_GENTYPE_FUNCS(max)
1166 DECLARE_UVEC_UINT_FUNCS(maxVecScalar)
1167 DECLARE_TERNARY_GENTYPE_FUNCS(clamp)
1168 DECLARE_VEC_FLOAT_FLOAT_FUNCS(clampVecScalarScalar)
1169 DECLARE_TERNARY_INT_GENTYPE_FUNCS(clamp)
1170 DECLARE_IVEC_INT_INT_FUNCS(clampVecScalarScalar)
1171 DECLARE_TERNARY_UINT_GENTYPE_FUNCS(clamp)
1172 DECLARE_UVEC_UINT_UINT_FUNCS(clampVecScalarScalar)
1173 DECLARE_TERNARY_GENTYPE_FUNCS(mix)
1174 DECLARE_VEC_VEC_FLOAT_FUNCS(mixVecVecScalar)
1175 DECLARE_BINARY_GENTYPE_FUNCS(step)
1176 DECLARE_FLOAT_VEC_FUNCS(stepScalarVec)
1177 DECLARE_TERNARY_GENTYPE_FUNCS(smoothStep)
1178 DECLARE_FLOAT_FLOAT_VEC_FUNCS(smoothStepScalarScalarVec)
1180 DECLARE_UNARY_SCALAR_GENTYPE_FUNCS(length)
1181 DECLARE_BINARY_SCALAR_GENTYPE_FUNCS(distance)
1182 DECLARE_BINARY_SCALAR_GENTYPE_FUNCS(dot)
1183 void eval_cross_vec3 (ShaderEvalContext& c) { c.color.xyz() = cross(c.in[0].swizzle(2, 0, 1), c.in[1].swizzle(1, 2, 0)); }
1185 DECLARE_UNARY_GENTYPE_FUNCS(normalize)
1186 DECLARE_TERNARY_GENTYPE_FUNCS(faceForward)
1187 DECLARE_BINARY_GENTYPE_FUNCS(reflect)
1189 void eval_refract_float (ShaderEvalContext& c) { c.color.x() = refract(c.in[0].z(), c.in[1].x(), c.in[2].y()); }
1190 void eval_refract_vec2 (ShaderEvalContext& c) { c.color.yz() = refract(c.in[0].swizzle(3, 1), c.in[1].swizzle(1, 0), c.in[2].y()); }
1191 void eval_refract_vec3 (ShaderEvalContext& c) { c.color.xyz() = refract(c.in[0].swizzle(2, 0, 1), c.in[1].swizzle(1, 2, 0), c.in[2].y()); }
1192 void eval_refract_vec4 (ShaderEvalContext& c) { c.color = refract(c.in[0].swizzle(1, 2, 3, 0), c.in[1].swizzle(3, 2, 1, 0), c.in[2].y()); }
1194 // Compare functions.
1196 #define DECLARE_FLOAT_COMPARE_FUNCS(FUNC_NAME) \
1197 void eval_##FUNC_NAME##_float (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(c.in[0].z(), c.in[1].x()); } \
1198 void eval_##FUNC_NAME##_vec2 (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(c.in[0].swizzle(3, 1), c.in[1].swizzle(1, 0)); } \
1199 void eval_##FUNC_NAME##_vec3 (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(c.in[0].swizzle(2, 0, 1), c.in[1].swizzle(1, 2, 0)); } \
1200 void eval_##FUNC_NAME##_vec4 (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0), c.in[1].swizzle(3, 2, 1, 0)); }
1202 #define DECLARE_FLOAT_CWISE_COMPARE_FUNCS(FUNC_NAME) \
1203 void eval_##FUNC_NAME##_float (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(c.in[0].z(), c.in[1].x()); } \
1204 DECLARE_FLOAT_VEC_CWISE_COMPARE_FUNCS(FUNC_NAME)
1206 #define DECLARE_FLOAT_VEC_CWISE_COMPARE_FUNCS(FUNC_NAME) \
1207 void eval_##FUNC_NAME##_vec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1), c.in[1].swizzle(1, 0)).asFloat(); } \
1208 void eval_##FUNC_NAME##_vec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1), c.in[1].swizzle(1, 2, 0)).asFloat(); } \
1209 void eval_##FUNC_NAME##_vec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0), c.in[1].swizzle(3, 2, 1, 0)).asFloat(); }
1211 #define DECLARE_INT_COMPARE_FUNCS(FUNC_NAME) \
1212 void eval_##FUNC_NAME##_int (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(chopToInt(c.in[0].z()), chopToInt(c.in[1].x())); } \
1213 void eval_##FUNC_NAME##_ivec2 (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(chopToInt(c.in[0].swizzle(3, 1)), chopToInt(c.in[1].swizzle(1, 0))); } \
1214 void eval_##FUNC_NAME##_ivec3 (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(chopToInt(c.in[0].swizzle(2, 0, 1)), chopToInt(c.in[1].swizzle(1, 2, 0))); } \
1215 void eval_##FUNC_NAME##_ivec4 (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(chopToInt(c.in[0].swizzle(1, 2, 3, 0)), chopToInt(c.in[1].swizzle(3, 2, 1, 0))); }
1217 #define DECLARE_INT_CWISE_COMPARE_FUNCS(FUNC_NAME) \
1218 void eval_##FUNC_NAME##_int (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(chopToInt(c.in[0].z()), chopToInt(c.in[1].x())); } \
1219 DECLARE_INT_VEC_CWISE_COMPARE_FUNCS(FUNC_NAME)
1221 #define DECLARE_INT_VEC_CWISE_COMPARE_FUNCS(FUNC_NAME) \
1222 void eval_##FUNC_NAME##_ivec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(chopToInt(c.in[0].swizzle(3, 1)), chopToInt(c.in[1].swizzle(1, 0))).asFloat(); } \
1223 void eval_##FUNC_NAME##_ivec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(chopToInt(c.in[0].swizzle(2, 0, 1)), chopToInt(c.in[1].swizzle(1, 2, 0))).asFloat(); } \
1224 void eval_##FUNC_NAME##_ivec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(chopToInt(c.in[0].swizzle(1, 2, 3, 0)), chopToInt(c.in[1].swizzle(3, 2, 1, 0))).asFloat(); }
1226 #define DECLARE_UINT_COMPARE_FUNCS(FUNC_NAME) \
1227 void eval_##FUNC_NAME##_uint (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME((deUint32)c.in[0].z(), (deUint32)c.in[1].x()); } \
1228 void eval_##FUNC_NAME##_uvec2 (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(c.in[0].swizzle(3, 1).asUint(), c.in[1].swizzle(1, 0).asUint()); } \
1229 void eval_##FUNC_NAME##_uvec3 (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(c.in[0].swizzle(2, 0, 1).asUint(), c.in[1].swizzle(1, 2, 0).asUint()); } \
1230 void eval_##FUNC_NAME##_uvec4 (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0).asUint(), c.in[1].swizzle(3, 2, 1, 0).asUint()); }
1232 #define DECLARE_UINT_CWISE_COMPARE_FUNCS(FUNC_NAME) \
1233 DECLARE_UINT_SCALAR_CWISE_COMPARE_FUNCS(FUNC_NAME) \
1234 void eval_##FUNC_NAME##_uvec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(c.in[0].swizzle(3, 1).asUint(), c.in[1].swizzle(1, 0).asUint()).asFloat(); } \
1235 void eval_##FUNC_NAME##_uvec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(c.in[0].swizzle(2, 0, 1).asUint(), c.in[1].swizzle(1, 2, 0).asUint()).asFloat(); } \
1236 void eval_##FUNC_NAME##_uvec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(c.in[0].swizzle(1, 2, 3, 0).asUint(), c.in[1].swizzle(3, 2, 1, 0).asUint()).asFloat(); }
1238 #define DECLARE_UINT_SCALAR_CWISE_COMPARE_FUNCS(FUNC_NAME) \
1239 void eval_##FUNC_NAME##_uint (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME((deUint32)c.in[0].z(), (deUint32)c.in[1].x()); }
1241 #define DECLARE_BOOL_COMPARE_FUNCS(FUNC_NAME) \
1242 void eval_##FUNC_NAME##_bool (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(c.in[0].z() > 0.0f, c.in[1].x() > 0.0f); } \
1243 void eval_##FUNC_NAME##_bvec2 (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(greaterThan(c.in[0].swizzle(3, 1), Vec2(0.0f)), greaterThan(c.in[1].swizzle(1, 0), Vec2(0.0f))); } \
1244 void eval_##FUNC_NAME##_bvec3 (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(greaterThan(c.in[0].swizzle(2, 0, 1), Vec3(0.0f)), greaterThan(c.in[1].swizzle(1, 2, 0), Vec3(0.0f))); } \
1245 void eval_##FUNC_NAME##_bvec4 (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(greaterThan(c.in[0].swizzle(1, 2, 3, 0), Vec4(0.0f)), greaterThan(c.in[1].swizzle(3, 2, 1, 0), Vec4(0.0f))); }
1247 #define DECLARE_BOOL_CWISE_COMPARE_FUNCS(FUNC_NAME) \
1248 void eval_##FUNC_NAME##_bool (ShaderEvalContext& c) { c.color.x() = (float)FUNC_NAME(c.in[0].z() > 0.0f, c.in[1].x() > 0.0f); } \
1249 DECLARE_BOOL_VEC_CWISE_COMPARE_FUNCS(FUNC_NAME)
1251 #define DECLARE_BOOL_VEC_CWISE_COMPARE_FUNCS(FUNC_NAME) \
1252 void eval_##FUNC_NAME##_bvec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(greaterThan(c.in[0].swizzle(3, 1), Vec2(0.0f)), greaterThan(c.in[1].swizzle(1, 0), Vec2(0.0f))).asFloat(); } \
1253 void eval_##FUNC_NAME##_bvec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(greaterThan(c.in[0].swizzle(2, 0, 1), Vec3(0.0f)), greaterThan(c.in[1].swizzle(1, 2, 0), Vec3(0.0f))).asFloat(); } \
1254 void eval_##FUNC_NAME##_bvec4 (ShaderEvalContext& c) { c.color = FUNC_NAME(greaterThan(c.in[0].swizzle(1, 2, 3, 0), Vec4(0.0f)), greaterThan(c.in[1].swizzle(3, 2, 1, 0), Vec4(0.0f))).asFloat(); }
1256 DECLARE_FLOAT_COMPARE_FUNCS(allEqual)
1257 DECLARE_FLOAT_COMPARE_FUNCS(anyNotEqual)
1258 DECLARE_FLOAT_CWISE_COMPARE_FUNCS(lessThan)
1259 DECLARE_FLOAT_CWISE_COMPARE_FUNCS(lessThanEqual)
1260 DECLARE_FLOAT_CWISE_COMPARE_FUNCS(greaterThan)
1261 DECLARE_FLOAT_CWISE_COMPARE_FUNCS(greaterThanEqual)
1262 DECLARE_FLOAT_VEC_CWISE_COMPARE_FUNCS(equal)
1263 DECLARE_FLOAT_VEC_CWISE_COMPARE_FUNCS(notEqual)
1265 DECLARE_INT_COMPARE_FUNCS(allEqual)
1266 DECLARE_INT_COMPARE_FUNCS(anyNotEqual)
1267 DECLARE_INT_CWISE_COMPARE_FUNCS(lessThan)
1268 DECLARE_INT_CWISE_COMPARE_FUNCS(lessThanEqual)
1269 DECLARE_INT_CWISE_COMPARE_FUNCS(greaterThan)
1270 DECLARE_INT_CWISE_COMPARE_FUNCS(greaterThanEqual)
1271 DECLARE_INT_VEC_CWISE_COMPARE_FUNCS(equal)
1272 DECLARE_INT_VEC_CWISE_COMPARE_FUNCS(notEqual)
1274 DECLARE_UINT_COMPARE_FUNCS(allEqual)
1275 DECLARE_UINT_COMPARE_FUNCS(anyNotEqual)
1276 DECLARE_UINT_SCALAR_CWISE_COMPARE_FUNCS(lessThan)
1277 DECLARE_UINT_SCALAR_CWISE_COMPARE_FUNCS(lessThanEqual)
1278 DECLARE_UINT_SCALAR_CWISE_COMPARE_FUNCS(greaterThan)
1279 DECLARE_UINT_SCALAR_CWISE_COMPARE_FUNCS(greaterThanEqual)
1281 DECLARE_BOOL_COMPARE_FUNCS(allEqual)
1282 DECLARE_BOOL_COMPARE_FUNCS(anyNotEqual)
1283 DECLARE_BOOL_VEC_CWISE_COMPARE_FUNCS(equal)
1284 DECLARE_BOOL_VEC_CWISE_COMPARE_FUNCS(notEqual)
1286 // Boolean functions.
1288 #define DECLARE_UNARY_SCALAR_BVEC_FUNCS(GLSL_NAME, FUNC_NAME) \
1289 void eval_##GLSL_NAME##_bvec2 (ShaderEvalContext& c) { c.color.x() = float(FUNC_NAME(greaterThan(c.in[0].swizzle(3, 1), Vec2(0.0f)))); } \
1290 void eval_##GLSL_NAME##_bvec3 (ShaderEvalContext& c) { c.color.x() = float(FUNC_NAME(greaterThan(c.in[0].swizzle(2, 0, 1), Vec3(0.0f)))); } \
1291 void eval_##GLSL_NAME##_bvec4 (ShaderEvalContext& c) { c.color.x() = float(FUNC_NAME(greaterThan(c.in[0].swizzle(1, 2, 3, 0), Vec4(0.0f)))); }
1293 #define DECLARE_UNARY_BVEC_BVEC_FUNCS(GLSL_NAME, FUNC_NAME) \
1294 void eval_##GLSL_NAME##_bvec2 (ShaderEvalContext& c) { c.color.yz() = FUNC_NAME(greaterThan(c.in[0].swizzle(3, 1), Vec2(0.0f))).asFloat(); } \
1295 void eval_##GLSL_NAME##_bvec3 (ShaderEvalContext& c) { c.color.xyz() = FUNC_NAME(greaterThan(c.in[0].swizzle(2, 0, 1), Vec3(0.0f))).asFloat(); } \
1296 void eval_##GLSL_NAME##_bvec4 (ShaderEvalContext& c) { c.color.xyzw() = FUNC_NAME(greaterThan(c.in[0].swizzle(1, 2, 3, 0), Vec4(0.0f))).asFloat(); }
1298 DECLARE_UNARY_SCALAR_BVEC_FUNCS(any, boolAny);
1299 DECLARE_UNARY_SCALAR_BVEC_FUNCS(all, boolAll);
1301 // ShaderOperatorTests.
1303 class ShaderOperatorTests : public tcu::TestCaseGroup
1306 ShaderOperatorTests (tcu::TestContext& context);
1307 virtual ~ShaderOperatorTests (void);
1309 virtual void init (void);
1312 ShaderOperatorTests (const ShaderOperatorTests&); // not allowed!
1313 ShaderOperatorTests& operator= (const ShaderOperatorTests&); // not allowed!
1316 ShaderOperatorTests::ShaderOperatorTests(tcu::TestContext& testCtx)
1317 : TestCaseGroup(testCtx, "operator", "Operator tests.")
1321 ShaderOperatorTests::~ShaderOperatorTests (void)
1325 void ShaderOperatorTests::init (void)
1327 #define BOOL_FUNCS(FUNC_NAME) eval_##FUNC_NAME##_bool, DE_NULL, DE_NULL, DE_NULL
1329 #define FLOAT_VEC_FUNCS(FUNC_NAME) DE_NULL, eval_##FUNC_NAME##_vec2, eval_##FUNC_NAME##_vec3, eval_##FUNC_NAME##_vec4
1330 #define INT_VEC_FUNCS(FUNC_NAME) DE_NULL, eval_##FUNC_NAME##_ivec2, eval_##FUNC_NAME##_ivec3, eval_##FUNC_NAME##_ivec4
1331 #define UINT_VEC_FUNCS(FUNC_NAME) DE_NULL, eval_##FUNC_NAME##_uvec2, eval_##FUNC_NAME##_uvec3, eval_##FUNC_NAME##_uvec4
1332 #define BOOL_VEC_FUNCS(FUNC_NAME) DE_NULL, eval_##FUNC_NAME##_bvec2, eval_##FUNC_NAME##_bvec3, eval_##FUNC_NAME##_bvec4
1334 #define FLOAT_GENTYPE_FUNCS(FUNC_NAME) eval_##FUNC_NAME##_float, eval_##FUNC_NAME##_vec2, eval_##FUNC_NAME##_vec3, eval_##FUNC_NAME##_vec4
1335 #define INT_GENTYPE_FUNCS(FUNC_NAME) eval_##FUNC_NAME##_int, eval_##FUNC_NAME##_ivec2, eval_##FUNC_NAME##_ivec3, eval_##FUNC_NAME##_ivec4
1336 #define UINT_GENTYPE_FUNCS(FUNC_NAME) eval_##FUNC_NAME##_uint, eval_##FUNC_NAME##_uvec2, eval_##FUNC_NAME##_uvec3, eval_##FUNC_NAME##_uvec4
1337 #define BOOL_GENTYPE_FUNCS(FUNC_NAME) eval_##FUNC_NAME##_bool, eval_##FUNC_NAME##_bvec2, eval_##FUNC_NAME##_bvec3, eval_##FUNC_NAME##_bvec4
1340 Value notUsed = Value(VALUE_NONE, 0.0f, 0.0f);
1342 std::vector<BuiltinFuncGroup> funcInfoGroups;
1345 funcInfoGroups.push_back(
1346 BuiltinFuncGroup("unary_operator", "Unary operator tests")
1347 << BuiltinOperInfo ("plus", "+", GT, Value(GT, -1.0f, 1.0f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(nop))
1348 << BuiltinOperInfo ("plus", "+", IGT, Value(IGT, -5.0f, 5.0f), notUsed, notUsed, 0.1f, 0.5f, PRECMASK_ALL, INT_GENTYPE_FUNCS(nop))
1349 << BuiltinOperInfo ("plus", "+", UGT, Value(UGT, 0.0f, 2e2f), notUsed, notUsed, 5e-3f, 0.0f, PRECMASK_ALL, UINT_GENTYPE_FUNCS(nop))
1350 << BuiltinOperInfo ("minus", "-", GT, Value(GT, -1.0f, 1.0f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(negate))
1351 << BuiltinOperInfo ("minus", "-", IGT, Value(IGT, -5.0f, 5.0f), notUsed, notUsed, 0.1f, 0.5f, PRECMASK_ALL, INT_GENTYPE_FUNCS(negate))
1352 << BuiltinOperInfo ("minus", "-", UGT, Value(UGT, 0.0f, 4e9f), notUsed, notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_GENTYPE_FUNCS(negate))
1353 << BuiltinOperInfo ("not", "!", B, Value(B, -1.0f, 1.0f), notUsed, notUsed, 1.0f, 0.0f, PRECMASK_NA, eval_boolNot_bool, DE_NULL, DE_NULL, DE_NULL)
1354 << BuiltinOperInfo ("bitwise_not", "~", IGT, Value(IGT, -1e5f, 1e5f), notUsed, notUsed, 5e-5f, 0.5f, PRECMASK_HIGHP, INT_GENTYPE_FUNCS(bitwiseNot))
1355 << BuiltinOperInfo ("bitwise_not", "~", UGT, Value(UGT, 0.0f, 2e9f), notUsed, notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_GENTYPE_FUNCS(bitwiseNot))
1357 // Pre/post incr/decr side effect cases.
1358 << BuiltinSideEffOperInfo ("pre_increment_effect", "++", GT, Value(GT, -1.0f, 1.0f), notUsed, notUsed, 0.5f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(addOne))
1359 << BuiltinSideEffOperInfo ("pre_increment_effect", "++", IGT, Value(IGT, -6.0f, 4.0f), notUsed, notUsed, 0.1f, 0.5f, PRECMASK_ALL, INT_GENTYPE_FUNCS(addOne))
1360 << BuiltinSideEffOperInfo ("pre_increment_effect", "++", UGT, Value(UGT, 0.0f, 9.0f), notUsed, notUsed, 0.1f, 0.0f, PRECMASK_ALL, UINT_GENTYPE_FUNCS(addOne))
1361 << BuiltinSideEffOperInfo ("pre_decrement_effect", "--", GT, Value(GT, -1.0f, 1.0f), notUsed, notUsed, 0.5f, 1.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(subOne))
1362 << BuiltinSideEffOperInfo ("pre_decrement_effect", "--", IGT, Value(IGT, -4.0f, 6.0f), notUsed, notUsed, 0.1f, 0.5f, PRECMASK_ALL, INT_GENTYPE_FUNCS(subOne))
1363 << BuiltinSideEffOperInfo ("pre_decrement_effect", "--", UGT, Value(UGT, 1.0f, 10.0f), notUsed, notUsed, 0.1f, 0.0f, PRECMASK_ALL, UINT_GENTYPE_FUNCS(subOne))
1364 << BuiltinPostSideEffOperInfo ("post_increment_effect", "++", GT, Value(GT, -1.0f, 1.0f), notUsed, notUsed, 0.5f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(addOne))
1365 << BuiltinPostSideEffOperInfo ("post_increment_effect", "++", IGT, Value(IGT, -6.0f, 4.0f), notUsed, notUsed, 0.1f, 0.5f, PRECMASK_ALL, INT_GENTYPE_FUNCS(addOne))
1366 << BuiltinPostSideEffOperInfo ("post_increment_effect", "++", UGT, Value(UGT, 0.0f, 9.0f), notUsed, notUsed, 0.1f, 0.0f, PRECMASK_ALL, UINT_GENTYPE_FUNCS(addOne))
1367 << BuiltinPostSideEffOperInfo ("post_decrement_effect", "--", GT, Value(GT, -1.0f, 1.0f), notUsed, notUsed, 0.5f, 1.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(subOne))
1368 << BuiltinPostSideEffOperInfo ("post_decrement_effect", "--", IGT, Value(IGT, -4.0f, 6.0f), notUsed, notUsed, 0.1f, 0.5f, PRECMASK_ALL, INT_GENTYPE_FUNCS(subOne))
1369 << BuiltinPostSideEffOperInfo ("post_decrement_effect", "--", UGT, Value(UGT, 1.0f, 10.0f), notUsed, notUsed, 0.1f, 0.0f, PRECMASK_ALL, UINT_GENTYPE_FUNCS(subOne))
1371 // Pre/post incr/decr result cases.
1372 << BuiltinOperInfo ("pre_increment_result", "++", GT, Value(GT, -1.0f, 1.0f), notUsed, notUsed, 0.5f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(addOne))
1373 << BuiltinOperInfo ("pre_increment_result", "++", IGT, Value(IGT, -6.0f, 4.0f), notUsed, notUsed, 0.1f, 0.5f, PRECMASK_ALL, INT_GENTYPE_FUNCS(addOne))
1374 << BuiltinOperInfo ("pre_increment_result", "++", UGT, Value(UGT, 0.0f, 9.0f), notUsed, notUsed, 0.1f, 0.0f, PRECMASK_ALL, UINT_GENTYPE_FUNCS(addOne))
1375 << BuiltinOperInfo ("pre_decrement_result", "--", GT, Value(GT, -1.0f, 1.0f), notUsed, notUsed, 0.5f, 1.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(subOne))
1376 << BuiltinOperInfo ("pre_decrement_result", "--", IGT, Value(IGT, -4.0f, 6.0f), notUsed, notUsed, 0.1f, 0.5f, PRECMASK_ALL, INT_GENTYPE_FUNCS(subOne))
1377 << BuiltinOperInfo ("pre_decrement_result", "--", UGT, Value(UGT, 1.0f, 10.0f), notUsed, notUsed, 0.1f, 0.0f, PRECMASK_ALL, UINT_GENTYPE_FUNCS(subOne))
1378 << BuiltinPostOperInfo ("post_increment_result", "++", GT, Value(GT, -1.0f, 1.0f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(nop))
1379 << BuiltinPostOperInfo ("post_increment_result", "++", IGT, Value(IGT, -5.0f, 5.0f), notUsed, notUsed, 0.1f, 0.5f, PRECMASK_ALL, INT_GENTYPE_FUNCS(nop))
1380 << BuiltinPostOperInfo ("post_increment_result", "++", UGT, Value(UGT, 0.0f, 9.0f), notUsed, notUsed, 0.1f, 0.0f, PRECMASK_ALL, UINT_GENTYPE_FUNCS(nop))
1381 << BuiltinPostOperInfo ("post_decrement_result", "--", GT, Value(GT, -1.0f, 1.0f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(nop))
1382 << BuiltinPostOperInfo ("post_decrement_result", "--", IGT, Value(IGT, -5.0f, 5.0f), notUsed, notUsed, 0.1f, 0.5f, PRECMASK_ALL, INT_GENTYPE_FUNCS(nop))
1383 << BuiltinPostOperInfo ("post_decrement_result", "--", UGT, Value(UGT, 1.0f, 10.0f), notUsed, notUsed, 0.1f, 0.0f, PRECMASK_ALL, UINT_GENTYPE_FUNCS(nop))
1386 BuiltinFuncGroup binaryOpGroup("binary_operator", "Binary operator tests");
1388 // Normal binary operations and their corresponding assignment operations have lots in common; generate both in the following loop.
1390 for (int binaryOperatorType = 0; binaryOperatorType <= 2; binaryOperatorType++) // 0: normal op test, 1: assignment op side-effect test, 2: assignment op result test
1392 const bool isNormalOp = binaryOperatorType == 0;
1393 const bool isAssignEff = binaryOperatorType == 1;
1394 const bool isAssignRes = binaryOperatorType == 2;
1396 DE_ASSERT(isNormalOp || isAssignEff || isAssignRes);
1397 DE_UNREF(isAssignRes);
1399 const char* addName = isNormalOp ? "add" : isAssignEff ? "add_assign_effect" : "add_assign_result";
1400 const char* subName = isNormalOp ? "sub" : isAssignEff ? "sub_assign_effect" : "sub_assign_result";
1401 const char* mulName = isNormalOp ? "mul" : isAssignEff ? "mul_assign_effect" : "mul_assign_result";
1402 const char* divName = isNormalOp ? "div" : isAssignEff ? "div_assign_effect" : "div_assign_result";
1403 const char* modName = isNormalOp ? "mod" : isAssignEff ? "mod_assign_effect" : "mod_assign_result";
1404 const char* andName = isNormalOp ? "bitwise_and" : isAssignEff ? "bitwise_and_assign_effect" : "bitwise_and_assign_result";
1405 const char* orName = isNormalOp ? "bitwise_or" : isAssignEff ? "bitwise_or_assign_effect" : "bitwise_or_assign_result";
1406 const char* xorName = isNormalOp ? "bitwise_xor" : isAssignEff ? "bitwise_xor_assign_effect" : "bitwise_xor_assign_result";
1407 const char* leftShiftName = isNormalOp ? "left_shift" : isAssignEff ? "left_shift_assign_effect" : "left_shift_assign_result";
1408 const char* rightShiftName = isNormalOp ? "right_shift" : isAssignEff ? "right_shift_assign_effect" : "right_shift_assign_result";
1409 const char* addOp = isNormalOp ? "+" : "+=";
1410 const char* subOp = isNormalOp ? "-" : "-=";
1411 const char* mulOp = isNormalOp ? "*" : "*=";
1412 const char* divOp = isNormalOp ? "/" : "/=";
1413 const char* modOp = isNormalOp ? "%" : "%=";
1414 const char* andOp = isNormalOp ? "&" : "&=";
1415 const char* orOp = isNormalOp ? "|" : "|=";
1416 const char* xorOp = isNormalOp ? "^" : "^=";
1417 const char* leftShiftOp = isNormalOp ? "<<" : "<<=";
1418 const char* rightShiftOp = isNormalOp ? ">>" : ">>=";
1420 // Pointer to appropriate OperInfo function.
1421 BuiltinFuncInfo (*operInfoFunc)(const char*, const char*, ValueType, Value, Value, Value, const float, const float, deUint32, ShaderEvalFunc, ShaderEvalFunc, ShaderEvalFunc, ShaderEvalFunc) =
1422 isAssignEff ? BuiltinSideEffOperInfo : BuiltinOperInfo;
1424 DE_ASSERT(operInfoFunc != DE_NULL);
1426 // The following cases will be added for each operator, precision and fundamental type (float, int, uint) combination, where applicable:
1427 // gentype <op> gentype
1428 // vector <op> scalar
1429 // For normal (non-assigning) operators only:
1430 // scalar <op> vector
1432 // The add operator.
1435 << operInfoFunc(addName, addOp, GT, Value(GT, -1.0f, 1.0f), Value(GT, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(add))
1436 << operInfoFunc(addName, addOp, IGT, Value(IGT, -4.0f, 6.0f), Value(IGT, -6.0f, 5.0f), notUsed, 0.1f, 0.5f, PRECMASK_MEDIUMP, INT_GENTYPE_FUNCS(add))
1437 << operInfoFunc(addName, addOp, IGT, Value(IGT, -2e9f, 2e9f), Value(IGT, -2e9f, 2e9f), notUsed, 4e-10f, 0.5f, PRECMASK_HIGHP, INT_GENTYPE_FUNCS(add))
1438 << operInfoFunc(addName, addOp, UGT, Value(UGT, 0.0f, 1e2f), Value(UGT, 0.0f, 1e2f), notUsed, 5e-3f, 0.0f, PRECMASK_MEDIUMP, UINT_GENTYPE_FUNCS(add))
1439 << operInfoFunc(addName, addOp, UGT, Value(UGT, 0.0f, 4e9f), Value(UGT, 0.0f, 4e9f), notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_GENTYPE_FUNCS(add))
1440 << operInfoFunc(addName, addOp, FV, Value(FV, -1.0f, 1.0f), Value(F, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_VEC_FUNCS(addVecScalar))
1441 << operInfoFunc(addName, addOp, IV, Value(IV, -4.0f, 6.0f), Value(I, -6.0f, 5.0f), notUsed, 0.1f, 0.5f, PRECMASK_MEDIUMP, INT_VEC_FUNCS(addVecScalar))
1442 << operInfoFunc(addName, addOp, IV, Value(IV, -2e9f, 2e9f), Value(I, -2e9f, 2e9f), notUsed, 4e-10f, 0.5f, PRECMASK_HIGHP, INT_VEC_FUNCS(addVecScalar))
1443 << operInfoFunc(addName, addOp, UV, Value(UV, 0.0f, 1e2f), Value(U, 0.0f, 1e2f), notUsed, 5e-3f, 0.0f, PRECMASK_MEDIUMP, UINT_VEC_FUNCS(addVecScalar))
1444 << operInfoFunc(addName, addOp, UV, Value(UV, 0.0f, 4e9f), Value(U, 0.0f, 4e9f), notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_VEC_FUNCS(addVecScalar));
1448 << operInfoFunc(addName, addOp, FV, Value(F, -1.0f, 1.0f), Value(FV, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_VEC_FUNCS(addScalarVec))
1449 << operInfoFunc(addName, addOp, IV, Value(I, -4.0f, 6.0f), Value(IV, -6.0f, 5.0f), notUsed, 0.1f, 0.5f, PRECMASK_MEDIUMP, INT_VEC_FUNCS(addScalarVec))
1450 << operInfoFunc(addName, addOp, IV, Value(I, -2e9f, 2e9f), Value(IV, -2e9f, 2e9f), notUsed, 4e-10f, 0.5f, PRECMASK_HIGHP, INT_VEC_FUNCS(addScalarVec))
1451 << operInfoFunc(addName, addOp, UV, Value(U, 0.0f, 1e2f), Value(UV, 0.0f, 1e2f), notUsed, 5e-3f, 0.0f, PRECMASK_MEDIUMP, UINT_VEC_FUNCS(addScalarVec))
1452 << operInfoFunc(addName, addOp, UV, Value(U, 0.0f, 4e9f), Value(UV, 0.0f, 4e9f), notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_VEC_FUNCS(addScalarVec));
1454 // The subtract operator.
1457 << operInfoFunc(subName, subOp, GT, Value(GT, -1.0f, 1.0f), Value(GT, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(sub))
1458 << operInfoFunc(subName, subOp, IGT, Value(IGT, -4.0f, 6.0f), Value(IGT, -6.0f, 5.0f), notUsed, 0.1f, 0.5f, PRECMASK_MEDIUMP, INT_GENTYPE_FUNCS(sub))
1459 << operInfoFunc(subName, subOp, IGT, Value(IGT, -2e9f, 2e9f), Value(IGT, -2e9f, 2e9f), notUsed, 4e-10f, 0.5f, PRECMASK_HIGHP, INT_GENTYPE_FUNCS(sub))
1460 << operInfoFunc(subName, subOp, UGT, Value(UGT, 1e2f, 2e2f), Value(UGT, 0.0f, 1e2f), notUsed, 5e-3f, 0.0f, PRECMASK_MEDIUMP, UINT_GENTYPE_FUNCS(sub))
1461 << operInfoFunc(subName, subOp, UGT, Value(UGT, .5e9f, 3.7e9f), Value(UGT, 0.0f, 3.9e9f), notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_GENTYPE_FUNCS(sub))
1462 << operInfoFunc(subName, subOp, FV, Value(FV, -1.0f, 1.0f), Value(F, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_VEC_FUNCS(subVecScalar))
1463 << operInfoFunc(subName, subOp, IV, Value(IV, -4.0f, 6.0f), Value(I, -6.0f, 5.0f), notUsed, 0.1f, 0.5f, PRECMASK_MEDIUMP, INT_VEC_FUNCS(subVecScalar))
1464 << operInfoFunc(subName, subOp, IV, Value(IV, -2e9f, 2e9f), Value(I, -2e9f, 2e9f), notUsed, 4e-10f, 0.5f, PRECMASK_HIGHP, INT_VEC_FUNCS(subVecScalar))
1465 << operInfoFunc(subName, subOp, UV, Value(UV, 1e2f, 2e2f), Value(U, 0.0f, 1e2f), notUsed, 5e-3f, 0.0f, PRECMASK_MEDIUMP, UINT_VEC_FUNCS(subVecScalar))
1466 << operInfoFunc(subName, subOp, UV, Value(UV, 0.0f, 4e9f), Value(U, 0.0f, 4e9f), notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_VEC_FUNCS(subVecScalar));
1470 << operInfoFunc(subName, subOp, FV, Value(F, -1.0f, 1.0f), Value(FV, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_VEC_FUNCS(subScalarVec))
1471 << operInfoFunc(subName, subOp, IV, Value(I, -4.0f, 6.0f), Value(IV, -6.0f, 5.0f), notUsed, 0.1f, 0.5f, PRECMASK_MEDIUMP, INT_VEC_FUNCS(subScalarVec))
1472 << operInfoFunc(subName, subOp, IV, Value(I, -2e9f, 2e9f), Value(IV, -2e9f, 2e9f), notUsed, 4e-10f, 0.5f, PRECMASK_HIGHP, INT_VEC_FUNCS(subScalarVec))
1473 << operInfoFunc(subName, subOp, UV, Value(U, 1e2f, 2e2f), Value(UV, 0.0f, 1e2f), notUsed, 5e-3f, 0.0f, PRECMASK_MEDIUMP, UINT_VEC_FUNCS(subScalarVec))
1474 << operInfoFunc(subName, subOp, UV, Value(U, 0.0f, 4e9f), Value(UV, 0.0f, 4e9f), notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_VEC_FUNCS(subScalarVec));
1476 // The multiply operator.
1479 << operInfoFunc(mulName, mulOp, GT, Value(GT, -1.0f, 1.0f), Value(GT, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(mul))
1480 << operInfoFunc(mulName, mulOp, IGT, Value(IGT, -4.0f, 6.0f), Value(IGT, -6.0f, 5.0f), notUsed, 0.1f, 0.5f, PRECMASK_MEDIUMP, INT_GENTYPE_FUNCS(mul))
1481 << operInfoFunc(mulName, mulOp, IGT, Value(IGT, -3e5f, 3e5f), Value(IGT, -3e4f, 3e4f), notUsed, 4e-10f, 0.5f, PRECMASK_HIGHP, INT_GENTYPE_FUNCS(mul))
1482 << operInfoFunc(mulName, mulOp, UGT, Value(UGT, 0.0f, 16.0f), Value(UGT, 0.0f, 16.0f), notUsed, 4e-3f, 0.0f, PRECMASK_MEDIUMP, UINT_GENTYPE_FUNCS(mul))
1483 << operInfoFunc(mulName, mulOp, UGT, Value(UGT, 0.0f, 6e5f), Value(UGT, 0.0f, 6e4f), notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_GENTYPE_FUNCS(mul))
1484 << operInfoFunc(mulName, mulOp, FV, Value(FV, -1.0f, 1.0f), Value(F, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_VEC_FUNCS(mulVecScalar))
1485 << operInfoFunc(mulName, mulOp, IV, Value(IV, -4.0f, 6.0f), Value(I, -6.0f, 5.0f), notUsed, 0.1f, 0.5f, PRECMASK_MEDIUMP, INT_VEC_FUNCS(mulVecScalar))
1486 << operInfoFunc(mulName, mulOp, IV, Value(IV, -3e5f, 3e5f), Value(I, -3e4f, 3e4f), notUsed, 4e-10f, 0.5f, PRECMASK_HIGHP, INT_VEC_FUNCS(mulVecScalar))
1487 << operInfoFunc(mulName, mulOp, UV, Value(UV, 0.0f, 16.0f), Value(U, 0.0f, 16.0f), notUsed, 4e-3f, 0.0f, PRECMASK_MEDIUMP, UINT_VEC_FUNCS(mulVecScalar))
1488 << operInfoFunc(mulName, mulOp, UV, Value(UV, 0.0f, 6e5f), Value(U, 0.0f, 6e4f), notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_VEC_FUNCS(mulVecScalar));
1492 << operInfoFunc(mulName, mulOp, FV, Value(F, -1.0f, 1.0f), Value(FV, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_VEC_FUNCS(mulScalarVec))
1493 << operInfoFunc(mulName, mulOp, IV, Value(I, -4.0f, 6.0f), Value(IV, -6.0f, 5.0f), notUsed, 0.1f, 0.5f, PRECMASK_MEDIUMP, INT_VEC_FUNCS(mulScalarVec))
1494 << operInfoFunc(mulName, mulOp, IV, Value(I, -3e5f, 3e5f), Value(IV, -3e4f, 3e4f), notUsed, 4e-10f, 0.5f, PRECMASK_HIGHP, INT_VEC_FUNCS(mulScalarVec))
1495 << operInfoFunc(mulName, mulOp, UV, Value(U, 0.0f, 16.0f), Value(UV, 0.0f, 16.0f), notUsed, 4e-3f, 0.0f, PRECMASK_MEDIUMP, UINT_VEC_FUNCS(mulScalarVec))
1496 << operInfoFunc(mulName, mulOp, UV, Value(U, 0.0f, 6e5f), Value(UV, 0.0f, 6e4f), notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_VEC_FUNCS(mulScalarVec));
1498 // The divide operator.
1501 << operInfoFunc(divName, divOp, GT, Value(GT, -1.0f, 1.0f), Value(GT, -2.0f, -0.5f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(div))
1502 << operInfoFunc(divName, divOp, IGT, Value(IGT, 24.0f, 24.0f), Value(IGT, -4.0f, -1.0f), notUsed, 0.04f, 1.0f, PRECMASK_MEDIUMP, INT_GENTYPE_FUNCS(div))
1503 << operInfoFunc(divName, divOp, IGT, Value(IGT, 40320.0f, 40320.0f), Value(IGT, -8.0f, -1.0f), notUsed, 1e-5f, 0.5f, PRECMASK_HIGHP, INT_GENTYPE_FUNCS(div))
1504 << operInfoFunc(divName, divOp, UGT, Value(UGT, 0.0f, 24.0f), Value(UGT, 1.0f, 4.0f), notUsed, 0.04f, 0.0f, PRECMASK_MEDIUMP, UINT_GENTYPE_FUNCS(div))
1505 << operInfoFunc(divName, divOp, UGT, Value(UGT, 0.0f, 40320.0f), Value(UGT, 1.0f, 8.0f), notUsed, 1e-5f, 0.0f, PRECMASK_HIGHP, UINT_GENTYPE_FUNCS(div))
1506 << operInfoFunc(divName, divOp, FV, Value(FV, -1.0f, 1.0f), Value(F, -2.0f, -0.5f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_VEC_FUNCS(divVecScalar))
1507 << operInfoFunc(divName, divOp, IV, Value(IV, 24.0f, 24.0f), Value(I, -4.0f, -1.0f), notUsed, 0.04f, 1.0f, PRECMASK_MEDIUMP, INT_VEC_FUNCS(divVecScalar))
1508 << operInfoFunc(divName, divOp, IV, Value(IV, 40320.0f, 40320.0f), Value(I, -8.0f, -1.0f), notUsed, 1e-5f, 0.5f, PRECMASK_HIGHP, INT_VEC_FUNCS(divVecScalar))
1509 << operInfoFunc(divName, divOp, UV, Value(UV, 0.0f, 24.0f), Value(U, 1.0f, 4.0f), notUsed, 0.04f, 0.0f, PRECMASK_MEDIUMP, UINT_VEC_FUNCS(divVecScalar))
1510 << operInfoFunc(divName, divOp, UV, Value(UV, 0.0f, 40320.0f), Value(U, 1.0f, 8.0f), notUsed, 1e-5f, 0.0f, PRECMASK_HIGHP, UINT_VEC_FUNCS(divVecScalar));
1514 << operInfoFunc(divName, divOp, FV, Value(F, -1.0f, 1.0f), Value(FV, -2.0f, -0.5f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_VEC_FUNCS(divScalarVec))
1515 << operInfoFunc(divName, divOp, IV, Value(I, 24.0f, 24.0f), Value(IV, -4.0f, -1.0f), notUsed, 0.04f, 1.0f, PRECMASK_MEDIUMP, INT_VEC_FUNCS(divScalarVec))
1516 << operInfoFunc(divName, divOp, IV, Value(I, 40320.0f, 40320.0f), Value(IV, -8.0f, -1.0f), notUsed, 1e-5f, 0.5f, PRECMASK_HIGHP, INT_VEC_FUNCS(divScalarVec))
1517 << operInfoFunc(divName, divOp, UV, Value(U, 0.0f, 24.0f), Value(UV, 1.0f, 4.0f), notUsed, 0.04f, 0.0f, PRECMASK_MEDIUMP, UINT_VEC_FUNCS(divScalarVec))
1518 << operInfoFunc(divName, divOp, UV, Value(U, 0.0f, 40320.0f), Value(UV, 1.0f, 8.0f), notUsed, 1e-5f, 0.0f, PRECMASK_HIGHP, UINT_VEC_FUNCS(divScalarVec));
1520 // The modulus operator.
1523 << operInfoFunc(modName, modOp, IGT, Value(IGT, 0.0f, 6.0f), Value(IGT, 1.1f, 6.1f), notUsed, 0.25f, 0.5f, PRECMASK_MEDIUMP, INT_GENTYPE_FUNCS(mod))
1524 << operInfoFunc(modName, modOp, IGT, Value(IGT, 0.0f, 14.0f), Value(IGT, 1.1f, 11.1f), notUsed, 0.1f, 0.5f, PRECMASK_HIGHP, INT_GENTYPE_FUNCS(mod))
1525 << operInfoFunc(modName, modOp, UGT, Value(UGT, 0.0f, 6.0f), Value(UGT, 1.1f, 6.1f), notUsed, 0.25f, 0.0f, PRECMASK_MEDIUMP, UINT_GENTYPE_FUNCS(mod))
1526 << operInfoFunc(modName, modOp, UGT, Value(UGT, 0.0f, 24.0f), Value(UGT, 1.1f, 11.1f), notUsed, 0.1f, 0.0f, PRECMASK_HIGHP, UINT_GENTYPE_FUNCS(mod))
1527 << operInfoFunc(modName, modOp, IV, Value(IV, 0.0f, 6.0f), Value(I, 1.1f, 6.1f), notUsed, 0.25f, 0.5f, PRECMASK_MEDIUMP, INT_VEC_FUNCS(modVecScalar))
1528 << operInfoFunc(modName, modOp, IV, Value(IV, 0.0f, 6.0f), Value(I, 1.1f, 11.1f), notUsed, 0.1f, 0.5f, PRECMASK_HIGHP, INT_VEC_FUNCS(modVecScalar))
1529 << operInfoFunc(modName, modOp, UV, Value(UV, 0.0f, 6.0f), Value(U, 1.1f, 6.1f), notUsed, 0.25f, 0.0f, PRECMASK_MEDIUMP, UINT_VEC_FUNCS(modVecScalar))
1530 << operInfoFunc(modName, modOp, UV, Value(UV, 0.0f, 24.0f), Value(U, 1.1f, 11.1f), notUsed, 0.1f, 0.0f, PRECMASK_HIGHP, UINT_VEC_FUNCS(modVecScalar));
1534 << operInfoFunc(modName, modOp, IV, Value(I, 0.0f, 6.0f), Value(IV, 1.1f, 6.1f), notUsed, 0.25f, 0.5f, PRECMASK_MEDIUMP, INT_VEC_FUNCS(modScalarVec))
1535 << operInfoFunc(modName, modOp, IV, Value(I, 0.0f, 6.0f), Value(IV, 1.1f, 11.1f), notUsed, 0.1f, 0.5f, PRECMASK_HIGHP, INT_VEC_FUNCS(modScalarVec))
1536 << operInfoFunc(modName, modOp, UV, Value(U, 0.0f, 6.0f), Value(UV, 1.1f, 6.1f), notUsed, 0.25f, 0.0f, PRECMASK_MEDIUMP, UINT_VEC_FUNCS(modScalarVec))
1537 << operInfoFunc(modName, modOp, UV, Value(U, 0.0f, 24.0f), Value(UV, 1.1f, 11.1f), notUsed, 0.1f, 0.0f, PRECMASK_HIGHP, UINT_VEC_FUNCS(modScalarVec));
1539 // The bitwise and operator.
1542 << operInfoFunc(andName, andOp, IGT, Value(IGT, -16.0f, 16.0f), Value(IGT, -16.0f, 16.0f), notUsed, 0.03f, 0.5f, PRECMASK_MEDIUMP, INT_GENTYPE_FUNCS(bitwiseAnd))
1543 << operInfoFunc(andName, andOp, IGT, Value(IGT, -2e9f, 2e9f), Value(IGT, -2e9f, 2e9f), notUsed, 4e-10f, 0.5f, PRECMASK_HIGHP, INT_GENTYPE_FUNCS(bitwiseAnd))
1544 << operInfoFunc(andName, andOp, UGT, Value(UGT, 0.0f, 32.0f), Value(UGT, 0.0f, 32.0f), notUsed, 0.03f, 0.0f, PRECMASK_MEDIUMP, UINT_GENTYPE_FUNCS(bitwiseAnd))
1545 << operInfoFunc(andName, andOp, UGT, Value(UGT, 0.0f, 4e9f), Value(UGT, 0.0f, 4e9f), notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_GENTYPE_FUNCS(bitwiseAnd))
1546 << operInfoFunc(andName, andOp, IV, Value(IV, -16.0f, 16.0f), Value(I, -16.0f, 16.0f), notUsed, 0.03f, 0.5f, PRECMASK_MEDIUMP, INT_VEC_FUNCS(bitwiseAndVecScalar))
1547 << operInfoFunc(andName, andOp, IV, Value(IV, -2e9f, 2e9f), Value(I, -2e9f, 2e9f), notUsed, 4e-10f, 0.5f, PRECMASK_HIGHP, INT_VEC_FUNCS(bitwiseAndVecScalar))
1548 << operInfoFunc(andName, andOp, UV, Value(UV, 0.0f, 32.0f), Value(U, 0.0f, 32.0f), notUsed, 0.03f, 0.0f, PRECMASK_MEDIUMP, UINT_VEC_FUNCS(bitwiseAndVecScalar))
1549 << operInfoFunc(andName, andOp, UV, Value(UV, 0.0f, 4e9f), Value(U, 0.0f, 4e9f), notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_VEC_FUNCS(bitwiseAndVecScalar));
1553 << operInfoFunc(andName, andOp, IV, Value(I, -16.0f, 16.0f), Value(IV, -16.0f, 16.0f), notUsed, 0.03f, 0.5f, PRECMASK_MEDIUMP, INT_VEC_FUNCS(bitwiseAndScalarVec))
1554 << operInfoFunc(andName, andOp, IV, Value(I, -2e9f, 2e9f), Value(IV, -2e9f, 2e9f), notUsed, 4e-10f, 0.5f, PRECMASK_HIGHP, INT_VEC_FUNCS(bitwiseAndScalarVec))
1555 << operInfoFunc(andName, andOp, UV, Value(U, 0.0f, 32.0f), Value(UV, 0.0f, 32.0f), notUsed, 0.03f, 0.0f, PRECMASK_MEDIUMP, UINT_VEC_FUNCS(bitwiseAndScalarVec))
1556 << operInfoFunc(andName, andOp, UV, Value(U, 0.0f, 4e9f), Value(UV, 0.0f, 4e9f), notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_VEC_FUNCS(bitwiseAndScalarVec));
1558 // The bitwise or operator.
1561 << operInfoFunc(orName, orOp, IGT, Value(IGT, -16.0f, 16.0f), Value(IGT, -16.0f, 16.0f), notUsed, 0.03f, 0.5f, PRECMASK_MEDIUMP, INT_GENTYPE_FUNCS(bitwiseOr))
1562 << operInfoFunc(orName, orOp, IGT, Value(IGT, -2e9f, 2e9f), Value(IGT, -2e9f, 2e9f), notUsed, 4e-10f, 0.5f, PRECMASK_HIGHP, INT_GENTYPE_FUNCS(bitwiseOr))
1563 << operInfoFunc(orName, orOp, UGT, Value(UGT, 0.0f, 32.0f), Value(UGT, 0.0f, 32.0f), notUsed, 0.03f, 0.0f, PRECMASK_MEDIUMP, UINT_GENTYPE_FUNCS(bitwiseOr))
1564 << operInfoFunc(orName, orOp, UGT, Value(UGT, 0.0f, 4e9f), Value(UGT, 0.0f, 4e9f), notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_GENTYPE_FUNCS(bitwiseOr))
1565 << operInfoFunc(orName, orOp, IV, Value(IV, -16.0f, 16.0f), Value(I, -16.0f, 16.0f), notUsed, 0.03f, 0.5f, PRECMASK_MEDIUMP, INT_VEC_FUNCS(bitwiseOrVecScalar))
1566 << operInfoFunc(orName, orOp, IV, Value(IV, -2e9f, 2e9f), Value(I, -2e9f, 2e9f), notUsed, 4e-10f, 0.5f, PRECMASK_HIGHP, INT_VEC_FUNCS(bitwiseOrVecScalar))
1567 << operInfoFunc(orName, orOp, UV, Value(UV, 0.0f, 32.0f), Value(U, 0.0f, 32.0f), notUsed, 0.03f, 0.0f, PRECMASK_MEDIUMP, UINT_VEC_FUNCS(bitwiseOrVecScalar))
1568 << operInfoFunc(orName, orOp, UV, Value(UV, 0.0f, 4e9f), Value(U, 0.0f, 4e9f), notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_VEC_FUNCS(bitwiseOrVecScalar));
1572 << operInfoFunc(orName, orOp, IV, Value(I, -16.0f, 16.0f), Value(IV, -16.0f, 16.0f), notUsed, 0.03f, 0.5f, PRECMASK_MEDIUMP, INT_VEC_FUNCS(bitwiseOrScalarVec))
1573 << operInfoFunc(orName, orOp, IV, Value(I, -2e9f, 2e9f), Value(IV, -2e9f, 2e9f), notUsed, 4e-10f, 0.5f, PRECMASK_HIGHP, INT_VEC_FUNCS(bitwiseOrScalarVec))
1574 << operInfoFunc(orName, orOp, UV, Value(U, 0.0f, 32.0f), Value(UV, 0.0f, 32.0f), notUsed, 0.03f, 0.0f, PRECMASK_MEDIUMP, UINT_VEC_FUNCS(bitwiseOrScalarVec))
1575 << operInfoFunc(orName, orOp, UV, Value(U, 0.0f, 4e9f), Value(UV, 0.0f, 4e9f), notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_VEC_FUNCS(bitwiseOrScalarVec));
1577 // The bitwise xor operator.
1580 << operInfoFunc(xorName, xorOp, IGT, Value(IGT, -16.0f, 16.0f), Value(IGT, -16.0f, 16.0f), notUsed, 0.03f, 0.5f, PRECMASK_MEDIUMP, INT_GENTYPE_FUNCS(bitwiseXor))
1581 << operInfoFunc(xorName, xorOp, IGT, Value(IGT, -2e9f, 2e9f), Value(IGT, -2e9f, 2e9f), notUsed, 4e-10f, 0.5f, PRECMASK_HIGHP, INT_GENTYPE_FUNCS(bitwiseXor))
1582 << operInfoFunc(xorName, xorOp, UGT, Value(UGT, 0.0f, 32.0f), Value(UGT, 0.0f, 32.0f), notUsed, 0.03f, 0.0f, PRECMASK_MEDIUMP, UINT_GENTYPE_FUNCS(bitwiseXor))
1583 << operInfoFunc(xorName, xorOp, UGT, Value(UGT, 0.0f, 4e9f), Value(UGT, 0.0f, 4e9f), notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_GENTYPE_FUNCS(bitwiseXor))
1584 << operInfoFunc(xorName, xorOp, IV, Value(IV, -16.0f, 16.0f), Value(I, -16.0f, 16.0f), notUsed, 0.03f, 0.5f, PRECMASK_MEDIUMP, INT_VEC_FUNCS(bitwiseXorVecScalar))
1585 << operInfoFunc(xorName, xorOp, IV, Value(IV, -2e9f, 2e9f), Value(I, -2e9f, 2e9f), notUsed, 4e-10f, 0.5f, PRECMASK_HIGHP, INT_VEC_FUNCS(bitwiseXorVecScalar))
1586 << operInfoFunc(xorName, xorOp, UV, Value(UV, 0.0f, 32.0f), Value(U, 0.0f, 32.0f), notUsed, 0.03f, 0.0f, PRECMASK_MEDIUMP, UINT_VEC_FUNCS(bitwiseXorVecScalar))
1587 << operInfoFunc(xorName, xorOp, UV, Value(UV, 0.0f, 4e9f), Value(U, 0.0f, 4e9f), notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_VEC_FUNCS(bitwiseXorVecScalar));
1591 << operInfoFunc(xorName, xorOp, IV, Value(I, -16.0f, 16.0f), Value(IV, -16.0f, 16.0f), notUsed, 0.03f, 0.5f, PRECMASK_MEDIUMP, INT_VEC_FUNCS(bitwiseXorScalarVec))
1592 << operInfoFunc(xorName, xorOp, IV, Value(I, -2e9f, 2e9f), Value(IV, -2e9f, 2e9f), notUsed, 4e-10f, 0.5f, PRECMASK_HIGHP, INT_VEC_FUNCS(bitwiseXorScalarVec))
1593 << operInfoFunc(xorName, xorOp, UV, Value(U, 0.0f, 32.0f), Value(UV, 0.0f, 32.0f), notUsed, 0.03f, 0.0f, PRECMASK_MEDIUMP, UINT_VEC_FUNCS(bitwiseXorScalarVec))
1594 << operInfoFunc(xorName, xorOp, UV, Value(U, 0.0f, 4e9f), Value(UV, 0.0f, 4e9f), notUsed, 2e-10f, 0.0f, PRECMASK_HIGHP, UINT_VEC_FUNCS(bitwiseXorScalarVec));
1596 // The left shift operator. Second operand (shift amount) can be either int or uint, even for uint and int first operand, respectively.
1598 for (int isSignedAmount = 0; isSignedAmount <= 1; isSignedAmount++)
1600 ValueType gType = isSignedAmount == 0 ? UGT : IGT;
1601 ValueType sType = isSignedAmount == 0 ? U : I;
1603 << operInfoFunc(leftShiftName, leftShiftOp, IGT, Value(IGT, -7.0f, 7.0f), Value(gType, 0.0f, 4.0f), notUsed, 4e-3f, 0.5f, PRECMASK_MEDIUMP, INT_GENTYPE_FUNCS(leftShift))
1604 << operInfoFunc(leftShiftName, leftShiftOp, IGT, Value(IGT, -7.0f, 7.0f), Value(gType, 0.0f, 27.0f), notUsed, 5e-10f, 0.5f, PRECMASK_HIGHP, INT_GENTYPE_FUNCS(leftShift))
1605 << operInfoFunc(leftShiftName, leftShiftOp, UGT, Value(UGT, 0.0f, 7.0f), Value(gType, 0.0f, 5.0f), notUsed, 4e-3f, 0.0f, PRECMASK_MEDIUMP, UINT_GENTYPE_FUNCS(leftShift))
1606 << operInfoFunc(leftShiftName, leftShiftOp, UGT, Value(UGT, 0.0f, 7.0f), Value(gType, 0.0f, 28.0f), notUsed, 5e-10f, 0.0f, PRECMASK_HIGHP, UINT_GENTYPE_FUNCS(leftShift))
1607 << operInfoFunc(leftShiftName, leftShiftOp, IV, Value(IV, -7.0f, 7.0f), Value(sType, 0.0f, 4.0f), notUsed, 4e-3f, 0.5f, PRECMASK_MEDIUMP, INT_VEC_FUNCS(leftShiftVecScalar))
1608 << operInfoFunc(leftShiftName, leftShiftOp, IV, Value(IV, -7.0f, 7.0f), Value(sType, 0.0f, 27.0f), notUsed, 5e-10f, 0.5f, PRECMASK_HIGHP, INT_VEC_FUNCS(leftShiftVecScalar))
1609 << operInfoFunc(leftShiftName, leftShiftOp, UV, Value(UV, 0.0f, 7.0f), Value(sType, 0.0f, 5.0f), notUsed, 4e-3f, 0.0f, PRECMASK_MEDIUMP, UINT_VEC_FUNCS(leftShiftVecScalar))
1610 << operInfoFunc(leftShiftName, leftShiftOp, UV, Value(UV, 0.0f, 7.0f), Value(sType, 0.0f, 28.0f), notUsed, 5e-10f, 0.0f, PRECMASK_HIGHP, UINT_VEC_FUNCS(leftShiftVecScalar));
1613 // The right shift operator. Second operand (shift amount) can be either int or uint, even for uint and int first operand, respectively.
1615 for (int isSignedAmount = 0; isSignedAmount <= 1; isSignedAmount++)
1617 ValueType gType = isSignedAmount == 0 ? UGT : IGT;
1618 ValueType sType = isSignedAmount == 0 ? U : I;
1620 << operInfoFunc(rightShiftName, rightShiftOp, IGT, Value(IGT, -127.0f, 127.0f), Value(gType, 0.0f, 8.0f), notUsed, 4e-3f, 0.5f, PRECMASK_MEDIUMP, INT_GENTYPE_FUNCS(rightShift))
1621 << operInfoFunc(rightShiftName, rightShiftOp, IGT, Value(IGT, -2e9f, 2e9f), Value(gType, 0.0f, 31.0f), notUsed, 5e-10f, 0.5f, PRECMASK_HIGHP, INT_GENTYPE_FUNCS(rightShift))
1622 << operInfoFunc(rightShiftName, rightShiftOp, UGT, Value(UGT, 0.0f, 255.0f), Value(gType, 0.0f, 8.0f), notUsed, 4e-3f, 0.0f, PRECMASK_MEDIUMP, UINT_GENTYPE_FUNCS(rightShift))
1623 << operInfoFunc(rightShiftName, rightShiftOp, UGT, Value(UGT, 0.0f, 4e9f), Value(gType, 0.0f, 31.0f), notUsed, 5e-10f, 0.0f, PRECMASK_HIGHP, UINT_GENTYPE_FUNCS(rightShift))
1624 << operInfoFunc(rightShiftName, rightShiftOp, IV, Value(IV, -127.0f, 127.0f), Value(sType, 0.0f, 8.0f), notUsed, 4e-3f, 0.5f, PRECMASK_MEDIUMP, INT_VEC_FUNCS(rightShiftVecScalar))
1625 << operInfoFunc(rightShiftName, rightShiftOp, IV, Value(IV, -2e9f, 2e9f), Value(sType, 0.0f, 31.0f), notUsed, 5e-10f, 0.5f, PRECMASK_HIGHP, INT_VEC_FUNCS(rightShiftVecScalar))
1626 << operInfoFunc(rightShiftName, rightShiftOp, UV, Value(UV, 0.0f, 255.0f), Value(sType, 0.0f, 8.0f), notUsed, 4e-3f, 0.0f, PRECMASK_MEDIUMP, UINT_VEC_FUNCS(rightShiftVecScalar))
1627 << operInfoFunc(rightShiftName, rightShiftOp, UV, Value(UV, 0.0f, 4e9f), Value(sType, 0.0f, 31.0f), notUsed, 5e-10f, 0.0f, PRECMASK_HIGHP, UINT_VEC_FUNCS(rightShiftVecScalar));
1631 // Rest of binary operators.
1634 // Scalar relational operators.
1635 << BuiltinOperInfo("less", "<", B, Value(F, -1.0f, 1.0f), Value(F, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, eval_lessThan_float, DE_NULL, DE_NULL, DE_NULL)
1636 << BuiltinOperInfo("less", "<", B, Value(I, -5.0f, 5.0f), Value(I, -5.0f, 5.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, eval_lessThan_int, DE_NULL, DE_NULL, DE_NULL)
1637 << BuiltinOperInfo("less", "<", B, Value(U, 0.0f, 16.0f), Value(U, 0.0f, 16.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, eval_lessThan_uint, DE_NULL, DE_NULL, DE_NULL)
1638 << BuiltinOperInfo("less_or_equal", "<=", B, Value(F, -1.0f, 1.0f), Value(F, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, eval_lessThanEqual_float, DE_NULL, DE_NULL, DE_NULL)
1639 << BuiltinOperInfo("less_or_equal", "<=", B, Value(I, -5.0f, 5.0f), Value(I, -5.0f, 5.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, eval_lessThanEqual_int, DE_NULL, DE_NULL, DE_NULL)
1640 << BuiltinOperInfo("less_or_equal", "<=", B, Value(U, 0.0f, 16.0f), Value(U, 0.0f, 16.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, eval_lessThanEqual_uint, DE_NULL, DE_NULL, DE_NULL)
1641 << BuiltinOperInfo("greater", ">", B, Value(F, -1.0f, 1.0f), Value(F, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, eval_greaterThan_float, DE_NULL, DE_NULL, DE_NULL)
1642 << BuiltinOperInfo("greater", ">", B, Value(I, -5.0f, 5.0f), Value(I, -5.0f, 5.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, eval_greaterThan_int, DE_NULL, DE_NULL, DE_NULL)
1643 << BuiltinOperInfo("greater", ">", B, Value(U, 0.0f, 16.0f), Value(U, 0.0f, 16.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, eval_greaterThan_uint, DE_NULL, DE_NULL, DE_NULL)
1644 << BuiltinOperInfo("greater_or_equal", ">=", B, Value(F, -1.0f, 1.0f), Value(F, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, eval_greaterThanEqual_float, DE_NULL, DE_NULL, DE_NULL)
1645 << BuiltinOperInfo("greater_or_equal", ">=", B, Value(I, -5.0f, 5.0f), Value(I, -5.0f, 5.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, eval_greaterThanEqual_int, DE_NULL, DE_NULL, DE_NULL)
1646 << BuiltinOperInfo("greater_or_equal", ">=", B, Value(U, 0.0f, 16.0f), Value(U, 0.0f, 16.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, eval_greaterThanEqual_uint, DE_NULL, DE_NULL, DE_NULL)
1648 // Equality comparison operators.
1649 << BuiltinOperInfo("equal", "==", B, Value(GT, -1.0f, 1.0f), Value(GT, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(allEqual))
1650 << BuiltinOperInfo("equal", "==", B, Value(IGT, -5.5f, 4.7f), Value(IGT, -2.1f, 0.1f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, INT_GENTYPE_FUNCS(allEqual))
1651 << BuiltinOperInfo("equal", "==", B, Value(UGT, 0.0f, 8.0f), Value(UGT, 3.5f, 4.5f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, UINT_GENTYPE_FUNCS(allEqual))
1652 << BuiltinOperInfo("equal", "==", B, Value(BGT, -2.1f, 2.1f), Value(BGT, -1.1f, 3.0f), notUsed, 1.0f, 0.0f, PRECMASK_NA, BOOL_GENTYPE_FUNCS(allEqual))
1653 << BuiltinOperInfo("not_equal", "!=", B, Value(GT, -1.0f, 1.0f), Value(GT, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(anyNotEqual))
1654 << BuiltinOperInfo("not_equal", "!=", B, Value(IGT, -5.5f, 4.7f), Value(IGT, -2.1f, 0.1f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, INT_GENTYPE_FUNCS(anyNotEqual))
1655 << BuiltinOperInfo("not_equal", "!=", B, Value(UGT, 0.0f, 8.0f), Value(UGT, 3.5f, 4.5f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, UINT_GENTYPE_FUNCS(anyNotEqual))
1656 << BuiltinOperInfo("not_equal", "!=", B, Value(BGT, -2.1f, 2.1f), Value(BGT, -1.1f, 3.0f), notUsed, 1.0f, 0.0f, PRECMASK_NA, BOOL_GENTYPE_FUNCS(anyNotEqual))
1658 // Logical operators.
1659 << BuiltinOperInfo("logical_and", "&&", B, Value(B, -1.0f, 1.0f), Value(B, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_NA, BOOL_FUNCS(logicalAnd))
1660 << BuiltinOperInfo("logical_or", "||", B, Value(B, -1.0f, 1.0f), Value(B, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_NA, BOOL_FUNCS(logicalOr))
1661 << BuiltinOperInfo("logical_xor", "^^", B, Value(B, -1.0f, 1.0f), Value(B, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_NA, BOOL_FUNCS(logicalXor));
1663 funcInfoGroups.push_back(binaryOpGroup);
1665 // Angle and Trigonometry Functions.
1666 funcInfoGroups.push_back(
1667 BuiltinFuncGroup("angle_and_trigonometry", "Angle and trigonometry function tests.")
1668 << BuiltinFuncInfo("radians", "radians", GT, Value(GT, -1.0f, 1.0f), notUsed, notUsed, 25.0f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(radians) )
1669 << BuiltinFuncInfo("degrees", "degrees", GT, Value(GT, -1.0f, 1.0f), notUsed, notUsed, 0.04f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(degrees) )
1670 << BuiltinFuncInfo("sin", "sin", GT, Value(GT, -5.0f, 5.0f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(sin) )
1671 << BuiltinFuncInfo("sin2", "sin", GT, Value(GT, -1.5f, 1.5f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_MEDIUMP, FLOAT_GENTYPE_FUNCS(sin) )
1672 << BuiltinFuncInfo("cos", "cos", GT, Value(GT, -5.0f, 5.0f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(cos) )
1673 << BuiltinFuncInfo("cos2", "cos", GT, Value(GT, -1.5f, 1.5f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_MEDIUMP, FLOAT_GENTYPE_FUNCS(cos) )
1674 << BuiltinFuncInfo("tan", "tan", GT, Value(GT, -5.0f, 5.0f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(tan) )
1675 << BuiltinFuncInfo("tan2", "tan", GT, Value(GT, -1.5f, 5.5f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_MEDIUMP, FLOAT_GENTYPE_FUNCS(tan) )
1676 << BuiltinFuncInfo("asin", "asin", GT, Value(GT, -1.0f, 1.0f), notUsed, notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(asin) )
1677 << BuiltinFuncInfo("acos", "acos", GT, Value(GT, -1.0f, 1.0f), notUsed, notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(acos) )
1678 << BuiltinFuncInfo("atan", "atan", GT, Value(GT, -4.0f, 4.0f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_HIGHP, FLOAT_GENTYPE_FUNCS(atan) )
1679 << BuiltinFuncInfo("atan2", "atan", GT, Value(GT, -4.0f, 4.0f), Value(GT, 0.5f, 2.0f), notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(atan2) )
1680 << BuiltinFuncInfo("sinh", "sinh", GT, Value(GT, -5.0f, 5.0f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(sinh) )
1681 << BuiltinFuncInfo("sinh2", "sinh", GT, Value(GT, -1.5f, 1.5f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_MEDIUMP, FLOAT_GENTYPE_FUNCS(sinh) )
1682 << BuiltinFuncInfo("cosh", "cosh", GT, Value(GT, -5.0f, 5.0f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(cosh) )
1683 << BuiltinFuncInfo("cosh2", "cosh", GT, Value(GT, -1.5f, 1.5f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_MEDIUMP, FLOAT_GENTYPE_FUNCS(cosh) )
1684 << BuiltinFuncInfo("tanh", "tanh", GT, Value(GT, -5.0f, 5.0f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(tanh) )
1685 << BuiltinFuncInfo("tanh2", "tanh", GT, Value(GT, -1.5f, 5.5f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_MEDIUMP, FLOAT_GENTYPE_FUNCS(tanh) )
1686 << BuiltinFuncInfo("asinh", "asinh", GT, Value(GT, -1.0f, 1.0f), notUsed, notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(asinh) )
1687 << BuiltinFuncInfo("acosh", "acosh", GT, Value(GT, 1.0f, 2.2f), notUsed, notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(acosh) )
1688 << BuiltinFuncInfo("atanh", "atanh", GT, Value(GT, -0.99f, 0.99f), notUsed, notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(atanh) )
1691 // Exponential Functions.
1692 funcInfoGroups.push_back(
1693 BuiltinFuncGroup("exponential", "Exponential function tests")
1694 << BuiltinFuncInfo("pow", "pow", GT, Value(GT, 0.1f, 8.0f), Value(GT, -4.0f, 2.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(pow) )
1695 << BuiltinFuncInfo("exp", "exp", GT, Value(GT, -6.0f, 3.0f), notUsed, notUsed, 0.5f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(exp) )
1696 << BuiltinFuncInfo("log", "log", GT, Value(GT, 0.1f, 10.0f), notUsed, notUsed, 0.5f, 0.3f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(log) )
1697 << BuiltinFuncInfo("exp2", "exp2", GT, Value(GT, -7.0f, 2.0f), notUsed, notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(exp2) )
1698 << BuiltinFuncInfo("log2", "log2", GT, Value(GT, 0.1f, 10.0f), notUsed, notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(log2) )
1699 << BuiltinFuncInfo("sqrt", "sqrt", GT, Value(GT, 0.0f, 10.0f), notUsed, notUsed, 0.3f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(sqrt) )
1700 << BuiltinFuncInfo("inversesqrt", "inversesqrt", GT, Value(GT, 0.5f, 10.0f), notUsed, notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(inverseSqrt) )
1703 // Common Functions.
1704 funcInfoGroups.push_back(
1705 BuiltinFuncGroup("common_functions", "Common function tests.")
1706 << BuiltinFuncInfo("abs", "abs", GT, Value(GT, -2.0f, 2.0f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(abs) )
1707 << BuiltinFuncInfo("sign", "sign", GT, Value(GT, -1.5f, 1.5f), notUsed, notUsed, 0.3f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(sign) )
1708 << BuiltinFuncInfo("floor", "floor", GT, Value(GT, -2.5f, 2.5f), notUsed, notUsed, 0.2f, 0.7f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(floor) )
1709 << BuiltinFuncInfo("trunc", "trunc", GT, Value(GT, -2.5f, 2.5f), notUsed, notUsed, 0.2f, 0.7f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(trunc) )
1710 << BuiltinFuncInfo("round", "round", GT, Value(GT, -2.5f, 2.5f), notUsed, notUsed, 0.2f, 0.7f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(roundToEven) )
1711 << BuiltinFuncInfo("roundEven", "roundEven", GT, Value(GT, -2.5f, 2.5f), notUsed, notUsed, 0.2f, 0.7f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(roundToEven) )
1712 << BuiltinFuncInfo("ceil", "ceil", GT, Value(GT, -2.5f, 2.5f), notUsed, notUsed, 0.2f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(ceil) )
1713 << BuiltinFuncInfo("fract", "fract", GT, Value(GT, -1.5f, 1.5f), notUsed, notUsed, 0.8f, 0.1f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(fract) )
1714 << BuiltinFuncInfo("mod", "mod", GT, Value(GT, -2.0f, 2.0f), Value(GT, 0.9f, 6.0f), notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(mod) )
1715 << BuiltinFuncInfo("mod", "mod", GT, Value(FV, -2.0f, 2.0f), Value(F, 0.9f, 6.0f), notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_VEC_FUNCS(modVecScalar) )
1716 << BuiltinFuncInfo("min", "min", GT, Value(GT, -1.0f, 1.0f), Value(GT, -1.0f, 1.0f), notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(min) )
1717 << BuiltinFuncInfo("min", "min", GT, Value(FV, -1.0f, 1.0f), Value(F, -1.0f, 1.0f), notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_VEC_FUNCS(minVecScalar) )
1718 << BuiltinFuncInfo("min", "min", IGT,Value(IGT, -4.0f, 4.0f), Value(IGT, -4.0f, 4.0f), notUsed, 0.125f, 0.5f, PRECMASK_ALL, INT_GENTYPE_FUNCS(min) )
1719 << BuiltinFuncInfo("min", "min", IGT,Value(IV, -4.0f, 4.0f), Value(I, -4.0f, 4.0f), notUsed, 0.125f, 0.5f, PRECMASK_ALL, INT_VEC_FUNCS(minVecScalar) )
1720 << BuiltinFuncInfo("min", "min", UGT,Value(UGT, 0.0f, 8.0f), Value(UGT, 0.0f, 8.0f), notUsed, 0.125f, 0.0f, PRECMASK_ALL, UINT_GENTYPE_FUNCS(min) )
1721 << BuiltinFuncInfo("min", "min", UGT,Value(UV, 0.0f, 8.0f), Value(U, 0.0f, 8.0f), notUsed, 0.125f, 0.0f, PRECMASK_ALL, UINT_VEC_FUNCS(minVecScalar) )
1722 << BuiltinFuncInfo("max", "max", GT, Value(GT, -1.0f, 1.0f), Value(GT, -1.0f, 1.0f), notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(max) )
1723 << BuiltinFuncInfo("max", "max", GT, Value(FV, -1.0f, 1.0f), Value(F, -1.0f, 1.0f), notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_VEC_FUNCS(maxVecScalar) )
1724 << BuiltinFuncInfo("max", "max", IGT,Value(IGT, -4.0f, 4.0f), Value(IGT, -4.0f, 4.0f), notUsed, 0.125f, 0.5f, PRECMASK_ALL, INT_GENTYPE_FUNCS(max) )
1725 << BuiltinFuncInfo("max", "max", IGT,Value(IV, -4.0f, 4.0f), Value(I, -4.0f, 4.0f), notUsed, 0.125f, 0.5f, PRECMASK_ALL, INT_VEC_FUNCS(maxVecScalar) )
1726 << BuiltinFuncInfo("max", "max", UGT,Value(UGT, 0.0f, 8.0f), Value(UGT, 0.0f, 8.0f), notUsed, 0.125f, 0.0f, PRECMASK_ALL, UINT_GENTYPE_FUNCS(max) )
1727 << BuiltinFuncInfo("max", "max", UGT,Value(UV, 0.0f, 8.0f), Value(U, 0.0f, 8.0f), notUsed, 0.125f, 0.0f, PRECMASK_ALL, UINT_VEC_FUNCS(maxVecScalar) )
1728 << BuiltinFuncInfo("clamp", "clamp", GT, Value(GT, -1.0f, 1.0f), Value(GT, -0.5f, 0.5f), Value(GT, 0.5f, 1.0f), 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(clamp) )
1729 << BuiltinFuncInfo("clamp", "clamp", GT, Value(FV, -1.0f, 1.0f), Value(F, -0.5f, 0.5f), Value(F, 0.5f, 1.0f), 0.5f, 0.5f, PRECMASK_ALL, FLOAT_VEC_FUNCS(clampVecScalarScalar) )
1730 << BuiltinFuncInfo("clamp", "clamp", IGT,Value(IGT, -4.0f, 4.0f), Value(IGT, -2.0f, 2.0f), Value(IGT, 2.0f, 4.0f), 0.125f, 0.5f, PRECMASK_ALL, INT_GENTYPE_FUNCS(clamp) )
1731 << BuiltinFuncInfo("clamp", "clamp", IGT,Value(IV, -4.0f, 4.0f), Value(I, -2.0f, 2.0f), Value(I, 2.0f, 4.0f), 0.125f, 0.5f, PRECMASK_ALL, INT_VEC_FUNCS(clampVecScalarScalar) )
1732 << BuiltinFuncInfo("clamp", "clamp", UGT,Value(UGT, 0.0f, 8.0f), Value(UGT, 2.0f, 6.0f), Value(UGT, 6.0f, 8.0f), 0.125f, 0.0f, PRECMASK_ALL, UINT_GENTYPE_FUNCS(clamp) )
1733 << BuiltinFuncInfo("clamp", "clamp", UGT,Value(UV, 0.0f, 8.0f), Value(U, 2.0f, 6.0f), Value(U, 6.0f, 8.0f), 0.125f, 0.0f, PRECMASK_ALL, UINT_VEC_FUNCS(clampVecScalarScalar) )
1734 << BuiltinFuncInfo("mix", "mix", GT, Value(GT, -1.0f, 1.0f), Value(GT, -1.0f, 1.0f), Value(GT, 0.0f, 1.0f), 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(mix) )
1735 << BuiltinFuncInfo("mix", "mix", GT, Value(FV, -1.0f, 1.0f), Value(FV, -1.0f, 1.0f), Value(F, 0.0f, 1.0f), 0.5f, 0.5f, PRECMASK_ALL, FLOAT_VEC_FUNCS(mixVecVecScalar) )
1736 << BuiltinFuncInfo("step", "step", GT, Value(GT, -1.0f, 1.0f), Value(GT, -1.0f, 0.0f), notUsed, 0.5f, 0.25f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(step) )
1737 << BuiltinFuncInfo("step", "step", GT, Value(F, -1.0f, 1.0f), Value(FV, -1.0f, 0.0f), notUsed, 0.5f, 0.25f, PRECMASK_ALL, FLOAT_VEC_FUNCS(stepScalarVec) )
1738 << BuiltinFuncInfo("smoothstep", "smoothstep", GT, Value(GT, -0.5f, 0.0f), Value(GT, 0.1f, 1.0f), Value(GT, -1.0f, 1.0f), 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(smoothStep) )
1739 << BuiltinFuncInfo("smoothstep", "smoothstep", GT, Value(F, -0.5f, 0.0f), Value(F, 0.1f, 1.0f), Value(FV, -1.0f, 1.0f), 0.5f, 0.5f, PRECMASK_ALL, FLOAT_VEC_FUNCS(smoothStepScalarScalarVec) )
1742 // Geometric Functions.
1743 funcInfoGroups.push_back(
1744 BuiltinFuncGroup("geometric", "Geometric function tests.")
1745 << BuiltinFuncInfo("length", "length", F, Value(GT, -5.0f, 5.0f), notUsed, notUsed, 0.1f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(length) )
1746 << BuiltinFuncInfo("distance", "distance", F, Value(GT, -5.0f, 5.0f), Value(GT, -5.0f, 5.0f), notUsed, 0.1f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(distance) )
1747 << BuiltinFuncInfo("dot", "dot", F, Value(GT, -5.0f, 5.0f), Value(GT, -5.0f, 5.0f), notUsed, 0.1f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(dot) )
1748 << BuiltinFuncInfo("cross", "cross", V3, Value(GT, -5.0f, 5.0f), Value(GT, -5.0f, 5.0f), notUsed, 0.1f, 0.5f, PRECMASK_ALL, DE_NULL, DE_NULL, eval_cross_vec3, DE_NULL )
1749 << BuiltinFuncInfo("normalize", "normalize", GT, Value(GT, 0.1f, 4.0f), notUsed, notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(normalize) )
1750 << BuiltinFuncInfo("faceforward", "faceforward", GT, Value(GT, -5.0f, 5.0f), Value(GT, -5.0f, 5.0f), Value(GT, -1.0f, 1.0f), 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(faceForward) )
1751 << BuiltinFuncInfo("reflect", "reflect", GT, Value(GT, -0.8f, -0.5f), Value(GT, 0.5f, 0.8f), notUsed, 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(reflect) )
1752 << BuiltinFuncInfo("refract", "refract", GT, Value(GT, -0.8f, 1.2f), Value(GT, -1.1f, 0.5f), Value(F, 0.2f, 1.5f), 0.5f, 0.5f, PRECMASK_ALL, FLOAT_GENTYPE_FUNCS(refract) )
1755 // Vector Relational Functions.
1756 funcInfoGroups.push_back(
1757 BuiltinFuncGroup("float_compare", "Floating point comparison tests.")
1758 << BuiltinFuncInfo("lessThan", "lessThan", BV, Value(FV, -1.0f, 1.0f), Value(FV, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_VEC_FUNCS(lessThan) )
1759 << BuiltinFuncInfo("lessThanEqual", "lessThanEqual", BV, Value(FV, -1.0f, 1.0f), Value(FV, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_VEC_FUNCS(lessThanEqual) )
1760 << BuiltinFuncInfo("greaterThan", "greaterThan", BV, Value(FV, -1.0f, 1.0f), Value(FV, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_VEC_FUNCS(greaterThan) )
1761 << BuiltinFuncInfo("greaterThanEqual", "greaterThanEqual", BV, Value(FV, -1.0f, 1.0f), Value(FV, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_VEC_FUNCS(greaterThanEqual) )
1762 << BuiltinFuncInfo("equal", "equal", BV, Value(FV, -1.0f, 1.0f), Value(FV, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_VEC_FUNCS(equal) )
1763 << BuiltinFuncInfo("notEqual", "notEqual", BV, Value(FV, -1.0f, 1.0f), Value(FV, -1.0f, 1.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, FLOAT_VEC_FUNCS(notEqual) )
1766 funcInfoGroups.push_back(
1767 BuiltinFuncGroup("int_compare", "Integer comparison tests.")
1768 << BuiltinFuncInfo("lessThan", "lessThan", BV, Value(IV, -5.2f, 4.9f), Value(IV, -5.0f, 5.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, INT_VEC_FUNCS(lessThan) )
1769 << BuiltinFuncInfo("lessThanEqual", "lessThanEqual", BV, Value(IV, -5.2f, 4.9f), Value(IV, -5.0f, 5.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, INT_VEC_FUNCS(lessThanEqual) )
1770 << BuiltinFuncInfo("greaterThan", "greaterThan", BV, Value(IV, -5.2f, 4.9f), Value(IV, -5.0f, 5.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, INT_VEC_FUNCS(greaterThan) )
1771 << BuiltinFuncInfo("greaterThanEqual", "greaterThanEqual", BV, Value(IV, -5.2f, 4.9f), Value(IV, -5.0f, 5.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, INT_VEC_FUNCS(greaterThanEqual) )
1772 << BuiltinFuncInfo("equal", "equal", BV, Value(IV, -5.2f, 4.9f), Value(IV, -5.0f, 5.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, INT_VEC_FUNCS(equal) )
1773 << BuiltinFuncInfo("notEqual", "notEqual", BV, Value(IV, -5.2f, 4.9f), Value(IV, -5.0f, 5.0f), notUsed, 1.0f, 0.0f, PRECMASK_ALL, INT_VEC_FUNCS(notEqual) )
1776 funcInfoGroups.push_back(
1777 BuiltinFuncGroup("bool_compare", "Boolean comparison tests.")
1778 << BuiltinFuncInfo("equal", "equal", BV, Value(BV, -5.2f, 4.9f), Value(BV, -5.0f, 5.0f), notUsed, 1.0f, 0.0f, PRECMASK_NA, BOOL_VEC_FUNCS(equal) )
1779 << BuiltinFuncInfo("notEqual", "notEqual", BV, Value(BV, -5.2f, 4.9f), Value(BV, -5.0f, 5.0f), notUsed, 1.0f, 0.0f, PRECMASK_NA, BOOL_VEC_FUNCS(notEqual) )
1780 << BuiltinFuncInfo("any", "any", B, Value(BV, -1.0f, 0.3f), notUsed, notUsed, 1.0f, 0.0f, PRECMASK_NA, BOOL_VEC_FUNCS(any) )
1781 << BuiltinFuncInfo("all", "all", B, Value(BV, -0.3f, 1.0f), notUsed, notUsed, 1.0f, 0.0f, PRECMASK_NA, BOOL_VEC_FUNCS(all) )
1782 << BuiltinFuncInfo("not", "not", BV, Value(BV, -1.0f, 1.0f), notUsed, notUsed, 1.0f, 0.0f, PRECMASK_NA, BOOL_VEC_FUNCS(boolNot) )
1785 static const ShaderType s_shaderTypes[] =
1791 static const DataType s_floatTypes[] =
1799 static const DataType s_intTypes[] =
1807 static const DataType s_uintTypes[] =
1815 static const DataType s_boolTypes[] =
1823 for (int outerGroupNdx = 0; outerGroupNdx < (int)funcInfoGroups.size(); outerGroupNdx++)
1825 // Create outer group.
1826 const BuiltinFuncGroup& outerGroupInfo = funcInfoGroups[outerGroupNdx];
1827 TestCaseGroup* outerGroup = new TestCaseGroup(m_testCtx, outerGroupInfo.name, outerGroupInfo.description);
1828 addChild(outerGroup);
1830 // Only create new group if name differs from previous one.
1831 TestCaseGroup* innerGroup = DE_NULL;
1833 for (int funcInfoNdx = 0; funcInfoNdx < (int)outerGroupInfo.funcInfos.size(); funcInfoNdx++)
1835 const BuiltinFuncInfo& funcInfo = outerGroupInfo.funcInfos[funcInfoNdx];
1836 const char* shaderFuncName = funcInfo.shaderFuncName;
1837 const bool isBoolCase = (funcInfo.precisionMask == PRECMASK_NA);
1838 const bool isBoolOut = (funcInfo.outValue & (VALUE_BOOL | VALUE_BOOL_VEC | VALUE_BOOL_GENTYPE)) != 0;
1839 const bool isIntOut = (funcInfo.outValue & (VALUE_INT | VALUE_INT_VEC | VALUE_INT_GENTYPE)) != 0;
1840 const bool isUintOut = (funcInfo.outValue & (VALUE_UINT | VALUE_UINT_VEC | VALUE_UINT_GENTYPE)) != 0;
1841 const bool isFloatOut = !isBoolOut && !isIntOut && !isUintOut;
1843 if (!innerGroup || (std::string(innerGroup->getName()) != funcInfo.caseName))
1845 std::string groupDesc = std::string("Built-in function ") + shaderFuncName + "() tests.";
1846 innerGroup = new TestCaseGroup(m_testCtx, funcInfo.caseName, groupDesc.c_str());
1847 outerGroup->addChild(innerGroup);
1850 for (int inScalarSize = 1; inScalarSize <= 4; inScalarSize++)
1852 const int outScalarSize = ((funcInfo.outValue == VALUE_FLOAT) || (funcInfo.outValue == VALUE_BOOL)) ? 1 : inScalarSize;
1853 const DataType outDataType = isFloatOut ? s_floatTypes[outScalarSize - 1]
1854 : isIntOut ? s_intTypes[outScalarSize - 1]
1855 : isUintOut ? s_uintTypes[outScalarSize - 1]
1856 : isBoolOut ? s_boolTypes[outScalarSize - 1]
1859 ShaderEvalFunc evalFunc = DE_NULL;
1860 if (inScalarSize == 1) evalFunc = funcInfo.evalFuncScalar;
1861 else if (inScalarSize == 2) evalFunc = funcInfo.evalFuncVec2;
1862 else if (inScalarSize == 3) evalFunc = funcInfo.evalFuncVec3;
1863 else if (inScalarSize == 4) evalFunc = funcInfo.evalFuncVec4;
1864 else DE_ASSERT(false);
1866 // Skip if no valid eval func.
1867 if (evalFunc == DE_NULL)
1870 for (int precision = PRECISION_MEDIUMP; precision < PRECISION_LAST; precision++)
1872 if ((funcInfo.precisionMask & (1<<precision)) ||
1873 (funcInfo.precisionMask == PRECMASK_NA && precision == PRECISION_MEDIUMP)) // use mediump interpolators for booleans
1875 const char* precisionStr = getPrecisionName((Precision)precision);
1876 const std::string precisionPrefix = isBoolCase ? "" : (std::string(precisionStr) + "_");
1878 for (int shaderTypeNdx = 0; shaderTypeNdx < DE_LENGTH_OF_ARRAY(s_shaderTypes); shaderTypeNdx++)
1880 const ShaderType shaderType = s_shaderTypes[shaderTypeNdx];
1881 const char* shaderTypeName = getShaderTypeName(shaderType);
1882 const bool isVertexCase = (ShaderType)shaderType == SHADERTYPE_VERTEX;
1883 const bool isUnaryOp = (funcInfo.input1.valueType == VALUE_NONE);
1885 // \note Data type names will be added to description and name in a following loop.
1886 std::string desc = std::string("Built-in function ") + shaderFuncName + "(";
1887 std::string name = precisionPrefix;
1889 // Generate shader op.
1890 std::string shaderOp = std::string("res = ");
1892 // Setup shader data info.
1893 ShaderDataSpec shaderSpec;
1894 shaderSpec.numInputs = 0;
1895 shaderSpec.precision = isBoolCase ? PRECISION_LAST : (Precision)precision;
1896 shaderSpec.output = outDataType;
1897 shaderSpec.resultScale = funcInfo.resultScale;
1898 shaderSpec.resultBias = funcInfo.resultBias;
1899 shaderSpec.referenceScale = funcInfo.referenceScale;
1900 shaderSpec.referenceBias = funcInfo.referenceBias;
1902 if (funcInfo.type == OPERATOR)
1904 if (isUnaryOp && funcInfo.isUnaryPrefix)
1905 shaderOp += shaderFuncName;
1907 else if (funcInfo.type == FUNCTION)
1908 shaderOp += std::string(shaderFuncName) + "(";
1909 else // SIDE_EFFECT_OPERATOR
1910 shaderOp += "in0;\n\t";
1912 for (int inputNdx = 0; inputNdx < MAX_INPUTS; inputNdx++)
1914 const Value& prevV = (inputNdx == 1) ? funcInfo.input0 : (inputNdx == 2) ? funcInfo.input1 : funcInfo.input2;
1915 const Value& v = (inputNdx == 0) ? funcInfo.input0 : (inputNdx == 1) ? funcInfo.input1 : funcInfo.input2;
1917 if (v.valueType == VALUE_NONE)
1918 continue; // Skip unused input.
1920 const int prevInScalarSize = isScalarType(prevV.valueType) ? 1 : inScalarSize;
1921 const DataType prevInDataType = isFloatType(prevV.valueType) ? s_floatTypes[prevInScalarSize - 1]
1922 : isIntType(prevV.valueType) ? s_intTypes[prevInScalarSize - 1]
1923 : isUintType(prevV.valueType) ? s_uintTypes[prevInScalarSize - 1]
1924 : isBoolType(prevV.valueType) ? s_boolTypes[prevInScalarSize - 1]
1927 const int curInScalarSize = isScalarType(v.valueType) ? 1 : inScalarSize;
1928 const DataType curInDataType = isFloatType(v.valueType) ? s_floatTypes[curInScalarSize - 1]
1929 : isIntType(v.valueType) ? s_intTypes[curInScalarSize - 1]
1930 : isUintType(v.valueType) ? s_uintTypes[curInScalarSize - 1]
1931 : isBoolType(v.valueType) ? s_boolTypes[curInScalarSize - 1]
1934 // Write input type(s) to case description and name.
1939 desc += getDataTypeName(curInDataType);
1941 if (inputNdx == 0 || prevInDataType != curInDataType) // \note Only write input type to case name if different from previous input type (avoid overly long names).
1942 name += std::string("") + getDataTypeName(curInDataType) + "_";
1944 // Generate op input source.
1946 if (funcInfo.type == OPERATOR || funcInfo.type == FUNCTION)
1950 if (funcInfo.type == OPERATOR && !isUnaryOp)
1951 shaderOp += " " + std::string(shaderFuncName) + " ";
1956 shaderOp += "in" + de::toString(inputNdx);
1958 if (funcInfo.type == OPERATOR && isUnaryOp && !funcInfo.isUnaryPrefix)
1959 shaderOp += std::string(shaderFuncName);
1963 DE_ASSERT(funcInfo.type == SIDE_EFFECT_OPERATOR);
1965 if (inputNdx != 0 || (isUnaryOp && funcInfo.isUnaryPrefix))
1966 shaderOp += std::string("") + (isUnaryOp ? "" : " ") + shaderFuncName + (isUnaryOp ? "" : " ");
1968 shaderOp += inputNdx == 0 ? "res" : "in" + de::toString(inputNdx); // \note in0 has already been assigned to res, so start from in1.
1970 if (isUnaryOp && !funcInfo.isUnaryPrefix)
1971 shaderOp += shaderFuncName;
1974 // Fill in shader info.
1975 shaderSpec.inputs[shaderSpec.numInputs++] = ShaderValue(curInDataType, v.rangeMin, v.rangeMax);
1978 if (funcInfo.type == FUNCTION)
1984 name += shaderTypeName;
1986 // Create the test case.
1987 innerGroup->addChild(new ShaderOperatorCase(m_testCtx, name.c_str(), desc.c_str(), isVertexCase, evalFunc, shaderOp, shaderSpec));
1995 // The ?: selection operator.
1999 const DataType type; // The type of "Y" and "Z" operands in "X ? Y : Z" (X is always bool).
2000 const ShaderEvalFunc evalFunc;
2001 } s_selectionInfo[] =
2003 { TYPE_FLOAT, eval_selection_float },
2004 { TYPE_FLOAT_VEC2, eval_selection_vec2 },
2005 { TYPE_FLOAT_VEC3, eval_selection_vec3 },
2006 { TYPE_FLOAT_VEC4, eval_selection_vec4 },
2007 { TYPE_INT, eval_selection_int },
2008 { TYPE_INT_VEC2, eval_selection_ivec2 },
2009 { TYPE_INT_VEC3, eval_selection_ivec3 },
2010 { TYPE_INT_VEC4, eval_selection_ivec4 },
2011 { TYPE_UINT, eval_selection_uint },
2012 { TYPE_UINT_VEC2, eval_selection_uvec2 },
2013 { TYPE_UINT_VEC3, eval_selection_uvec3 },
2014 { TYPE_UINT_VEC4, eval_selection_uvec4 },
2015 { TYPE_BOOL, eval_selection_bool },
2016 { TYPE_BOOL_VEC2, eval_selection_bvec2 },
2017 { TYPE_BOOL_VEC3, eval_selection_bvec3 },
2018 { TYPE_BOOL_VEC4, eval_selection_bvec4 }
2021 TestCaseGroup* selectionGroup = new TestCaseGroup(m_testCtx, "selection", "Selection operator tests");
2022 addChild(selectionGroup);
2024 for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(s_selectionInfo); typeNdx++)
2026 const DataType curType = s_selectionInfo[typeNdx].type;
2027 const ShaderEvalFunc evalFunc = s_selectionInfo[typeNdx].evalFunc;
2028 const bool isBoolCase = isDataTypeBoolOrBVec(curType);
2029 const bool isFloatCase = isDataTypeFloatOrVec(curType);
2030 const bool isIntCase = isDataTypeIntOrIVec(curType);
2031 const bool isUintCase = isDataTypeUintOrUVec(curType);
2032 const char* dataTypeStr = getDataTypeName(curType);
2034 DE_ASSERT(isBoolCase || isFloatCase || isIntCase || isUintCase);
2035 DE_UNREF(isIntCase);
2037 for (int precision = (int)PRECISION_MEDIUMP; precision < (int)PRECISION_LAST; precision++)
2039 if (isBoolCase && precision != PRECISION_MEDIUMP) // Use mediump interpolators for booleans.
2042 const char* precisionStr = getPrecisionName((Precision)precision);
2043 std::string precisionPrefix = isBoolCase ? "" : (std::string(precisionStr) + "_");
2045 for (int shaderTypeNdx = 0; shaderTypeNdx < DE_LENGTH_OF_ARRAY(s_shaderTypes); shaderTypeNdx++)
2047 const ShaderType shaderType = s_shaderTypes[shaderTypeNdx];
2048 const char* shaderTypeName = getShaderTypeName(shaderType);
2049 const bool isVertexCase = (ShaderType)shaderType == SHADERTYPE_VERTEX;
2051 std::string name = precisionPrefix + dataTypeStr + "_" + shaderTypeName;
2053 ShaderDataSpec shaderSpec;
2054 shaderSpec.numInputs = 3;
2055 shaderSpec.precision = isBoolCase ? PRECISION_LAST : (Precision)precision;
2056 shaderSpec.output = curType;
2057 shaderSpec.resultScale = (isBoolCase ? 1.0f : (isFloatCase ? 0.5f : (isUintCase ? 0.5f : 0.1f)));
2058 shaderSpec.resultBias = (isBoolCase ? 0.0f : (isFloatCase ? 0.5f : (isUintCase ? 0.0f : 0.5f)));
2059 shaderSpec.referenceScale = shaderSpec.resultScale;
2060 shaderSpec.referenceBias = shaderSpec.resultBias;
2062 const float rangeMin = (isBoolCase ? -1.0f : (isFloatCase ? -1.0f : (isUintCase ? 0.0f : -5.0f)));
2063 const float rangeMax = (isBoolCase ? 1.0f : (isFloatCase ? 1.0f : (isUintCase ? 2.0f : 5.0f)));
2065 shaderSpec.inputs[0] = ShaderValue(TYPE_BOOL, -1.0f, 1.0f);
2066 shaderSpec.inputs[1] = ShaderValue(curType, rangeMin, rangeMax);
2067 shaderSpec.inputs[2] = ShaderValue(curType, rangeMin, rangeMax);
2069 selectionGroup->addChild(new ShaderOperatorCase(m_testCtx, name.c_str(), "", isVertexCase, evalFunc, "res = in0 ? in1 : in2;", shaderSpec));
2074 // The sequence operator (comma).
2076 TestCaseGroup* sequenceGroup = new TestCaseGroup(m_testCtx, "sequence", "Sequence operator tests");
2077 addChild(sequenceGroup);
2079 TestCaseGroup* sequenceNoSideEffGroup = new TestCaseGroup(m_testCtx, "no_side_effects", "Sequence tests without side-effects");
2080 TestCaseGroup* sequenceSideEffGroup = new TestCaseGroup(m_testCtx, "side_effects", "Sequence tests with side-effects");
2081 sequenceGroup->addChild(sequenceNoSideEffGroup);
2082 sequenceGroup->addChild(sequenceSideEffGroup);
2086 const bool containsSideEffects;
2087 const char* caseName;
2088 const char* expressionStr;
2089 const int numInputs;
2090 const DataType inputTypes[MAX_INPUTS];
2091 const DataType resultType;
2092 const ShaderEvalFunc evalFunc;
2093 } s_sequenceCases[] =
2095 { false, "vec4", "in0, in2 + in1, in1 + in0", 3, { TYPE_FLOAT_VEC4, TYPE_FLOAT_VEC4, TYPE_FLOAT_VEC4 }, TYPE_FLOAT_VEC4, evalSequenceNoSideEffCase0 },
2096 { false, "float_uint", "in0 + in2, in1 + in1", 3, { TYPE_FLOAT, TYPE_UINT, TYPE_FLOAT }, TYPE_UINT, evalSequenceNoSideEffCase1 },
2097 { false, "bool_vec2", "in0 && in1, in0, ivec2(vec2(in0) + in2)", 3, { TYPE_BOOL, TYPE_BOOL, TYPE_FLOAT_VEC2 }, TYPE_INT_VEC2, evalSequenceNoSideEffCase2 },
2098 { false, "vec4_ivec4_bvec4", "in0 + vec4(in1), in2, in1", 3, { TYPE_FLOAT_VEC4, TYPE_INT_VEC4, TYPE_BOOL_VEC4 }, TYPE_INT_VEC4, evalSequenceNoSideEffCase3 },
2100 { true, "vec4", "in0++, in1 = in0 + in2, in2 = in1", 3, { TYPE_FLOAT_VEC4, TYPE_FLOAT_VEC4, TYPE_FLOAT_VEC4 }, TYPE_FLOAT_VEC4, evalSequenceSideEffCase0 },
2101 { true, "float_uint", "in1++, in0 = float(in1), in1 = uint(in0 + in2)", 3, { TYPE_FLOAT, TYPE_UINT, TYPE_FLOAT }, TYPE_UINT, evalSequenceSideEffCase1 },
2102 { true, "bool_vec2", "in1 = in0, in2++, in2 = in2 + vec2(in1), ivec2(in2)", 3, { TYPE_BOOL, TYPE_BOOL, TYPE_FLOAT_VEC2 }, TYPE_INT_VEC2, evalSequenceSideEffCase2 },
2103 { true, "vec4_ivec4_bvec4", "in0 = in0 + vec4(in2), in1 = in1 + ivec4(in0), in1++", 3, { TYPE_FLOAT_VEC4, TYPE_INT_VEC4, TYPE_BOOL_VEC4 }, TYPE_INT_VEC4, evalSequenceSideEffCase3 }
2106 for (int caseNdx = 0; caseNdx < DE_LENGTH_OF_ARRAY(s_sequenceCases); caseNdx++)
2108 for (int precision = (int)PRECISION_MEDIUMP; precision < (int)PRECISION_LAST; precision++)
2110 for (int shaderTypeNdx = 0; shaderTypeNdx < DE_LENGTH_OF_ARRAY(s_shaderTypes); shaderTypeNdx++)
2112 const ShaderType shaderType = s_shaderTypes[shaderTypeNdx];
2113 const char* shaderTypeName = getShaderTypeName(shaderType);
2114 const bool isVertexCase = (ShaderType)shaderType == SHADERTYPE_VERTEX;
2116 std::string name = std::string("") + getPrecisionName((Precision)precision) + "_" + s_sequenceCases[caseNdx].caseName + "_" + shaderTypeName;
2118 ShaderDataSpec shaderSpec;
2119 shaderSpec.numInputs = s_sequenceCases[caseNdx].numInputs;
2120 shaderSpec.precision = (Precision)precision;
2121 shaderSpec.output = s_sequenceCases[caseNdx].resultType;
2122 shaderSpec.resultScale = 0.5f;
2123 shaderSpec.resultBias = 0.0f;
2124 shaderSpec.referenceScale = shaderSpec.resultScale;
2125 shaderSpec.referenceBias = shaderSpec.resultBias;
2127 for (int inputNdx = 0; inputNdx < s_sequenceCases[caseNdx].numInputs; inputNdx++)
2129 const DataType type = s_sequenceCases[caseNdx].inputTypes[inputNdx];
2130 const float rangeMin = (isDataTypeFloatOrVec(type) ? -0.5f : (isDataTypeIntOrIVec(type) ? -2.0f : (isDataTypeUintOrUVec(type) ? 0.0f : -1.0f)));
2131 const float rangeMax = (isDataTypeFloatOrVec(type) ? 0.5f : (isDataTypeIntOrIVec(type) ? 2.0f : (isDataTypeUintOrUVec(type) ? 2.0f : 1.0f)));
2133 shaderSpec.inputs[inputNdx] = ShaderValue(type, rangeMin, rangeMax);
2136 const std::string expression = std::string("") + "res = (" + s_sequenceCases[caseNdx].expressionStr + ");";
2138 TestCaseGroup* group = s_sequenceCases[caseNdx].containsSideEffects ? sequenceSideEffGroup : sequenceNoSideEffGroup;
2139 group->addChild(new ShaderOperatorCase(m_testCtx, name.c_str(), "", isVertexCase, s_sequenceCases[caseNdx].evalFunc, expression.c_str(), shaderSpec));
2147 tcu::TestCaseGroup* createOperatorTests (tcu::TestContext& testCtx)
2149 return new ShaderOperatorTests(testCtx);