Commit e180559f by Olli Etuaho Committed by Commit Bot

Use GetOperatorString when writing GLSL built-in function calls

GetOperatorString is now used when writing GLSL for built-in calls that fall under TIntermAggregate. Component wise and not component wise TOperator enums are disambiguated from each other. BUG=angleproject:1682 TEST=angle_unittests, angle_end2end_tests, WebGL conformance tests Change-Id: I861f1e94eb695eb712592df99705848b442ef07b Reviewed-on: https://chromium-review.googlesource.com/424532Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 8aee6546
......@@ -40,12 +40,12 @@ class BuiltInFunctionEmulator::BuiltInFunctionEmulationMarker : public TIntermTr
// currently identified as problematic.
switch (node->getOp())
{
case EOpLessThan:
case EOpGreaterThan:
case EOpLessThanEqual:
case EOpGreaterThanEqual:
case EOpVectorEqual:
case EOpVectorNotEqual:
case EOpEqualComponentWise:
case EOpNotEqualComponentWise:
case EOpLessThanComponentWise:
case EOpGreaterThanComponentWise:
case EOpLessThanEqualComponentWise:
case EOpGreaterThanEqualComponentWise:
case EOpMod:
case EOpPow:
case EOpAtan:
......@@ -61,8 +61,8 @@ class BuiltInFunctionEmulator::BuiltInFunctionEmulationMarker : public TIntermTr
case EOpFaceForward:
case EOpReflect:
case EOpRefract:
case EOpMulMatrixComponentWise:
case EOpOuterProduct:
case EOpMul:
break;
default:
return true;
......
......@@ -170,15 +170,24 @@ void InsertBuiltInFunctions(sh::GLenum type,
//
// Matrix Functions.
//
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMul, mat2, "matrixCompMult", mat2, mat2);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMul, mat3, "matrixCompMult", mat3, mat3);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMul, mat4, "matrixCompMult", mat4, mat4);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat2x3, "matrixCompMult", mat2x3, mat2x3);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat3x2, "matrixCompMult", mat3x2, mat3x2);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat2x4, "matrixCompMult", mat2x4, mat2x4);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat4x2, "matrixCompMult", mat4x2, mat4x2);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat3x4, "matrixCompMult", mat3x4, mat3x4);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat4x3, "matrixCompMult", mat4x3, mat4x3);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMulMatrixComponentWise, mat2, "matrixCompMult",
mat2, mat2);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMulMatrixComponentWise, mat3, "matrixCompMult",
mat3, mat3);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMulMatrixComponentWise, mat4, "matrixCompMult",
mat4, mat4);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMulMatrixComponentWise, mat2x3, "matrixCompMult",
mat2x3, mat2x3);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMulMatrixComponentWise, mat3x2, "matrixCompMult",
mat3x2, mat3x2);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMulMatrixComponentWise, mat2x4, "matrixCompMult",
mat2x4, mat2x4);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMulMatrixComponentWise, mat4x2, "matrixCompMult",
mat4x2, mat4x2);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMulMatrixComponentWise, mat3x4, "matrixCompMult",
mat3x4, mat3x4);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMulMatrixComponentWise, mat4x3, "matrixCompMult",
mat4x3, mat4x3);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat2, "outerProduct", float2,
float2);
......@@ -225,29 +234,42 @@ void InsertBuiltInFunctions(sh::GLenum type,
//
// Vector relational functions.
//
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThan, bvec, "lessThan", vec, vec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThan, bvec, "lessThan", ivec, ivec);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpLessThan, bvec, "lessThan", uvec, uvec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThanEqual, bvec, "lessThanEqual", vec, vec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThanEqual, bvec, "lessThanEqual", ivec, ivec);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpLessThanEqual, bvec, "lessThanEqual", uvec, uvec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThan, bvec, "greaterThan", vec, vec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThan, bvec, "greaterThan", ivec, ivec);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpGreaterThan, bvec, "greaterThan", uvec, uvec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThanEqual, bvec, "greaterThanEqual", vec,
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThanComponentWise, bvec, "lessThan", vec,
vec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThanEqual, bvec, "greaterThanEqual", ivec,
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThanComponentWise, bvec, "lessThan", ivec,
ivec);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpGreaterThanEqual, bvec, "greaterThanEqual", uvec,
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpLessThanComponentWise, bvec, "lessThan", uvec,
uvec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorEqual, bvec, "equal", vec, vec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorEqual, bvec, "equal", ivec, ivec);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpVectorEqual, bvec, "equal", uvec, uvec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorEqual, bvec, "equal", bvec, bvec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", vec, vec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", ivec, ivec);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", uvec, uvec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", bvec, bvec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThanEqualComponentWise, bvec, "lessThanEqual",
vec, vec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThanEqualComponentWise, bvec, "lessThanEqual",
ivec, ivec);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpLessThanEqualComponentWise, bvec, "lessThanEqual",
uvec, uvec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThanComponentWise, bvec, "greaterThan",
vec, vec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThanComponentWise, bvec, "greaterThan",
ivec, ivec);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpGreaterThanComponentWise, bvec, "greaterThan",
uvec, uvec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThanEqualComponentWise, bvec,
"greaterThanEqual", vec, vec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThanEqualComponentWise, bvec,
"greaterThanEqual", ivec, ivec);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpGreaterThanEqualComponentWise, bvec,
"greaterThanEqual", uvec, uvec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpEqualComponentWise, bvec, "equal", vec, vec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpEqualComponentWise, bvec, "equal", ivec, ivec);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpEqualComponentWise, bvec, "equal", uvec, uvec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpEqualComponentWise, bvec, "equal", bvec, bvec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpNotEqualComponentWise, bvec, "notEqual", vec,
vec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpNotEqualComponentWise, bvec, "notEqual", ivec,
ivec);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpNotEqualComponentWise, bvec, "notEqual", uvec,
uvec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpNotEqualComponentWise, bvec, "notEqual", bvec,
bvec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAny, bool1, "any", bvec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAll, bool1, "all", bvec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorLogicalNot, bvec, "not", bvec);
......
......@@ -2427,7 +2427,7 @@ TConstantUnion *TIntermConstantUnion::FoldAggregateBuiltIn(TIntermAggregate *agg
break;
}
case EOpLessThan:
case EOpLessThanComponentWise:
{
resultArray = new TConstantUnion[maxObjectSize];
for (size_t i = 0; i < maxObjectSize; i++)
......@@ -2454,7 +2454,7 @@ TConstantUnion *TIntermConstantUnion::FoldAggregateBuiltIn(TIntermAggregate *agg
break;
}
case EOpLessThanEqual:
case EOpLessThanEqualComponentWise:
{
resultArray = new TConstantUnion[maxObjectSize];
for (size_t i = 0; i < maxObjectSize; i++)
......@@ -2481,7 +2481,7 @@ TConstantUnion *TIntermConstantUnion::FoldAggregateBuiltIn(TIntermAggregate *agg
break;
}
case EOpGreaterThan:
case EOpGreaterThanComponentWise:
{
resultArray = new TConstantUnion[maxObjectSize];
for (size_t i = 0; i < maxObjectSize; i++)
......@@ -2507,7 +2507,7 @@ TConstantUnion *TIntermConstantUnion::FoldAggregateBuiltIn(TIntermAggregate *agg
}
break;
}
case EOpGreaterThanEqual:
case EOpGreaterThanEqualComponentWise:
{
resultArray = new TConstantUnion[maxObjectSize];
for (size_t i = 0; i < maxObjectSize; i++)
......@@ -2534,7 +2534,7 @@ TConstantUnion *TIntermConstantUnion::FoldAggregateBuiltIn(TIntermAggregate *agg
}
break;
case EOpVectorEqual:
case EOpEqualComponentWise:
{
resultArray = new TConstantUnion[maxObjectSize];
for (size_t i = 0; i < maxObjectSize; i++)
......@@ -2565,7 +2565,7 @@ TConstantUnion *TIntermConstantUnion::FoldAggregateBuiltIn(TIntermAggregate *agg
break;
}
case EOpVectorNotEqual:
case EOpNotEqualComponentWise:
{
resultArray = new TConstantUnion[maxObjectSize];
for (size_t i = 0; i < maxObjectSize; i++)
......@@ -2652,7 +2652,7 @@ TConstantUnion *TIntermConstantUnion::FoldAggregateBuiltIn(TIntermAggregate *agg
break;
}
case EOpMul:
case EOpMulMatrixComponentWise:
{
ASSERT(basicType == EbtFloat && (*sequence)[0]->getAsTyped()->isMatrix() &&
(*sequence)[1]->getAsTyped()->isMatrix());
......
......@@ -364,14 +364,14 @@ TIntermTyped *TIntermediate::foldAggregateBuiltIn(TIntermAggregate *aggregate,
case EOpMix:
case EOpStep:
case EOpSmoothStep:
case EOpMul:
case EOpMulMatrixComponentWise:
case EOpOuterProduct:
case EOpLessThan:
case EOpLessThanEqual:
case EOpGreaterThan:
case EOpGreaterThanEqual:
case EOpVectorEqual:
case EOpVectorNotEqual:
case EOpEqualComponentWise:
case EOpNotEqualComponentWise:
case EOpLessThanComponentWise:
case EOpLessThanEqualComponentWise:
case EOpGreaterThanComponentWise:
case EOpGreaterThanEqualComponentWise:
case EOpDistance:
case EOpDot:
case EOpCross:
......
......@@ -42,14 +42,11 @@ const char *GetOperatorString(TOperator op)
return "/";
case EOpIMod:
return "%";
case EOpEqual:
return "==";
case EOpNotEqual:
return "!=";
case EOpVectorEqual:
return "equal";
case EOpVectorNotEqual:
return "notEqual";
case EOpLessThan:
return "<";
case EOpGreaterThan:
......@@ -58,6 +55,20 @@ const char *GetOperatorString(TOperator op)
return "<=";
case EOpGreaterThanEqual:
return ">=";
case EOpEqualComponentWise:
return "equal";
case EOpNotEqualComponentWise:
return "notEqual";
case EOpLessThanComponentWise:
return "lessThan";
case EOpGreaterThanComponentWise:
return "greaterThan";
case EOpLessThanEqualComponentWise:
return "lessThanEqual";
case EOpGreaterThanEqualComponentWise:
return "greaterThanEqual";
case EOpComma:
return ",";
......@@ -66,6 +77,7 @@ const char *GetOperatorString(TOperator op)
case EOpVectorTimesMatrix:
case EOpMatrixTimesVector:
case EOpMatrixTimesScalar:
case EOpMatrixTimesMatrix:
return "*";
case EOpLogicalOr:
......@@ -224,9 +236,8 @@ const char *GetOperatorString(TOperator op)
case EOpFwidth:
return "fwidth";
case EOpMatrixTimesMatrix:
return "*";
case EOpMulMatrixComponentWise:
return "matrixCompMult";
case EOpOuterProduct:
return "outerProduct";
case EOpTranspose:
......
......@@ -42,20 +42,28 @@ enum TOperator
EOpMul,
EOpDiv,
EOpIMod,
EOpEqual,
EOpNotEqual,
EOpVectorEqual,
EOpVectorNotEqual,
EOpLessThan,
EOpGreaterThan,
EOpLessThanEqual,
EOpGreaterThanEqual,
EOpEqualComponentWise,
EOpNotEqualComponentWise,
EOpLessThanComponentWise,
EOpLessThanEqualComponentWise,
EOpGreaterThanComponentWise,
EOpGreaterThanEqualComponentWise,
EOpComma,
EOpVectorTimesScalar,
EOpVectorTimesMatrix,
EOpMatrixTimesVector,
EOpMatrixTimesScalar,
EOpMatrixTimesMatrix,
EOpLogicalOr,
EOpLogicalXor,
......@@ -145,8 +153,7 @@ enum TOperator
EOpDFdy, // Fragment only, OES_standard_derivatives extension
EOpFwidth, // Fragment only, OES_standard_derivatives extension
EOpMatrixTimesMatrix,
EOpMulMatrixComponentWise,
EOpOuterProduct,
EOpTranspose,
EOpDeterminant,
......
......@@ -140,12 +140,16 @@ void TOutputGLSLBase::writeTriplet(Visit visit,
}
void TOutputGLSLBase::writeBuiltInFunctionTriplet(Visit visit,
const char *preStr,
TOperator op,
bool useEmulatedFunction)
{
TString preString =
useEmulatedFunction ? BuiltInFunctionEmulator::GetEmulatedFunctionName(preStr) : preStr;
writeTriplet(visit, preString.c_str(), ", ", ")");
TString opStr(GetOperatorString(op));
opStr += "(";
if (useEmulatedFunction)
{
opStr = BuiltInFunctionEmulator::GetEmulatedFunctionName(opStr);
}
writeTriplet(visit, opStr.c_str(), ", ", ")");
}
void TOutputGLSLBase::writeLayoutQualifier(const TType &type)
......@@ -1039,100 +1043,38 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node)
writeConstructorTriplet(visit, node->getType());
break;
case EOpOuterProduct:
writeBuiltInFunctionTriplet(visit, "outerProduct(", useEmulatedFunction);
break;
case EOpLessThan:
writeBuiltInFunctionTriplet(visit, "lessThan(", useEmulatedFunction);
break;
case EOpGreaterThan:
writeBuiltInFunctionTriplet(visit, "greaterThan(", useEmulatedFunction);
break;
case EOpLessThanEqual:
writeBuiltInFunctionTriplet(visit, "lessThanEqual(", useEmulatedFunction);
break;
case EOpGreaterThanEqual:
writeBuiltInFunctionTriplet(visit, "greaterThanEqual(", useEmulatedFunction);
break;
case EOpVectorEqual:
writeBuiltInFunctionTriplet(visit, "equal(", useEmulatedFunction);
break;
case EOpVectorNotEqual:
writeBuiltInFunctionTriplet(visit, "notEqual(", useEmulatedFunction);
break;
case EOpEqualComponentWise:
case EOpNotEqualComponentWise:
case EOpLessThanComponentWise:
case EOpGreaterThanComponentWise:
case EOpLessThanEqualComponentWise:
case EOpGreaterThanEqualComponentWise:
case EOpMod:
writeBuiltInFunctionTriplet(visit, "mod(", useEmulatedFunction);
break;
case EOpModf:
writeBuiltInFunctionTriplet(visit, "modf(", useEmulatedFunction);
break;
case EOpPow:
writeBuiltInFunctionTriplet(visit, "pow(", useEmulatedFunction);
break;
case EOpAtan:
writeBuiltInFunctionTriplet(visit, "atan(", useEmulatedFunction);
break;
case EOpMin:
writeBuiltInFunctionTriplet(visit, "min(", useEmulatedFunction);
break;
case EOpMax:
writeBuiltInFunctionTriplet(visit, "max(", useEmulatedFunction);
break;
case EOpClamp:
writeBuiltInFunctionTriplet(visit, "clamp(", useEmulatedFunction);
break;
case EOpMix:
writeBuiltInFunctionTriplet(visit, "mix(", useEmulatedFunction);
break;
case EOpStep:
writeBuiltInFunctionTriplet(visit, "step(", useEmulatedFunction);
break;
case EOpSmoothStep:
writeBuiltInFunctionTriplet(visit, "smoothstep(", useEmulatedFunction);
break;
case EOpDistance:
writeBuiltInFunctionTriplet(visit, "distance(", useEmulatedFunction);
break;
case EOpDot:
writeBuiltInFunctionTriplet(visit, "dot(", useEmulatedFunction);
break;
case EOpCross:
writeBuiltInFunctionTriplet(visit, "cross(", useEmulatedFunction);
break;
case EOpFaceForward:
writeBuiltInFunctionTriplet(visit, "faceforward(", useEmulatedFunction);
break;
case EOpReflect:
writeBuiltInFunctionTriplet(visit, "reflect(", useEmulatedFunction);
break;
case EOpRefract:
writeBuiltInFunctionTriplet(visit, "refract(", useEmulatedFunction);
break;
case EOpMul:
writeBuiltInFunctionTriplet(visit, "matrixCompMult(", useEmulatedFunction);
break;
case EOpMulMatrixComponentWise:
case EOpOuterProduct:
case EOpBarrier:
writeBuiltInFunctionTriplet(visit, "barrier(", useEmulatedFunction);
break;
case EOpMemoryBarrier:
writeBuiltInFunctionTriplet(visit, "memoryBarrier(", useEmulatedFunction);
break;
case EOpMemoryBarrierAtomicCounter:
writeBuiltInFunctionTriplet(visit, "memoryBarrierAtomicCounter(", useEmulatedFunction);
break;
case EOpMemoryBarrierBuffer:
writeBuiltInFunctionTriplet(visit, "memoryBarrierBuffer(", useEmulatedFunction);
break;
case EOpMemoryBarrierImage:
writeBuiltInFunctionTriplet(visit, "memoryBarrierImage(", useEmulatedFunction);
break;
case EOpMemoryBarrierShared:
writeBuiltInFunctionTriplet(visit, "memoryBarrierShared(", useEmulatedFunction);
break;
case EOpGroupMemoryBarrier:
writeBuiltInFunctionTriplet(visit, "groupMemoryBarrier(", useEmulatedFunction);
writeBuiltInFunctionTriplet(visit, node->getOp(), useEmulatedFunction);
break;
default:
UNREACHABLE();
......
......@@ -81,7 +81,7 @@ class TOutputGLSLBase : public TIntermTraverser
void declareInterfaceBlockLayout(const TInterfaceBlock *interfaceBlock);
void declareInterfaceBlock(const TInterfaceBlock *interfaceBlock);
void writeBuiltInFunctionTriplet(Visit visit, const char *preStr, bool useEmulatedFunction);
void writeBuiltInFunctionTriplet(Visit visit, TOperator op, bool useEmulatedFunction);
const char *mapQualifierToString(TQualifier qialifier);
......
......@@ -1846,24 +1846,24 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
outputTriplet(out, visit, (structName + "_ctor(").c_str(), ", ", ")");
}
break;
case EOpLessThan:
case EOpEqualComponentWise:
outputTriplet(out, visit, "(", " == ", ")");
break;
case EOpNotEqualComponentWise:
outputTriplet(out, visit, "(", " != ", ")");
break;
case EOpLessThanComponentWise:
outputTriplet(out, visit, "(", " < ", ")");
break;
case EOpGreaterThan:
case EOpGreaterThanComponentWise:
outputTriplet(out, visit, "(", " > ", ")");
break;
case EOpLessThanEqual:
case EOpLessThanEqualComponentWise:
outputTriplet(out, visit, "(", " <= ", ")");
break;
case EOpGreaterThanEqual:
case EOpGreaterThanEqualComponentWise:
outputTriplet(out, visit, "(", " >= ", ")");
break;
case EOpVectorEqual:
outputTriplet(out, visit, "(", " == ", ")");
break;
case EOpVectorNotEqual:
outputTriplet(out, visit, "(", " != ", ")");
break;
case EOpMod:
ASSERT(node->getUseEmulatedFunction());
writeEmulatedFunctionTriplet(out, visit, "mod(");
......@@ -1934,7 +1934,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
ASSERT(node->getUseEmulatedFunction());
writeEmulatedFunctionTriplet(out, visit, "outerProduct(");
break;
case EOpMul:
case EOpMulMatrixComponentWise:
outputTriplet(out, visit, "(", " * ", ")");
break;
default:
......
......@@ -3898,13 +3898,20 @@ bool TParseContext::binaryOpCommonCheck(TOperator op,
GetOperatorString(op));
return false;
}
if ((left->getNominalSize() != right->getNominalSize()) ||
(left->getSecondarySize() != right->getSecondarySize()))
{
error(loc, "dimension mismatch", GetOperatorString(op));
return false;
}
break;
case EOpLessThan:
case EOpGreaterThan:
case EOpLessThanEqual:
case EOpGreaterThanEqual:
if ((left->getNominalSize() != right->getNominalSize()) ||
(left->getSecondarySize() != right->getSecondarySize()))
if (!left->isScalar() || !right->isScalar())
{
error(loc, "comparison operator only defined for scalars", GetOperatorString(op));
return false;
}
break;
......@@ -4011,17 +4018,10 @@ TIntermTyped *TParseContext::addBinaryMathInternal(TOperator op,
{
case EOpEqual:
case EOpNotEqual:
break;
case EOpLessThan:
case EOpGreaterThan:
case EOpLessThanEqual:
case EOpGreaterThanEqual:
ASSERT(!left->isArray() && !right->isArray() && !left->getType().getStruct() &&
!right->getType().getStruct());
if (left->isMatrix() || left->isVector())
{
return nullptr;
}
break;
case EOpLogicalOr:
case EOpLogicalXor:
......
......@@ -608,23 +608,23 @@ bool TOutputTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
out << "Construct structure";
break;
case EOpLessThan:
out << "Compare Less Than";
case EOpEqualComponentWise:
out << "component-wise equal";
break;
case EOpGreaterThan:
out << "Compare Greater Than";
case EOpNotEqualComponentWise:
out << "component-wise not equal";
break;
case EOpLessThanEqual:
out << "Compare Less Than or Equal";
case EOpLessThanComponentWise:
out << "component-wise less than";
break;
case EOpGreaterThanEqual:
out << "Compare Greater Than or Equal";
case EOpGreaterThanComponentWise:
out << "component-wise greater than";
break;
case EOpVectorEqual:
out << "Equal";
case EOpLessThanEqualComponentWise:
out << "component-wise less than or equal";
break;
case EOpVectorNotEqual:
out << "NotEqual";
case EOpGreaterThanEqualComponentWise:
out << "component-wise greater than or equal";
break;
case EOpMod:
......@@ -678,7 +678,7 @@ bool TOutputTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
case EOpRefract:
out << "refract";
break;
case EOpMul:
case EOpMulMatrixComponentWise:
out << "component-wise multiply";
break;
......
......@@ -215,8 +215,9 @@ TEST_F(TypeTrackingTest, BuiltInVecToBoolFunctionResultType)
"}\n";
compile(shaderString);
ASSERT_FALSE(foundErrorInIntermediateTree());
ASSERT_TRUE(foundInIntermediateTree("Less Than (2-component vector of bool)"));
ASSERT_TRUE(foundInIntermediateTree("Greater Than (2-component vector of bool)"));
ASSERT_TRUE(foundInIntermediateTree("component-wise less than (2-component vector of bool)"));
ASSERT_TRUE(
foundInIntermediateTree("component-wise greater than (2-component vector of bool)"));
}
TEST_F(TypeTrackingTest, Texture2DResultTypeAndPrecision)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment