Title: [280904] trunk
Revision
280904
Author
[email protected]
Date
2021-08-11 04:20:55 -0700 (Wed, 11 Aug 2021)

Log Message

Cherry-pick ANGLE: Revise WebGL's shaderSource validation
https://bugs.webkit.org/show_bug.cgi?id=228951

Patch by Kimmo Kinnunen <[email protected]> on 2021-08-11
Reviewed by Kenneth Russell.

Source/ThirdParty/ANGLE:

Cherry-pick ANGLE commit: b4fd46288aa65d61dc9c7140c7d1cdba3f4cdf9a
From: Kenneth Russell <[email protected]>
Date: Wed, 27 Jan 2021 15:56:58 -0800
Revise WebGL's shaderSource validation.

Per discussion in the WebGL working group, shaderSource no longer
generates INVALID_VALUE for sources containing characters outside the
ESSL character set. Compilation and/or linking is still specified to
fail when illegal constructs are used.

With this change, https://github.com/KhronosGroup/WebGL/pull/3206
passes with the passthrough command decoder.

Revise WebGL compatibility tests to follow the new rules.

* src/libANGLE/validationES2.cpp:
(gl::ValidateShaderSource):
* src/tests/gl_tests/WebGLCompatibilityTest.cpp:

LayoutTests:

Fixes tests:
webgl/1.0.x/conformance/misc/invalid-passed-params.html
webgl/1.0.x/conformance/glsl/bugs/character-set.html
webgl/2.0.y/conformance/misc/invalid-passed-params.html
webgl/2.0.y/conformance/glsl/bugs/character-set.html

* TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (280903 => 280904)


--- trunk/LayoutTests/ChangeLog	2021-08-11 10:50:40 UTC (rev 280903)
+++ trunk/LayoutTests/ChangeLog	2021-08-11 11:20:55 UTC (rev 280904)
@@ -1,3 +1,18 @@
+2021-08-11  Kimmo Kinnunen  <[email protected]>
+
+        Cherry-pick ANGLE: Revise WebGL's shaderSource validation
+        https://bugs.webkit.org/show_bug.cgi?id=228951
+
+        Reviewed by Kenneth Russell.
+
+        Fixes tests:
+        webgl/1.0.x/conformance/misc/invalid-passed-params.html
+        webgl/1.0.x/conformance/glsl/bugs/character-set.html
+        webgl/2.0.y/conformance/misc/invalid-passed-params.html
+        webgl/2.0.y/conformance/glsl/bugs/character-set.html
+
+        * TestExpectations:
+
 2021-08-11  Cathie Chen  <[email protected]>
 
         REGRESSION (r277997): Max-height not applied for image

Modified: trunk/LayoutTests/TestExpectations (280903 => 280904)


--- trunk/LayoutTests/TestExpectations	2021-08-11 10:50:40 UTC (rev 280903)
+++ trunk/LayoutTests/TestExpectations	2021-08-11 11:20:55 UTC (rev 280904)
@@ -3641,6 +3641,8 @@
 
 # Explicitly enable tests which we have fixed and do not have corresponding 1.0.3 test functionality.
 webgl/1.0.x/conformance/canvas/to-data-url-test.html [ Pass ]
+webgl/1.0.x/conformance/misc/invalid-passed-params.html [ Pass ]
+webgl/1.0.x/conformance/glsl/bugs/character-set.html [ Pass ]
 
 # WebGL conformance test suite 2.0.1 is skipped until 2.0.0 is retired.
 webgl/2.0.y [ Skip ]
@@ -3647,7 +3649,17 @@
 
 # Explicitly enable tests which we have fixed and do not have corresponding 2.0.y test functionality.
 webgl/2.0.y/conformance/canvas/to-data-url-test.html [ Pass ]
+webgl/2.0.y/conformance/misc/invalid-passed-params.html [ Pass ]
+webgl/2.0.y/conformance/glsl/bugs/character-set.html [ Pass ]
 
+# WebGL 1.0.3 and 2.0.0 tests where behavior is obsolete and WebKit contains implementation
+# and tests for the new behavior. Should be removed once 1.0.3 and 2.0.0 are retired.
+webgl/1.0.3/conformance/glsl/misc/shader-with-define-line-continuation.frag.html [ Skip ]
+webgl/1.0.3/conformance/misc/invalid-passed-params.html [ Skip ]
+webgl/2.0.0/conformance/glsl/misc/shader-with-define-line-continuation.frag.html [ Skip ]
+webgl/2.0.0/conformance/misc/invalid-passed-params.html [ Skip ]
+fast/canvas/webgl/invalid-passed-params.html [ Skip ]
+
 # pre-wrap progression. Other rendering engines agree with the result.
 webkit.org/b/206168 [ Debug ] fast/dom/insert-span-into-long-text-bug-28245.html [ Skip ]
 

Modified: trunk/Source/ThirdParty/ANGLE/ChangeLog (280903 => 280904)


--- trunk/Source/ThirdParty/ANGLE/ChangeLog	2021-08-11 10:50:40 UTC (rev 280903)
+++ trunk/Source/ThirdParty/ANGLE/ChangeLog	2021-08-11 11:20:55 UTC (rev 280904)
@@ -1,3 +1,29 @@
+2021-08-11  Kimmo Kinnunen  <[email protected]>
+
+        Cherry-pick ANGLE: Revise WebGL's shaderSource validation
+        https://bugs.webkit.org/show_bug.cgi?id=228951
+
+        Reviewed by Kenneth Russell.
+
+        Cherry-pick ANGLE commit: b4fd46288aa65d61dc9c7140c7d1cdba3f4cdf9a
+        From: Kenneth Russell <[email protected]>
+        Date: Wed, 27 Jan 2021 15:56:58 -0800
+        Revise WebGL's shaderSource validation.
+
+        Per discussion in the WebGL working group, shaderSource no longer
+        generates INVALID_VALUE for sources containing characters outside the
+        ESSL character set. Compilation and/or linking is still specified to
+        fail when illegal constructs are used.
+
+        With this change, https://github.com/KhronosGroup/WebGL/pull/3206
+        passes with the passthrough command decoder.
+
+        Revise WebGL compatibility tests to follow the new rules.
+
+        * src/libANGLE/validationES2.cpp:
+        (gl::ValidateShaderSource):
+        * src/tests/gl_tests/WebGLCompatibilityTest.cpp:
+
 2021-07-23  Dean Jackson  <[email protected]>
 
         3.5 MB system-wide footprint impact due to thread-locals in libANGLE

Modified: trunk/Source/ThirdParty/ANGLE/src/libANGLE/validationES2.cpp (280903 => 280904)


--- trunk/Source/ThirdParty/ANGLE/src/libANGLE/validationES2.cpp	2021-08-11 10:50:40 UTC (rev 280903)
+++ trunk/Source/ThirdParty/ANGLE/src/libANGLE/validationES2.cpp	2021-08-11 11:20:55 UTC (rev 280904)
@@ -805,130 +805,6 @@
     return true;
 }
 
-bool IsValidESSLShaderSourceString(const char *str, size_t len, bool lineContinuationAllowed)
-{
-    enum class ParseState
-    {
-        // Have not seen an ASCII non-whitespace character yet on
-        // this line. Possible that we might see a preprocessor
-        // directive.
-        BEGINING_OF_LINE,
-
-        // Have seen at least one ASCII non-whitespace character
-        // on this line.
-        MIDDLE_OF_LINE,
-
-        // Handling a preprocessor directive. Passes through all
-        // characters up to the end of the line. Disables comment
-        // processing.
-        IN_PREPROCESSOR_DIRECTIVE,
-
-        // Handling a single-line comment. The comment text is
-        // replaced with a single space.
-        IN_SINGLE_LINE_COMMENT,
-
-        // Handling a multi-line comment. Newlines are passed
-        // through to preserve line numbers.
-        IN_MULTI_LINE_COMMENT
-    };
-
-    ParseState state = ParseState::BEGINING_OF_LINE;
-    size_t pos       = 0;
-
-    while (pos < len)
-    {
-        char c    = str[pos];
-        char next = pos + 1 < len ? str[pos + 1] : 0;
-
-        // Check for newlines
-        if (c == '\n' || c == '\r')
-        {
-            if (state != ParseState::IN_MULTI_LINE_COMMENT)
-            {
-                state = ParseState::BEGINING_OF_LINE;
-            }
-
-            pos++;
-            continue;
-        }
-
-        switch (state)
-        {
-            case ParseState::BEGINING_OF_LINE:
-                if (c == ' ')
-                {
-                    // Maintain the BEGINING_OF_LINE state until a non-space is seen
-                    pos++;
-                }
-                else if (c == '#')
-                {
-                    state = ParseState::IN_PREPROCESSOR_DIRECTIVE;
-                    pos++;
-                }
-                else
-                {
-                    // Don't advance, re-process this character with the MIDDLE_OF_LINE state
-                    state = ParseState::MIDDLE_OF_LINE;
-                }
-                break;
-
-            case ParseState::MIDDLE_OF_LINE:
-                if (c == '/' && next == '/')
-                {
-                    state = ParseState::IN_SINGLE_LINE_COMMENT;
-                    pos++;
-                }
-                else if (c == '/' && next == '*')
-                {
-                    state = ParseState::IN_MULTI_LINE_COMMENT;
-                    pos++;
-                }
-                else if (lineContinuationAllowed && c == '\\' && (next == '\n' || next == '\r'))
-                {
-                    // Skip line continuation characters
-                }
-                else if (!IsValidESSLCharacter(c))
-                {
-                    return false;
-                }
-                pos++;
-                break;
-
-            case ParseState::IN_PREPROCESSOR_DIRECTIVE:
-                // Line-continuation characters may not be permitted.
-                // Otherwise, just pass it through. Do not parse comments in this state.
-                if (!lineContinuationAllowed && c == '\\')
-                {
-                    return false;
-                }
-                pos++;
-                break;
-
-            case ParseState::IN_SINGLE_LINE_COMMENT:
-                // Line-continuation characters are processed before comment processing.
-                // Advance string if a new line character is immediately behind
-                // line-continuation character.
-                if (c == '\\' && (next == '\n' || next == '\r'))
-                {
-                    pos++;
-                }
-                pos++;
-                break;
-
-            case ParseState::IN_MULTI_LINE_COMMENT:
-                if (c == '*' && next == '/')
-                {
-                    state = ParseState::MIDDLE_OF_LINE;
-                    pos++;
-                }
-                pos++;
-                break;
-        }
-    }
-
-    return true;
-}
-
 bool ValidateWebGLNamePrefix(const Context *context, const GLchar *name)
 {
     ASSERT(context->isWebGL());
@@ -4948,25 +4824,6 @@
         return false;
     }
 
-    // The WebGL spec (section 6.20) disallows strings containing invalid ESSL characters for
-    // shader-related entry points
-    if (context->getExtensions().webglCompatibility)
-    {
-        for (GLsizei i = 0; i < count; i++)
-        {
-            size_t len =
-                (length && length[i] >= 0) ? static_cast<size_t>(length[i]) : strlen(string[i]);
-
-            // Backslash as line-continuation is allowed in WebGL 2.0.
-            if (!IsValidESSLShaderSourceString(string[i], len,
-                                               context->getClientVersion() >= ES_3_0))
-            {
-                context->validationError(GL_INVALID_VALUE, kShaderSourceInvalidCharacters);
-                return false;
-            }
-        }
-    }
-
     Shader *shaderObject = GetValidShader(context, shader);
     if (!shaderObject)
     {

Modified: trunk/Source/ThirdParty/ANGLE/src/tests/gl_tests/WebGLCompatibilityTest.cpp (280903 => 280904)


--- trunk/Source/ThirdParty/ANGLE/src/tests/gl_tests/WebGLCompatibilityTest.cpp	2021-08-11 10:50:40 UTC (rev 280903)
+++ trunk/Source/ThirdParty/ANGLE/src/tests/gl_tests/WebGLCompatibilityTest.cpp	2021-08-11 11:20:55 UTC (rev 280904)
@@ -2156,39 +2156,27 @@
     for (char invalidChar : invalidSet)
     {
         std::string invalidAttribName = validAttribName + invalidChar;
-        const char *invalidVert[]     = {
-            "attribute float ",
-            invalidAttribName.c_str(),
-            R"(;,
+        std::string invalidVert       = "attribute float ";
+        invalidVert += invalidAttribName;
+        invalidVert += R"(;,
 void main(),
 {,
     gl_Position = vec4(1.0);,
-})",
-        };
-
-        GLuint shader = glCreateShader(GL_VERTEX_SHADER);
-        glShaderSource(shader, static_cast<GLsizei>(ArraySize(invalidVert)), invalidVert, nullptr);
-        EXPECT_GL_ERROR(GL_INVALID_VALUE);
-        glDeleteShader(shader);
+})";
+        GLuint program = CompileProgram(invalidVert.c_str(), essl1_shaders::fs::Red());
+        EXPECT_EQ(0u, program);
     }
 }
 
-// Test that line continuation is handled correctly when valdiating shader source
+// Test that line continuation is handled correctly when validating shader source
 TEST_P(WebGLCompatibilityTest, ShaderSourceLineContinuation)
 {
-    // Verify that a line continuation character (i.e. backslash) cannot be used
-    // within a preprocessor directive in a ES2 context.
-    ANGLE_SKIP_TEST_IF(getClientMajorVersion() >= 3);
+    // With recent changes to WebGL's shader source validation in
+    // https://github.com/KhronosGroup/WebGL/pull/3206 and follow-ons,
+    // the backslash character can be used in both WebGL 1.0 and 2.0
+    // contexts.
 
     const char *validVert =
-        R"(#define foo this is a test
-precision mediump float;
-void main()
-{
-    gl_Position = vec4(1.0);
-})";
-
-    const char *invalidVert =
         R"(#define foo this \
     is a test
 precision mediump float;
@@ -2197,13 +2185,9 @@
     gl_Position = vec4(1.0);
 })";
 
-    GLuint shader = glCreateShader(GL_VERTEX_SHADER);
-    glShaderSource(shader, 1, &validVert, nullptr);
-    EXPECT_GL_NO_ERROR();
-
-    glShaderSource(shader, 1, &invalidVert, nullptr);
-    EXPECT_GL_ERROR(GL_INVALID_VALUE);
-    glDeleteShader(shader);
+    GLuint program = CompileProgram(validVert, essl1_shaders::fs::Red());
+    EXPECT_NE(0u, program);
+    glDeleteProgram(program);
 }
 
 // Test that line continuation is handled correctly when valdiating shader source
@@ -2231,12 +2215,12 @@
     gl_Position = vec4(foo);
 })";
 
-    GLuint shader = glCreateShader(GL_VERTEX_SHADER);
-    glShaderSource(shader, 1, &validVert, nullptr);
-    EXPECT_GL_NO_ERROR();
-    glShaderSource(shader, 1, &invalidVert, nullptr);
-    EXPECT_GL_ERROR(GL_INVALID_VALUE);
-    glDeleteShader(shader);
+    GLuint program = CompileProgram(validVert, essl3_shaders::fs::Red());
+    EXPECT_NE(0u, program);
+    glDeleteProgram(program);
+
+    program = CompileProgram(invalidVert, essl3_shaders::fs::Red());
+    EXPECT_EQ(0u, program);
 }
 
 // Tests bindAttribLocations for reserved prefixes and length limits
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to