Commit 54e99d36 by Tim Van Patten Committed by Commit Bot

Vulkan: Cleanup garbage when destroying EGL images

SurfaceFlinger will optimistically create EGL images just in case it does need them in the future, since creating them can be slow and waiting until they're necessary can cause jank on 90hz+ devices. However, since the images are never actually used, ANGLE's garbage is never cleaned up so vkDestroyImage() and the memory is never freed. This can lead to exhausting the device's memory when many EGL images are allocated. For example, when running the CTS test CtsBiometricsTestCases. This CL adds a call to always cleanup the renderer's garbage when an EGL image is destroyed via eglDestroyImageKHR(), since we can't know if a draw will ever be performed in the future (which would normally cleanup the garbage). Bug: b/184388756 Test: atest CtsBiometricsTestCases Change-Id: I104c05c7be44f1e57123ac7eed23effaa982837a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2848131Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJason Macnak <natsu@google.com> Reviewed-by: 's avatarCharlie Lao <cclao@google.com> Commit-Queue: Tim Van Patten <timvp@google.com>
parent ce89d99f
...@@ -47,6 +47,11 @@ void ImageVk::onDestroy(const egl::Display *display) ...@@ -47,6 +47,11 @@ void ImageVk::onDestroy(const egl::Display *display)
GetImplAs<ExternalImageSiblingVk>(GetAs<egl::ExternalImageSibling>(mState.source)); GetImplAs<ExternalImageSiblingVk>(GetAs<egl::ExternalImageSibling>(mState.source));
externalImageSibling->release(renderer); externalImageSibling->release(renderer);
mImage = nullptr; mImage = nullptr;
// This is called as a special case where resources may be allocated by the caller, without
// the caller ever issuing a draw command to free them. Specifically, SurfaceFlinger
// optimistically allocates EGLImages that it may never draw to.
renderer->cleanupCompletedCommandsGarbage();
} }
} }
......
...@@ -2781,6 +2781,11 @@ angle::Result RendererVk::cleanupGarbage(Serial lastCompletedQueueSerial) ...@@ -2781,6 +2781,11 @@ angle::Result RendererVk::cleanupGarbage(Serial lastCompletedQueueSerial)
return angle::Result::Continue; return angle::Result::Continue;
} }
void RendererVk::cleanupCompletedCommandsGarbage()
{
(void)cleanupGarbage(getLastCompletedQueueSerial());
}
void RendererVk::onNewValidationMessage(const std::string &message) void RendererVk::onNewValidationMessage(const std::string &message)
{ {
mLastValidationMessage = message; mLastValidationMessage = message;
......
...@@ -338,6 +338,7 @@ class RendererVk : angle::NonCopyable ...@@ -338,6 +338,7 @@ class RendererVk : angle::NonCopyable
bool haveSameFormatFeatureBits(angle::FormatID formatID1, angle::FormatID formatID2) const; bool haveSameFormatFeatureBits(angle::FormatID formatID1, angle::FormatID formatID2) const;
angle::Result cleanupGarbage(Serial lastCompletedQueueSerial); angle::Result cleanupGarbage(Serial lastCompletedQueueSerial);
void cleanupCompletedCommandsGarbage();
angle::Result submitFrame(vk::Context *context, angle::Result submitFrame(vk::Context *context,
egl::ContextPriority contextPriority, egl::ContextPriority contextPriority,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment