Commit 331640e5 by Mohan Maiya Committed by Commit Bot

Vulkan: Pass in the correct size to acquireBufferHelper

When BufferVk::acquireAndUpdate calls into acquireBufferHelper to allocate a new buffer helper we were passing in the update size instead of the full buffer size. Modified acquireAndUpdate's parameter to better reflect intent. Bug: angleproject:5689 Change-Id: Ic4fbc015651491ec028d747da5d45670264b93fa Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2746066Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
parent b2f547f4
......@@ -679,24 +679,25 @@ angle::Result BufferVk::stagedUpdate(ContextVk *contextVk,
angle::Result BufferVk::acquireAndUpdate(ContextVk *contextVk,
const uint8_t *data,
size_t size,
size_t updateSize,
size_t offset)
{
// Here we acquire a new BufferHelper and directUpdate() the new buffer.
// If the subData size was less than the buffer's size we additionally enqueue
// a GPU copy of the remaining regions from the old mBuffer to the new one.
vk::BufferHelper *src = mBuffer;
size_t offsetAfterSubdata = (offset + size);
size_t bufferSize = static_cast<size_t>(mState.getSize());
size_t offsetAfterSubdata = (offset + updateSize);
bool updateRegionBeforeSubData = (offset > 0);
bool updateRegionAfterSubData = (offsetAfterSubdata < static_cast<size_t>(mState.getSize()));
bool updateRegionAfterSubData = (offsetAfterSubdata < bufferSize);
if (updateRegionBeforeSubData || updateRegionAfterSubData)
{
src->retain(&contextVk->getResourceUseList());
}
ANGLE_TRY(acquireBufferHelper(contextVk, size, &mBuffer));
ANGLE_TRY(directUpdate(contextVk, data, size, offset));
ANGLE_TRY(acquireBufferHelper(contextVk, bufferSize, &mBuffer));
ANGLE_TRY(directUpdate(contextVk, data, updateSize, offset));
constexpr int kMaxCopyRegions = 2;
angle::FixedVector<VkBufferCopy, kMaxCopyRegions> copyRegions;
......@@ -707,8 +708,8 @@ angle::Result BufferVk::acquireAndUpdate(ContextVk *contextVk,
}
if (updateRegionAfterSubData)
{
copyRegions.push_back({offsetAfterSubdata, offsetAfterSubdata,
(static_cast<size_t>(mState.getSize()) - offsetAfterSubdata)});
copyRegions.push_back(
{offsetAfterSubdata, offsetAfterSubdata, (bufferSize - offsetAfterSubdata)});
}
if (!copyRegions.empty())
......
......@@ -158,7 +158,7 @@ class BufferVk : public BufferImpl
size_t offset);
angle::Result acquireAndUpdate(ContextVk *contextVk,
const uint8_t *data,
size_t size,
size_t updateSize,
size_t offset);
angle::Result setDataWithMemoryType(const gl::Context *context,
gl::BufferBinding target,
......
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