⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 294877 in webkit


Ignore:
Timestamp:
May 26, 2022, 7:00:35 AM (4 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Kimmo Kinnunen <​kkinnunen@apple.com> 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/ContextMtl.mm

    r294834 r294877  
    22172217                                    bool xfbPass)
    22182218{
     2219    ANGLE_TRY(setupDrawImpl(context, mode, firstVertex, vertexOrIndexCount, instances,
     2220                            indexTypeOrNone, indices, xfbPass));
     2221    if (!mRenderEncoder.valid())
     2222    {
     2223        // Flush occurred during setup, due to running out of memory while setting up the render
     2224        // pass state. This would happen for example when there is no more space in the uniform
     2225        // buffers in the uniform buffer pool. The rendering would be flushed to free the uniform
     2226        // buffer memory for new usage. In this case, re-run the setup.
     2227        ANGLE_TRY(setupDrawImpl(context, mode, firstVertex, vertexOrIndexCount, instances,
     2228                                indexTypeOrNone, indices, xfbPass));
     2229        // Setup with flushed state should either produce a working encoder or fail with an error
     2230        // result.
     2231        ASSERT(mRenderEncoder.valid());
     2232    }
     2233    return angle::Result::Continue;
     2234}
     2235
     2236angle::Result ContextMtl::setupDrawImpl(const gl::Context *context,
     2237                                        gl::PrimitiveMode mode,
     2238                                        GLint firstVertex,
     2239                                        GLsizei vertexOrIndexCount,
     2240                                        GLsizei instances,
     2241                                        gl::DrawElementsType indexTypeOrNone,
     2242                                        const void *indices,
     2243                                        bool xfbPass)
     2244{
    22192245    ASSERT(mProgram);
    22202246
Note: See TracChangeset for help on using the changeset viewer.