mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-01 05:48:11 +03:00
Move buffer suballocation callers to ContextVk
* Moved the following functions from BufferHelper to ContextVk. * initBufferForBufferCopy() * initBufferForImageCopy() * initBufferForVertexConversion() Bug: b/280304441 Change-Id: I890f4396b00b0c20feb44f0ad113c55924ce1014 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4854760 Commit-Queue: Amirali Abdolrashidi <abdolrashidi@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
This commit is contained in:
committed by
Angle LUCI CQ
parent
a1f52f1bdd
commit
91ef1f3cfd
@@ -511,7 +511,7 @@ angle::Result BufferVk::allocStagingBuffer(ContextVk *contextVk,
|
||||
}
|
||||
|
||||
ANGLE_TRY(
|
||||
mStagingBuffer.allocateForCopyBuffer(contextVk, static_cast<size_t>(size), coherency));
|
||||
contextVk->initBufferForBufferCopy(&mStagingBuffer, static_cast<size_t>(size), coherency));
|
||||
*mapPtr = mStagingBuffer.getMappedMemory();
|
||||
mIsStagingBufferMapped = true;
|
||||
|
||||
|
||||
@@ -7136,6 +7136,81 @@ angle::Result ContextVk::initImageAllocation(vk::ImageHelper *imageHelper,
|
||||
return angle::Result::Continue;
|
||||
}
|
||||
|
||||
angle::Result ContextVk::initBufferForBufferCopy(vk::BufferHelper *bufferHelper,
|
||||
size_t size,
|
||||
vk::MemoryCoherency coherency)
|
||||
{
|
||||
uint32_t memoryTypeIndex = mRenderer->getStagingBufferMemoryTypeIndex(coherency);
|
||||
size_t alignment = mRenderer->getStagingBufferAlignment();
|
||||
return initBufferAllocation(bufferHelper, memoryTypeIndex, size, alignment,
|
||||
BufferUsageType::Dynamic);
|
||||
}
|
||||
|
||||
angle::Result ContextVk::initBufferForImageCopy(vk::BufferHelper *bufferHelper,
|
||||
size_t size,
|
||||
vk::MemoryCoherency coherency,
|
||||
angle::FormatID formatId,
|
||||
VkDeviceSize *offset,
|
||||
uint8_t **dataPtr)
|
||||
{
|
||||
// When a buffer is used in copyImage, the offset must be multiple of pixel bytes. This may
|
||||
// result in non-power of two alignment. VMA's virtual allocator can not handle non-power of two
|
||||
// alignment. We have to adjust offset manually.
|
||||
uint32_t memoryTypeIndex = mRenderer->getStagingBufferMemoryTypeIndex(coherency);
|
||||
size_t imageCopyAlignment = vk::GetImageCopyBufferAlignment(formatId);
|
||||
|
||||
// Add extra padding for potential offset alignment
|
||||
size_t allocationSize = size + imageCopyAlignment;
|
||||
allocationSize = roundUp(allocationSize, imageCopyAlignment);
|
||||
size_t stagingAlignment = static_cast<size_t>(mRenderer->getStagingBufferAlignment());
|
||||
|
||||
ANGLE_TRY(initBufferAllocation(bufferHelper, memoryTypeIndex, allocationSize, stagingAlignment,
|
||||
BufferUsageType::Static));
|
||||
|
||||
*offset = roundUp(bufferHelper->getOffset(), static_cast<VkDeviceSize>(imageCopyAlignment));
|
||||
*dataPtr = bufferHelper->getMappedMemory() + (*offset) - bufferHelper->getOffset();
|
||||
|
||||
return angle::Result::Continue;
|
||||
}
|
||||
|
||||
angle::Result ContextVk::initBufferForVertexConversion(vk::BufferHelper *bufferHelper,
|
||||
size_t size,
|
||||
vk::MemoryHostVisibility hostVisibility)
|
||||
{
|
||||
if (bufferHelper->valid())
|
||||
{
|
||||
// If size is big enough and it is idle, then just reuse the existing buffer.
|
||||
if (size <= bufferHelper->getSize() &&
|
||||
(hostVisibility == vk::MemoryHostVisibility::Visible) == bufferHelper->isHostVisible())
|
||||
{
|
||||
if (mRenderer->hasResourceUseFinished(bufferHelper->getResourceUse()))
|
||||
{
|
||||
bufferHelper->initializeBarrierTracker(this);
|
||||
return angle::Result::Continue;
|
||||
}
|
||||
else if (hostVisibility == vk::MemoryHostVisibility::NonVisible)
|
||||
{
|
||||
// For device local buffer, we can reuse the buffer even if it is still GPU busy.
|
||||
// The memory barrier should take care of this.
|
||||
return angle::Result::Continue;
|
||||
}
|
||||
}
|
||||
|
||||
bufferHelper->release(mRenderer);
|
||||
}
|
||||
|
||||
uint32_t memoryTypeIndex = mRenderer->getVertexConversionBufferMemoryTypeIndex(hostVisibility);
|
||||
size_t alignment = static_cast<size_t>(mRenderer->getVertexConversionBufferAlignment());
|
||||
|
||||
// The size is retrieved and used in descriptor set. The descriptor set wants aligned size,
|
||||
// otherwise there are test failures. Note that underline VMA allocation always allocate aligned
|
||||
// size anyway.
|
||||
size_t sizeToAllocate = roundUp(size, alignment);
|
||||
|
||||
return initBufferAllocation(bufferHelper, memoryTypeIndex, sizeToAllocate, alignment,
|
||||
BufferUsageType::Static);
|
||||
}
|
||||
|
||||
angle::Result ContextVk::updateActiveTextures(const gl::Context *context, gl::Command command)
|
||||
{
|
||||
const gl::ProgramExecutable *executable = mState.getProgramExecutable();
|
||||
|
||||
@@ -822,6 +822,23 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
|
||||
VkMemoryPropertyFlags flags,
|
||||
vk::MemoryAllocationType allocationType);
|
||||
|
||||
// Helper functions to initialize a buffer for a specific usage
|
||||
// Suballocate a host visible buffer with alignment good for copyBuffer.
|
||||
angle::Result initBufferForBufferCopy(vk::BufferHelper *bufferHelper,
|
||||
size_t size,
|
||||
vk::MemoryCoherency coherency);
|
||||
// Suballocate a host visible buffer with alignment good for copyImage.
|
||||
angle::Result initBufferForImageCopy(vk::BufferHelper *bufferHelper,
|
||||
size_t size,
|
||||
vk::MemoryCoherency coherency,
|
||||
angle::FormatID formatId,
|
||||
VkDeviceSize *offset,
|
||||
uint8_t **dataPtr);
|
||||
// Suballocate a buffer with alignment good for shader storage or copyBuffer.
|
||||
angle::Result initBufferForVertexConversion(vk::BufferHelper *bufferHelper,
|
||||
size_t size,
|
||||
vk::MemoryHostVisibility hostVisibility);
|
||||
|
||||
// In the event of collecting too much garbage, we should flush the garbage so it can be freed.
|
||||
void addToPendingImageGarbage(vk::ResourceUse use, VkDeviceSize size);
|
||||
|
||||
|
||||
@@ -3048,8 +3048,8 @@ angle::Result TextureVk::convertBufferToRGBA(ContextVk *contextVk, size_t &conve
|
||||
vk::BufferHelper *conversionBufferHelper = conversion->data.get();
|
||||
if (!conversionBufferHelper->valid())
|
||||
{
|
||||
ANGLE_TRY(conversionBufferHelper->allocateForVertexConversion(
|
||||
contextVk, conversionBufferSize, vk::MemoryHostVisibility::NonVisible));
|
||||
ANGLE_TRY(contextVk->initBufferForVertexConversion(
|
||||
conversionBufferHelper, conversionBufferSize, vk::MemoryHostVisibility::NonVisible));
|
||||
}
|
||||
|
||||
if (conversion->dirty)
|
||||
|
||||
@@ -219,8 +219,9 @@ angle::Result VertexArrayVk::convertIndexBufferGPU(ContextVk *contextVk,
|
||||
size_t srcDataSize = static_cast<size_t>(bufferVk->getSize()) - offsetIntoSrcData;
|
||||
|
||||
// Allocate buffer for results
|
||||
ANGLE_TRY(mTranslatedByteIndexData.allocateForVertexConversion(
|
||||
contextVk, sizeof(GLushort) * srcDataSize, vk::MemoryHostVisibility::NonVisible));
|
||||
ANGLE_TRY(contextVk->initBufferForVertexConversion(&mTranslatedByteIndexData,
|
||||
sizeof(GLushort) * srcDataSize,
|
||||
vk::MemoryHostVisibility::NonVisible));
|
||||
mCurrentElementArrayBuffer = &mTranslatedByteIndexData;
|
||||
|
||||
vk::BufferHelper *dst = &mTranslatedByteIndexData;
|
||||
@@ -248,12 +249,14 @@ angle::Result VertexArrayVk::convertIndexBufferIndirectGPU(ContextVk *contextVk,
|
||||
vk::BufferHelper *srcIndexBuf = mCurrentElementArrayBuffer;
|
||||
|
||||
// Allocate buffer for results
|
||||
ANGLE_TRY(mTranslatedByteIndexData.allocateForVertexConversion(
|
||||
contextVk, sizeof(GLushort) * srcDataSize, vk::MemoryHostVisibility::NonVisible));
|
||||
ANGLE_TRY(contextVk->initBufferForVertexConversion(&mTranslatedByteIndexData,
|
||||
sizeof(GLushort) * srcDataSize,
|
||||
vk::MemoryHostVisibility::NonVisible));
|
||||
vk::BufferHelper *dstIndexBuf = &mTranslatedByteIndexData;
|
||||
|
||||
ANGLE_TRY(mTranslatedByteIndirectData.allocateForVertexConversion(
|
||||
contextVk, sizeof(VkDrawIndexedIndirectCommand), vk::MemoryHostVisibility::NonVisible));
|
||||
ANGLE_TRY(contextVk->initBufferForVertexConversion(&mTranslatedByteIndirectData,
|
||||
sizeof(VkDrawIndexedIndirectCommand),
|
||||
vk::MemoryHostVisibility::NonVisible));
|
||||
vk::BufferHelper *dstIndirectBuf = &mTranslatedByteIndirectData;
|
||||
|
||||
// Save new element array buffer
|
||||
@@ -371,8 +374,8 @@ angle::Result VertexArrayVk::convertIndexBufferCPU(ContextVk *contextVk,
|
||||
}
|
||||
}
|
||||
|
||||
ANGLE_TRY(mStreamedIndexData.allocateForVertexConversion(contextVk, amount,
|
||||
vk::MemoryHostVisibility::Visible));
|
||||
ANGLE_TRY(contextVk->initBufferForVertexConversion(&mStreamedIndexData, amount,
|
||||
vk::MemoryHostVisibility::Visible));
|
||||
GLubyte *dst = mStreamedIndexData.getMappedMemory();
|
||||
|
||||
*bindingDirty = BufferBindingDirty::Yes;
|
||||
@@ -450,8 +453,8 @@ angle::Result VertexArrayVk::convertVertexBufferGPU(ContextVk *contextVk,
|
||||
|
||||
// Allocate buffer for results
|
||||
vk::BufferHelper *dstBuffer = conversion->data.get();
|
||||
ANGLE_TRY(dstBuffer->allocateForVertexConversion(contextVk, numVertices * dstFormatSize,
|
||||
vk::MemoryHostVisibility::NonVisible));
|
||||
ANGLE_TRY(contextVk->initBufferForVertexConversion(dstBuffer, numVertices * dstFormatSize,
|
||||
vk::MemoryHostVisibility::NonVisible));
|
||||
|
||||
ASSERT(conversion->dirty);
|
||||
conversion->dirty = false;
|
||||
@@ -500,8 +503,8 @@ angle::Result VertexArrayVk::convertVertexBufferCPU(ContextVk *contextVk,
|
||||
|
||||
vk::BufferHelper *dstBufferHelper = conversion->data.get();
|
||||
// Allocate buffer for results
|
||||
ANGLE_TRY(dstBufferHelper->allocateForVertexConversion(contextVk, numVertices * dstFormatSize,
|
||||
vk::MemoryHostVisibility::Visible));
|
||||
ANGLE_TRY(contextVk->initBufferForVertexConversion(dstBufferHelper, numVertices * dstFormatSize,
|
||||
vk::MemoryHostVisibility::Visible));
|
||||
|
||||
ANGLE_TRY(StreamVertexData(contextVk, dstBufferHelper, srcBytes, numVertices * dstFormatSize, 0,
|
||||
numVertices, binding.getStride(),
|
||||
|
||||
@@ -4457,8 +4457,8 @@ angle::Result LineLoopHelper::getIndexBufferForDrawArrays(ContextVk *contextVk,
|
||||
BufferHelper **bufferOut)
|
||||
{
|
||||
size_t allocateBytes = sizeof(uint32_t) * (static_cast<size_t>(clampedVertexCount) + 1);
|
||||
ANGLE_TRY(mDynamicIndexBuffer.allocateForVertexConversion(contextVk, allocateBytes,
|
||||
MemoryHostVisibility::Visible));
|
||||
ANGLE_TRY(contextVk->initBufferForVertexConversion(&mDynamicIndexBuffer, allocateBytes,
|
||||
MemoryHostVisibility::Visible));
|
||||
uint32_t *indices = reinterpret_cast<uint32_t *>(mDynamicIndexBuffer.getMappedMemory());
|
||||
|
||||
// Note: there could be an overflow in this addition.
|
||||
@@ -4507,8 +4507,8 @@ angle::Result LineLoopHelper::getIndexBufferForElementArrayBuffer(ContextVk *con
|
||||
size_t unitSize = contextVk->getVkIndexTypeSize(glIndexType);
|
||||
|
||||
size_t allocateBytes = unitSize * (indexCount + 1) + 1;
|
||||
ANGLE_TRY(mDynamicIndexBuffer.allocateForVertexConversion(contextVk, allocateBytes,
|
||||
MemoryHostVisibility::Visible));
|
||||
ANGLE_TRY(contextVk->initBufferForVertexConversion(&mDynamicIndexBuffer, allocateBytes,
|
||||
MemoryHostVisibility::Visible));
|
||||
|
||||
BufferHelper *sourceBuffer = &elementArrayBufferVk->getBuffer();
|
||||
VkDeviceSize sourceOffset =
|
||||
@@ -4552,8 +4552,8 @@ angle::Result LineLoopHelper::streamIndices(ContextVk *contextVk,
|
||||
}
|
||||
*indexCountOut = numOutIndices;
|
||||
|
||||
ANGLE_TRY(mDynamicIndexBuffer.allocateForVertexConversion(contextVk, unitSize * numOutIndices,
|
||||
MemoryHostVisibility::Visible));
|
||||
ANGLE_TRY(contextVk->initBufferForVertexConversion(
|
||||
&mDynamicIndexBuffer, unitSize * numOutIndices, MemoryHostVisibility::Visible));
|
||||
uint8_t *indices = mDynamicIndexBuffer.getMappedMemory();
|
||||
|
||||
if (contextVk->getState().isPrimitiveRestartEnabled())
|
||||
@@ -4615,10 +4615,11 @@ angle::Result LineLoopHelper::streamIndicesIndirect(ContextVk *contextVk,
|
||||
}
|
||||
|
||||
// Allocate buffer for results
|
||||
ANGLE_TRY(mDynamicIndexBuffer.allocateForVertexConversion(contextVk, allocateBytes,
|
||||
MemoryHostVisibility::Visible));
|
||||
ANGLE_TRY(mDynamicIndirectBuffer.allocateForVertexConversion(
|
||||
contextVk, sizeof(VkDrawIndexedIndirectCommand), MemoryHostVisibility::Visible));
|
||||
ANGLE_TRY(contextVk->initBufferForVertexConversion(&mDynamicIndexBuffer, allocateBytes,
|
||||
MemoryHostVisibility::Visible));
|
||||
ANGLE_TRY(contextVk->initBufferForVertexConversion(&mDynamicIndirectBuffer,
|
||||
sizeof(VkDrawIndexedIndirectCommand),
|
||||
MemoryHostVisibility::Visible));
|
||||
|
||||
*indexBufferOut = &mDynamicIndexBuffer;
|
||||
*indirectBufferOut = &mDynamicIndirectBuffer;
|
||||
@@ -4649,10 +4650,11 @@ angle::Result LineLoopHelper::streamArrayIndirect(ContextVk *contextVk,
|
||||
auto unitSize = sizeof(uint32_t);
|
||||
size_t allocateBytes = static_cast<size_t>((vertexCount + 1) * unitSize);
|
||||
|
||||
ANGLE_TRY(mDynamicIndexBuffer.allocateForVertexConversion(contextVk, allocateBytes,
|
||||
MemoryHostVisibility::Visible));
|
||||
ANGLE_TRY(mDynamicIndirectBuffer.allocateForVertexConversion(
|
||||
contextVk, sizeof(VkDrawIndexedIndirectCommand), MemoryHostVisibility::Visible));
|
||||
ANGLE_TRY(contextVk->initBufferForVertexConversion(&mDynamicIndexBuffer, allocateBytes,
|
||||
MemoryHostVisibility::Visible));
|
||||
ANGLE_TRY(contextVk->initBufferForVertexConversion(&mDynamicIndirectBuffer,
|
||||
sizeof(VkDrawIndexedIndirectCommand),
|
||||
MemoryHostVisibility::Visible));
|
||||
|
||||
*indexBufferOut = &mDynamicIndexBuffer;
|
||||
*indexIndirectBufferOut = &mDynamicIndirectBuffer;
|
||||
@@ -4886,87 +4888,7 @@ VkResult BufferHelper::initSuballocation(ContextVk *contextVk,
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
angle::Result BufferHelper::allocateForCopyBuffer(ContextVk *contextVk,
|
||||
size_t size,
|
||||
MemoryCoherency coherency)
|
||||
{
|
||||
RendererVk *renderer = contextVk->getRenderer();
|
||||
uint32_t memoryTypeIndex = renderer->getStagingBufferMemoryTypeIndex(coherency);
|
||||
size_t alignment = renderer->getStagingBufferAlignment();
|
||||
return contextVk->initBufferAllocation(this, memoryTypeIndex, size, alignment,
|
||||
BufferUsageType::Dynamic);
|
||||
}
|
||||
|
||||
angle::Result BufferHelper::allocateForVertexConversion(ContextVk *contextVk,
|
||||
size_t size,
|
||||
MemoryHostVisibility hostVisibility)
|
||||
{
|
||||
RendererVk *renderer = contextVk->getRenderer();
|
||||
|
||||
if (valid())
|
||||
{
|
||||
// If size is big enough and it is idle, then just reuse the existing buffer.
|
||||
if (size <= getSize() &&
|
||||
(hostVisibility == MemoryHostVisibility::Visible) == isHostVisible())
|
||||
{
|
||||
if (renderer->hasResourceUseFinished(getResourceUse()))
|
||||
{
|
||||
initializeBarrierTracker(contextVk);
|
||||
return angle::Result::Continue;
|
||||
}
|
||||
else if (hostVisibility == MemoryHostVisibility::NonVisible)
|
||||
{
|
||||
// For device local buffer, we can reuse the buffer even if it is still GPU busy.
|
||||
// The memory barrier should take care of this.
|
||||
return angle::Result::Continue;
|
||||
}
|
||||
}
|
||||
|
||||
release(renderer);
|
||||
}
|
||||
|
||||
uint32_t memoryTypeIndex = renderer->getVertexConversionBufferMemoryTypeIndex(hostVisibility);
|
||||
size_t alignment = static_cast<size_t>(renderer->getVertexConversionBufferAlignment());
|
||||
|
||||
// The size is retrieved and used in descriptor set. The descriptor set wants aligned size,
|
||||
// otherwise there are test failures. Note that underline VMA allocation always allocate aligned
|
||||
// size anyway.
|
||||
size_t sizeToAllocate = roundUp(size, alignment);
|
||||
|
||||
return contextVk->initBufferAllocation(this, memoryTypeIndex, sizeToAllocate, alignment,
|
||||
BufferUsageType::Static);
|
||||
}
|
||||
|
||||
angle::Result BufferHelper::allocateForCopyImage(ContextVk *contextVk,
|
||||
size_t size,
|
||||
MemoryCoherency coherency,
|
||||
angle::FormatID formatId,
|
||||
VkDeviceSize *offset,
|
||||
uint8_t **dataPtr)
|
||||
{
|
||||
RendererVk *renderer = contextVk->getRenderer();
|
||||
|
||||
// When a buffer is used in copyImage, the offset must be multiple of pixel bytes. This may
|
||||
// result in non-power of two alignment. VMA's virtual allocator can not handle non-power of two
|
||||
// alignment. We have to adjust offset manually.
|
||||
uint32_t memoryTypeIndex = renderer->getStagingBufferMemoryTypeIndex(coherency);
|
||||
size_t imageCopyAlignment = GetImageCopyBufferAlignment(formatId);
|
||||
|
||||
// Add extra padding for potential offset alignment
|
||||
size_t allocationSize = size + imageCopyAlignment;
|
||||
allocationSize = roundUp(allocationSize, imageCopyAlignment);
|
||||
size_t stagingAlignment = static_cast<size_t>(renderer->getStagingBufferAlignment());
|
||||
|
||||
ANGLE_TRY(contextVk->initBufferAllocation(this, memoryTypeIndex, allocationSize,
|
||||
stagingAlignment, BufferUsageType::Static));
|
||||
|
||||
*offset = roundUp(getOffset(), static_cast<VkDeviceSize>(imageCopyAlignment));
|
||||
*dataPtr = getMappedMemory() + (*offset) - getOffset();
|
||||
|
||||
return angle::Result::Continue;
|
||||
}
|
||||
|
||||
ANGLE_INLINE void BufferHelper::initializeBarrierTracker(Context *context)
|
||||
void BufferHelper::initializeBarrierTracker(Context *context)
|
||||
{
|
||||
RendererVk *renderer = context->getRenderer();
|
||||
mCurrentQueueFamilyIndex = renderer->getQueueFamilyIndex();
|
||||
@@ -7506,9 +7428,9 @@ angle::Result ImageHelper::stageSubresourceUpdateImpl(ContextVk *contextVk,
|
||||
|
||||
uint8_t *stagingPointer;
|
||||
VkDeviceSize stagingOffset;
|
||||
ANGLE_TRY(currentBuffer->allocateForCopyImage(contextVk, allocationSize,
|
||||
MemoryCoherency::NonCoherent, storageFormat.id,
|
||||
&stagingOffset, &stagingPointer));
|
||||
ANGLE_TRY(contextVk->initBufferForImageCopy(currentBuffer, allocationSize,
|
||||
MemoryCoherency::NonCoherent, storageFormat.id,
|
||||
&stagingOffset, &stagingPointer));
|
||||
|
||||
loadFunctionInfo.loadFunction(
|
||||
contextVk->getImageLoadContext(), glExtents.width, glExtents.height, glExtents.depth,
|
||||
@@ -7783,9 +7705,9 @@ angle::Result ImageHelper::reformatStagedBufferUpdates(ContextVk *contextVk,
|
||||
uint8_t *dstData;
|
||||
VkDeviceSize dstBufferOffset;
|
||||
size_t dstBufferSize = dstDataDepthPitch * copy.imageExtent.depth;
|
||||
ANGLE_TRY(dstBuffer->allocateForCopyImage(contextVk, dstBufferSize,
|
||||
MemoryCoherency::NonCoherent, dstFormatID,
|
||||
&dstBufferOffset, &dstData));
|
||||
ANGLE_TRY(contextVk->initBufferForImageCopy(
|
||||
dstBuffer, dstBufferSize, MemoryCoherency::NonCoherent, dstFormatID,
|
||||
&dstBufferOffset, &dstData));
|
||||
|
||||
rx::PixelReadFunction pixelReadFunction = srcFormat.pixelReadFunction;
|
||||
rx::PixelWriteFunction pixelWriteFunction = dstFormat.pixelWriteFunction;
|
||||
@@ -8125,9 +8047,9 @@ angle::Result ImageHelper::stageSubresourceUpdateAndGetData(ContextVk *contextVk
|
||||
BufferHelper *currentBuffer = &stagingBuffer->get();
|
||||
|
||||
VkDeviceSize stagingOffset;
|
||||
ANGLE_TRY(currentBuffer->allocateForCopyImage(contextVk, allocationSize,
|
||||
MemoryCoherency::NonCoherent, formatID,
|
||||
&stagingOffset, dstData));
|
||||
ANGLE_TRY(contextVk->initBufferForImageCopy(currentBuffer, allocationSize,
|
||||
MemoryCoherency::NonCoherent, formatID,
|
||||
&stagingOffset, dstData));
|
||||
|
||||
gl::LevelIndex updateLevelGL(imageIndex.getLevelIndex());
|
||||
|
||||
@@ -8199,9 +8121,9 @@ angle::Result ImageHelper::stageSubresourceUpdateFromFramebuffer(
|
||||
|
||||
// The destination is only one layer deep.
|
||||
size_t allocationSize = outputDepthPitch;
|
||||
ANGLE_TRY(currentBuffer->allocateForCopyImage(contextVk, allocationSize,
|
||||
MemoryCoherency::NonCoherent, storageFormat.id,
|
||||
&stagingOffset, &stagingPointer));
|
||||
ANGLE_TRY(contextVk->initBufferForImageCopy(currentBuffer, allocationSize,
|
||||
MemoryCoherency::NonCoherent, storageFormat.id,
|
||||
&stagingOffset, &stagingPointer));
|
||||
|
||||
const angle::Format ©Format =
|
||||
GetFormatFromFormatType(formatInfo.internalFormat, formatInfo.type);
|
||||
@@ -8369,9 +8291,9 @@ angle::Result ImageHelper::stageResourceClearWithFormat(ContextVk *contextVk,
|
||||
|
||||
uint8_t *stagingPointer;
|
||||
VkDeviceSize stagingOffset;
|
||||
ANGLE_TRY(currentBuffer->allocateForCopyImage(contextVk, totalSize,
|
||||
MemoryCoherency::NonCoherent, imageFormat.id,
|
||||
&stagingOffset, &stagingPointer));
|
||||
ANGLE_TRY(contextVk->initBufferForImageCopy(currentBuffer, totalSize,
|
||||
MemoryCoherency::NonCoherent, imageFormat.id,
|
||||
&stagingOffset, &stagingPointer));
|
||||
memset(stagingPointer, 0, totalSize);
|
||||
|
||||
VkBufferImageCopy copyRegion = {};
|
||||
@@ -9299,8 +9221,8 @@ angle::Result ImageHelper::copyImageDataToBuffer(ContextVk *contextVk,
|
||||
// Allocate coherent staging buffer
|
||||
ASSERT(dstBuffer != nullptr && !dstBuffer->valid());
|
||||
VkDeviceSize dstOffset;
|
||||
ANGLE_TRY(dstBuffer->allocateForCopyImage(contextVk, bufferSize, MemoryCoherency::Coherent,
|
||||
imageFormat.id, &dstOffset, outDataPtr));
|
||||
ANGLE_TRY(contextVk->initBufferForImageCopy(dstBuffer, bufferSize, MemoryCoherency::Coherent,
|
||||
imageFormat.id, &dstOffset, outDataPtr));
|
||||
VkBuffer bufferHandle = dstBuffer->getBuffer().getHandle();
|
||||
|
||||
LevelIndex sourceLevelVk = toVkLevel(sourceLevelGL);
|
||||
@@ -9901,9 +9823,9 @@ angle::Result ImageHelper::readPixelsImpl(ContextVk *contextVk,
|
||||
VkDeviceSize stagingOffset = 0;
|
||||
size_t allocationSize = readFormat->pixelBytes * area.width * area.height;
|
||||
|
||||
ANGLE_TRY(stagingBuffer->allocateForCopyImage(contextVk, allocationSize,
|
||||
MemoryCoherency::Coherent, mActualFormatID,
|
||||
&stagingOffset, &readPixelBuffer));
|
||||
ANGLE_TRY(contextVk->initBufferForImageCopy(stagingBuffer, allocationSize,
|
||||
MemoryCoherency::Coherent, mActualFormatID,
|
||||
&stagingOffset, &readPixelBuffer));
|
||||
VkBuffer bufferHandle = stagingBuffer->getBuffer().getHandle();
|
||||
|
||||
VkBufferImageCopy region = {};
|
||||
|
||||
@@ -759,23 +759,6 @@ class BufferHelper : public ReadWriteResource
|
||||
size_t alignment,
|
||||
BufferUsageType usageType);
|
||||
|
||||
// Helper functions to initialize a buffer for a specific usage
|
||||
// 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);
|
||||
void releaseBufferAndDescriptorSetCache(RendererVk *renderer);
|
||||
@@ -873,9 +856,9 @@ class BufferHelper : public ReadWriteResource
|
||||
// size. Thus when user size changes, we must clear and recreate this mBufferWithUserSize.
|
||||
void onBufferUserSizeChange(RendererVk *renderer);
|
||||
|
||||
private:
|
||||
void initializeBarrierTracker(Context *context);
|
||||
|
||||
private:
|
||||
// Only called by DynamicBuffer.
|
||||
friend class DynamicBuffer;
|
||||
void setSuballocationOffsetAndSize(VkDeviceSize offset, VkDeviceSize size)
|
||||
|
||||
Reference in New Issue
Block a user