Title: [269316] branches/safari-610-branch
Revision
269316
Author
[email protected]
Date
2020-11-03 11:14:05 -0800 (Tue, 03 Nov 2020)

Log Message

Cherry-pick r266362. rdar://problem/70970398

    WebGL goes in a bad state where glContext.createProgram() returns null
    https://bugs.webkit.org/show_bug.cgi?id=215844

    Patch by James Darpinian <[email protected]> on 2020-08-31
    Reviewed by Kenneth Russell.

    Added test webgl/2.0.0/conformance/canvas/render-after-resize-test.html

    * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
    (WebCore::GraphicsContextGLOpenGL::reshape):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266362 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Added: branches/safari-610-branch/LayoutTests/webgl/2.0.0/conformance/canvas/render-after-resize-test-expected.txt (0 => 269316)


--- branches/safari-610-branch/LayoutTests/webgl/2.0.0/conformance/canvas/render-after-resize-test-expected.txt	                        (rev 0)
+++ branches/safari-610-branch/LayoutTests/webgl/2.0.0/conformance/canvas/render-after-resize-test-expected.txt	2020-11-03 19:14:05 UTC (rev 269316)
@@ -0,0 +1,4 @@
+This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.
+
+Test: ../../resources/webgl_test_files/conformance/canvas/render-after-resize-test.html
+[ PASS ] All tests passed

Added: branches/safari-610-branch/LayoutTests/webgl/2.0.0/conformance/canvas/render-after-resize-test.html (0 => 269316)


--- branches/safari-610-branch/LayoutTests/webgl/2.0.0/conformance/canvas/render-after-resize-test.html	                        (rev 0)
+++ branches/safari-610-branch/LayoutTests/webgl/2.0.0/conformance/canvas/render-after-resize-test.html	2020-11-03 19:14:05 UTC (rev 269316)
@@ -0,0 +1,18 @@
+<!-- This file is auto-generated by generate-webgl-tests.py. DO NOT EDIT -->
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Conformance Test Wrapper for render-after-resize-test.html</title>
+<script type="text/_javascript_" src=""
+<script type="text/_javascript_" src=""
+</head>
+<body>
+<p>This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.</p>
+Test: <a href=""
+<div id="iframe">
+<iframe src="" width="800" height="600"></iframe>
+</div>
+<div id="result"></div>
+</body>
+</html>

Modified: branches/safari-610-branch/LayoutTests/webgl/2.0.0/resources/webgl_test_files/conformance/canvas/render-after-resize-test.html (269315 => 269316)


--- branches/safari-610-branch/LayoutTests/webgl/2.0.0/resources/webgl_test_files/conformance/canvas/render-after-resize-test.html	2020-11-03 18:45:58 UTC (rev 269315)
+++ branches/safari-610-branch/LayoutTests/webgl/2.0.0/resources/webgl_test_files/conformance/canvas/render-after-resize-test.html	2020-11-03 19:14:05 UTC (rev 269316)
@@ -1,28 +1,7 @@
 <!--
-
-/*
-** Copyright (c) 2017 The Khronos Group Inc.
-**
-** Permission is hereby granted, free of charge, to any person obtaining a
-** copy of this software and/or associated documentation files (the
-** "Materials"), to deal in the Materials without restriction, including
-** without limitation the rights to use, copy, modify, merge, publish,
-** distribute, sublicense, and/or sell copies of the Materials, and to
-** permit persons to whom the Materials are furnished to do so, subject to
-** the following conditions:
-**
-** The above copyright notice and this permission notice shall be included
-** in all copies or substantial portions of the Materials.
-**
-** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
-*/
-
+Copyright (c) 2020 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
 -->
 <!DOCTYPE html>
 <html>
@@ -35,59 +14,126 @@
 </head>
 <body>
 <div id="description"></div>
-<canvas style="width: 100px, height: 100px; border: 1px solid blue;" id="c"></canvas>
+<canvas style="width: 100px; height: 100px; border: 1px solid black;" id="c"></canvas>
 <div id="console"></div>
 <script>
 description("This test ensures WebGL implementations can render correctly after resizing the canvas.");
 debug("");
 
-var wtu = WebGLTestUtils;
-var gl = wtu.create3DContext("c");
+const wtu = WebGLTestUtils;
+const gl = wtu.create3DContext("c", {depth: true, stencil: true});
 shouldBeTrue("gl != null");
 
-var positionLocation = 0;
-var texcoordLocation = 1;
-var program = wtu.setupColorQuad(gl, positionLocation);
-var colorLocation = gl.getUniformLocation(program, 'u_color');
-gl.uniform4fv(colorLocation, [0.0, 1.0, 0.0, 1.0]);
+gl.clearColor(1,0,0,1);
 
-const smallWidth = 300;
-const smallHeight = 150;
+const positionLocation = 0;
+const program = wtu.setupColorQuad(gl, positionLocation);
+const colorLocation = gl.getUniformLocation(program, 'u_color');
+gl.useProgram(program);
+
+const SMALL = 2;
 // Changing this size to something smaller produces
 // different results. Sometimes wrong, sometimes correct.
-const largeWidth = 1200;
-const largeHeight = 672;
+const LARGE = 1200;
 
-function render() {
-  gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
+gl.uniform4fv(colorLocation, [0.0, 1.0, 0.0, 1.0]);
 
-  gl.enable(gl.DEPTH_TEST);
-  gl.clearColor(1,0,0,1);
-  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+// -
 
-  gl.useProgram(program);
-  wtu.drawUnitQuad(gl);
-}
+debug('\nResize then render.');
+gl.canvas.width = gl.canvas.height = SMALL;
+gl.viewport(0, 0, SMALL, SMALL);
 
-function checkForQuad(ctx) {
-  let w = ctx.drawingBufferWidth;
-  let h = ctx.drawingBufferHeight;
+gl.clear(gl.COLOR_BUFFER_BIT);
+wtu.drawUnitQuad(gl);
 
-  wtu.checkCanvasRect(gl, 0, 0, w, h, [ 0, 255, 0, 255 ]);
-}
+wtu.checkCanvasRect(gl, 0, 0, 1, 1, [ 0, 255, 0, 255 ]);
 
-gl.canvas.width = smallWidth;
-gl.canvas.height = smallHeight;
-render();
-checkForQuad(gl); // passes
+// -
 
-gl.canvas.width = largeWidth;
-gl.canvas.height = largeHeight;
-gl.canvas.width = smallWidth;
-gl.canvas.height = smallHeight;
-render();
-checkForQuad(gl); // fails (almost all the time)
+debug('\nResize twice then render.');
+gl.canvas.width = gl.canvas.height = LARGE;
+gl.canvas.width = gl.canvas.height = SMALL;
 
+gl.clear(gl.COLOR_BUFFER_BIT);
+wtu.drawUnitQuad(gl);
+
+wtu.checkCanvasRect(gl, 0, 0, 1, 1, [ 0, 255, 0, 255 ]);
+
+debug('\nCause a GL error, then resize and render.');
+gl.depthFunc(0); // Causes INVALID_ENUM
+gl.canvas.width = gl.canvas.height = LARGE;
+gl.clear(gl.COLOR_BUFFER_BIT);
+gl.canvas.width = gl.canvas.height = SMALL;
+
+gl.clear(gl.COLOR_BUFFER_BIT);
+wtu.drawUnitQuad(gl);
+
+wtu.checkCanvasRect(gl, 0, 0, 1, 1, [ 0, 255, 0, 255 ]);
+wtu.glErrorShouldBe(gl, gl.INVALID_ENUM);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+// -
+
+debug('\nRender, no-op resize, then depth-fail render.');
+
+gl.enable(gl.DEPTH_TEST);
+gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
+gl.uniform4fv(colorLocation, [0.0, 1.0, 0.0, 1.0]);
+wtu.drawUnitQuad(gl);
+
+gl.canvas.width = gl.canvas.width;
+gl.uniform4fv(colorLocation, [0.0, 0.0, 1.0, 1.0]);
+wtu.drawUnitQuad(gl);
+
+wtu.checkCanvasRect(gl, 0, 0, 1, 1, [ 0, 255, 0, 255 ]);
+
+// Reset
+gl.disable(gl.DEPTH_TEST);
+
+// -
+
+debug('\nRender, no-op resize, then stencil-fail render.');
+
+gl.enable(gl.STENCIL_TEST);
+gl.stencilOp(gl.KEEP, gl.KEEP, gl.INCR);
+gl.stencilFunc(gl.EQUAL, 0, 0xff);
+gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
+gl.uniform4fv(colorLocation, [0.0, 1.0, 0.0, 1.0]);
+wtu.drawUnitQuad(gl);
+
+gl.canvas.width = gl.canvas.width;
+gl.uniform4fv(colorLocation, [0.0, 0.0, 1.0, 1.0]);
+wtu.drawUnitQuad(gl);
+
+wtu.checkCanvasRect(gl, 0, 0, 1, 1, [ 0, 255, 0, 255 ]);
+
+// Reset
+gl.disable(gl.STENCIL_TEST);
+gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);
+gl.stencilFunc(gl.ALWAYS, 0, 0xff);
+
+// -
+
+debug('\nRender, no-op resize, then scissor render.');
+
+gl.enable(gl.SCISSOR_TEST);
+gl.clear(gl.COLOR_BUFFER_BIT);
+gl.uniform4fv(colorLocation, [0.0, 1.0, 0.0, 1.0]);
+wtu.drawUnitQuad(gl);
+
+gl.canvas.width = gl.canvas.width;
+gl.enable(gl.SCISSOR_TEST);
+gl.scissor(0, 0, 1, 1);
+gl.uniform4fv(colorLocation, [0.0, 0.0, 1.0, 1.0]);
+wtu.drawUnitQuad(gl);
+gl.disable(gl.SCISSOR_TEST);
+
+wtu.checkCanvasRect(gl, 1, 0, 1, 1, [ 0, 255, 0, 255 ]);
+wtu.checkCanvasRect(gl, 0, 0, 1, 1, [ 0, 0, 255, 255 ]);
+
+// -
+
 finishTest();
 
 var successfullyParsed = true;

Modified: branches/safari-610-branch/Source/WebCore/ChangeLog (269315 => 269316)


--- branches/safari-610-branch/Source/WebCore/ChangeLog	2020-11-03 18:45:58 UTC (rev 269315)
+++ branches/safari-610-branch/Source/WebCore/ChangeLog	2020-11-03 19:14:05 UTC (rev 269316)
@@ -1,3 +1,32 @@
+2020-11-02  Alan Coon  <[email protected]>
+
+        Cherry-pick r266362. rdar://problem/70970398
+
+    WebGL goes in a bad state where glContext.createProgram() returns null
+    https://bugs.webkit.org/show_bug.cgi?id=215844
+    
+    Patch by James Darpinian <[email protected]> on 2020-08-31
+    Reviewed by Kenneth Russell.
+    
+    Added test webgl/2.0.0/conformance/canvas/render-after-resize-test.html
+    
+    * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
+    (WebCore::GraphicsContextGLOpenGL::reshape):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266362 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-08-31  James Darpinian  <[email protected]>
+
+            WebGL goes in a bad state where glContext.createProgram() returns null
+            https://bugs.webkit.org/show_bug.cgi?id=215844
+
+            Reviewed by Kenneth Russell.
+
+            Added test webgl/2.0.0/conformance/canvas/render-after-resize-test.html
+
+            * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
+            (WebCore::GraphicsContextGLOpenGL::reshape):
+
 2020-10-29  Russell Epstein  <[email protected]>
 
         Cherry-pick r269118. rdar://problem/70795320

Modified: branches/safari-610-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp (269315 => 269316)


--- branches/safari-610-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp	2020-11-03 18:45:58 UTC (rev 269315)
+++ branches/safari-610-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp	2020-11-03 19:14:05 UTC (rev 269316)
@@ -644,6 +644,7 @@
     m_currentHeight = height;
 
     makeContextCurrent();
+    moveErrorsToSyntheticErrorList();
     validateAttributes();
 
     TemporaryANGLESetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to