Enabled loop indexing validation for fragment shaders compiled using renderers configured for FL9_3 and below.
BUG=angleproject:1130
Change-Id: I2b5d7091c394565354b14fbf9297276dce8d92a5
Reviewed-on: https://chromium-review.googlesource.com/294733
Tested-by: Cooper Partin <coopp@microsoft.com>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/tests/gl_tests/GLSLTest.cpp b/src/tests/gl_tests/GLSLTest.cpp
index 78872d1..96e4d8b 100644
--- a/src/tests/gl_tests/GLSLTest.cpp
+++ b/src/tests/gl_tests/GLSLTest.cpp
@@ -1057,8 +1057,79 @@
EXPECT_GL_NO_ERROR();
}
+// Test that fragment shaders which contain non-constant loop indexers and compiled for FL9_3 and
+// below
+// fail with a specific error message.
+// Additionally test that the same fragment shader compiles successfully with feature levels greater
+// than FL9_3.
+TEST_P(GLSLTest, LoopIndexingValidation)
+{
+ const std::string fragmentShaderSource = SHADER_SOURCE
+ (
+ precision mediump float;
+
+ uniform float loopMax;
+
+ void main()
+ {
+ gl_FragColor = vec4(1, 0, 0, 1);
+ for (float l = 0.0; l < loopMax; l++)
+ {
+ if (loopMax > 3.0)
+ {
+ gl_FragColor.a += 0.1;
+ }
+ }
+ }
+ );
+
+ GLuint shader = glCreateShader(GL_FRAGMENT_SHADER);
+
+ const char *sourceArray[1] = {fragmentShaderSource.c_str()};
+ glShaderSource(shader, 1, sourceArray, nullptr);
+ glCompileShader(shader);
+
+ GLint compileResult;
+ glGetShaderiv(shader, GL_COMPILE_STATUS, &compileResult);
+
+ // If the test is configured to run limited to Feature Level 9_3, then it is
+ // assumed that shader compilation will fail with an expected error message containing
+ // "Loop index cannot be compared with non-constant expression"
+ if ((GetParam() == ES2_D3D11_FL9_3()))
+ {
+ if (compileResult != 0)
+ {
+ FAIL() << "Shader compilation succeeded, expected failure";
+ }
+ else
+ {
+ GLint infoLogLength;
+ glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);
+
+ std::string infoLog;
+ infoLog.resize(infoLogLength);
+ glGetShaderInfoLog(shader, static_cast<GLsizei>(infoLog.size()), NULL, &infoLog[0]);
+
+ if (infoLog.find("Loop index cannot be compared with non-constant expression") ==
+ std::string::npos)
+ {
+ FAIL() << "Shader compilation failed with unexpected error message";
+ }
+ }
+ }
+ else
+ {
+ EXPECT_NE(0, compileResult);
+ }
+
+ if (shader != 0)
+ {
+ glDeleteShader(shader);
+ }
+}
+
// 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(), ES2_D3D11());
+ANGLE_INSTANTIATE_TEST(GLSLTest, ES2_D3D9(), ES2_D3D11(), ES2_D3D11_FL9_3());
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(GLSLTest_ES3, ES3_D3D11());