Vulkan: Rename BufferHelper::initFor* to allocateFor*

Simply name change per feedback from other CL's review.

Bug: b/205337962
Change-Id: Ieb53ed9a2922d09716a1219eb340fe273e5f1807
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3402882
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Charlie Lao <cclao@google.com>
This commit is contained in:
Charlie Lao 2022-01-20 10:59:05 -08:00 коммит произвёл Angle LUCI CQ
Родитель a83f7e91c9
Коммит d235496894
4 изменённых файлов: 70 добавлений и 66 удалений

Просмотреть файл

@ -488,7 +488,8 @@ angle::Result BufferVk::allocStagingBuffer(ContextVk *contextVk,
mStagingBuffer.release(contextVk->getRenderer()); mStagingBuffer.release(contextVk->getRenderer());
} }
ANGLE_TRY(mStagingBuffer.initForCopyBuffer(contextVk, static_cast<size_t>(size), coherency)); ANGLE_TRY(
mStagingBuffer.allocateForCopyBuffer(contextVk, static_cast<size_t>(size), coherency));
*mapPtr = mStagingBuffer.getMappedMemory(); *mapPtr = mStagingBuffer.getMappedMemory();
mIsStagingBufferMapped = true; mIsStagingBufferMapped = true;

Просмотреть файл

@ -76,8 +76,8 @@ angle::Result StreamVertexData(ContextVk *contextVk,
RendererVk *renderer = contextVk->getRenderer(); RendererVk *renderer = contextVk->getRenderer();
// Allocate buffer for results // Allocate buffer for results
ANGLE_TRY(dstBufferHelper->initForVertexConversion(contextVk, bytesToAllocate, ANGLE_TRY(dstBufferHelper->allocateForVertexConversion(contextVk, bytesToAllocate,
vk::MemoryHostVisibility::Visible)); vk::MemoryHostVisibility::Visible));
uint8_t *dst = dstBufferHelper->getMappedMemory() + dstOffset; uint8_t *dst = dstBufferHelper->getMappedMemory() + dstOffset;
if (replicateCount == 1) if (replicateCount == 1)
@ -167,7 +167,7 @@ angle::Result VertexArrayVk::convertIndexBufferGPU(ContextVk *contextVk,
size_t srcDataSize = static_cast<size_t>(bufferVk->getSize()) - offsetIntoSrcData; size_t srcDataSize = static_cast<size_t>(bufferVk->getSize()) - offsetIntoSrcData;
// Allocate buffer for results // Allocate buffer for results
ANGLE_TRY(mTranslatedByteIndexData.initForVertexConversion( ANGLE_TRY(mTranslatedByteIndexData.allocateForVertexConversion(
contextVk, sizeof(GLushort) * srcDataSize, vk::MemoryHostVisibility::NonVisible)); contextVk, sizeof(GLushort) * srcDataSize, vk::MemoryHostVisibility::NonVisible));
mCurrentElementArrayBuffer = &mTranslatedByteIndexData; mCurrentElementArrayBuffer = &mTranslatedByteIndexData;
@ -196,11 +196,11 @@ angle::Result VertexArrayVk::convertIndexBufferIndirectGPU(ContextVk *contextVk,
vk::BufferHelper *srcIndexBuf = mCurrentElementArrayBuffer; vk::BufferHelper *srcIndexBuf = mCurrentElementArrayBuffer;
// Allocate buffer for results // Allocate buffer for results
ANGLE_TRY(mTranslatedByteIndexData.initForVertexConversion( ANGLE_TRY(mTranslatedByteIndexData.allocateForVertexConversion(
contextVk, sizeof(GLushort) * srcDataSize, vk::MemoryHostVisibility::NonVisible)); contextVk, sizeof(GLushort) * srcDataSize, vk::MemoryHostVisibility::NonVisible));
vk::BufferHelper *dstIndexBuf = &mTranslatedByteIndexData; vk::BufferHelper *dstIndexBuf = &mTranslatedByteIndexData;
ANGLE_TRY(mTranslatedByteIndirectData.initForVertexConversion( ANGLE_TRY(mTranslatedByteIndirectData.allocateForVertexConversion(
contextVk, sizeof(VkDrawIndexedIndirectCommand), vk::MemoryHostVisibility::NonVisible)); contextVk, sizeof(VkDrawIndexedIndirectCommand), vk::MemoryHostVisibility::NonVisible));
vk::BufferHelper *dstIndirectBuf = &mTranslatedByteIndirectData; vk::BufferHelper *dstIndirectBuf = &mTranslatedByteIndirectData;
@ -277,8 +277,8 @@ angle::Result VertexArrayVk::convertIndexBufferCPU(ContextVk *contextVk,
size_t elementSize = contextVk->getVkIndexTypeSize(indexType); size_t elementSize = contextVk->getVkIndexTypeSize(indexType);
const size_t amount = elementSize * indexCount; const size_t amount = elementSize * indexCount;
ANGLE_TRY(mStreamedIndexData.initForVertexConversion(contextVk, amount, ANGLE_TRY(mStreamedIndexData.allocateForVertexConversion(contextVk, amount,
vk::MemoryHostVisibility::Visible)); vk::MemoryHostVisibility::Visible));
GLubyte *dst = mStreamedIndexData.getMappedMemory(); GLubyte *dst = mStreamedIndexData.getMappedMemory();
mCurrentElementArrayBuffer = &mStreamedIndexData; mCurrentElementArrayBuffer = &mStreamedIndexData;
@ -354,8 +354,8 @@ angle::Result VertexArrayVk::convertVertexBufferGPU(ContextVk *contextVk,
// Allocate buffer for results // Allocate buffer for results
vk::BufferHelper *dstBuffer = conversion->data.get(); vk::BufferHelper *dstBuffer = conversion->data.get();
ANGLE_TRY(dstBuffer->initForVertexConversion(contextVk, numVertices * dstFormatSize, ANGLE_TRY(dstBuffer->allocateForVertexConversion(contextVk, numVertices * dstFormatSize,
vk::MemoryHostVisibility::NonVisible)); vk::MemoryHostVisibility::NonVisible));
ASSERT(conversion->dirty); ASSERT(conversion->dirty);
conversion->dirty = false; conversion->dirty = false;

Просмотреть файл

@ -3632,8 +3632,8 @@ angle::Result LineLoopHelper::getIndexBufferForDrawArrays(ContextVk *contextVk,
BufferHelper **bufferOut) BufferHelper **bufferOut)
{ {
size_t allocateBytes = sizeof(uint32_t) * (static_cast<size_t>(clampedVertexCount) + 1); size_t allocateBytes = sizeof(uint32_t) * (static_cast<size_t>(clampedVertexCount) + 1);
ANGLE_TRY(mDynamicIndexBuffer.initForVertexConversion(contextVk, allocateBytes, ANGLE_TRY(mDynamicIndexBuffer.allocateForVertexConversion(contextVk, allocateBytes,
MemoryHostVisibility::Visible)); MemoryHostVisibility::Visible));
uint32_t *indices = reinterpret_cast<uint32_t *>(mDynamicIndexBuffer.getMappedMemory()); uint32_t *indices = reinterpret_cast<uint32_t *>(mDynamicIndexBuffer.getMappedMemory());
// Note: there could be an overflow in this addition. // Note: there could be an overflow in this addition.
@ -3682,8 +3682,8 @@ angle::Result LineLoopHelper::getIndexBufferForElementArrayBuffer(ContextVk *con
size_t unitSize = contextVk->getVkIndexTypeSize(glIndexType); size_t unitSize = contextVk->getVkIndexTypeSize(glIndexType);
size_t allocateBytes = unitSize * (indexCount + 1) + 1; size_t allocateBytes = unitSize * (indexCount + 1) + 1;
ANGLE_TRY(mDynamicIndexBuffer.initForVertexConversion(contextVk, allocateBytes, ANGLE_TRY(mDynamicIndexBuffer.allocateForVertexConversion(contextVk, allocateBytes,
MemoryHostVisibility::Visible)); MemoryHostVisibility::Visible));
BufferHelper *sourceBuffer = &elementArrayBufferVk->getBuffer(); BufferHelper *sourceBuffer = &elementArrayBufferVk->getBuffer();
VkDeviceSize sourceOffset = VkDeviceSize sourceOffset =
@ -3727,8 +3727,8 @@ angle::Result LineLoopHelper::streamIndices(ContextVk *contextVk,
} }
*indexCountOut = numOutIndices; *indexCountOut = numOutIndices;
ANGLE_TRY(mDynamicIndexBuffer.initForVertexConversion(contextVk, unitSize * numOutIndices, ANGLE_TRY(mDynamicIndexBuffer.allocateForVertexConversion(contextVk, unitSize * numOutIndices,
MemoryHostVisibility::Visible)); MemoryHostVisibility::Visible));
uint8_t *indices = mDynamicIndexBuffer.getMappedMemory(); uint8_t *indices = mDynamicIndexBuffer.getMappedMemory();
if (contextVk->getState().isPrimitiveRestartEnabled()) if (contextVk->getState().isPrimitiveRestartEnabled())
@ -3790,9 +3790,9 @@ angle::Result LineLoopHelper::streamIndicesIndirect(ContextVk *contextVk,
} }
// Allocate buffer for results // Allocate buffer for results
ANGLE_TRY(mDynamicIndexBuffer.initForVertexConversion(contextVk, allocateBytes, ANGLE_TRY(mDynamicIndexBuffer.allocateForVertexConversion(contextVk, allocateBytes,
MemoryHostVisibility::Visible)); MemoryHostVisibility::Visible));
ANGLE_TRY(mDynamicIndirectBuffer.initForVertexConversion( ANGLE_TRY(mDynamicIndirectBuffer.allocateForVertexConversion(
contextVk, sizeof(VkDrawIndexedIndirectCommand), MemoryHostVisibility::Visible)); contextVk, sizeof(VkDrawIndexedIndirectCommand), MemoryHostVisibility::Visible));
*indexBufferOut = &mDynamicIndexBuffer; *indexBufferOut = &mDynamicIndexBuffer;
@ -3824,9 +3824,9 @@ angle::Result LineLoopHelper::streamArrayIndirect(ContextVk *contextVk,
auto unitSize = sizeof(uint32_t); auto unitSize = sizeof(uint32_t);
size_t allocateBytes = static_cast<size_t>((vertexCount + 1) * unitSize); size_t allocateBytes = static_cast<size_t>((vertexCount + 1) * unitSize);
ANGLE_TRY(mDynamicIndexBuffer.initForVertexConversion(contextVk, allocateBytes, ANGLE_TRY(mDynamicIndexBuffer.allocateForVertexConversion(contextVk, allocateBytes,
MemoryHostVisibility::Visible)); MemoryHostVisibility::Visible));
ANGLE_TRY(mDynamicIndirectBuffer.initForVertexConversion( ANGLE_TRY(mDynamicIndirectBuffer.allocateForVertexConversion(
contextVk, sizeof(VkDrawIndexedIndirectCommand), MemoryHostVisibility::Visible)); contextVk, sizeof(VkDrawIndexedIndirectCommand), MemoryHostVisibility::Visible));
*indexBufferOut = &mDynamicIndexBuffer; *indexBufferOut = &mDynamicIndexBuffer;
@ -4052,9 +4052,9 @@ angle::Result BufferHelper::initSuballocation(ContextVk *contextVk,
return angle::Result::Continue; return angle::Result::Continue;
} }
angle::Result BufferHelper::initForCopyBuffer(ContextVk *contextVk, angle::Result BufferHelper::allocateForCopyBuffer(ContextVk *contextVk,
size_t size, size_t size,
MemoryCoherency coherency) MemoryCoherency coherency)
{ {
RendererVk *renderer = contextVk->getRenderer(); RendererVk *renderer = contextVk->getRenderer();
uint32_t memoryTypeIndex = renderer->getStagingBufferMemoryTypeIndex(coherency); uint32_t memoryTypeIndex = renderer->getStagingBufferMemoryTypeIndex(coherency);
@ -4062,9 +4062,9 @@ angle::Result BufferHelper::initForCopyBuffer(ContextVk *contextVk,
return initSuballocation(contextVk, memoryTypeIndex, size, alignment); return initSuballocation(contextVk, memoryTypeIndex, size, alignment);
} }
angle::Result BufferHelper::initForVertexConversion(ContextVk *contextVk, angle::Result BufferHelper::allocateForVertexConversion(ContextVk *contextVk,
size_t size, size_t size,
MemoryHostVisibility hostVisibility) MemoryHostVisibility hostVisibility)
{ {
RendererVk *renderer = contextVk->getRenderer(); RendererVk *renderer = contextVk->getRenderer();
@ -4101,12 +4101,12 @@ angle::Result BufferHelper::initForVertexConversion(ContextVk *contextVk,
return initSuballocation(contextVk, memoryTypeIndex, sizeToAllocate, alignment); return initSuballocation(contextVk, memoryTypeIndex, sizeToAllocate, alignment);
} }
angle::Result BufferHelper::initForCopyImage(ContextVk *contextVk, angle::Result BufferHelper::allocateForCopyImage(ContextVk *contextVk,
size_t size, size_t size,
MemoryCoherency coherency, MemoryCoherency coherency,
angle::FormatID formatId, angle::FormatID formatId,
VkDeviceSize *offset, VkDeviceSize *offset,
uint8_t **dataPtr) uint8_t **dataPtr)
{ {
RendererVk *renderer = contextVk->getRenderer(); RendererVk *renderer = contextVk->getRenderer();
@ -6231,9 +6231,9 @@ angle::Result ImageHelper::stageSubresourceUpdateImpl(ContextVk *contextVk,
uint8_t *stagingPointer; uint8_t *stagingPointer;
VkDeviceSize stagingOffset; VkDeviceSize stagingOffset;
ANGLE_TRY(currentBuffer->initForCopyImage(contextVk, allocationSize, ANGLE_TRY(currentBuffer->allocateForCopyImage(contextVk, allocationSize,
MemoryCoherency::NonCoherent, storageFormat.id, MemoryCoherency::NonCoherent, storageFormat.id,
&stagingOffset, &stagingPointer)); &stagingOffset, &stagingPointer));
const uint8_t *source = pixels + static_cast<ptrdiff_t>(inputSkipBytes); const uint8_t *source = pixels + static_cast<ptrdiff_t>(inputSkipBytes);
@ -6403,9 +6403,9 @@ angle::Result ImageHelper::reformatStagedBufferUpdates(ContextVk *contextVk,
uint8_t *dstData; uint8_t *dstData;
VkDeviceSize dstBufferOffset; VkDeviceSize dstBufferOffset;
size_t dstBufferSize = dstDataDepthPitch * copy.imageExtent.depth; size_t dstBufferSize = dstDataDepthPitch * copy.imageExtent.depth;
ANGLE_TRY(dstBuffer->initForCopyImage(contextVk, dstBufferSize, ANGLE_TRY(dstBuffer->allocateForCopyImage(contextVk, dstBufferSize,
MemoryCoherency::NonCoherent, dstFormatID, MemoryCoherency::NonCoherent, dstFormatID,
&dstBufferOffset, &dstData)); &dstBufferOffset, &dstData));
rx::PixelReadFunction pixelReadFunction = srcFormat.pixelReadFunction; rx::PixelReadFunction pixelReadFunction = srcFormat.pixelReadFunction;
rx::PixelWriteFunction pixelWriteFunction = dstFormat.pixelWriteFunction; rx::PixelWriteFunction pixelWriteFunction = dstFormat.pixelWriteFunction;
@ -6623,9 +6623,9 @@ angle::Result ImageHelper::stageSubresourceUpdateAndGetData(ContextVk *contextVk
BufferHelper *currentBuffer = &stagingBuffer->get(); BufferHelper *currentBuffer = &stagingBuffer->get();
VkDeviceSize stagingOffset; VkDeviceSize stagingOffset;
ANGLE_TRY(currentBuffer->initForCopyImage(contextVk, allocationSize, ANGLE_TRY(currentBuffer->allocateForCopyImage(contextVk, allocationSize,
MemoryCoherency::NonCoherent, formatID, MemoryCoherency::NonCoherent, formatID,
&stagingOffset, dstData)); &stagingOffset, dstData));
gl::LevelIndex updateLevelGL(imageIndex.getLevelIndex()); gl::LevelIndex updateLevelGL(imageIndex.getLevelIndex());
@ -6697,9 +6697,9 @@ angle::Result ImageHelper::stageSubresourceUpdateFromFramebuffer(
// The destination is only one layer deep. // The destination is only one layer deep.
size_t allocationSize = outputDepthPitch; size_t allocationSize = outputDepthPitch;
ANGLE_TRY(currentBuffer->initForCopyImage(contextVk, allocationSize, ANGLE_TRY(currentBuffer->allocateForCopyImage(contextVk, allocationSize,
MemoryCoherency::NonCoherent, storageFormat.id, MemoryCoherency::NonCoherent, storageFormat.id,
&stagingOffset, &stagingPointer)); &stagingOffset, &stagingPointer));
const angle::Format &copyFormat = const angle::Format &copyFormat =
GetFormatFromFormatType(formatInfo.internalFormat, formatInfo.type); GetFormatFromFormatType(formatInfo.internalFormat, formatInfo.type);
@ -6868,9 +6868,9 @@ angle::Result ImageHelper::stageRobustResourceClearWithFormat(ContextVk *context
uint8_t *stagingPointer; uint8_t *stagingPointer;
VkDeviceSize stagingOffset; VkDeviceSize stagingOffset;
ANGLE_TRY(currentBuffer->initForCopyImage(contextVk, totalSize, ANGLE_TRY(currentBuffer->allocateForCopyImage(contextVk, totalSize,
MemoryCoherency::NonCoherent, imageFormat.id, MemoryCoherency::NonCoherent, imageFormat.id,
&stagingOffset, &stagingPointer)); &stagingOffset, &stagingPointer));
memset(stagingPointer, 0, totalSize); memset(stagingPointer, 0, totalSize);
VkBufferImageCopy copyRegion = {}; VkBufferImageCopy copyRegion = {};
@ -7690,8 +7690,8 @@ angle::Result ImageHelper::copyImageDataToBuffer(ContextVk *contextVk,
// Allocate coherent staging buffer // Allocate coherent staging buffer
ASSERT(dstBuffer != nullptr && !dstBuffer->valid()); ASSERT(dstBuffer != nullptr && !dstBuffer->valid());
VkDeviceSize dstOffset; VkDeviceSize dstOffset;
ANGLE_TRY(dstBuffer->initForCopyImage(contextVk, bufferSize, MemoryCoherency::Coherent, ANGLE_TRY(dstBuffer->allocateForCopyImage(contextVk, bufferSize, MemoryCoherency::Coherent,
imageFormat.id, &dstOffset, outDataPtr)); imageFormat.id, &dstOffset, outDataPtr));
VkBuffer bufferHandle = dstBuffer->getBuffer().getHandle(); VkBuffer bufferHandle = dstBuffer->getBuffer().getHandle();
LevelIndex sourceLevelVk = toVkLevel(sourceLevelGL); LevelIndex sourceLevelVk = toVkLevel(sourceLevelGL);
@ -8006,8 +8006,9 @@ angle::Result ImageHelper::readPixels(ContextVk *contextVk,
VkDeviceSize 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(stagingBuffer->initForCopyImage(contextVk, allocationSize, MemoryCoherency::Coherent, ANGLE_TRY(stagingBuffer->allocateForCopyImage(contextVk, allocationSize,
mActualFormatID, &stagingOffset, &readPixelBuffer)); MemoryCoherency::Coherent, mActualFormatID,
&stagingOffset, &readPixelBuffer));
VkBuffer bufferHandle = stagingBuffer->getBuffer().getHandle(); VkBuffer bufferHandle = stagingBuffer->getBuffer().getHandle();
VkBufferImageCopy region = {}; VkBufferImageCopy region = {};

Просмотреть файл

@ -741,19 +741,21 @@ class BufferHelper : public ReadWriteResource
size_t alignment); size_t alignment);
// Helper functions to initialize a buffer for a specific usage // Helper functions to initialize a buffer for a specific usage
// Initialize a buffer with alignment good for shader storage or copyBuffer . // Suballocate a buffer with alignment good for shader storage or copyBuffer .
angle::Result initForVertexConversion(ContextVk *contextVk, angle::Result allocateForVertexConversion(ContextVk *contextVk,
size_t size, size_t size,
MemoryHostVisibility hostVisibility); MemoryHostVisibility hostVisibility);
// Initialize a host visible buffer with alignment good for copyBuffer . // Suballocate a host visible buffer with alignment good for copyBuffer .
angle::Result initForCopyBuffer(ContextVk *contextVk, size_t size, MemoryCoherency coherency); angle::Result allocateForCopyBuffer(ContextVk *contextVk,
// Initialize a host visible buffer with alignment good for copyImage . size_t size,
angle::Result initForCopyImage(ContextVk *contextVk, MemoryCoherency coherency);
size_t size, // Suballocate a host visible buffer with alignment good for copyImage .
MemoryCoherency coherency, angle::Result allocateForCopyImage(ContextVk *contextVk,
angle::FormatID formatId, size_t size,
VkDeviceSize *offset, MemoryCoherency coherency,
uint8_t **dataPtr); angle::FormatID formatId,
VkDeviceSize *offset,
uint8_t **dataPtr);
void destroy(RendererVk *renderer); void destroy(RendererVk *renderer);
void release(RendererVk *renderer); void release(RendererVk *renderer);