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 "libANGLE/renderer/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 VmaAllocator *pAllocator);
25
26 void DestroyAllocator(VmaAllocator allocator);
27
28 void FreeMemory(VmaAllocator allocator, VmaAllocation allocation);
29
30 VkResult CreateBuffer(VmaAllocator allocator,
31 const VkBufferCreateInfo *pBufferCreateInfo,
32 VkMemoryPropertyFlags requiredFlags,
33 VkMemoryPropertyFlags preferredFlags,
34 bool persistentlyMappedBuffers,
35 uint32_t *pMemoryTypeIndexOut,
36 VkBuffer *pBuffer,
37 VmaAllocation *pAllocation);
38
39 VkResult FindMemoryTypeIndexForBufferInfo(VmaAllocator allocator,
40 const VkBufferCreateInfo *pBufferCreateInfo,
41 VkMemoryPropertyFlags requiredFlags,
42 VkMemoryPropertyFlags preferredFlags,
43 bool persistentlyMappedBuffers,
44 uint32_t *pMemoryTypeIndexOut);
45
46 void GetMemoryTypeProperties(VmaAllocator allocator,
47 uint32_t memoryTypeIndex,
48 VkMemoryPropertyFlags *pFlags);
49
50 VkResult MapMemory(VmaAllocator allocator, VmaAllocation allocation, void **ppData);
51
52 void UnmapMemory(VmaAllocator allocator, VmaAllocation allocation);
53
54 void FlushAllocation(VmaAllocator allocator,
55 VmaAllocation allocation,
56 VkDeviceSize offset,
57 VkDeviceSize size);
58
59 void InvalidateAllocation(VmaAllocator allocator,
60 VmaAllocation allocation,
61 VkDeviceSize offset,
62 VkDeviceSize size);
63
64 } // namespace vma
65
66 #endif // LIBANGLE_RENDERER_VULKAN_VK_MEM_ALLOC_WRAPPER_H_