Title: [295331] branches/safari-7614.1.14.10-branch/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/ContextMtl.mm
Revision
295331
Author
[email protected]
Date
2022-06-06 22:47:37 -0700 (Mon, 06 Jun 2022)

Log Message

Cherry-pick r294877. rdar://problem/93834054

    Uniform buffer reuse causes flush, creates invalid state
    https://bugs.webkit.org/show_bug.cgi?id=240896

    Patch by Kimmo Kinnunen <[email protected]> on 2022-05-26
    Patch by Kyle Piddington.

    Reviewed by Kimmo Kinnunen.

    A flush during draw setup would leave the render command encoder
    not started and render pipeline unset. This would assert in debug
    and leak memory with corrupted draws in release.

    This would happen for example when uniform buffer pool would run
    out of uniform memory. If the pool is maxed out, we flush the
    existing rendering to obtain free buffers. After the flush,
    we need to re-run the setup.

    Test is tracked in bug 240948.

    * Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/ContextMtl.mm:
    (rx::ContextMtl::setupDraw):
    (rx::ContextMtl::setupDrawImpl):

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

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

Modified Paths

Diff

Modified: branches/safari-7614.1.14.10-branch/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/ContextMtl.mm (295330 => 295331)


--- branches/safari-7614.1.14.10-branch/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/ContextMtl.mm	2022-06-07 05:47:34 UTC (rev 295330)
+++ branches/safari-7614.1.14.10-branch/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/ContextMtl.mm	2022-06-07 05:47:37 UTC (rev 295331)
@@ -2222,6 +2222,32 @@
                                     const void *indices,
                                     bool xfbPass)
 {
+    ANGLE_TRY(setupDrawImpl(context, mode, firstVertex, vertexOrIndexCount, instances,
+                            indexTypeOrNone, indices, xfbPass));
+    if (!mRenderEncoder.valid())
+    {
+        // Flush occurred during setup, due to running out of memory while setting up the render
+        // pass state. This would happen for example when there is no more space in the uniform
+        // buffers in the uniform buffer pool. The rendering would be flushed to free the uniform
+        // buffer memory for new usage. In this case, re-run the setup.
+        ANGLE_TRY(setupDrawImpl(context, mode, firstVertex, vertexOrIndexCount, instances,
+                                indexTypeOrNone, indices, xfbPass));
+        // Setup with flushed state should either produce a working encoder or fail with an error
+        // result.
+        ASSERT(mRenderEncoder.valid());
+    }
+    return angle::Result::Continue;
+}
+
+angle::Result ContextMtl::setupDrawImpl(const gl::Context *context,
+                                        gl::PrimitiveMode mode,
+                                        GLint firstVertex,
+                                        GLsizei vertexOrIndexCount,
+                                        GLsizei instances,
+                                        gl::DrawElementsType indexTypeOrNone,
+                                        const void *indices,
+                                        bool xfbPass)
+{
     ASSERT(mProgram);
 
     // instances=0 means no instanced draw.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to