Flutter Engine
 
Loading...
Searching...
No Matches
vma.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_VMA_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_VMA_H_
7
12
13namespace impeller {
14
15// -----------------------------------------------------------------------------
16// Unique handles to VMA allocators.
17// -----------------------------------------------------------------------------
19 static VmaAllocator InvalidValue() { return {}; }
20
21 static bool IsValid(const VmaAllocator& value) {
22 return value != InvalidValue();
23 }
24
25 static void Free(VmaAllocator allocator) {
26 TRACE_EVENT0("impeller", "DestroyAllocator");
27 ::vmaDestroyAllocator(allocator);
28 }
29};
30
32
33// -----------------------------------------------------------------------------
34// Unique handles to VMA pools.
35// -----------------------------------------------------------------------------
36
37struct PoolVMA {
38 VmaAllocator allocator = {};
39 VmaPool pool = {};
40
41 constexpr bool operator==(const PoolVMA& other) const = default;
42};
43
45 static PoolVMA InvalidValue() { return {}; }
46
47 static bool IsValid(const PoolVMA& value) {
48 return value.allocator != VmaAllocator{};
49 }
50
51 static void Free(const PoolVMA& pool) {
52 TRACE_EVENT0("impeller", "DestroyPool");
53 ::vmaDestroyPool(pool.allocator, pool.pool);
54 }
55};
56
58
59// -----------------------------------------------------------------------------
60// Unique handles to VMA buffers.
61// -----------------------------------------------------------------------------
62
63struct BufferVMA {
64 VmaAllocator allocator = {};
65 VmaAllocation allocation = {};
66 vk::Buffer buffer = {};
67
68 constexpr bool operator==(const BufferVMA& other) const {
69 return allocator == other.allocator && allocation == other.allocation &&
70 buffer == other.buffer;
71 }
72
73 constexpr bool operator!=(const BufferVMA& other) const {
74 return !(*this == other);
75 }
76};
77
79 static BufferVMA InvalidValue() { return {}; }
80
81 static bool IsValid(const BufferVMA& value) {
82 return value.allocator != VmaAllocator{};
83 }
84
85 static void Free(const BufferVMA& buffer) {
86 TRACE_EVENT0("impeller", "DestroyBuffer");
87 ::vmaDestroyBuffer(buffer.allocator, static_cast<VkBuffer>(buffer.buffer),
88 buffer.allocation);
89 }
90};
91
93
94// -----------------------------------------------------------------------------
95// Unique handles to VMA images.
96// -----------------------------------------------------------------------------
97
98struct ImageVMA {
99 VmaAllocator allocator = {};
100 VmaAllocation allocation = {};
101 vk::Image image = {};
102
103 constexpr bool operator==(const ImageVMA& other) const {
104 return allocator == other.allocator && allocation == other.allocation &&
105 image == other.image;
106 }
107
108 constexpr bool operator!=(const ImageVMA& other) const {
109 return !(*this == other);
110 }
111};
112
114 static ImageVMA InvalidValue() { return {}; }
115
116 static bool IsValid(const ImageVMA& value) {
117 return value.allocator != VmaAllocator{};
118 }
119
120 static void Free(const ImageVMA& image) {
121 TRACE_EVENT0("impeller", "DestroyImage");
122 ::vmaDestroyImage(image.allocator, static_cast<VkImage>(image.image),
123 image.allocation);
124 }
125};
126
128
129} // namespace impeller
130
131#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_VMA_H_
int32_t value
FlutterVulkanImage * image
FlutterVulkanImageHandle image
Definition embedder.h:931
static VmaAllocator InvalidValue()
Definition vma.h:19
static bool IsValid(const VmaAllocator &value)
Definition vma.h:21
static void Free(VmaAllocator allocator)
Definition vma.h:25
constexpr bool operator==(const BufferVMA &other) const
Definition vma.h:68
VmaAllocator allocator
Definition vma.h:64
vk::Buffer buffer
Definition vma.h:66
VmaAllocation allocation
Definition vma.h:65
constexpr bool operator!=(const BufferVMA &other) const
Definition vma.h:73
static BufferVMA InvalidValue()
Definition vma.h:79
static bool IsValid(const BufferVMA &value)
Definition vma.h:81
static void Free(const BufferVMA &buffer)
Definition vma.h:85
VmaAllocator allocator
Definition vma.h:99
constexpr bool operator!=(const ImageVMA &other) const
Definition vma.h:108
constexpr bool operator==(const ImageVMA &other) const
Definition vma.h:103
VmaAllocation allocation
Definition vma.h:100
vk::Image image
Definition vma.h:101
static ImageVMA InvalidValue()
Definition vma.h:114
static bool IsValid(const ImageVMA &value)
Definition vma.h:116
static void Free(const ImageVMA &image)
Definition vma.h:120
VmaAllocator allocator
Definition vma.h:38
constexpr bool operator==(const PoolVMA &other) const =default
VmaPool pool
Definition vma.h:39
static PoolVMA InvalidValue()
Definition vma.h:45
static void Free(const PoolVMA &pool)
Definition vma.h:51
static bool IsValid(const PoolVMA &value)
Definition vma.h:47
#define TRACE_EVENT0(category_group, name)