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());
}
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();
mIsStagingBufferMapped = true;

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

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

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

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

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

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