1 //
2 // Copyright 2020 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // vma_allocator_wrapper.h:
7 // Hides VMA functions so we can use separate warning sets.
8 //
9
10 #ifndef LIBANGLE_RENDERER_VULKAN_VK_MEM_ALLOC_WRAPPER_H_
11 #define LIBANGLE_RENDERER_VULKAN_VK_MEM_ALLOC_WRAPPER_H_
12
13 #include "common/vulkan/vk_headers.h"
14
15 VK_DEFINE_HANDLE(VmaAllocator)
VK_DEFINE_HANDLE(VmaAllocation)16 VK_DEFINE_HANDLE(VmaAllocation)
17
18 namespace vma
19 {
20 VkResult InitAllocator(VkPhysicalDevice physicalDevice,
21 VkDevice device,
22 VkInstance instance,
23 uint32_t apiVersion,
24 VkDeviceSize preferredLargeHeapBlockSize,
25 VmaAllocator *pAllocator);
26
27 void DestroyAllocator(VmaAllocator allocator);
28
29 void FreeMemory(VmaAllocator allocator, VmaAllocation allocation);
30
31 VkResult CreateBuffer(VmaAllocator allocator,
32 const VkBufferCreateInfo *pBufferCreateInfo,
33 VkMemoryPropertyFlags requiredFlags,
34 VkMemoryPropertyFlags preferredFlags,
35 bool persistentlyMappedBuffers,
36 uint32_t *pMemoryTypeIndexOut,
37 VkBuffer *pBuffer,
38 VmaAllocation *pAllocation);
39
40 VkResult FindMemoryTypeIndexForBufferInfo(VmaAllocator allocator,
41 const VkBufferCreateInfo *pBufferCreateInfo,
42 VkMemoryPropertyFlags requiredFlags,
43 VkMemoryPropertyFlags preferredFlags,
44 bool persistentlyMappedBuffers,
45 uint32_t *pMemoryTypeIndexOut);
46
47 void GetMemoryTypeProperties(VmaAllocator allocator,
48 uint32_t memoryTypeIndex,
49 VkMemoryPropertyFlags *pFlags);
50
51 VkResult MapMemory(VmaAllocator allocator, VmaAllocation allocation, void **ppData);
52
53 void UnmapMemory(VmaAllocator allocator, VmaAllocation allocation);
54
55 void FlushAllocation(VmaAllocator allocator,
56 VmaAllocation allocation,
57 VkDeviceSize offset,
58 VkDeviceSize size);
59
60 void InvalidateAllocation(VmaAllocator allocator,
61 VmaAllocation allocation,
62 VkDeviceSize offset,
63 VkDeviceSize size);
64
65 void BuildStatsString(VmaAllocator allocator, char **statsString, VkBool32 detailedMap);
66 void FreeStatsString(VmaAllocator allocator, char *statsString);
67
68 } // namespace vma
69
70 #endif // LIBANGLE_RENDERER_VULKAN_VK_MEM_ALLOC_WRAPPER_H_
71