Title: [295684] trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp
Revision
295684
Author
[email protected]
Date
2022-06-21 01:52:19 -0700 (Tue, 21 Jun 2022)

Log Message

Apply implicit clears and clearBuffer commands in proper order
https://bugs.webkit.org/show_bug.cgi?id=241765

Patch by Alexey Knyazev <[email protected]> on 2022-06-21
Reviewed by Kimmo Kinnunen.

Merging clearBuffer comamnds with implicit clears was producing
incorrect results, especially with enabled scissor test.

To resolve that, treat clearBuffer commands as draw calls,
i.e., apply implicit clears before them and notify the canvas
after, if needed.

It may be possible to reintroduce merged and/or skipped clears
provided that such an optimization does not break any tests.

See conformance2/rendering/clearbuffer-and-draw.html

* Source/WebCore/html/canvas/WebGL2RenderingContext.cpp:
(WebCore::WebGL2RenderingContext::clearBufferiv):
(WebCore::WebGL2RenderingContext::clearBufferuiv):
(WebCore::WebGL2RenderingContext::clearBufferfv):
(WebCore::WebGL2RenderingContext::clearBufferfi):

Canonical link: https://commits.webkit.org/251689@main

Modified Paths

Diff

Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp (295683 => 295684)


--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp	2022-06-21 08:26:31 UTC (rev 295683)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp	2022-06-21 08:52:19 UTC (rev 295684)
@@ -1680,8 +1680,11 @@
     if (!data)
         return;
 
+    // Flush any pending implicit clears. This cannot be done after the
+    // user-requested clearBuffer call because of scissor test side effects.
+    clearIfComposited(CallerTypeDrawOrClear);
+
     m_context->clearBufferiv(buffer, drawbuffer, data.value());
-    updateBuffersToAutoClear(ClearBufferCaller::ClearBufferiv, buffer, drawbuffer);
 }
 
 void WebGL2RenderingContext::clearBufferuiv(GCGLenum buffer, GCGLint drawbuffer, Uint32List&& values, GCGLuint srcOffset)
@@ -1691,8 +1694,11 @@
     auto data = "" buffer, values, srcOffset);
     if (!data)
         return;
+
+    // This call is not applicable to the default framebuffer attachments
+    // as they cannot have UINT type. Ignore any pending implicit clears.
+
     m_context->clearBufferuiv(buffer, drawbuffer, data.value());
-    updateBuffersToAutoClear(ClearBufferCaller::ClearBufferuiv, buffer, drawbuffer);
 }
 
 void WebGL2RenderingContext::clearBufferfv(GCGLenum buffer, GCGLint drawbuffer, Float32List&& values, GCGLuint srcOffset)
@@ -1703,13 +1709,15 @@
     if (!data)
         return;
 
+    // Flush any pending implicit clears. This cannot be done after the
+    // user-requested clearBuffer call because of scissor test side effects.
+    clearIfComposited(CallerTypeDrawOrClear);
+
     m_context->clearBufferfv(buffer, drawbuffer, data.value());
-    // clearBufferiv and clearBufferuiv will currently generate an error
-    // if they're called against the default back buffer. If support for
-    // extended canvas color spaces is added, this call might need to be
-    // added to the other versions.
-    markContextChanged();
-    updateBuffersToAutoClear(ClearBufferCaller::ClearBufferfv, buffer, drawbuffer);
+
+    // This might have been used to clear the color buffer of the default
+    // back buffer. Notification is required to update the canvas.
+    markContextChangedAndNotifyCanvasObserver();
 }
 
 void WebGL2RenderingContext::clearBufferfi(GCGLenum buffer, GCGLint drawbuffer, GCGLfloat depth, GCGLint stencil)
@@ -1717,11 +1725,11 @@
     if (isContextLostOrPending())
         return;
 
+    // Flush any pending implicit clears. This cannot be done after the
+    // user-requested clearBuffer call because of scissor test side effects.
+    clearIfComposited(CallerTypeDrawOrClear);
+
     m_context->clearBufferfi(buffer, drawbuffer, depth, stencil);
-    // This might have been used to clear the depth and stencil buffers
-    // of the default back buffer.
-    markContextChanged();
-    updateBuffersToAutoClear(ClearBufferCaller::ClearBufferfi, buffer, drawbuffer);
 }
 
 RefPtr<WebGLQuery> WebGL2RenderingContext::createQuery()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to