Vulkan: Don't retain in buffer/imageRead unnecessarily

mUsedBuffers/images already tracks whether a buffer/image is used in a
render pass, so we can add to ContextVk's resource use list only once.

Bug: angleproject:6717
Change-Id: Idd528c7f0f3fcb4d8d8879ab6cc7055260ecb45d
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3310523
Commit-Queue: Lingfeng Yang <lfy@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Charlie Lao <cclao@google.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
Lingfeng Yang 2021-12-01 08:58:01 -08:00 коммит произвёл Angle LUCI CQ
Родитель 2d41e0f742
Коммит 8815245a8c
1 изменённых файлов: 6 добавлений и 3 удалений

Просмотреть файл

@ -1104,7 +1104,6 @@ void CommandBufferHelper::bufferRead(ContextVk *contextVk,
PipelineStage readStage,
BufferHelper *buffer)
{
buffer->retainReadOnly(&contextVk->getResourceUseList());
VkPipelineStageFlagBits stageBits = kPipelineStageFlagBitMap[readStage];
if (buffer->recordReadBarrier(readAccessType, stageBits, &mPipelineBarriers[readStage]))
{
@ -1115,6 +1114,7 @@ void CommandBufferHelper::bufferRead(ContextVk *contextVk,
if (!mUsedBuffers.contains(buffer->getBufferSerial().getValue()))
{
mUsedBuffers.insert(buffer->getBufferSerial().getValue(), BufferAccess::Read);
buffer->retainReadOnly(&contextVk->getResourceUseList());
}
}
@ -1155,8 +1155,6 @@ void CommandBufferHelper::imageRead(ContextVk *contextVk,
ImageLayout imageLayout,
ImageHelper *image)
{
image->retain(&contextVk->getResourceUseList());
if (image->isReadBarrierNecessary(imageLayout))
{
updateImageLayoutAndBarrier(contextVk, image, aspectFlags, imageLayout);
@ -1169,8 +1167,13 @@ void CommandBufferHelper::imageRead(ContextVk *contextVk,
if (!usesImageInRenderPass(*image))
{
mRenderPassUsedImages.insert(image->getImageSerial().getValue());
image->retain(&contextVk->getResourceUseList());
}
}
else
{
image->retain(&contextVk->getResourceUseList());
}
}
void CommandBufferHelper::imageWrite(ContextVk *contextVk,