Commit 916d204c by Jamie Madill Committed by Commit Bot

Vulkan: Use new APIs in BufferHelper::copyFromBuffer.

We shouldn't need to special case the barrier logic in this function any more. Instead use the 'onBufferRead' and 'onBufferWrite' APIs. Bug: angleproject:4029 Change-Id: I7f67b67aa312d9ae64172b40d73086b7772d49d2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2071143 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent 660c0dd6
......@@ -364,7 +364,7 @@ angle::Result BufferVk::setDataImpl(ContextVk *contextVk,
// Enqueue a copy command on the GPU.
VkBufferCopy copyRegion = {stagingBufferOffset, offset, size};
ANGLE_TRY(mBuffer.copyFromBuffer(contextVk, mStagingBuffer.getCurrentBuffer()->getBuffer(),
ANGLE_TRY(mBuffer.copyFromBuffer(contextVk, mStagingBuffer.getCurrentBuffer(),
VK_ACCESS_HOST_WRITE_BIT, copyRegion));
mStagingBuffer.getCurrentBuffer()->retain(&contextVk->getResourceUseList());
}
......
......@@ -1566,33 +1566,16 @@ bool BufferHelper::needsOnWriteBarrier(VkAccessFlags writeAccessType,
}
angle::Result BufferHelper::copyFromBuffer(ContextVk *contextVk,
const Buffer &buffer,
BufferHelper *srcBuffer,
VkAccessFlags bufferAccessType,
const VkBufferCopy &copyRegion)
{
// 'recordCommands' will implicitly stop any reads from using the old buffer data.
CommandBuffer *commandBuffer = nullptr;
ANGLE_TRY(contextVk->onBufferWrite(bufferAccessType, this));
ANGLE_TRY(contextVk->onBufferRead(VK_ACCESS_TRANSFER_READ_BIT, srcBuffer));
ANGLE_TRY(contextVk->endRenderPassAndGetCommandBuffer(&commandBuffer));
if (mCurrentReadAccess != 0 || mCurrentWriteAccess != 0 || bufferAccessType != 0)
{
// Insert a barrier to ensure reads/writes are complete.
// Use a global memory barrier to keep things simple.
// TODO(jmadill): Can we revisit this with http://anglebug.com/4029
VkMemoryBarrier memoryBarrier = {};
memoryBarrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
memoryBarrier.srcAccessMask = mCurrentReadAccess | mCurrentWriteAccess | bufferAccessType;
memoryBarrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
commandBuffer->pipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, &memoryBarrier, 0,
nullptr, 0, nullptr);
}
mCurrentWriteAccess = VK_ACCESS_TRANSFER_WRITE_BIT;
mCurrentReadAccess = 0;
commandBuffer->copyBuffer(buffer, mBuffer, 1, &copyRegion);
commandBuffer->copyBuffer(srcBuffer->getBuffer(), mBuffer, 1, &copyRegion);
return angle::Result::Continue;
}
......
......@@ -482,7 +482,7 @@ class BufferHelper final : public Resource
// Also implicitly sets up the correct barriers.
angle::Result copyFromBuffer(ContextVk *contextVk,
const Buffer &buffer,
BufferHelper *srcBuffer,
VkAccessFlags bufferAccessType,
const VkBufferCopy &copyRegion);
......
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