Hash :
421dbf20
Author :
Date :
2021-10-26T19:06:19
Revert "Vulkan: Use different strategy for buffer memory allocation" This reverts commit 0dbe308d91a3526e28fecd9014d873c649f4ef71. Reason for revert: crbug.com/1253325 Original change's description: > Vulkan: Use different strategy for buffer memory allocation > > This CL uses different memory allocation strategy based on the requested > size. If the requested size exceeds 1M, we use dedicated memory > allocation to avoid memory waste associated with the sub-allocator. > Otherwise we uses VMA's sub-allocator pool. This CL creates two sets of > customized pool so that we uses different allocation strategy for each > set of pool: the small pool uses buddy algorithm which favors speed over > memory and large pool uses default algorithm that favors memory saving > over speed. This CL also replaces vmaFindMemoryTypeIndexForBufferInfo > with vmaFindMemoryTypeIndex to avoid create and destroy VkBuffer object > just try to find memoryTypeIndex. > > Bug: b/195588159 > Change-Id: I2bddbfffd77ba2ce6b9389d83a31051c4b748c4d > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2939490 > Commit-Queue: Charlie Lao <cclao@google.com> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Tim Van Patten <timvp@google.com> Bug: b/195588159 Change-Id: I2c8fe8cb2930d16f5212570d32be68e7c6a6e5f3 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3244258 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Charlie Lao <cclao@google.com> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// vma_allocator_wrapper.h:
// Hides VMA functions so we can use separate warning sets.
//
#ifndef LIBANGLE_RENDERER_VULKAN_VK_MEM_ALLOC_WRAPPER_H_
#define LIBANGLE_RENDERER_VULKAN_VK_MEM_ALLOC_WRAPPER_H_
#include "common/vulkan/vk_headers.h"
VK_DEFINE_HANDLE(VmaAllocator)
VK_DEFINE_HANDLE(VmaAllocation)
VK_DEFINE_HANDLE(VmaPool)
namespace vma
{
VkResult InitAllocator(VkPhysicalDevice physicalDevice,
VkDevice device,
VkInstance instance,
uint32_t apiVersion,
VkDeviceSize preferredLargeHeapBlockSize,
VmaAllocator *pAllocator);
void DestroyAllocator(VmaAllocator allocator);
VkResult CreatePool(VmaAllocator allocator,
uint32_t memoryTypeIndex,
bool buddyAlgorithm,
VkDeviceSize blockSize,
VmaPool *pPool);
void DestroyPool(VmaAllocator allocator, VmaPool pool);
void FreeMemory(VmaAllocator allocator, VmaAllocation allocation);
VkResult CreateBuffer(VmaAllocator allocator,
const VkBufferCreateInfo *pBufferCreateInfo,
VkMemoryPropertyFlags requiredFlags,
VkMemoryPropertyFlags preferredFlags,
bool persistentlyMappedBuffers,
uint32_t *pMemoryTypeIndexOut,
VkBuffer *pBuffer,
VmaAllocation *pAllocation);
VkResult FindMemoryTypeIndexForBufferInfo(VmaAllocator allocator,
const VkBufferCreateInfo *pBufferCreateInfo,
VkMemoryPropertyFlags requiredFlags,
VkMemoryPropertyFlags preferredFlags,
bool persistentlyMappedBuffers,
uint32_t *pMemoryTypeIndexOut);
void GetMemoryTypeProperties(VmaAllocator allocator,
uint32_t memoryTypeIndex,
VkMemoryPropertyFlags *pFlags);
VkResult MapMemory(VmaAllocator allocator, VmaAllocation allocation, void **ppData);
void UnmapMemory(VmaAllocator allocator, VmaAllocation allocation);
void FlushAllocation(VmaAllocator allocator,
VmaAllocation allocation,
VkDeviceSize offset,
VkDeviceSize size);
void InvalidateAllocation(VmaAllocator allocator,
VmaAllocation allocation,
VkDeviceSize offset,
VkDeviceSize size);
void BuildStatsString(VmaAllocator allocator, char **statsString, VkBool32 detailedMap);
void FreeStatsString(VmaAllocator allocator, char *statsString);
} // namespace vma
#endif // LIBANGLE_RENDERER_VULKAN_VK_MEM_ALLOC_WRAPPER_H_