Commit a4fa9c27 by Luc Ferron Committed by Commit Bot

Vulkan: drawElements with GL_LINE_LOOP and an offset

Also enables a test in LineLoopTest that validates this case. Bug: angleproject:2473 Change-Id: Icb4c5735c11be40cdeceaa051f5a5cef33fd22c6 Reviewed-on: https://chromium-review.googlesource.com/1011669 Commit-Queue: Luc Ferron <lucferron@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 20fa8d5c
...@@ -415,9 +415,11 @@ gl::Error VertexArrayVk::drawElements(const gl::Context *context, ...@@ -415,9 +415,11 @@ gl::Error VertexArrayVk::drawElements(const gl::Context *context,
} }
else else
{ {
// When using an element array buffer, 'indices' is an offset to the first element.
intptr_t offset = reinterpret_cast<intptr_t>(drawCallParams.indices());
BufferVk *elementArrayBufferVk = vk::GetImpl(elementArrayBuffer); BufferVk *elementArrayBufferVk = vk::GetImpl(elementArrayBuffer);
ANGLE_TRY(mLineLoopHelper.getIndexBufferForElementArrayBuffer( ANGLE_TRY(mLineLoopHelper.getIndexBufferForElementArrayBuffer(
renderer, elementArrayBufferVk, indexType, drawCallParams.indexCount(), renderer, elementArrayBufferVk, indexType, drawCallParams.indexCount(), offset,
&mCurrentElementArrayBufferHandle, &mCurrentElementArrayBufferOffset)); &mCurrentElementArrayBufferHandle, &mCurrentElementArrayBufferOffset));
} }
} }
......
...@@ -370,23 +370,26 @@ gl::Error LineLoopHelper::getIndexBufferForElementArrayBuffer(RendererVk *render ...@@ -370,23 +370,26 @@ gl::Error LineLoopHelper::getIndexBufferForElementArrayBuffer(RendererVk *render
BufferVk *elementArrayBufferVk, BufferVk *elementArrayBufferVk,
VkIndexType indexType, VkIndexType indexType,
int indexCount, int indexCount,
intptr_t elementArrayOffset,
VkBuffer *bufferHandleOut, VkBuffer *bufferHandleOut,
VkDeviceSize *bufferOffsetOut) VkDeviceSize *bufferOffsetOut)
{ {
ASSERT(indexType == VK_INDEX_TYPE_UINT16 || indexType == VK_INDEX_TYPE_UINT32); ASSERT(indexType == VK_INDEX_TYPE_UINT16 || indexType == VK_INDEX_TYPE_UINT32);
uint32_t *indices = nullptr; uint32_t *indices = nullptr;
uint32_t offset = 0; uint32_t destinationOffset = 0;
auto unitSize = (indexType == VK_INDEX_TYPE_UINT16 ? sizeof(uint16_t) : sizeof(uint32_t)); auto unitSize = (indexType == VK_INDEX_TYPE_UINT16 ? sizeof(uint16_t) : sizeof(uint32_t));
size_t allocateBytes = unitSize * (indexCount + 1); size_t allocateBytes = unitSize * (indexCount + 1);
ANGLE_TRY(mDynamicIndexBuffer.allocate(renderer, allocateBytes, ANGLE_TRY(mDynamicIndexBuffer.allocate(renderer, allocateBytes,
reinterpret_cast<uint8_t **>(&indices), bufferHandleOut, reinterpret_cast<uint8_t **>(&indices), bufferHandleOut,
&offset, nullptr)); &destinationOffset, nullptr));
*bufferOffsetOut = static_cast<VkDeviceSize>(offset); *bufferOffsetOut = static_cast<VkDeviceSize>(destinationOffset);
VkBufferCopy copy1 = {0, offset, static_cast<VkDeviceSize>(indexCount) * unitSize}; VkDeviceSize sourceOffset = static_cast<VkDeviceSize>(elementArrayOffset);
VkBufferCopy copy2 = {0, offset + static_cast<VkDeviceSize>(indexCount) * unitSize, unitSize}; uint64_t unitCount = static_cast<VkDeviceSize>(indexCount);
VkBufferCopy copy1 = {sourceOffset, destinationOffset, unitCount * unitSize};
VkBufferCopy copy2 = {sourceOffset, destinationOffset + unitCount * unitSize, unitSize};
std::array<VkBufferCopy, 2> copies = {{copy1, copy2}}; std::array<VkBufferCopy, 2> copies = {{copy1, copy2}};
vk::CommandBuffer *commandBuffer; vk::CommandBuffer *commandBuffer;
......
...@@ -131,6 +131,7 @@ class LineLoopHelper final : public vk::CommandGraphResource ...@@ -131,6 +131,7 @@ class LineLoopHelper final : public vk::CommandGraphResource
BufferVk *elementArrayBufferVk, BufferVk *elementArrayBufferVk,
VkIndexType indexType, VkIndexType indexType,
int indexCount, int indexCount,
intptr_t elementArrayOffset,
VkBuffer *bufferHandleOut, VkBuffer *bufferHandleOut,
VkDeviceSize *bufferOffsetOut); VkDeviceSize *bufferOffsetOut);
gl::Error getIndexBufferForClientElementArray(RendererVk *renderer, gl::Error getIndexBufferForClientElementArray(RendererVk *renderer,
......
...@@ -169,11 +169,6 @@ TEST_P(LineLoopTest, LineLoopUByteIndexBuffer) ...@@ -169,11 +169,6 @@ TEST_P(LineLoopTest, LineLoopUByteIndexBuffer)
TEST_P(LineLoopTest, LineLoopUShortIndexBuffer) TEST_P(LineLoopTest, LineLoopUShortIndexBuffer)
{ {
// TODO(lucferron): Looks like we have a bug supporting ushort as index buffers
// on line loops drawing.
// http://anglebug.com/2473
ANGLE_SKIP_TEST_IF(IsVulkan());
// Disable D3D11 SDK Layers warnings checks, see ANGLE issue 667 for details // Disable D3D11 SDK Layers warnings checks, see ANGLE issue 667 for details
ignoreD3D11SDKLayersWarnings(); ignoreD3D11SDKLayersWarnings();
......
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