Commit 4c310831 by Jamie Madill Committed by Commit Bot

Vulkan: Return VkDeviceSize from DynamicBuffer.

This obviates many static_casts. More closely represents what Vulkan is doing. One cast remains where we are using uint32_t for dynamic offsets with uniform buffers. Bug: angleproject:2786 Change-Id: I043ebb5d965f46ee6ebbfcb91d75a58508cacfe3 Reviewed-on: https://chromium-review.googlesource.com/1188949Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 3e217f65
...@@ -902,7 +902,7 @@ angle::Result ContextVk::updateDriverUniforms(const gl::State &glState) ...@@ -902,7 +902,7 @@ angle::Result ContextVk::updateDriverUniforms(const gl::State &glState)
// Allocate a new region in the dynamic buffer. // Allocate a new region in the dynamic buffer.
uint8_t *ptr = nullptr; uint8_t *ptr = nullptr;
VkBuffer buffer = VK_NULL_HANDLE; VkBuffer buffer = VK_NULL_HANDLE;
uint32_t offset = 0; VkDeviceSize offset = 0;
bool newBufferAllocated = false; bool newBufferAllocated = false;
ANGLE_TRY(mDriverUniformsBuffer.allocate(this, sizeof(DriverUniforms), &ptr, &buffer, &offset, ANGLE_TRY(mDriverUniformsBuffer.allocate(this, sizeof(DriverUniforms), &ptr, &buffer, &offset,
&newBufferAllocated)); &newBufferAllocated));
...@@ -1034,7 +1034,7 @@ angle::Result ContextVk::updateDefaultAttribute(size_t attribIndex) ...@@ -1034,7 +1034,7 @@ angle::Result ContextVk::updateDefaultAttribute(size_t attribIndex)
uint8_t *ptr; uint8_t *ptr;
VkBuffer bufferHandle = VK_NULL_HANDLE; VkBuffer bufferHandle = VK_NULL_HANDLE;
uint32_t offset = 0; VkDeviceSize offset = 0;
ANGLE_TRY( ANGLE_TRY(
defaultBuffer.allocate(this, kDefaultValueSize, &ptr, &bufferHandle, &offset, nullptr)); defaultBuffer.allocate(this, kDefaultValueSize, &ptr, &bufferHandle, &offset, nullptr));
...@@ -1049,7 +1049,8 @@ angle::Result ContextVk::updateDefaultAttribute(size_t attribIndex) ...@@ -1049,7 +1049,8 @@ angle::Result ContextVk::updateDefaultAttribute(size_t attribIndex)
ANGLE_TRY(defaultBuffer.flush(this)); ANGLE_TRY(defaultBuffer.flush(this));
VertexArrayVk *vertexArrayVk = vk::GetImpl(glState.getVertexArray()); VertexArrayVk *vertexArrayVk = vk::GetImpl(glState.getVertexArray());
vertexArrayVk->updateDefaultAttrib(mRenderer, attribIndex, bufferHandle, offset); vertexArrayVk->updateDefaultAttrib(mRenderer, attribIndex, bufferHandle,
static_cast<uint32_t>(offset));
return angle::Result::Continue(); return angle::Result::Continue();
} }
} // namespace rx } // namespace rx
...@@ -454,7 +454,7 @@ angle::Result FramebufferVk::blitWithReadback(ContextVk *contextVk, ...@@ -454,7 +454,7 @@ angle::Result FramebufferVk::blitWithReadback(ContextVk *contextVk,
size_t blitAllocationSize = copyFormat.pixelBytes * copyArea.width * copyArea.height; size_t blitAllocationSize = copyFormat.pixelBytes * copyArea.width * copyArea.height;
uint8_t *destPtr = nullptr; uint8_t *destPtr = nullptr;
VkBuffer destBufferHandle = VK_NULL_HANDLE; VkBuffer destBufferHandle = VK_NULL_HANDLE;
uint32_t destOffset = 0; VkDeviceSize destOffset = 0;
ANGLE_TRY(mBlitPixelBuffer.allocate(contextVk, blitAllocationSize, &destPtr, &destBufferHandle, ANGLE_TRY(mBlitPixelBuffer.allocate(contextVk, blitAllocationSize, &destPtr, &destBufferHandle,
&destOffset, nullptr)); &destOffset, nullptr));
...@@ -1165,7 +1165,7 @@ angle::Result FramebufferVk::readPixelsImpl(ContextVk *contextVk, ...@@ -1165,7 +1165,7 @@ angle::Result FramebufferVk::readPixelsImpl(ContextVk *contextVk,
VkBuffer bufferHandle = VK_NULL_HANDLE; VkBuffer bufferHandle = VK_NULL_HANDLE;
uint8_t *readPixelBuffer = nullptr; uint8_t *readPixelBuffer = nullptr;
bool newBufferAllocated = false; bool newBufferAllocated = false;
uint32_t stagingOffset = 0; VkDeviceSize stagingOffset = 0;
size_t allocationSize = readFormat->pixelBytes * area.width * area.height; size_t allocationSize = readFormat->pixelBytes * area.width * area.height;
ANGLE_TRY(mReadPixelBuffer.allocate(contextVk, allocationSize, &readPixelBuffer, &bufferHandle, ANGLE_TRY(mReadPixelBuffer.allocate(contextVk, allocationSize, &readPixelBuffer, &bufferHandle,
...@@ -1173,7 +1173,7 @@ angle::Result FramebufferVk::readPixelsImpl(ContextVk *contextVk, ...@@ -1173,7 +1173,7 @@ angle::Result FramebufferVk::readPixelsImpl(ContextVk *contextVk,
VkBufferImageCopy region; VkBufferImageCopy region;
region.bufferImageHeight = area.height; region.bufferImageHeight = area.height;
region.bufferOffset = static_cast<VkDeviceSize>(stagingOffset); region.bufferOffset = stagingOffset;
region.bufferRowLength = area.width; region.bufferRowLength = area.width;
region.imageExtent.width = area.width; region.imageExtent.width = area.width;
region.imageExtent.height = area.height; region.imageExtent.height = area.height;
......
...@@ -120,10 +120,10 @@ angle::Result SyncDefaultUniformBlock(ContextVk *contextVk, ...@@ -120,10 +120,10 @@ angle::Result SyncDefaultUniformBlock(ContextVk *contextVk,
ASSERT(!bufferData.empty()); ASSERT(!bufferData.empty());
uint8_t *data = nullptr; uint8_t *data = nullptr;
VkBuffer *outBuffer = nullptr; VkBuffer *outBuffer = nullptr;
uint32_t offset; VkDeviceSize offset = 0;
ANGLE_TRY(dynamicBuffer->allocate(contextVk, bufferData.size(), &data, outBuffer, &offset, ANGLE_TRY(dynamicBuffer->allocate(contextVk, bufferData.size(), &data, outBuffer, &offset,
outBufferModified)); outBufferModified));
*outOffset = offset; *outOffset = static_cast<uint32_t>(offset);
memcpy(data, bufferData.data(), bufferData.size()); memcpy(data, bufferData.data(), bufferData.size());
ANGLE_TRY(dynamicBuffer->flush(contextVk)); ANGLE_TRY(dynamicBuffer->flush(contextVk));
return angle::Result::Continue(); return angle::Result::Continue();
......
...@@ -128,7 +128,7 @@ angle::Result PixelBuffer::stageSubresourceUpdate(ContextVk *contextVk, ...@@ -128,7 +128,7 @@ angle::Result PixelBuffer::stageSubresourceUpdate(ContextVk *contextVk,
uint8_t *stagingPointer = nullptr; uint8_t *stagingPointer = nullptr;
bool newBufferAllocated = false; bool newBufferAllocated = false;
uint32_t stagingOffset = 0; VkDeviceSize stagingOffset = 0;
size_t allocationSize = outputDepthPitch * extents.depth; size_t allocationSize = outputDepthPitch * extents.depth;
ANGLE_TRY(mStagingBuffer.allocate(contextVk, allocationSize, &stagingPointer, &bufferHandle, ANGLE_TRY(mStagingBuffer.allocate(contextVk, allocationSize, &stagingPointer, &bufferHandle,
&stagingOffset, &newBufferAllocated)); &stagingOffset, &newBufferAllocated));
...@@ -142,7 +142,7 @@ angle::Result PixelBuffer::stageSubresourceUpdate(ContextVk *contextVk, ...@@ -142,7 +142,7 @@ angle::Result PixelBuffer::stageSubresourceUpdate(ContextVk *contextVk,
VkBufferImageCopy copy; VkBufferImageCopy copy;
copy.bufferOffset = static_cast<VkDeviceSize>(stagingOffset); copy.bufferOffset = stagingOffset;
copy.bufferRowLength = extents.width; copy.bufferRowLength = extents.width;
copy.bufferImageHeight = extents.height; copy.bufferImageHeight = extents.height;
copy.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; copy.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
...@@ -199,7 +199,7 @@ angle::Result PixelBuffer::stageSubresourceUpdateFromFramebuffer( ...@@ -199,7 +199,7 @@ angle::Result PixelBuffer::stageSubresourceUpdateFromFramebuffer(
uint8_t *stagingPointer = nullptr; uint8_t *stagingPointer = nullptr;
bool newBufferAllocated = false; bool newBufferAllocated = false;
uint32_t stagingOffset = 0; VkDeviceSize stagingOffset = 0;
// The destination is only one layer deep. // The destination is only one layer deep.
size_t allocationSize = outputDepthPitch; size_t allocationSize = outputDepthPitch;
...@@ -269,7 +269,7 @@ angle::Result PixelBuffer::allocate(ContextVk *contextVk, ...@@ -269,7 +269,7 @@ angle::Result PixelBuffer::allocate(ContextVk *contextVk,
size_t sizeInBytes, size_t sizeInBytes,
uint8_t **ptrOut, uint8_t **ptrOut,
VkBuffer *handleOut, VkBuffer *handleOut,
uint32_t *offsetOut, VkDeviceSize *offsetOut,
bool *newBufferAllocatedOut) bool *newBufferAllocatedOut)
{ {
return mStagingBuffer.allocate(contextVk, sizeInBytes, ptrOut, handleOut, offsetOut, return mStagingBuffer.allocate(contextVk, sizeInBytes, ptrOut, handleOut, offsetOut,
...@@ -345,13 +345,13 @@ angle::Result PixelBuffer::stageSubresourceUpdateAndGetData(ContextVk *contextVk ...@@ -345,13 +345,13 @@ angle::Result PixelBuffer::stageSubresourceUpdateAndGetData(ContextVk *contextVk
uint8_t **destData) uint8_t **destData)
{ {
VkBuffer bufferHandle; VkBuffer bufferHandle;
uint32_t stagingOffset = 0; VkDeviceSize stagingOffset = 0;
bool newBufferAllocated = false; bool newBufferAllocated = false;
ANGLE_TRY(mStagingBuffer.allocate(contextVk, allocationSize, destData, &bufferHandle, ANGLE_TRY(mStagingBuffer.allocate(contextVk, allocationSize, destData, &bufferHandle,
&stagingOffset, &newBufferAllocated)); &stagingOffset, &newBufferAllocated));
VkBufferImageCopy copy; VkBufferImageCopy copy;
copy.bufferOffset = static_cast<VkDeviceSize>(stagingOffset); copy.bufferOffset = stagingOffset;
copy.bufferRowLength = extents.width; copy.bufferRowLength = extents.width;
copy.bufferImageHeight = extents.height; copy.bufferImageHeight = extents.height;
copy.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; copy.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
...@@ -779,12 +779,12 @@ angle::Result TextureVk::copyImageDataToBuffer(ContextVk *contextVk, ...@@ -779,12 +779,12 @@ angle::Result TextureVk::copyImageDataToBuffer(ContextVk *contextVk,
// Allocate enough memory to copy the sourceArea region of the source texture into its pixel // Allocate enough memory to copy the sourceArea region of the source texture into its pixel
// buffer. // buffer.
VkBuffer copyBufferHandle; VkBuffer copyBufferHandle;
uint32_t sourceCopyOffset = 0; VkDeviceSize sourceCopyOffset = 0;
ANGLE_TRY(mPixelBuffer.allocate(contextVk, sourceCopyAllocationSize, outDataPtr, ANGLE_TRY(mPixelBuffer.allocate(contextVk, sourceCopyAllocationSize, outDataPtr,
&copyBufferHandle, &sourceCopyOffset, &newBufferAllocated)); &copyBufferHandle, &sourceCopyOffset, &newBufferAllocated));
VkBufferImageCopy region; VkBufferImageCopy region;
region.bufferOffset = static_cast<VkDeviceSize>(sourceCopyOffset); region.bufferOffset = sourceCopyOffset;
region.bufferRowLength = imageSize.width; region.bufferRowLength = imageSize.width;
region.bufferImageHeight = imageSize.height; region.bufferImageHeight = imageSize.height;
region.imageExtent.width = sourceArea.width; region.imageExtent.width = sourceArea.width;
...@@ -907,7 +907,7 @@ angle::Result TextureVk::generateMipmapWithCPU(const gl::Context *context) ...@@ -907,7 +907,7 @@ angle::Result TextureVk::generateMipmapWithCPU(const gl::Context *context)
VkBuffer copyBufferHandle; VkBuffer copyBufferHandle;
uint8_t *baseLevelBuffers; uint8_t *baseLevelBuffers;
uint32_t copyBaseOffset; VkDeviceSize copyBaseOffset;
// Allocate enough memory to copy every level 0 image (one for each layer of the texture). // Allocate enough memory to copy every level 0 image (one for each layer of the texture).
ANGLE_TRY(mPixelBuffer.allocate(contextVk, totalAllocationSize, &baseLevelBuffers, ANGLE_TRY(mPixelBuffer.allocate(contextVk, totalAllocationSize, &baseLevelBuffers,
...@@ -916,7 +916,7 @@ angle::Result TextureVk::generateMipmapWithCPU(const gl::Context *context) ...@@ -916,7 +916,7 @@ angle::Result TextureVk::generateMipmapWithCPU(const gl::Context *context)
// Do only one copy for all layers at once. // Do only one copy for all layers at once.
VkBufferImageCopy region; VkBufferImageCopy region;
region.bufferImageHeight = baseLevelExtents.height; region.bufferImageHeight = baseLevelExtents.height;
region.bufferOffset = static_cast<VkDeviceSize>(copyBaseOffset); region.bufferOffset = copyBaseOffset;
region.bufferRowLength = baseLevelExtents.width; region.bufferRowLength = baseLevelExtents.width;
region.imageExtent.width = baseLevelExtents.width; region.imageExtent.width = baseLevelExtents.width;
region.imageExtent.height = baseLevelExtents.height; region.imageExtent.height = baseLevelExtents.height;
......
...@@ -58,7 +58,7 @@ class PixelBuffer final : angle::NonCopyable ...@@ -58,7 +58,7 @@ class PixelBuffer final : angle::NonCopyable
size_t sizeInBytes, size_t sizeInBytes,
uint8_t **ptrOut, uint8_t **ptrOut,
VkBuffer *handleOut, VkBuffer *handleOut,
uint32_t *offsetOut, VkDeviceSize *offsetOut,
bool *newBufferAllocatedOut); bool *newBufferAllocatedOut);
angle::Result flushUpdatesToImage(ContextVk *contextVk, angle::Result flushUpdatesToImage(ContextVk *contextVk,
......
...@@ -122,12 +122,10 @@ angle::Result VertexArrayVk::streamVertexData(ContextVk *contextVk, ...@@ -122,12 +122,10 @@ angle::Result VertexArrayVk::streamVertexData(ContextVk *contextVk,
const uint8_t *src = static_cast<const uint8_t *>(attrib.pointer) + const uint8_t *src = static_cast<const uint8_t *>(attrib.pointer) +
drawCallParams.firstVertex() * binding.getStride(); drawCallParams.firstVertex() * binding.getStride();
uint8_t *dst = nullptr; uint8_t *dst = nullptr;
uint32_t offset = 0;
ANGLE_TRY(mDynamicVertexData.allocate(contextVk, bytesAllocated, &dst, ANGLE_TRY(mDynamicVertexData.allocate(contextVk, bytesAllocated, &dst,
&mCurrentArrayBufferHandles[attribIndex], &offset, &mCurrentArrayBufferHandles[attribIndex],
nullptr)); &mCurrentArrayBufferOffsets[attribIndex], nullptr));
dst += drawCallParams.firstVertex() * mCurrentArrayBufferStrides[attribIndex]; dst += drawCallParams.firstVertex() * mCurrentArrayBufferStrides[attribIndex];
mCurrentArrayBufferOffsets[attribIndex] = static_cast<VkDeviceSize>(offset);
mCurrentArrayBufferFormats[attribIndex]->vertexLoadFunction( mCurrentArrayBufferFormats[attribIndex]->vertexLoadFunction(
src, binding.getStride(), drawCallParams.vertexCount(), dst); src, binding.getStride(), drawCallParams.vertexCount(), dst);
} }
...@@ -142,13 +140,11 @@ angle::Result VertexArrayVk::streamIndexData(ContextVk *contextVk, ...@@ -142,13 +140,11 @@ angle::Result VertexArrayVk::streamIndexData(ContextVk *contextVk,
{ {
ASSERT(!mState.getElementArrayBuffer().get()); ASSERT(!mState.getElementArrayBuffer().get());
uint32_t offset = 0;
const GLsizei amount = sizeof(GLushort) * drawCallParams.indexCount(); const GLsizei amount = sizeof(GLushort) * drawCallParams.indexCount();
GLubyte *dst = nullptr; GLubyte *dst = nullptr;
ANGLE_TRY(mDynamicIndexData.allocate(contextVk, amount, &dst, &mCurrentElementArrayBufferHandle, ANGLE_TRY(mDynamicIndexData.allocate(contextVk, amount, &dst, &mCurrentElementArrayBufferHandle,
&offset, nullptr)); &mCurrentElementArrayBufferOffset, nullptr));
if (drawCallParams.type() == GL_UNSIGNED_BYTE) if (drawCallParams.type() == GL_UNSIGNED_BYTE)
{ {
// Unsigned bytes don't have direct support in Vulkan so we have to expand the // Unsigned bytes don't have direct support in Vulkan so we have to expand the
...@@ -166,7 +162,6 @@ angle::Result VertexArrayVk::streamIndexData(ContextVk *contextVk, ...@@ -166,7 +162,6 @@ angle::Result VertexArrayVk::streamIndexData(ContextVk *contextVk,
} }
ANGLE_TRY(mDynamicIndexData.flush(contextVk)); ANGLE_TRY(mDynamicIndexData.flush(contextVk));
mDynamicIndexData.releaseRetainedBuffers(contextVk->getRenderer()); mDynamicIndexData.releaseRetainedBuffers(contextVk->getRenderer());
mCurrentElementArrayBufferOffset = offset;
return angle::Result::Continue(); return angle::Result::Continue();
} }
...@@ -201,11 +196,10 @@ angle::Result VertexArrayVk::convertVertexBuffer(ContextVk *context, ...@@ -201,11 +196,10 @@ angle::Result VertexArrayVk::convertVertexBuffer(ContextVk *context,
void *src = nullptr; void *src = nullptr;
uint8_t *dst = nullptr; uint8_t *dst = nullptr;
uint32_t offset = 0;
ANGLE_TRY(mCurrentArrayBufferConversion[attribIndex].allocate( ANGLE_TRY(mCurrentArrayBufferConversion[attribIndex].allocate(
context, numVertices * dstFormatSize, &dst, &mCurrentArrayBufferHandles[attribIndex], context, numVertices * dstFormatSize, &dst, &mCurrentArrayBufferHandles[attribIndex],
&offset, nullptr)); &mCurrentArrayBufferOffsets[attribIndex], nullptr));
ANGLE_TRY(srcBuffer->mapImpl(context, &src)); ANGLE_TRY(srcBuffer->mapImpl(context, &src));
mCurrentArrayBufferFormats[attribIndex]->vertexLoadFunction( mCurrentArrayBufferFormats[attribIndex]->vertexLoadFunction(
static_cast<const uint8_t *>(src) + binding.getOffset(), binding.getStride(), numVertices, static_cast<const uint8_t *>(src) + binding.getOffset(), binding.getStride(), numVertices,
...@@ -214,7 +208,6 @@ angle::Result VertexArrayVk::convertVertexBuffer(ContextVk *context, ...@@ -214,7 +208,6 @@ angle::Result VertexArrayVk::convertVertexBuffer(ContextVk *context,
ANGLE_TRY(mCurrentArrayBufferConversion[attribIndex].flush(context)); ANGLE_TRY(mCurrentArrayBufferConversion[attribIndex].flush(context));
mCurrentArrayBufferConversionCanRelease[attribIndex] = true; mCurrentArrayBufferConversionCanRelease[attribIndex] = true;
mCurrentArrayBufferOffsets[attribIndex] = offset;
mCurrentArrayBufferStrides[attribIndex] = dstFormatSize; mCurrentArrayBufferStrides[attribIndex] = dstFormatSize;
return angle::Result::Continue(); return angle::Result::Continue();
...@@ -644,11 +637,10 @@ gl::Error VertexArrayVk::onIndexedDraw(const gl::Context *context, ...@@ -644,11 +637,10 @@ gl::Error VertexArrayVk::onIndexedDraw(const gl::Context *context,
// go from unsigned byte to unsigned short. // go from unsigned byte to unsigned short.
uint8_t *allocatedData = nullptr; uint8_t *allocatedData = nullptr;
bool newBufferAllocated = false; bool newBufferAllocated = false;
uint32_t expandedDataOffset = 0;
ANGLE_TRY(mTranslatedByteIndexData.allocate( ANGLE_TRY(mTranslatedByteIndexData.allocate(
contextVk, static_cast<size_t>(bufferVk->getSize()) * 2, &allocatedData, contextVk, static_cast<size_t>(bufferVk->getSize()) * 2, &allocatedData,
&mCurrentElementArrayBufferHandle, &expandedDataOffset, &newBufferAllocated)); &mCurrentElementArrayBufferHandle, &mCurrentElementArrayBufferOffset,
mCurrentElementArrayBufferOffset = static_cast<VkDeviceSize>(expandedDataOffset); &newBufferAllocated));
// Expand the source into the destination // Expand the source into the destination
ASSERT(!context->getGLState().isPrimitiveRestartEnabled()); ASSERT(!context->getGLState().isPrimitiveRestartEnabled());
......
...@@ -106,7 +106,7 @@ angle::Result DynamicBuffer::allocate(Context *context, ...@@ -106,7 +106,7 @@ angle::Result DynamicBuffer::allocate(Context *context,
size_t sizeInBytes, size_t sizeInBytes,
uint8_t **ptrOut, uint8_t **ptrOut,
VkBuffer *handleOut, VkBuffer *handleOut,
uint32_t *offsetOut, VkDeviceSize *offsetOut,
bool *newBufferAllocatedOut) bool *newBufferAllocatedOut)
{ {
size_t sizeToAllocate = roundUp(sizeInBytes, mAlignment); size_t sizeToAllocate = roundUp(sizeInBytes, mAlignment);
...@@ -163,7 +163,7 @@ angle::Result DynamicBuffer::allocate(Context *context, ...@@ -163,7 +163,7 @@ angle::Result DynamicBuffer::allocate(Context *context,
ASSERT(mMappedMemory); ASSERT(mMappedMemory);
*ptrOut = mMappedMemory + mNextAllocationOffset; *ptrOut = mMappedMemory + mNextAllocationOffset;
*offsetOut = mNextAllocationOffset; *offsetOut = static_cast<VkDeviceSize>(mNextAllocationOffset);
mNextAllocationOffset += static_cast<uint32_t>(sizeToAllocate); mNextAllocationOffset += static_cast<uint32_t>(sizeToAllocate);
return angle::Result::Continue(); return angle::Result::Continue();
} }
...@@ -373,13 +373,11 @@ angle::Result LineLoopHelper::getIndexBufferForDrawArrays(Context *context, ...@@ -373,13 +373,11 @@ angle::Result LineLoopHelper::getIndexBufferForDrawArrays(Context *context,
{ {
uint32_t *indices = nullptr; uint32_t *indices = nullptr;
size_t allocateBytes = sizeof(uint32_t) * (drawCallParams.vertexCount() + 1); size_t allocateBytes = sizeof(uint32_t) * (drawCallParams.vertexCount() + 1);
uint32_t offset = 0;
mDynamicIndexBuffer.releaseRetainedBuffers(context->getRenderer()); mDynamicIndexBuffer.releaseRetainedBuffers(context->getRenderer());
ANGLE_TRY(mDynamicIndexBuffer.allocate(context, allocateBytes, ANGLE_TRY(mDynamicIndexBuffer.allocate(context, allocateBytes,
reinterpret_cast<uint8_t **>(&indices), bufferHandleOut, reinterpret_cast<uint8_t **>(&indices), bufferHandleOut,
&offset, nullptr)); offsetOut, nullptr));
*offsetOut = static_cast<VkDeviceSize>(offset);
uint32_t clampedVertexCount = drawCallParams.getClampedVertexCount<uint32_t>(); uint32_t clampedVertexCount = drawCallParams.getClampedVertexCount<uint32_t>();
...@@ -411,7 +409,6 @@ angle::Result LineLoopHelper::getIndexBufferForElementArrayBuffer(Context *conte ...@@ -411,7 +409,6 @@ angle::Result LineLoopHelper::getIndexBufferForElementArrayBuffer(Context *conte
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 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);
...@@ -419,13 +416,12 @@ angle::Result LineLoopHelper::getIndexBufferForElementArrayBuffer(Context *conte ...@@ -419,13 +416,12 @@ angle::Result LineLoopHelper::getIndexBufferForElementArrayBuffer(Context *conte
mDynamicIndexBuffer.releaseRetainedBuffers(context->getRenderer()); mDynamicIndexBuffer.releaseRetainedBuffers(context->getRenderer());
ANGLE_TRY(mDynamicIndexBuffer.allocate(context, allocateBytes, ANGLE_TRY(mDynamicIndexBuffer.allocate(context, allocateBytes,
reinterpret_cast<uint8_t **>(&indices), bufferHandleOut, reinterpret_cast<uint8_t **>(&indices), bufferHandleOut,
&destinationOffset, nullptr)); bufferOffsetOut, nullptr));
*bufferOffsetOut = static_cast<VkDeviceSize>(destinationOffset);
VkDeviceSize sourceOffset = static_cast<VkDeviceSize>(elementArrayOffset); VkDeviceSize sourceOffset = static_cast<VkDeviceSize>(elementArrayOffset);
uint64_t unitCount = static_cast<VkDeviceSize>(indexCount); uint64_t unitCount = static_cast<VkDeviceSize>(indexCount);
VkBufferCopy copy1 = {sourceOffset, destinationOffset, unitCount * unitSize}; VkBufferCopy copy1 = {sourceOffset, *bufferOffsetOut, unitCount * unitSize};
VkBufferCopy copy2 = {sourceOffset, destinationOffset + unitCount * unitSize, unitSize}; VkBufferCopy copy2 = {sourceOffset, *bufferOffsetOut + unitCount * unitSize, unitSize};
std::array<VkBufferCopy, 2> copies = {{copy1, copy2}}; std::array<VkBufferCopy, 2> copies = {{copy1, copy2}};
vk::CommandBuffer *commandBuffer; vk::CommandBuffer *commandBuffer;
...@@ -448,14 +444,12 @@ angle::Result LineLoopHelper::getIndexBufferForClientElementArray( ...@@ -448,14 +444,12 @@ angle::Result LineLoopHelper::getIndexBufferForClientElementArray(
VkIndexType indexType = gl_vk::GetIndexType(drawCallParams.type()); VkIndexType indexType = gl_vk::GetIndexType(drawCallParams.type());
uint8_t *indices = nullptr; uint8_t *indices = nullptr;
uint32_t offset = 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 * (drawCallParams.indexCount() + 1); size_t allocateBytes = unitSize * (drawCallParams.indexCount() + 1);
ANGLE_TRY(mDynamicIndexBuffer.allocate(context, allocateBytes, ANGLE_TRY(mDynamicIndexBuffer.allocate(context, allocateBytes,
reinterpret_cast<uint8_t **>(&indices), bufferHandleOut, reinterpret_cast<uint8_t **>(&indices), bufferHandleOut,
&offset, nullptr)); bufferOffsetOut, nullptr));
*bufferOffsetOut = static_cast<VkDeviceSize>(offset);
if (drawCallParams.type() == GL_UNSIGNED_BYTE) if (drawCallParams.type() == GL_UNSIGNED_BYTE)
{ {
......
...@@ -44,7 +44,7 @@ class DynamicBuffer : angle::NonCopyable ...@@ -44,7 +44,7 @@ class DynamicBuffer : angle::NonCopyable
size_t sizeInBytes, size_t sizeInBytes,
uint8_t **ptrOut, uint8_t **ptrOut,
VkBuffer *handleOut, VkBuffer *handleOut,
uint32_t *offsetOut, VkDeviceSize *offsetOut,
bool *newBufferAllocatedOut); bool *newBufferAllocatedOut);
// After a sequence of writes, call flush to ensure the data is visible to the device. // After a sequence of writes, call flush to ensure the data is visible to the device.
......
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