Commit 0c5a55a5 by Charlie Lao Committed by Commit Bot

Vulkan: MapBufferRange should avoid wait if INVALIDATE_BUFFER is set

If glMapBufferRange is called with GL_MAP_INVALIDATE_BUFFER_BIT bit set, caller indicates that it don't care about the previous content. If the buffer is busy, instead of wait for GPU to finish and then map the buffer, we should just allocate a new memory and return it. brawl_stars is hitting this case. With this CL, the frame time is cutting to half on the pixel device. Bug: b/175905404 Change-Id: If1220f07ebf53dd28fe6a4732eaba84e2e57598e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2597784Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
parent 4e2b6d6b
......@@ -457,7 +457,17 @@ angle::Result BufferVk::mapRangeImpl(ContextVk *contextVk,
{
ASSERT(mBuffer && mBuffer->valid());
if ((access & GL_MAP_UNSYNCHRONIZED_BIT) == 0)
if ((access & GL_MAP_INVALIDATE_BUFFER_BIT) != 0 &&
mBuffer->isCurrentlyInUse(contextVk->getLastCompletedQueueSerial()))
{
// We try to map buffer, but buffer is busy. Caller has told us it doesn't care about
// previous content. Instead of wait for GPU to finish, we just allocate a new buffer.
RendererVk *renderer = contextVk->getRenderer();
mBuffer->release(renderer);
ANGLE_TRY(
acquireBufferHelper(contextVk, static_cast<size_t>(mState.getSize()), &mBuffer));
}
else if ((access & GL_MAP_UNSYNCHRONIZED_BIT) == 0)
{
ANGLE_TRY(mBuffer->waitForIdle(contextVk,
"GPU stall due to mapping buffer in use by the GPU"));
......
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