Commit 22f12fed by Jamie Madill Committed by Commit Bot

Vulkan: Rename vk::LineLoopHelper.

This more closely follows the general pattern laid out by the naming in vk_helpers.h. It also changes the dynamic buffer that the helper wraps to be stored by-value since the header include order problem is fixed. Bug: angleproject:2318 Change-Id: I1de9e1edee2125d3afd490b4f9c99cf70c61215c Reviewed-on: https://chromium-review.googlesource.com/1001654Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarLuc Ferron <lucferron@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent d8c632c8
......@@ -61,7 +61,7 @@ void VertexArrayVk::destroy(const gl::Context *context)
mDynamicVertexData.destroy(device);
mDynamicIndexData.destroy(device);
mLineLoopHandler.destroy(device);
mLineLoopHelper.destroy(device);
}
gl::Error VertexArrayVk::streamVertexData(RendererVk *renderer,
......@@ -356,9 +356,9 @@ gl::Error VertexArrayVk::drawArrays(const gl::Context *context,
mLineLoopBufferFirstIndex != drawCallParams.firstVertex() ||
mLineLoopBufferLastIndex != lastVertex)
{
ANGLE_TRY(mLineLoopHandler.createIndexBuffer(renderer, drawCallParams,
&mCurrentElementArrayBufferHandle,
&mCurrentElementArrayBufferOffset));
ANGLE_TRY(mLineLoopHelper.getIndexBufferForDrawArrays(renderer, drawCallParams,
&mCurrentElementArrayBufferHandle,
&mCurrentElementArrayBufferOffset));
mLineLoopBufferFirstIndex = drawCallParams.firstVertex();
mLineLoopBufferLastIndex = lastVertex;
......@@ -367,7 +367,7 @@ gl::Error VertexArrayVk::drawArrays(const gl::Context *context,
commandBuffer->bindIndexBuffer(mCurrentElementArrayBufferHandle,
mCurrentElementArrayBufferOffset, VK_INDEX_TYPE_UINT32);
vk::LineLoopHandler::Draw(drawCallParams.vertexCount(), commandBuffer);
vk::LineLoopHelper::Draw(drawCallParams.vertexCount(), commandBuffer);
return gl::NoError();
}
......@@ -403,13 +403,13 @@ gl::Error VertexArrayVk::drawElements(const gl::Context *context,
// This also doesn't check if the element type changed, which should trigger translation.
if (mDirtyLineLoopTranslation)
{
ANGLE_TRY(mLineLoopHandler.createIndexBufferFromElementArrayBuffer(
ANGLE_TRY(mLineLoopHelper.getIndexBufferForElementArrayBuffer(
renderer, elementArrayBufferVk, indexType, drawCallParams.indexCount(),
&mCurrentElementArrayBufferHandle, &mCurrentElementArrayBufferOffset));
}
ANGLE_TRY(onIndexedDraw(context, renderer, drawCallParams, drawNode, newCommandBuffer));
vk::LineLoopHandler::Draw(drawCallParams.indexCount(), commandBuffer);
vk::LineLoopHelper::Draw(drawCallParams.indexCount(), commandBuffer);
return gl::NoError();
}
......
......@@ -119,7 +119,7 @@ class VertexArrayVk : public VertexArrayImpl
vk::DynamicBuffer mDynamicVertexData;
vk::DynamicBuffer mDynamicIndexData;
vk::LineLoopHandler mLineLoopHandler;
vk::LineLoopHelper mLineLoopHelper;
Optional<int> mLineLoopBufferFirstIndex;
Optional<int> mLineLoopBufferLastIndex;
bool mDirtyLineLoopTranslation;
......
......@@ -300,26 +300,25 @@ Error DynamicDescriptorPool::allocateNewPool(const VkDevice &device)
return NoError();
}
LineLoopHandler::LineLoopHandler()
: mDynamicLineLoopIndicesData(
new DynamicBuffer(kLineLoopDynamicBufferUsage, kLineLoopDynamicBufferMinSize))
LineLoopHelper::LineLoopHelper()
: mDynamicIndexBuffer(kLineLoopDynamicBufferUsage, kLineLoopDynamicBufferMinSize)
{
mDynamicLineLoopIndicesData->init(1);
mDynamicIndexBuffer.init(1);
}
LineLoopHandler::~LineLoopHandler() = default;
LineLoopHelper::~LineLoopHelper() = default;
gl::Error LineLoopHandler::createIndexBuffer(RendererVk *renderer,
const gl::DrawCallParams &drawCallParams,
VkBuffer *bufferHandleOut,
VkDeviceSize *offsetOut)
gl::Error LineLoopHelper::getIndexBufferForDrawArrays(RendererVk *renderer,
const gl::DrawCallParams &drawCallParams,
VkBuffer *bufferHandleOut,
VkDeviceSize *offsetOut)
{
uint32_t *indices = nullptr;
size_t allocateBytes = sizeof(uint32_t) * (drawCallParams.vertexCount() + 1);
uint32_t offset = 0;
ANGLE_TRY(mDynamicLineLoopIndicesData->allocate(renderer, allocateBytes,
reinterpret_cast<uint8_t **>(&indices),
bufferHandleOut, &offset, nullptr));
ANGLE_TRY(mDynamicIndexBuffer.allocate(renderer, allocateBytes,
reinterpret_cast<uint8_t **>(&indices), bufferHandleOut,
&offset, nullptr));
*offsetOut = static_cast<VkDeviceSize>(offset);
uint32_t unsignedFirstVertex = static_cast<uint32_t>(drawCallParams.firstVertex());
......@@ -333,17 +332,17 @@ gl::Error LineLoopHandler::createIndexBuffer(RendererVk *renderer,
// Since we are not using the VK_MEMORY_PROPERTY_HOST_COHERENT_BIT flag when creating the
// device memory in the StreamingBuffer, we always need to make sure we flush it after
// writing.
ANGLE_TRY(mDynamicLineLoopIndicesData->flush(renderer->getDevice()));
ANGLE_TRY(mDynamicIndexBuffer.flush(renderer->getDevice()));
return gl::NoError();
}
gl::Error LineLoopHandler::createIndexBufferFromElementArrayBuffer(RendererVk *renderer,
BufferVk *elementArrayBufferVk,
VkIndexType indexType,
int indexCount,
VkBuffer *bufferHandleOut,
VkDeviceSize *bufferOffsetOut)
gl::Error LineLoopHelper::getIndexBufferForElementArrayBuffer(RendererVk *renderer,
BufferVk *elementArrayBufferVk,
VkIndexType indexType,
int indexCount,
VkBuffer *bufferHandleOut,
VkDeviceSize *bufferOffsetOut)
{
ASSERT(indexType == VK_INDEX_TYPE_UINT16 || indexType == VK_INDEX_TYPE_UINT32);
......@@ -352,9 +351,9 @@ gl::Error LineLoopHandler::createIndexBufferFromElementArrayBuffer(RendererVk *r
auto unitSize = (indexType == VK_INDEX_TYPE_UINT16 ? sizeof(uint16_t) : sizeof(uint32_t));
size_t allocateBytes = unitSize * (indexCount + 1);
ANGLE_TRY(mDynamicLineLoopIndicesData->allocate(renderer, allocateBytes,
reinterpret_cast<uint8_t **>(&indices),
bufferHandleOut, &offset, nullptr));
ANGLE_TRY(mDynamicIndexBuffer.allocate(renderer, allocateBytes,
reinterpret_cast<uint8_t **>(&indices), bufferHandleOut,
&offset, nullptr));
*bufferOffsetOut = static_cast<VkDeviceSize>(offset);
VkBufferCopy copy1 = {0, offset, static_cast<VkDeviceSize>(indexCount) * unitSize};
......@@ -369,17 +368,17 @@ gl::Error LineLoopHandler::createIndexBufferFromElementArrayBuffer(RendererVk *r
commandBuffer->copyBuffer(elementArrayBufferVk->getVkBuffer().getHandle(), *bufferHandleOut, 2,
copies.data());
ANGLE_TRY(mDynamicLineLoopIndicesData->flush(renderer->getDevice()));
ANGLE_TRY(mDynamicIndexBuffer.flush(renderer->getDevice()));
return gl::NoError();
}
void LineLoopHandler::destroy(VkDevice device)
void LineLoopHelper::destroy(VkDevice device)
{
mDynamicLineLoopIndicesData->destroy(device);
mDynamicIndexBuffer.destroy(device);
}
// static
void LineLoopHandler::Draw(int count, CommandBuffer *commandBuffer)
void LineLoopHelper::Draw(int count, CommandBuffer *commandBuffer)
{
// Our first index is always 0 because that's how we set it up in createIndexBuffer*.
commandBuffer->drawIndexed(count + 1, 1, 0, 0, 0);
......
......@@ -112,28 +112,28 @@ class DynamicDescriptorPool final : angle::NonCopyable
//
// If the user wants to draw a loop between [v1, v2, v3], we will create an indexed buffer with
// these indexes: [0, 1, 2, 3, 0] to emulate the loop.
class LineLoopHandler final : public vk::CommandGraphResource
class LineLoopHelper final : public vk::CommandGraphResource
{
public:
LineLoopHandler();
~LineLoopHandler();
gl::Error createIndexBuffer(RendererVk *renderer,
const gl::DrawCallParams &drawCallParams,
VkBuffer *bufferHandleOut,
VkDeviceSize *offsetOut);
gl::Error createIndexBufferFromElementArrayBuffer(RendererVk *renderer,
BufferVk *elementArrayBufferVk,
VkIndexType indexType,
int indexCount,
VkBuffer *bufferHandleOut,
VkDeviceSize *bufferOffsetOut);
LineLoopHelper();
~LineLoopHelper();
gl::Error getIndexBufferForDrawArrays(RendererVk *renderer,
const gl::DrawCallParams &drawCallParams,
VkBuffer *bufferHandleOut,
VkDeviceSize *offsetOut);
gl::Error getIndexBufferForElementArrayBuffer(RendererVk *renderer,
BufferVk *elementArrayBufferVk,
VkIndexType indexType,
int indexCount,
VkBuffer *bufferHandleOut,
VkDeviceSize *bufferOffsetOut);
void destroy(VkDevice device);
static void Draw(int count, CommandBuffer *commandBuffer);
private:
std::unique_ptr<DynamicBuffer> mDynamicLineLoopIndicesData;
DynamicBuffer mDynamicIndexBuffer;
};
class ImageHelper final : angle::NonCopyable
......
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