<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[280904] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/280904">280904</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2021-08-11 04:20:55 -0700 (Wed, 11 Aug 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cherry-pick ANGLE: Revise WebGL's shaderSource validation
https://bugs.webkit.org/show_bug.cgi?id=228951

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-08-11
Reviewed by Kenneth Russell.

Source/ThirdParty/ANGLE:

Cherry-pick ANGLE commit: b4fd46288aa65d61dc9c7140c7d1cdba3f4cdf9a
From: Kenneth Russell <kbr@chromium.org>
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:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkSourceThirdPartyANGLEChangeLog">trunk/Source/ThirdParty/ANGLE/ChangeLog</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrclibANGLEvalidationES2cpp">trunk/Source/ThirdParty/ANGLE/src/libANGLE/validationES2.cpp</a></li>
<li><a href="#trunkSourceThirdPartyANGLEsrctestsgl_testsWebGLCompatibilityTestcpp">trunk/Source/ThirdParty/ANGLE/src/tests/gl_tests/WebGLCompatibilityTest.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (280903 => 280904)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2021-08-11 10:50:40 UTC (rev 280903)
+++ trunk/LayoutTests/ChangeLog 2021-08-11 11:20:55 UTC (rev 280904)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2021-08-11  Kimmo Kinnunen  <kkinnunen@apple.com>
+
+        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:
+
</ins><span class="cx"> 2021-08-11  Cathie Chen  <cathiechen@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r277997): Max-height not applied for image
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (280903 => 280904)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations       2021-08-11 10:50:40 UTC (rev 280903)
+++ trunk/LayoutTests/TestExpectations  2021-08-11 11:20:55 UTC (rev 280904)
</span><span class="lines">@@ -3641,6 +3641,8 @@
</span><span class="cx"> 
</span><span class="cx"> # Explicitly enable tests which we have fixed and do not have corresponding 1.0.3 test functionality.
</span><span class="cx"> webgl/1.0.x/conformance/canvas/to-data-url-test.html [ Pass ]
</span><ins>+webgl/1.0.x/conformance/misc/invalid-passed-params.html [ Pass ]
+webgl/1.0.x/conformance/glsl/bugs/character-set.html [ Pass ]
</ins><span class="cx"> 
</span><span class="cx"> # WebGL conformance test suite 2.0.1 is skipped until 2.0.0 is retired.
</span><span class="cx"> webgl/2.0.y [ Skip ]
</span><span class="lines">@@ -3647,7 +3649,17 @@
</span><span class="cx"> 
</span><span class="cx"> # Explicitly enable tests which we have fixed and do not have corresponding 2.0.y test functionality.
</span><span class="cx"> webgl/2.0.y/conformance/canvas/to-data-url-test.html [ Pass ]
</span><ins>+webgl/2.0.y/conformance/misc/invalid-passed-params.html [ Pass ]
+webgl/2.0.y/conformance/glsl/bugs/character-set.html [ Pass ]
</ins><span class="cx"> 
</span><ins>+# 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 ]
+
</ins><span class="cx"> # pre-wrap progression. Other rendering engines agree with the result.
</span><span class="cx"> webkit.org/b/206168 [ Debug ] fast/dom/insert-span-into-long-text-bug-28245.html [ Skip ]
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/ChangeLog (280903 => 280904)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2021-08-11  Kimmo Kinnunen  <kkinnunen@apple.com>
+
+        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 <kbr@chromium.org>
+        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:
+
</ins><span class="cx"> 2021-07-23  Dean Jackson  <dino@apple.com>
</span><span class="cx"> 
</span><span class="cx">         3.5 MB system-wide footprint impact due to thread-locals in libANGLE
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrclibANGLEvalidationES2cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/libANGLE/validationES2.cpp (280903 => 280904)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -805,130 +805,6 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-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;
-}
-
</del><span class="cx"> bool ValidateWebGLNamePrefix(const Context *context, const GLchar *name)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(context->isWebGL());
</span><span class="lines">@@ -4948,25 +4824,6 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // 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;
-            }
-        }
-    }
-
</del><span class="cx">     Shader *shaderObject = GetValidShader(context, shader);
</span><span class="cx">     if (!shaderObject)
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceThirdPartyANGLEsrctestsgl_testsWebGLCompatibilityTestcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/ANGLE/src/tests/gl_tests/WebGLCompatibilityTest.cpp (280903 => 280904)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -2156,39 +2156,27 @@
</span><span class="cx">     for (char invalidChar : invalidSet)
</span><span class="cx">     {
</span><span class="cx">         std::string invalidAttribName = validAttribName + invalidChar;
</span><del>-        const char *invalidVert[]     = {
-            "attribute float ",
-            invalidAttribName.c_str(),
-            R"(;,
</del><ins>+        std::string invalidVert       = "attribute float ";
+        invalidVert += invalidAttribName;
+        invalidVert += R"(;,
</ins><span class="cx"> void main(),
</span><span class="cx"> {,
</span><span class="cx">     gl_Position = vec4(1.0);,
</span><del>-})",
-        };
-
-        GLuint shader = glCreateShader(GL_VERTEX_SHADER);
-        glShaderSource(shader, static_cast<GLsizei>(ArraySize(invalidVert)), invalidVert, nullptr);
-        EXPECT_GL_ERROR(GL_INVALID_VALUE);
-        glDeleteShader(shader);
</del><ins>+})";
+        GLuint program = CompileProgram(invalidVert.c_str(), essl1_shaders::fs::Red());
+        EXPECT_EQ(0u, program);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Test that line continuation is handled correctly when valdiating shader source
</del><ins>+// Test that line continuation is handled correctly when validating shader source
</ins><span class="cx"> TEST_P(WebGLCompatibilityTest, ShaderSourceLineContinuation)
</span><span class="cx"> {
</span><del>-    // 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);
</del><ins>+    // 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.
</ins><span class="cx"> 
</span><span class="cx">     const char *validVert =
</span><del>-        R"(#define foo this is a test
-precision mediump float;
-void main()
-{
-    gl_Position = vec4(1.0);
-})";
-
-    const char *invalidVert =
</del><span class="cx">         R"(#define foo this \
</span><span class="cx">     is a test
</span><span class="cx"> precision mediump float;
</span><span class="lines">@@ -2197,13 +2185,9 @@
</span><span class="cx">     gl_Position = vec4(1.0);
</span><span class="cx"> })";
</span><span class="cx"> 
</span><del>-    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);
</del><ins>+    GLuint program = CompileProgram(validVert, essl1_shaders::fs::Red());
+    EXPECT_NE(0u, program);
+    glDeleteProgram(program);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Test that line continuation is handled correctly when valdiating shader source
</span><span class="lines">@@ -2231,12 +2215,12 @@
</span><span class="cx">     gl_Position = vec4(foo);
</span><span class="cx"> })";
</span><span class="cx"> 
</span><del>-    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);
</del><ins>+    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);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Tests bindAttribLocations for reserved prefixes and length limits
</span></span></pre>
</div>
</div>

</body>
</html>