Add ESSL 3.10 integer math built-ins
This adds built-ins found in ESSL 3.10 section 8.8 Integer functions.
This includes constant folding support for functions that may be
constant folded, and support for both GLSL and HLSL output. In HLSL
several of the functions need to be emulated.
The precision qualification for the return value of some of these
functions is determined by special rules, that are now part of type
promotion for TIntermUnary nodes and determining the type of
TIntermAggregate nodes.
BUG=angleproject:1730
TEST=angle_unittests
TEST=dEQP-GLES31.functional.shaders.builtin_functions.integer.*
Change-Id: Ib0056c17671c42b6496c2f0ef059b99f8f25c122
Reviewed-on: https://chromium-review.googlesource.com/431310
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/tests/gl_tests/GLSLTest.cpp b/src/tests/gl_tests/GLSLTest.cpp
index 31a9b15..c3e791d 100644
--- a/src/tests/gl_tests/GLSLTest.cpp
+++ b/src/tests/gl_tests/GLSLTest.cpp
@@ -458,6 +458,22 @@
}
};
+class GLSLTest_ES31 : public GLSLTest
+{
+ void SetUp() override
+ {
+ ANGLETest::SetUp();
+
+ mSimpleVSSource =
+ "#version 310 es\n"
+ "in vec4 inputAttribute;"
+ "void main()"
+ "{"
+ " gl_Position = inputAttribute;"
+ "}";
+ }
+};
+
TEST_P(GLSLTest, NamelessScopedStructs)
{
const std::string fragmentShaderSource = SHADER_SOURCE
@@ -2591,6 +2607,30 @@
} // anonymous namespace
+// Test that FindLSB and FindMSB return correct values in their corner cases.
+TEST_P(GLSLTest_ES31, FindMSBAndFindLSBCornerCases)
+{
+ const std::string &fragmentShader =
+ "#version 310 es\n"
+ "precision mediump float;\n"
+ "out vec4 my_FragColor;\n"
+ "uniform int u_zero;\n"
+ "void main() {\n"
+ " if (findLSB(u_zero) == -1 && findMSB(u_zero) == -1 && findMSB(u_zero - 1) == -1)\n"
+ " {\n"
+ " my_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
+ " }\n"
+ " else\n"
+ " {\n"
+ " my_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
+ " }\n"
+ "}\n";
+
+ ANGLE_GL_PROGRAM(program, mSimpleVSSource, fragmentShader);
+ drawQuad(program.get(), "inputAttribute", 0.5f);
+ EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
+}
+
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(GLSLTest,
ES2_D3D9(),
@@ -2605,3 +2645,5 @@
ANGLE_INSTANTIATE_TEST(GLSLTest_ES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
ANGLE_INSTANTIATE_TEST(WebGLGLSLTest, ES2_D3D11(), ES2_OPENGL(), ES2_OPENGLES());
+
+ANGLE_INSTANTIATE_TEST(GLSLTest_ES31, ES31_D3D11(), ES31_OPENGL(), ES31_OPENGLES());