Skip to content
Permalink
Browse files
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
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294877 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
kkinnunen-apple authored and webkit-commit-queue committed May 26, 2022
1 parent 5c8639a commit e7a1c79bcae5e3be72dfa85396b5a61e34716add
Showing 1 changed file with 26 additions and 0 deletions.
@@ -2215,6 +2215,32 @@ GLint GetOwnershipIdentity(const egl::AttributeMap &attribs)
gl::DrawElementsType indexTypeOrNone,
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);

0 comments on commit e7a1c79

Please sign in to comment.