Check pending garbage after some buffer releases

* Embedded BufferHelper::releaseBufferAndDescriptorSetCache() inside
  a new ContextVk method: releaseBufferAllocation()

  * After releasing the buffer, there is a check for excess pending
    garbage. If the tracked pending garbage size is larger than the
    threshold, the context will be flushed.

* Unskipped the test "BufferDataInLoopManyTimes", which was failing
  on Android devices.

Bug: b/280304441
Change-Id: Ib34319f3291dd2200fc1a92e30645f9d1da8e2b9
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4879086
Commit-Queue: Amirali Abdolrashidi <abdolrashidi@google.com>
Reviewed-by: Charlie Lao <cclao@google.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
Amirali Abdolrashidi
2023-09-20 11:53:15 -07:00
committed by Angle LUCI CQ
parent a1e3abc06b
commit e1d2e88ae4
5 changed files with 23 additions and 14 deletions

View File

@@ -297,15 +297,15 @@ void BufferVk::destroy(const gl::Context *context)
{
ContextVk *contextVk = vk::GetImpl(context);
release(contextVk);
(void)release(contextVk);
}
void BufferVk::release(ContextVk *contextVk)
angle::Result BufferVk::release(ContextVk *contextVk)
{
RendererVk *renderer = contextVk->getRenderer();
if (mBuffer.valid())
{
mBuffer.releaseBufferAndDescriptorSetCache(renderer);
ANGLE_TRY(contextVk->releaseBufferAllocation(&mBuffer));
}
if (mStagingBuffer.valid())
{
@@ -317,6 +317,8 @@ void BufferVk::release(ContextVk *contextVk)
buffer.data->release(renderer);
}
mVertexConversionBuffers.clear();
return angle::Result::Continue;
}
angle::Result BufferVk::setExternalBufferData(const gl::Context *context,
@@ -328,7 +330,7 @@ angle::Result BufferVk::setExternalBufferData(const gl::Context *context,
ContextVk *contextVk = vk::GetImpl(context);
// Release and re-create the memory and buffer.
release(contextVk);
ANGLE_TRY(release(contextVk));
VkBufferCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
@@ -627,7 +629,7 @@ angle::Result BufferVk::ghostMappedBuffer(ContextVk *contextVk,
memcpy(dstMapPtr, srcMapPtr, static_cast<size_t>(mState.getSize()));
}
src.releaseBufferAndDescriptorSetCache(contextVk->getRenderer());
ANGLE_TRY(contextVk->releaseBufferAllocation(&src));
// Return the already mapped pointer with the offset adjustment to avoid the call to unmap().
*mapPtr = dstMapPtr + offset;
@@ -1033,7 +1035,7 @@ angle::Result BufferVk::acquireAndUpdate(ContextVk *contextVk,
if (prevBuffer.valid())
{
prevBuffer.releaseBufferAndDescriptorSetCache(contextVk->getRenderer());
ANGLE_TRY(contextVk->releaseBufferAllocation(&prevBuffer));
}
return angle::Result::Continue;
@@ -1155,7 +1157,7 @@ angle::Result BufferVk::acquireBufferHelper(ContextVk *contextVk,
if (mBuffer.valid())
{
mBuffer.releaseBufferAndDescriptorSetCache(renderer);
ANGLE_TRY(contextVk->releaseBufferAllocation(&mBuffer));
}
// Allocate the buffer directly

View File

@@ -184,7 +184,7 @@ class BufferVk : public BufferImpl
size_t updateSize,
size_t updateOffset,
BufferUpdateType updateType);
void release(ContextVk *context);
angle::Result release(ContextVk *context);
void dataUpdated();
angle::Result acquireBufferHelper(ContextVk *contextVk,

View File

@@ -7142,6 +7142,17 @@ angle::Result ContextVk::initImageAllocation(vk::ImageHelper *imageHelper,
return angle::Result::Continue;
}
angle::Result ContextVk::releaseBufferAllocation(vk::BufferHelper *bufferHelper)
{
bufferHelper->releaseBufferAndDescriptorSetCache(mRenderer);
if (ANGLE_UNLIKELY(hasExcessPendingGarbage()))
{
ANGLE_TRY(flushImpl(nullptr, nullptr, RenderPassClosureReason::ExcessivePendingGarbage));
}
return angle::Result::Continue;
}
angle::Result ContextVk::initBufferForBufferCopy(vk::BufferHelper *bufferHelper,
size_t size,
vk::MemoryCoherency coherency)

View File

@@ -822,6 +822,8 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
VkMemoryPropertyFlags flags,
vk::MemoryAllocationType allocationType);
angle::Result releaseBufferAllocation(vk::BufferHelper *bufferHelper);
// Helper functions to initialize a buffer for a specific usage
// Suballocate a host visible buffer with alignment good for copyBuffer.
angle::Result initBufferForBufferCopy(vk::BufferHelper *bufferHelper,

View File

@@ -413,12 +413,6 @@ b/273271471 WIN INTEL VULKAN : ShaderAlgorithmTest.rgb_to_hsl_vertex_shader/* =
7059 ANDROID : EGLReadinessCheckTest.HasGetPlatformDisplayEXT/* = SKIP
7059 ANDROID : EGLContextSharingTestNoSyncTextureUploads.NoSync/* = SKIP
// Triggers lowmemorykiller on some Android devices.
280304441 ANDROID : UniformBufferMemoryTest.BufferDataInLoopManyTimes/* = SKIP
// Timeout on Swiftshader and failure due to too many allocations
280304441 SWIFTSHADER : UniformBufferMemoryTest.BufferDataInLoopManyTimes/* = SKIP
// Skipped due to long execution time
8351 LINUX INTEL : UniformBufferMemoryTest.BufferDataInLoopManyTimes/* = SKIP