Commit a2aff2a4 by Olli Etuaho Committed by Commit Bot

Use GetOperatorString in intermediate output

The special names for built-ins used in intermediate output are kept only where they add some significant value, like clearly disambiguating between component-wise and non-component-wise ops. Otherwise intermediate output now relies on GetOperatorString to give names for ops. This will make it easier to add new built-in functions. This also fixes intermediate output for TIntermSwizzle, dFdx, dFdy and fwidth. BUG=angleproject:1730 TEST=angle_unittests Change-Id: Ifa06b886ad8e24b0820513adae8decd60d80a0e7 Reviewed-on: https://chromium-review.googlesource.com/431032Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 492cfab2
......@@ -95,7 +95,12 @@ bool TOutputTraverser::visitSwizzle(Visit visit, TIntermSwizzle *node)
{
TInfoSinkBase &out = sink;
OutputTreeText(out, node, mDepth);
out << "vector swizzle";
out << "vector swizzle (";
node->writeOffsetsAsXYZW(&out);
out << ")";
out << " (" << node->getCompleteString() << ")";
out << "\n";
return true;
}
......@@ -295,6 +300,8 @@ bool TOutputTraverser::visitUnary(Visit visit, TIntermUnary *node)
switch (node->getOp())
{
// Give verbose names for ops that have special syntax and some built-in functions that are
// easy to confuse with others, but mostly use GLSL names for functions.
case EOpNegative:
out << "Negate value";
break;
......@@ -321,166 +328,13 @@ bool TOutputTraverser::visitUnary(Visit visit, TIntermUnary *node)
out << "Pre-Decrement";
break;
case EOpRadians:
out << "radians";
break;
case EOpDegrees:
out << "degrees";
break;
case EOpSin:
out << "sine";
break;
case EOpCos:
out << "cosine";
break;
case EOpTan:
out << "tangent";
break;
case EOpAsin:
out << "arc sine";
break;
case EOpAcos:
out << "arc cosine";
break;
case EOpAtan:
out << "arc tangent";
break;
case EOpSinh:
out << "hyperbolic sine";
break;
case EOpCosh:
out << "hyperbolic cosine";
break;
case EOpTanh:
out << "hyperbolic tangent";
break;
case EOpAsinh:
out << "arc hyperbolic sine";
break;
case EOpAcosh:
out << "arc hyperbolic cosine";
break;
case EOpAtanh:
out << "arc hyperbolic tangent";
break;
case EOpExp:
out << "exp";
break;
case EOpLog:
out << "log";
break;
case EOpExp2:
out << "exp2";
break;
case EOpLog2:
out << "log2";
break;
case EOpSqrt:
out << "sqrt";
break;
case EOpInverseSqrt:
out << "inverse sqrt";
break;
case EOpAbs:
out << "Absolute value";
break;
case EOpSign:
out << "Sign";
break;
case EOpFloor:
out << "Floor";
break;
case EOpTrunc:
out << "Truncate";
break;
case EOpRound:
out << "Round";
break;
case EOpRoundEven:
out << "Round half even";
break;
case EOpCeil:
out << "Ceiling";
break;
case EOpFract:
out << "Fraction";
break;
case EOpIsNan:
out << "Is not a number";
break;
case EOpIsInf:
out << "Is infinity";
break;
case EOpFloatBitsToInt:
out << "float bits to int";
break;
case EOpFloatBitsToUint:
out << "float bits to uint";
break;
case EOpIntBitsToFloat:
out << "int bits to float";
break;
case EOpUintBitsToFloat:
out << "uint bits to float";
break;
case EOpPackSnorm2x16:
out << "pack Snorm 2x16";
break;
case EOpPackUnorm2x16:
out << "pack Unorm 2x16";
break;
case EOpPackHalf2x16:
out << "pack half 2x16";
break;
case EOpUnpackSnorm2x16:
out << "unpack Snorm 2x16";
break;
case EOpUnpackUnorm2x16:
out << "unpack Unorm 2x16";
break;
case EOpUnpackHalf2x16:
out << "unpack half 2x16";
break;
case EOpLength:
out << "length";
break;
case EOpNormalize:
out << "normalize";
break;
// case EOpDPdx: out << "dPdx"; break;
// case EOpDPdy: out << "dPdy"; break;
// case EOpFwidth: out << "fwidth"; break;
case EOpDeterminant:
out << "determinant";
break;
case EOpTranspose:
out << "transpose";
break;
case EOpInverse:
out << "inverse";
break;
case EOpAny:
out << "any";
break;
case EOpAll:
out << "all";
break;
case EOpLogicalNotComponentWise:
out << "component-wise not";
break;
default:
out.prefix(SH_ERROR);
out << "Bad unary op";
out << GetOperatorString(node->getOp());
break;
}
out << " (" << node->getCompleteString() << ")";
......@@ -532,89 +386,26 @@ bool TOutputTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
return true;
}
if (node->isConstructor())
{
if (node->getOp() == EOpConstructStruct)
{
out << "Construct structure";
}
else
{
out << "Construct " << GetOperatorString(node->getOp());
}
}
else
{
// Give verbose names for some built-in functions that are easy to confuse with others, but
// mostly use GLSL names for functions.
switch (node->getOp())
{
case EOpFunctionCall:
OutputFunction(out, "Function Call", node->getFunctionSymbolInfo());
break;
case EOpConstructFloat:
out << "Construct float";
break;
case EOpConstructVec2:
out << "Construct vec2";
break;
case EOpConstructVec3:
out << "Construct vec3";
break;
case EOpConstructVec4:
out << "Construct vec4";
break;
case EOpConstructBool:
out << "Construct bool";
break;
case EOpConstructBVec2:
out << "Construct bvec2";
break;
case EOpConstructBVec3:
out << "Construct bvec3";
break;
case EOpConstructBVec4:
out << "Construct bvec4";
break;
case EOpConstructInt:
out << "Construct int";
break;
case EOpConstructIVec2:
out << "Construct ivec2";
break;
case EOpConstructIVec3:
out << "Construct ivec3";
break;
case EOpConstructIVec4:
out << "Construct ivec4";
break;
case EOpConstructUInt:
out << "Construct uint";
break;
case EOpConstructUVec2:
out << "Construct uvec2";
break;
case EOpConstructUVec3:
out << "Construct uvec3";
break;
case EOpConstructUVec4:
out << "Construct uvec4";
break;
case EOpConstructMat2:
out << "Construct mat2";
break;
case EOpConstructMat2x3:
out << "Construct mat2x3";
break;
case EOpConstructMat2x4:
out << "Construct mat2x4";
break;
case EOpConstructMat3x2:
out << "Construct mat3x2";
break;
case EOpConstructMat3:
out << "Construct mat3";
break;
case EOpConstructMat3x4:
out << "Construct mat3x4";
break;
case EOpConstructMat4x2:
out << "Construct mat4x2";
break;
case EOpConstructMat4x3:
out << "Construct mat4x3";
break;
case EOpConstructMat4:
out << "Construct mat4";
break;
case EOpConstructStruct:
out << "Construct structure";
break;
case EOpEqualComponentWise:
out << "component-wise equal";
......@@ -635,68 +426,20 @@ bool TOutputTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
out << "component-wise greater than or equal";
break;
case EOpMod:
out << "mod";
break;
case EOpModf:
out << "modf";
break;
case EOpPow:
out << "pow";
break;
case EOpAtan:
out << "arc tangent";
break;
case EOpMin:
out << "min";
break;
case EOpMax:
out << "max";
break;
case EOpClamp:
out << "clamp";
break;
case EOpMix:
out << "mix";
break;
case EOpStep:
out << "step";
break;
case EOpSmoothStep:
out << "smoothstep";
break;
case EOpDistance:
out << "distance";
break;
case EOpDot:
out << "dot-product";
out << "dot product";
break;
case EOpCross:
out << "cross-product";
break;
case EOpFaceForward:
out << "face-forward";
break;
case EOpReflect:
out << "reflect";
break;
case EOpRefract:
out << "refract";
out << "cross product";
break;
case EOpMulMatrixComponentWise:
out << "component-wise multiply";
break;
case EOpOuterProduct:
out << "outer product";
break;
default:
out.prefix(SH_ERROR);
out << "Bad aggregation op";
out << GetOperatorString(node->getOp());
break;
}
}
out << " (" << node->getCompleteString() << ")";
......
......@@ -104,7 +104,7 @@ TEST_F(TypeTrackingTest, BuiltInFunctionResultPrecision)
"}\n";
compile(shaderString);
ASSERT_FALSE(foundErrorInIntermediateTree());
ASSERT_TRUE(foundInIntermediateTree("sine (mediump float)"));
ASSERT_TRUE(foundInIntermediateTree("sin (mediump float)"));
}
TEST_F(TypeTrackingTest, BinaryMathResultPrecision)
......@@ -135,7 +135,7 @@ TEST_F(TypeTrackingTest, BuiltInVecFunctionResultTypeAndPrecision)
compile(shaderString);
ASSERT_FALSE(foundErrorInIntermediateTree());
ASSERT_TRUE(foundInIntermediateTree("length (mediump float)"));
ASSERT_TRUE(foundInIntermediateTree("dot-product (mediump float)"));
ASSERT_TRUE(foundInIntermediateTree("dot product (mediump float)"));
ASSERT_TRUE(foundInIntermediateTree("distance (mediump float)"));
}
......@@ -178,7 +178,7 @@ TEST_F(TypeTrackingTest, BuiltInFunctionChoosesHigherPrecision)
"}\n";
compile(shaderString);
ASSERT_FALSE(foundErrorInIntermediateTree());
ASSERT_TRUE(foundInIntermediateTree("dot-product (mediump float)"));
ASSERT_TRUE(foundInIntermediateTree("dot product (mediump float)"));
ASSERT_TRUE(foundInIntermediateTree("distance (mediump float)"));
}
......@@ -328,9 +328,9 @@ TEST_F(TypeTrackingTest, PackResultTypeAndPrecision)
"}\n";
compile(shaderString);
ASSERT_FALSE(foundErrorInIntermediateTree());
ASSERT_TRUE(foundInIntermediateTree("pack Snorm 2x16 (highp uint)"));
ASSERT_TRUE(foundInIntermediateTree("pack Unorm 2x16 (highp uint)"));
ASSERT_TRUE(foundInIntermediateTree("pack half 2x16 (highp uint)"));
ASSERT_TRUE(foundInIntermediateTree("packSnorm2x16 (highp uint)"));
ASSERT_TRUE(foundInIntermediateTree("packUnorm2x16 (highp uint)"));
ASSERT_TRUE(foundInIntermediateTree("packHalf2x16 (highp uint)"));
}
TEST_F(TypeTrackingTest, UnpackNormResultTypeAndPrecision)
......@@ -353,8 +353,8 @@ TEST_F(TypeTrackingTest, UnpackNormResultTypeAndPrecision)
"}\n";
compile(shaderString);
ASSERT_FALSE(foundErrorInIntermediateTree());
ASSERT_TRUE(foundInIntermediateTree("unpack Snorm 2x16 (highp 2-component vector of float)"));
ASSERT_TRUE(foundInIntermediateTree("unpack Unorm 2x16 (highp 2-component vector of float)"));
ASSERT_TRUE(foundInIntermediateTree("unpackSnorm2x16 (highp 2-component vector of float)"));
ASSERT_TRUE(foundInIntermediateTree("unpackUnorm2x16 (highp 2-component vector of float)"));
}
TEST_F(TypeTrackingTest, UnpackHalfResultTypeAndPrecision)
......@@ -376,7 +376,7 @@ TEST_F(TypeTrackingTest, UnpackHalfResultTypeAndPrecision)
"}\n";
compile(shaderString);
ASSERT_FALSE(foundErrorInIntermediateTree());
ASSERT_TRUE(foundInIntermediateTree("unpack half 2x16 (mediump 2-component vector of float)"));
ASSERT_TRUE(foundInIntermediateTree("unpackHalf2x16 (mediump 2-component vector of float)"));
}
TEST_F(TypeTrackingTest, BuiltInAbsSignFunctionFloatResultTypeAndPrecision)
......@@ -391,8 +391,8 @@ TEST_F(TypeTrackingTest, BuiltInAbsSignFunctionFloatResultTypeAndPrecision)
"}\n";
compile(shaderString);
ASSERT_FALSE(foundErrorInIntermediateTree());
ASSERT_TRUE(foundInIntermediateTree("Absolute value (mediump float)"));
ASSERT_TRUE(foundInIntermediateTree("Sign (mediump float)"));
ASSERT_TRUE(foundInIntermediateTree("abs (mediump float)"));
ASSERT_TRUE(foundInIntermediateTree("sign (mediump float)"));
}
TEST_F(TypeTrackingTest, BuiltInAbsSignFunctionIntResultTypeAndPrecision)
......@@ -410,8 +410,8 @@ TEST_F(TypeTrackingTest, BuiltInAbsSignFunctionIntResultTypeAndPrecision)
"}\n";
compile(shaderString);
ASSERT_FALSE(foundErrorInIntermediateTree());
ASSERT_TRUE(foundInIntermediateTree("Absolute value (mediump int)"));
ASSERT_TRUE(foundInIntermediateTree("Sign (mediump int)"));
ASSERT_TRUE(foundInIntermediateTree("abs (mediump int)"));
ASSERT_TRUE(foundInIntermediateTree("sign (mediump int)"));
}
TEST_F(TypeTrackingTest, BuiltInFloatBitsToIntResultTypeAndPrecision)
......@@ -430,8 +430,8 @@ TEST_F(TypeTrackingTest, BuiltInFloatBitsToIntResultTypeAndPrecision)
"}\n";
compile(shaderString);
ASSERT_FALSE(foundErrorInIntermediateTree());
ASSERT_TRUE(foundInIntermediateTree("float bits to int (highp int)"));
ASSERT_TRUE(foundInIntermediateTree("float bits to uint (highp uint)"));
ASSERT_TRUE(foundInIntermediateTree("floatBitsToInt (highp int)"));
ASSERT_TRUE(foundInIntermediateTree("floatBitsToUint (highp uint)"));
}
TEST_F(TypeTrackingTest, BuiltInIntBitsToFloatResultTypeAndPrecision)
......@@ -451,6 +451,6 @@ TEST_F(TypeTrackingTest, BuiltInIntBitsToFloatResultTypeAndPrecision)
"}\n";
compile(shaderString);
ASSERT_FALSE(foundErrorInIntermediateTree());
ASSERT_TRUE(foundInIntermediateTree("int bits to float (highp float)"));
ASSERT_TRUE(foundInIntermediateTree("uint bits to float (highp float)"));
ASSERT_TRUE(foundInIntermediateTree("intBitsToFloat (highp float)"));
ASSERT_TRUE(foundInIntermediateTree("uintBitsToFloat (highp float)"));
}
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