summaryrefslogtreecommitdiff
path: root/chromium/gpu/vulkan/vma_wrapper.h
blob: 470392e4fb78730b38ab645ef664a35e937390fb (plain)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef GPU_VULKAN_VMA_WRAPPER_H_
#define GPU_VULKAN_VMA_WRAPPER_H_

#include <vulkan/vulkan.h>

#include "base/component_export.h"

VK_DEFINE_HANDLE(VmaAllocator)
VK_DEFINE_HANDLE(VmaAllocation)

struct VmaAllocationCreateInfo;
struct VmaAllocationInfo;
struct VmaStats;

namespace gpu {
namespace vma {

COMPONENT_EXPORT(VULKAN)
VkResult CreateAllocator(VkPhysicalDevice physical_device,
                         VkDevice device,
                         VkInstance instance,
                         const VkDeviceSize* heap_size_limit,
                         VmaAllocator* allocator);

COMPONENT_EXPORT(VULKAN) void DestroyAllocator(VmaAllocator allocator);

COMPONENT_EXPORT(VULKAN)
VkResult AllocateMemoryForImage(VmaAllocator allocator,
                                VkImage image,
                                const VmaAllocationCreateInfo* create_info,
                                VmaAllocation* allocation,
                                VmaAllocationInfo* allocation_info);

COMPONENT_EXPORT(VULKAN)
VkResult AllocateMemoryForBuffer(VmaAllocator allocator,
                                 VkBuffer buffer,
                                 const VmaAllocationCreateInfo* create_info,
                                 VmaAllocation* allocation,
                                 VmaAllocationInfo* allocationInfo);

COMPONENT_EXPORT(VULKAN)
VkResult CreateBuffer(VmaAllocator allocator,
                      const VkBufferCreateInfo* buffer_create_info,
                      VkMemoryPropertyFlags required_flags,
                      VkMemoryPropertyFlags preferred_flags,
                      VkBuffer* buffer,
                      VmaAllocation* allocation);

COMPONENT_EXPORT(VULKAN)
void DestroyBuffer(VmaAllocator allocator,
                   VkBuffer buffer,
                   VmaAllocation allocation);

COMPONENT_EXPORT(VULKAN)
VkResult MapMemory(VmaAllocator allocator,
                   VmaAllocation allocation,
                   void** data);

COMPONENT_EXPORT(VULKAN)
void UnmapMemory(VmaAllocator allocator, VmaAllocation allocation);

COMPONENT_EXPORT(VULKAN)
void FreeMemory(VmaAllocator allocator, VmaAllocation allocation);

COMPONENT_EXPORT(VULKAN)
VkResult FlushAllocation(VmaAllocator allocator,
                         VmaAllocation allocation,
                         VkDeviceSize offset,
                         VkDeviceSize size);

COMPONENT_EXPORT(VULKAN)
VkResult InvalidateAllocation(VmaAllocator allocator,
                              VmaAllocation allocation,
                              VkDeviceSize offset,
                              VkDeviceSize size);

COMPONENT_EXPORT(VULKAN)
void GetAllocationInfo(VmaAllocator allocator,
                       VmaAllocation allocation,
                       VmaAllocationInfo* allocation_info);

COMPONENT_EXPORT(VULKAN)
void GetMemoryTypeProperties(VmaAllocator allocator,
                             uint32_t memory_type_index,
                             VkMemoryPropertyFlags* flags);

COMPONENT_EXPORT(VULKAN)
void GetPhysicalDeviceProperties(
    VmaAllocator allocator,
    const VkPhysicalDeviceProperties** physical_device_properties);

COMPONENT_EXPORT(VULKAN)
void CalculateStats(VmaAllocator allocator, VmaStats* stats);

COMPONENT_EXPORT(VULKAN)
uint64_t GetTotalAllocatedMemory(VmaAllocator allocator);

}  // namespace vma
}  // namespace gpu

#endif  // GPU_VULKAN_VMA_WRAPPER_H_