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