Commit f0d32401 by Charlie Lao Committed by Commit Bot

Vulkan: Optimize element buffer conversion

Uses CPU copy if the buffer is CPU visible. Also add dirty bit check to avoid repeated conversion on clean data Bug: angleproject:4400 Change-Id: I1f472703ebc4a65ee0de129c27f56b081748f900 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2057758Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTobin Ehlis <tobine@google.com> Commit-Queue: Tobin Ehlis <tobine@google.com>
parent 201bb086
......@@ -958,8 +958,24 @@ angle::Result ContextVk::setupIndexedDraw(const gl::Context *context,
if (indexType == gl::DrawElementsType::UnsignedByte &&
mGraphicsDirtyBits[DIRTY_BIT_INDEX_BUFFER])
{
BufferVk *bufferVk = vk::GetImpl(elementArrayBuffer);
ANGLE_TRY(mVertexArray->convertIndexBufferGPU(this, bufferVk, indices));
BufferVk *bufferVk = vk::GetImpl(elementArrayBuffer);
vk::BufferHelper &bufferHelper = bufferVk->getBuffer();
if (bufferHelper.isHostVisible() &&
!bufferHelper.isCurrentlyInUse(getLastCompletedQueueSerial()))
{
uint8_t *src = nullptr;
ANGLE_TRY(bufferVk->mapImpl(this, reinterpret_cast<void **>(&src)));
src += reinterpret_cast<uintptr_t>(indices);
const size_t byteCount = static_cast<size_t>(elementArrayBuffer->getSize()) -
reinterpret_cast<uintptr_t>(indices);
ANGLE_TRY(mVertexArray->convertIndexBufferCPU(this, indexType, byteCount, src));
bufferVk->unmapImpl(this);
}
else
{
ANGLE_TRY(mVertexArray->convertIndexBufferGPU(this, bufferVk, indices));
}
}
}
......
......@@ -475,6 +475,10 @@ class BufferHelper final : public Resource
const Buffer &getBuffer() const { return mBuffer; }
const DeviceMemory &getDeviceMemory() const { return mDeviceMemory; }
VkDeviceSize getSize() const { return mSize; }
bool isHostVisible() const
{
return (mMemoryPropertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0;
}
// Set write access mask when the buffer is modified externally, e.g. by host. There is no
// graph resource to create a dependency to.
......
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