зеркало из https://github.com/AvaloniaUI/angle.git
Vulkan: Remove BufferMemoryAllocator
This class was added in crrev.com/c/3036256. The original intention was to use VMA to implement buffer suballocation. Because VMA itself does not support buffer suballocation, I was thinking to use VMA custom pool to implement it and this class was intended to wrap all these functionality into one class. But now thanks to Jamie's effort, VMA exported generic suballocation algorithm via API and we have implemented buffer suballocation using that virtual allocation API. So this BufferMemoryAllocator class is really no longer useful. This CL mostly reverted that CL and flatten out the buffer allocation call to directly use VMA's Allocator object. Bug: b/205337962 Change-Id: I0336056e440f39e2ff49fee8e0ff4b1f355cefe4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3244022 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
This commit is contained in:
Родитель
dcac02ac1f
Коммит
15439f8e40
|
@ -174,8 +174,9 @@ angle::Result GetMemoryTypeIndex(ContextVk *contextVk,
|
|||
VkMemoryPropertyFlags memoryPropertyFlags,
|
||||
uint32_t *memoryTypeIndexOut)
|
||||
{
|
||||
RendererVk *renderer = contextVk->getRenderer();
|
||||
vk::BufferMemoryAllocator &bufferMemoryAllocator = renderer->getBufferMemoryAllocator();
|
||||
RendererVk *renderer = contextVk->getRenderer();
|
||||
const vk::Allocator &allocator = renderer->getAllocator();
|
||||
|
||||
bool persistentlyMapped = renderer->getFeatures().persistentlyMappedBuffers.enabled;
|
||||
VkBufferUsageFlags defaultBufferUsageFlags = GetDefaultBufferUsageFlags(renderer);
|
||||
|
||||
|
@ -196,9 +197,9 @@ angle::Result GetMemoryTypeIndex(ContextVk *contextVk,
|
|||
|
||||
// Check that the allocation is not too large.
|
||||
uint32_t memoryTypeIndex = 0;
|
||||
ANGLE_VK_TRY(contextVk, bufferMemoryAllocator.findMemoryTypeIndexForBufferInfo(
|
||||
renderer, createInfo, requiredFlags, preferredFlags,
|
||||
persistentlyMapped, &memoryTypeIndex));
|
||||
ANGLE_VK_TRY(contextVk, allocator.findMemoryTypeIndexForBufferInfo(
|
||||
createInfo, requiredFlags, preferredFlags, persistentlyMapped,
|
||||
&memoryTypeIndex));
|
||||
*memoryTypeIndexOut = memoryTypeIndex;
|
||||
|
||||
return angle::Result::Continue;
|
||||
|
|
|
@ -412,13 +412,11 @@ vk::BufferPool *ShareGroupVk::getDefaultBufferPool(RendererVk *renderer, uint32_
|
|||
{
|
||||
if (!mDefaultBufferPools[memoryTypeIndex])
|
||||
{
|
||||
vk::BufferMemoryAllocator &bufferMemoryAllocator = renderer->getBufferMemoryAllocator();
|
||||
|
||||
VkBufferUsageFlags usageFlags = GetDefaultBufferUsageFlags(renderer);
|
||||
const vk::Allocator &allocator = renderer->getAllocator();
|
||||
VkBufferUsageFlags usageFlags = GetDefaultBufferUsageFlags(renderer);
|
||||
|
||||
VkMemoryPropertyFlags memoryPropertyFlags;
|
||||
bufferMemoryAllocator.getMemoryTypeProperties(renderer, memoryTypeIndex,
|
||||
&memoryPropertyFlags);
|
||||
allocator.getMemoryTypeProperties(memoryTypeIndex, &memoryPropertyFlags);
|
||||
|
||||
std::unique_ptr<vk::BufferPool> pool = std::make_unique<vk::BufferPool>();
|
||||
pool->initWithFlags(renderer, vma::VirtualBlockCreateFlagBits::GENERAL, usageFlags, 0,
|
||||
|
|
|
@ -1092,7 +1092,6 @@ void RendererVk::onDestroy(vk::Context *context)
|
|||
mOutsideRenderPassCommandBufferRecycler.onDestroy();
|
||||
mRenderPassCommandBufferRecycler.onDestroy();
|
||||
|
||||
mBufferMemoryAllocator.destroy(this);
|
||||
mAllocator.destroy();
|
||||
|
||||
sh::FinalizeGlslang();
|
||||
|
@ -1492,9 +1491,6 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
|
|||
mAllocator.init(mPhysicalDevice, mDevice, mInstance, applicationInfo.apiVersion,
|
||||
preferredLargeHeapBlockSize));
|
||||
|
||||
// Create buffer memory allocator
|
||||
ANGLE_VK_TRY(displayVk, mBufferMemoryAllocator.initialize(this, preferredLargeHeapBlockSize));
|
||||
|
||||
ANGLE_VK_CHECK(displayVk, mMemoryProperties.getMemoryTypeCount() > 0,
|
||||
VK_ERROR_INITIALIZATION_FAILED);
|
||||
// Initialize staging buffer memory type index and alignment.
|
||||
|
@ -1516,14 +1512,14 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
|
|||
|
||||
// Coherent staging buffer
|
||||
VkMemoryPropertyFlags preferredFlags = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
|
||||
ANGLE_VK_TRY(displayVk, mBufferMemoryAllocator.findMemoryTypeIndexForBufferInfo(
|
||||
this, createInfo, requiredFlags, preferredFlags, persistentlyMapped,
|
||||
ANGLE_VK_TRY(displayVk, mAllocator.findMemoryTypeIndexForBufferInfo(
|
||||
createInfo, requiredFlags, preferredFlags, persistentlyMapped,
|
||||
&mCoherentStagingBufferMemoryTypeIndex));
|
||||
ASSERT(mCoherentStagingBufferMemoryTypeIndex != kInvalidMemoryTypeIndex);
|
||||
|
||||
// Non-coherent staging buffer
|
||||
ANGLE_VK_TRY(displayVk, mBufferMemoryAllocator.findMemoryTypeIndexForBufferInfo(
|
||||
this, createInfo, requiredFlags, 0, persistentlyMapped,
|
||||
ANGLE_VK_TRY(displayVk, mAllocator.findMemoryTypeIndexForBufferInfo(
|
||||
createInfo, requiredFlags, 0, persistentlyMapped,
|
||||
&mNonCoherentStagingBufferMemoryTypeIndex));
|
||||
ASSERT(mNonCoherentStagingBufferMemoryTypeIndex != kInvalidMemoryTypeIndex);
|
||||
|
||||
|
@ -1544,8 +1540,8 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
|
|||
createInfo.usage = vk::kVertexBufferUsageFlags;
|
||||
requiredFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
||||
preferredFlags = 0;
|
||||
ANGLE_VK_TRY(displayVk, mBufferMemoryAllocator.findMemoryTypeIndexForBufferInfo(
|
||||
this, createInfo, requiredFlags, preferredFlags, persistentlyMapped,
|
||||
ANGLE_VK_TRY(displayVk, mAllocator.findMemoryTypeIndexForBufferInfo(
|
||||
createInfo, requiredFlags, preferredFlags, persistentlyMapped,
|
||||
&mDeviceLocalVertexConversionBufferMemoryTypeIndex));
|
||||
ASSERT(mDeviceLocalVertexConversionBufferMemoryTypeIndex != kInvalidMemoryTypeIndex);
|
||||
|
||||
|
@ -3997,58 +3993,5 @@ void MemoryReport::logMemoryReportStats() const
|
|||
<< " (max=" << std::setw(10) << importedMemoryMax << ")";
|
||||
}
|
||||
}
|
||||
|
||||
// BufferMemoryAllocator implementation.
|
||||
BufferMemoryAllocator::BufferMemoryAllocator() {}
|
||||
|
||||
BufferMemoryAllocator::~BufferMemoryAllocator() {}
|
||||
|
||||
VkResult BufferMemoryAllocator::initialize(RendererVk *renderer,
|
||||
VkDeviceSize preferredLargeHeapBlockSize)
|
||||
{
|
||||
ASSERT(renderer->getAllocator().valid());
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
void BufferMemoryAllocator::destroy(RendererVk *renderer) {}
|
||||
|
||||
VkResult BufferMemoryAllocator::createBuffer(RendererVk *renderer,
|
||||
const VkBufferCreateInfo &bufferCreateInfo,
|
||||
VkMemoryPropertyFlags requiredFlags,
|
||||
VkMemoryPropertyFlags preferredFlags,
|
||||
bool persistentlyMappedBuffers,
|
||||
uint32_t *memoryTypeIndexOut,
|
||||
Buffer *bufferOut,
|
||||
Allocation *allocationOut)
|
||||
{
|
||||
ASSERT(bufferOut && !bufferOut->valid());
|
||||
ASSERT(allocationOut && !allocationOut->valid());
|
||||
const Allocator &allocator = renderer->getAllocator();
|
||||
return vma::CreateBuffer(allocator.getHandle(), &bufferCreateInfo, requiredFlags,
|
||||
preferredFlags, persistentlyMappedBuffers, memoryTypeIndexOut,
|
||||
&bufferOut->mHandle, &allocationOut->mHandle);
|
||||
}
|
||||
|
||||
void BufferMemoryAllocator::getMemoryTypeProperties(RendererVk *renderer,
|
||||
uint32_t memoryTypeIndex,
|
||||
VkMemoryPropertyFlags *flagsOut) const
|
||||
{
|
||||
const Allocator &allocator = renderer->getAllocator();
|
||||
vma::GetMemoryTypeProperties(allocator.getHandle(), memoryTypeIndex, flagsOut);
|
||||
}
|
||||
|
||||
VkResult BufferMemoryAllocator::findMemoryTypeIndexForBufferInfo(
|
||||
RendererVk *renderer,
|
||||
const VkBufferCreateInfo &bufferCreateInfo,
|
||||
VkMemoryPropertyFlags requiredFlags,
|
||||
VkMemoryPropertyFlags preferredFlags,
|
||||
bool persistentlyMappedBuffers,
|
||||
uint32_t *memoryTypeIndexOut) const
|
||||
{
|
||||
const Allocator &allocator = renderer->getAllocator();
|
||||
return vma::FindMemoryTypeIndexForBufferInfo(allocator.getHandle(), &bufferCreateInfo,
|
||||
requiredFlags, preferredFlags,
|
||||
persistentlyMappedBuffers, memoryTypeIndexOut);
|
||||
}
|
||||
} // namespace vk
|
||||
} // namespace rx
|
||||
|
|
|
@ -82,38 +82,6 @@ class MemoryReport final : angle::NonCopyable
|
|||
VkDeviceSize mMaxTotalImportedMemory;
|
||||
angle::HashMap<uint64_t, int> mUniqueIDCounts;
|
||||
};
|
||||
|
||||
class BufferMemoryAllocator : angle::NonCopyable
|
||||
{
|
||||
public:
|
||||
BufferMemoryAllocator();
|
||||
~BufferMemoryAllocator();
|
||||
|
||||
VkResult initialize(RendererVk *renderer, VkDeviceSize preferredLargeHeapBlockSize);
|
||||
void destroy(RendererVk *renderer);
|
||||
|
||||
// Initializes the buffer handle and memory allocation.
|
||||
VkResult createBuffer(RendererVk *renderer,
|
||||
const VkBufferCreateInfo &bufferCreateInfo,
|
||||
VkMemoryPropertyFlags requiredFlags,
|
||||
VkMemoryPropertyFlags preferredFlags,
|
||||
bool persistentlyMapped,
|
||||
uint32_t *memoryTypeIndexOut,
|
||||
Buffer *bufferOut,
|
||||
Allocation *allocationOut);
|
||||
|
||||
void getMemoryTypeProperties(RendererVk *renderer,
|
||||
uint32_t memoryTypeIndex,
|
||||
VkMemoryPropertyFlags *flagsOut) const;
|
||||
VkResult findMemoryTypeIndexForBufferInfo(RendererVk *renderer,
|
||||
const VkBufferCreateInfo &bufferCreateInfo,
|
||||
VkMemoryPropertyFlags requiredFlags,
|
||||
VkMemoryPropertyFlags preferredFlags,
|
||||
bool persistentlyMappedBuffers,
|
||||
uint32_t *memoryTypeIndexOut) const;
|
||||
|
||||
private:
|
||||
};
|
||||
} // namespace vk
|
||||
|
||||
// Supports one semaphore from current surface, and one semaphore passed to
|
||||
|
@ -195,7 +163,6 @@ class RendererVk : angle::NonCopyable
|
|||
const VkPhysicalDeviceFeatures2KHR &getEnabledFeatures() const { return mEnabledFeatures; }
|
||||
VkDevice getDevice() const { return mDevice; }
|
||||
|
||||
vk::BufferMemoryAllocator &getBufferMemoryAllocator() { return mBufferMemoryAllocator; }
|
||||
const vk::Allocator &getAllocator() const { return mAllocator; }
|
||||
|
||||
angle::Result selectPresentQueueForSurface(DisplayVk *displayVk,
|
||||
|
@ -685,7 +652,6 @@ class RendererVk : angle::NonCopyable
|
|||
vk::CommandBufferRecycler<vk::RenderPassCommandBuffer, vk::RenderPassCommandBufferHelper>
|
||||
mRenderPassCommandBufferRecycler;
|
||||
|
||||
vk::BufferMemoryAllocator mBufferMemoryAllocator;
|
||||
vk::Allocator mAllocator;
|
||||
SamplerCache mSamplerCache;
|
||||
SamplerYcbcrConversionCache mYuvConversionCache;
|
||||
|
|
|
@ -2757,8 +2757,9 @@ void BufferPool::pruneEmptyBuffers(RendererVk *renderer)
|
|||
|
||||
angle::Result BufferPool::allocateNewBuffer(ContextVk *contextVk, VkDeviceSize sizeInBytes)
|
||||
{
|
||||
RendererVk *renderer = contextVk->getRenderer();
|
||||
BufferMemoryAllocator &bufferMemoryAllocator = renderer->getBufferMemoryAllocator();
|
||||
RendererVk *renderer = contextVk->getRenderer();
|
||||
const Allocator &allocator = renderer->getAllocator();
|
||||
|
||||
VkDeviceSize heapSize =
|
||||
renderer->getMemoryProperties().getHeapSizeForMemoryType(mMemoryTypeIndex);
|
||||
|
||||
|
@ -2785,20 +2786,19 @@ angle::Result BufferPool::allocateNewBuffer(ContextVk *contextVk, VkDeviceSize s
|
|||
createInfo.pQueueFamilyIndices = nullptr;
|
||||
|
||||
VkMemoryPropertyFlags memoryPropertyFlags;
|
||||
bufferMemoryAllocator.getMemoryTypeProperties(renderer, mMemoryTypeIndex, &memoryPropertyFlags);
|
||||
allocator.getMemoryTypeProperties(mMemoryTypeIndex, &memoryPropertyFlags);
|
||||
|
||||
DeviceScoped<Buffer> buffer(renderer->getDevice());
|
||||
AllocatorScoped<Allocation> allocation(renderer->getAllocator());
|
||||
uint32_t memoryTypeIndex = kInvalidMemoryTypeIndex;
|
||||
ANGLE_VK_TRY(contextVk, bufferMemoryAllocator.createBuffer(
|
||||
renderer, createInfo, memoryPropertyFlags, 0,
|
||||
renderer->getFeatures().persistentlyMappedBuffers.enabled,
|
||||
&memoryTypeIndex, &buffer.get(), &allocation.get()));
|
||||
ANGLE_VK_TRY(contextVk,
|
||||
allocator.createBuffer(createInfo, memoryPropertyFlags, 0,
|
||||
renderer->getFeatures().persistentlyMappedBuffers.enabled,
|
||||
&memoryTypeIndex, &buffer.get(), &allocation.get()));
|
||||
ASSERT(memoryTypeIndex != kInvalidMemoryTypeIndex);
|
||||
if (memoryTypeIndex != mMemoryTypeIndex)
|
||||
{
|
||||
bufferMemoryAllocator.getMemoryTypeProperties(renderer, memoryTypeIndex,
|
||||
&memoryPropertyFlags);
|
||||
allocator.getMemoryTypeProperties(memoryTypeIndex, &memoryPropertyFlags);
|
||||
}
|
||||
|
||||
// Allocate bufferBlock
|
||||
|
@ -3919,7 +3919,8 @@ angle::Result BufferHelper::init(ContextVk *contextVk,
|
|||
const VkBufferCreateInfo &requestedCreateInfo,
|
||||
VkMemoryPropertyFlags memoryPropertyFlags)
|
||||
{
|
||||
RendererVk *renderer = contextVk->getRenderer();
|
||||
RendererVk *renderer = contextVk->getRenderer();
|
||||
const Allocator &allocator = renderer->getAllocator();
|
||||
|
||||
initializeBarrierTracker(contextVk);
|
||||
|
||||
|
@ -3940,14 +3941,13 @@ angle::Result BufferHelper::init(ContextVk *contextVk,
|
|||
VkMemoryPropertyFlags preferredFlags =
|
||||
(memoryPropertyFlags & (~VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT));
|
||||
|
||||
BufferMemoryAllocator &bufferMemoryAllocator = renderer->getBufferMemoryAllocator();
|
||||
bool persistentlyMapped = renderer->getFeatures().persistentlyMappedBuffers.enabled;
|
||||
|
||||
// Check that the allocation is not too large.
|
||||
uint32_t memoryTypeIndex = kInvalidMemoryTypeIndex;
|
||||
ANGLE_VK_TRY(contextVk, bufferMemoryAllocator.findMemoryTypeIndexForBufferInfo(
|
||||
renderer, *createInfo, requiredFlags, preferredFlags,
|
||||
persistentlyMapped, &memoryTypeIndex));
|
||||
ANGLE_VK_TRY(contextVk, allocator.findMemoryTypeIndexForBufferInfo(
|
||||
*createInfo, requiredFlags, preferredFlags, persistentlyMapped,
|
||||
&memoryTypeIndex));
|
||||
|
||||
VkDeviceSize heapSize =
|
||||
renderer->getMemoryProperties().getHeapSizeForMemoryType(memoryTypeIndex);
|
||||
|
@ -3957,13 +3957,11 @@ angle::Result BufferHelper::init(ContextVk *contextVk,
|
|||
// Allocate buffer object
|
||||
DeviceScoped<Buffer> buffer(renderer->getDevice());
|
||||
AllocatorScoped<Allocation> allocation(renderer->getAllocator());
|
||||
ANGLE_VK_TRY(contextVk, bufferMemoryAllocator.createBuffer(renderer, *createInfo, requiredFlags,
|
||||
preferredFlags, persistentlyMapped,
|
||||
&memoryTypeIndex, &buffer.get(),
|
||||
&allocation.get()));
|
||||
ANGLE_VK_TRY(contextVk, allocator.createBuffer(*createInfo, requiredFlags, preferredFlags,
|
||||
persistentlyMapped, &memoryTypeIndex,
|
||||
&buffer.get(), &allocation.get()));
|
||||
VkMemoryPropertyFlags memoryPropertyFlagsOut;
|
||||
bufferMemoryAllocator.getMemoryTypeProperties(renderer, memoryTypeIndex,
|
||||
&memoryPropertyFlagsOut);
|
||||
allocator.getMemoryTypeProperties(memoryTypeIndex, &memoryPropertyFlagsOut);
|
||||
|
||||
ANGLE_VK_TRY(contextVk, mSubAllocation.initWithEntireBuffer(
|
||||
contextVk, buffer.get(), allocation.get(), memoryPropertyFlagsOut,
|
||||
|
|
|
@ -616,21 +616,20 @@ angle::Result StagingBuffer::init(Context *context, VkDeviceSize size, StagingUs
|
|||
VkMemoryPropertyFlags requiredFlags =
|
||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
|
||||
|
||||
RendererVk *renderer = context->getRenderer();
|
||||
RendererVk *renderer = context->getRenderer();
|
||||
const Allocator &allocator = renderer->getAllocator();
|
||||
|
||||
uint32_t memoryTypeIndex = 0;
|
||||
BufferMemoryAllocator &bufferMemoryAllocator = renderer->getBufferMemoryAllocator();
|
||||
ANGLE_VK_TRY(context, bufferMemoryAllocator.createBuffer(
|
||||
renderer, createInfo, requiredFlags, preferredFlags,
|
||||
renderer->getFeatures().persistentlyMappedBuffers.enabled,
|
||||
&memoryTypeIndex, &mBuffer, &mAllocation));
|
||||
uint32_t memoryTypeIndex = 0;
|
||||
ANGLE_VK_TRY(context,
|
||||
allocator.createBuffer(createInfo, requiredFlags, preferredFlags,
|
||||
renderer->getFeatures().persistentlyMappedBuffers.enabled,
|
||||
&memoryTypeIndex, &mBuffer, &mAllocation));
|
||||
mSize = static_cast<size_t>(size);
|
||||
|
||||
// Wipe memory to an invalid value when the 'allocateNonZeroMemory' feature is enabled. The
|
||||
// invalid values ensures our testing doesn't assume zero-initialized memory.
|
||||
if (renderer->getFeatures().allocateNonZeroMemory.enabled)
|
||||
{
|
||||
const Allocator &allocator = renderer->getAllocator();
|
||||
ANGLE_TRY(InitMappableAllocation(context, allocator, &mAllocation, size, kNonZeroInitValue,
|
||||
requiredFlags));
|
||||
}
|
||||
|
|
|
@ -458,6 +458,22 @@ class Allocator : public WrappedObject<Allocator, VmaAllocator>
|
|||
uint32_t apiVersion,
|
||||
VkDeviceSize preferredLargeHeapBlockSize);
|
||||
|
||||
// Initializes the buffer handle and memory allocation.
|
||||
VkResult createBuffer(const VkBufferCreateInfo &bufferCreateInfo,
|
||||
VkMemoryPropertyFlags requiredFlags,
|
||||
VkMemoryPropertyFlags preferredFlags,
|
||||
bool persistentlyMappedBuffers,
|
||||
uint32_t *memoryTypeIndexOut,
|
||||
Buffer *bufferOut,
|
||||
Allocation *allocationOut) const;
|
||||
|
||||
void getMemoryTypeProperties(uint32_t memoryTypeIndex, VkMemoryPropertyFlags *flagsOut) const;
|
||||
VkResult findMemoryTypeIndexForBufferInfo(const VkBufferCreateInfo &bufferCreateInfo,
|
||||
VkMemoryPropertyFlags requiredFlags,
|
||||
VkMemoryPropertyFlags preferredFlags,
|
||||
bool persistentlyMappedBuffers,
|
||||
uint32_t *memoryTypeIndexOut) const;
|
||||
|
||||
void buildStatsString(char **statsString, VkBool32 detailedMap);
|
||||
void freeStatsString(char *statsString);
|
||||
};
|
||||
|
@ -474,7 +490,7 @@ class Allocation final : public WrappedObject<Allocation, VmaAllocation>
|
|||
void invalidate(const Allocator &allocator, VkDeviceSize offset, VkDeviceSize size) const;
|
||||
|
||||
private:
|
||||
friend class BufferMemoryAllocator;
|
||||
friend class Allocator;
|
||||
};
|
||||
|
||||
class RenderPass final : public WrappedObject<RenderPass, VkRenderPass>
|
||||
|
@ -505,7 +521,7 @@ class Buffer final : public WrappedObject<Buffer, VkBuffer>
|
|||
void getMemoryRequirements(VkDevice device, VkMemoryRequirements *memoryRequirementsOut);
|
||||
|
||||
private:
|
||||
friend class BufferMemoryAllocator;
|
||||
friend class Allocator;
|
||||
};
|
||||
|
||||
class BufferView final : public WrappedObject<BufferView, VkBufferView>
|
||||
|
@ -1356,6 +1372,42 @@ ANGLE_INLINE VkResult Allocator::init(VkPhysicalDevice physicalDevice,
|
|||
preferredLargeHeapBlockSize, &mHandle);
|
||||
}
|
||||
|
||||
ANGLE_INLINE VkResult Allocator::createBuffer(const VkBufferCreateInfo &bufferCreateInfo,
|
||||
VkMemoryPropertyFlags requiredFlags,
|
||||
VkMemoryPropertyFlags preferredFlags,
|
||||
bool persistentlyMappedBuffers,
|
||||
uint32_t *memoryTypeIndexOut,
|
||||
Buffer *bufferOut,
|
||||
Allocation *allocationOut) const
|
||||
{
|
||||
ASSERT(valid());
|
||||
ASSERT(bufferOut && !bufferOut->valid());
|
||||
ASSERT(allocationOut && !allocationOut->valid());
|
||||
return vma::CreateBuffer(mHandle, &bufferCreateInfo, requiredFlags, preferredFlags,
|
||||
persistentlyMappedBuffers, memoryTypeIndexOut, &bufferOut->mHandle,
|
||||
&allocationOut->mHandle);
|
||||
}
|
||||
|
||||
ANGLE_INLINE void Allocator::getMemoryTypeProperties(uint32_t memoryTypeIndex,
|
||||
VkMemoryPropertyFlags *flagsOut) const
|
||||
{
|
||||
ASSERT(valid());
|
||||
vma::GetMemoryTypeProperties(mHandle, memoryTypeIndex, flagsOut);
|
||||
}
|
||||
|
||||
ANGLE_INLINE VkResult
|
||||
Allocator::findMemoryTypeIndexForBufferInfo(const VkBufferCreateInfo &bufferCreateInfo,
|
||||
VkMemoryPropertyFlags requiredFlags,
|
||||
VkMemoryPropertyFlags preferredFlags,
|
||||
bool persistentlyMappedBuffers,
|
||||
uint32_t *memoryTypeIndexOut) const
|
||||
{
|
||||
ASSERT(valid());
|
||||
return vma::FindMemoryTypeIndexForBufferInfo(mHandle, &bufferCreateInfo, requiredFlags,
|
||||
preferredFlags, persistentlyMappedBuffers,
|
||||
memoryTypeIndexOut);
|
||||
}
|
||||
|
||||
ANGLE_INLINE void Allocator::buildStatsString(char **statsString, VkBool32 detailedMap)
|
||||
{
|
||||
ASSERT(valid());
|
||||
|
|
Загрузка…
Ссылка в новой задаче