Flutter Engine
The Flutter Engine
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
8#include "flutter/flutter_vma/flutter_vma.h"
9#include "flutter/fml/trace_event.h"
10#include "flutter/fml/unique_object.h"
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 {
42 return allocator == other.allocator && pool == other.pool;
43 }
44
45 constexpr bool operator!=(const PoolVMA& other) const {
46 return !(*this == other);
47 }
48};
49
51 static PoolVMA InvalidValue() { return {}; }
52
53 static bool IsValid(const PoolVMA& value) {
54 return value.allocator != VmaAllocator{};
55 }
56
57 static void Free(const PoolVMA& pool) {
58 TRACE_EVENT0("impeller", "DestroyPool");
59 ::vmaDestroyPool(pool.allocator, pool.pool);
60 }
61};
62
64
65// -----------------------------------------------------------------------------
66// Unique handles to VMA buffers.
67// -----------------------------------------------------------------------------
68
69struct BufferVMA {
70 VmaAllocator allocator = {};
71 VmaAllocation allocation = {};
72 vk::Buffer buffer = {};
73
74 constexpr bool operator==(const BufferVMA& other) const {
75 return allocator == other.allocator && allocation == other.allocation &&
76 buffer == other.buffer;
77 }
78
79 constexpr bool operator!=(const BufferVMA& other) const {
80 return !(*this == other);
81 }
82};
83
85 static BufferVMA InvalidValue() { return {}; }
86
87 static bool IsValid(const BufferVMA& value) {
88 return value.allocator != VmaAllocator{};
89 }
90
91 static void Free(const BufferVMA& buffer) {
92 TRACE_EVENT0("impeller", "DestroyBuffer");
93 ::vmaDestroyBuffer(buffer.allocator, static_cast<VkBuffer>(buffer.buffer),
94 buffer.allocation);
95 }
96};
97
99
100// -----------------------------------------------------------------------------
101// Unique handles to VMA images.
102// -----------------------------------------------------------------------------
103
104struct ImageVMA {
105 VmaAllocator allocator = {};
106 VmaAllocation allocation = {};
108
109 constexpr bool operator==(const ImageVMA& other) const {
110 return allocator == other.allocator && allocation == other.allocation &&
111 image == other.image;
112 }
113
114 constexpr bool operator!=(const ImageVMA& other) const {
115 return !(*this == other);
116 }
117};
118
120 static ImageVMA InvalidValue() { return {}; }
121
122 static bool IsValid(const ImageVMA& value) {
123 return value.allocator != VmaAllocator{};
124 }
125
126 static void Free(const ImageVMA& image) {
127 TRACE_EVENT0("impeller", "DestroyImage");
128 ::vmaDestroyImage(image.allocator, static_cast<VkImage>(image.image),
129 image.allocation);
130 }
131};
132
134
135} // namespace impeller
136
137#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_VMA_H_
AutoreleasePool pool
uint8_t value
sk_sp< const SkImage > image
Definition: SkRecords.h:269
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
CanvasImage Image
Definition: dart_ui.cc:55
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
static BufferVMA InvalidValue()
Definition: vma.h:85
static bool IsValid(const BufferVMA &value)
Definition: vma.h:87
static void Free(const BufferVMA &buffer)
Definition: vma.h:91
constexpr bool operator==(const BufferVMA &other) const
Definition: vma.h:74
VmaAllocator allocator
Definition: vma.h:70
vk::Buffer buffer
Definition: vma.h:72
VmaAllocation allocation
Definition: vma.h:71
constexpr bool operator!=(const BufferVMA &other) const
Definition: vma.h:79
static ImageVMA InvalidValue()
Definition: vma.h:120
static bool IsValid(const ImageVMA &value)
Definition: vma.h:122
static void Free(const ImageVMA &image)
Definition: vma.h:126
VmaAllocator allocator
Definition: vma.h:105
constexpr bool operator!=(const ImageVMA &other) const
Definition: vma.h:114
constexpr bool operator==(const ImageVMA &other) const
Definition: vma.h:109
VmaAllocation allocation
Definition: vma.h:106
vk::Image image
Definition: vma.h:107
static PoolVMA InvalidValue()
Definition: vma.h:51
static void Free(const PoolVMA &pool)
Definition: vma.h:57
static bool IsValid(const PoolVMA &value)
Definition: vma.h:53
VmaAllocator allocator
Definition: vma.h:38
constexpr bool operator!=(const PoolVMA &other) const
Definition: vma.h:45
constexpr bool operator==(const PoolVMA &other) const
Definition: vma.h:41
VmaPool pool
Definition: vma.h:39
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131