Commit 6b19d765 by Arun Patole Committed by Olli Etuaho

Implement missing variants of abs/sign

This change adds ANGLE support for abs/sign variants introduced in ESSL3. BUG=angle:923 TEST=Unit tests, dEQP tests Unit Tests: TypeTrackingTest.BuiltInAbsSignFunctionFloatResultTypeAndPrecision TypeTrackingTest.BuiltInAbsSignFunctionIntResultTypeAndPrecision dEQP tests passing 100% because of this change: dEQP-GLES3.functional.shaders.builtin_functions.common.abs dEQP-GLES3.functional.shaders.builtin_functions.common.sign Change-Id: I2a3b028611f0eaaac3c031f8926d34a0e146663d Reviewed-on: https://chromium-review.googlesource.com/251491Reviewed-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent 4ebb82e5
...@@ -151,11 +151,21 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR ...@@ -151,11 +151,21 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR
symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "abs", float3); symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "abs", float3);
symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "abs", float4); symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "abs", float4);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "abs", int1);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "abs", int2);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "abs", int3);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "abs", int4);
symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sign", float1); symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sign", float1);
symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sign", float2); symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sign", float2);
symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sign", float3); symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sign", float3);
symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sign", float4); symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sign", float4);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "sign", int1);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "sign", int2);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "sign", int3);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "sign", int4);
symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "floor", float1); symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "floor", float1);
symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "floor", float2); symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "floor", float2);
symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "floor", float3); symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "floor", float3);
...@@ -907,6 +917,8 @@ void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec, ...@@ -907,6 +917,8 @@ void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec,
symbolTable.relateToOperator(COMMON_BUILTINS, "step", EOpStep); symbolTable.relateToOperator(COMMON_BUILTINS, "step", EOpStep);
symbolTable.relateToOperator(COMMON_BUILTINS, "smoothstep", EOpSmoothStep); symbolTable.relateToOperator(COMMON_BUILTINS, "smoothstep", EOpSmoothStep);
symbolTable.relateToOperator(ESSL3_BUILTINS, "abs", EOpAbs);
symbolTable.relateToOperator(ESSL3_BUILTINS, "sign", EOpSign);
symbolTable.relateToOperator(ESSL3_BUILTINS, "modf", EOpModf); symbolTable.relateToOperator(ESSL3_BUILTINS, "modf", EOpModf);
symbolTable.relateToOperator(ESSL3_BUILTINS, "min", EOpMin); symbolTable.relateToOperator(ESSL3_BUILTINS, "min", EOpMin);
symbolTable.relateToOperator(ESSL3_BUILTINS, "max", EOpMax); symbolTable.relateToOperator(ESSL3_BUILTINS, "max", EOpMax);
......
...@@ -337,7 +337,8 @@ bool TIntermUnary::promote(TInfoSink &) ...@@ -337,7 +337,8 @@ bool TIntermUnary::promote(TInfoSink &)
return false; return false;
break; break;
// operators for built-ins are already type checked against their prototype // Operators for built-ins are already type checked against their prototype
// and some of them get the type of their return value assigned elsewhere.
case EOpAny: case EOpAny:
case EOpAll: case EOpAll:
case EOpVectorLogicalNot: case EOpVectorLogicalNot:
...@@ -348,6 +349,10 @@ bool TIntermUnary::promote(TInfoSink &) ...@@ -348,6 +349,10 @@ bool TIntermUnary::promote(TInfoSink &)
case EOpUnpackHalf2x16: case EOpUnpackHalf2x16:
return true; return true;
case EOpAbs:
case EOpSign:
break;
default: default:
if (mOperand->getBasicType() != EbtFloat) if (mOperand->getBasicType() != EbtFloat)
return false; return false;
......
...@@ -336,3 +336,38 @@ TEST_F(TypeTrackingTest, UnpackHalfResultTypeAndPrecision) ...@@ -336,3 +336,38 @@ TEST_F(TypeTrackingTest, UnpackHalfResultTypeAndPrecision)
ASSERT_FALSE(foundErrorInIntermediateTree()); ASSERT_FALSE(foundErrorInIntermediateTree());
ASSERT_TRUE(foundInIntermediateTree("unpack half 2x16 (mediump 2-component vector of float)")); ASSERT_TRUE(foundInIntermediateTree("unpack half 2x16 (mediump 2-component vector of float)"));
}; };
TEST_F(TypeTrackingTest, BuiltInAbsSignFunctionFloatResultTypeAndPrecision)
{
const std::string &shaderString =
"precision mediump float;\n"
"uniform float fval1;\n"
"void main() {\n"
" float fval2 = abs(fval1);\n"
" float fval3 = sign(fval1);\n"
" gl_FragColor = vec4(fval1, 0.0, 0.0, 1.0); \n"
"}\n";
compile(shaderString);
ASSERT_FALSE(foundErrorInIntermediateTree());
ASSERT_TRUE(foundInIntermediateTree("Absolute value (mediump float)"));
ASSERT_TRUE(foundInIntermediateTree("Sign (mediump float)"));
};
TEST_F(TypeTrackingTest, BuiltInAbsSignFunctionIntResultTypeAndPrecision)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"precision mediump int;\n"
"uniform int ival1;\n"
"out vec4 my_FragColor;\n"
"void main() {\n"
" int ival2 = abs(ival1);\n"
" int ival3 = sign(ival1);\n"
" my_FragColor = vec4(0.0, 0.0, 0.0, 1.0); \n"
"}\n";
compile(shaderString);
ASSERT_FALSE(foundErrorInIntermediateTree());
ASSERT_TRUE(foundInIntermediateTree("Absolute value (mediump int)"));
ASSERT_TRUE(foundInIntermediateTree("Sign (mediump int)"));
};
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