Commit 5e5c826c by Olli Etuaho

Fix float-int conversion return type precision tracking

Float-int conversion functions are defined to always return highp values. BUG=angleproject:865 TEST=angle_unittests Change-Id: Idf243b483f7b5edfcb54de2755af11e17c3756d3 Reviewed-on: https://chromium-review.googlesource.com/262413Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarNicolas Capens <capn@chromium.org>
parent cd69f1c9
......@@ -189,6 +189,10 @@ TIntermTyped *TIntermediate::addUnaryMath(
switch (op)
{
case EOpFloatBitsToInt:
case EOpFloatBitsToUint:
case EOpIntBitsToFloat:
case EOpUintBitsToFloat:
case EOpPackSnorm2x16:
case EOpPackUnorm2x16:
case EOpPackHalf2x16:
......
......@@ -371,3 +371,44 @@ TEST_F(TypeTrackingTest, BuiltInAbsSignFunctionIntResultTypeAndPrecision)
ASSERT_TRUE(foundInIntermediateTree("Absolute value (mediump int)"));
ASSERT_TRUE(foundInIntermediateTree("Sign (mediump int)"));
}
TEST_F(TypeTrackingTest, BuiltInFloatBitsToIntResultTypeAndPrecision)
{
// ESSL 3.00 section 8.3: floatBitsTo(U)int returns a highp value.
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"precision mediump int;\n"
"uniform float f;\n"
"out vec4 my_FragColor;\n"
"void main() {\n"
" int i = floatBitsToInt(f);\n"
" uint u = floatBitsToUint(f);\n"
" my_FragColor = vec4(0.0, 0.0, 0.0, 1.0); \n"
"}\n";
compile(shaderString);
ASSERT_FALSE(foundErrorInIntermediateTree());
ASSERT_TRUE(foundInIntermediateTree("float bits to int (highp int)"));
ASSERT_TRUE(foundInIntermediateTree("float bits to uint (highp uint)"));
}
TEST_F(TypeTrackingTest, BuiltInIntBitsToFloatResultTypeAndPrecision)
{
// ESSL 3.00 section 8.3: (u)intBitsToFloat returns a highp value.
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"precision mediump int;\n"
"uniform int i;\n"
"uniform uint u;\n"
"out vec4 my_FragColor;\n"
"void main() {\n"
" float f1 = intBitsToFloat(i);\n"
" float f2 = uintBitsToFloat(u);\n"
" my_FragColor = vec4(f1, f2, 0.0, 1.0); \n"
"}\n";
compile(shaderString);
ASSERT_FALSE(foundErrorInIntermediateTree());
ASSERT_TRUE(foundInIntermediateTree("int bits to float (highp float)"));
ASSERT_TRUE(foundInIntermediateTree("uint bits to float (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