| Flutter Impeller |

allocator_vk.cc
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 #include "impeller/renderer/backend/vulkan/allocator_vk.h"
6
7 #include <memory>
8
9 #include "flutter/fml/memory/ref_ptr.h"
10 #include "flutter/fml/trace_event.h"
11 #include "impeller/base/allocation_size.h"
12 #include "impeller/core/formats.h"
13 #include "impeller/renderer/backend/vulkan/capabilities_vk.h"
14 #include "impeller/renderer/backend/vulkan/device_buffer_vk.h"
15 #include "impeller/renderer/backend/vulkan/formats_vk.h"
16 #include "impeller/renderer/backend/vulkan/texture_vk.h"
17 #include "vulkan/vulkan_enums.hpp"
18
19 namespace impeller {
20
21 static constexpr vk::Flags<vk::MemoryPropertyFlagBits>
22 ToVKBufferMemoryPropertyFlags(StorageMode mode) {
23 switch (mode) {
24 case StorageMode::kHostVisible:
25 return vk::MemoryPropertyFlagBits::eHostVisible;
26 case StorageMode::kDevicePrivate:
27 return vk::MemoryPropertyFlagBits::eDeviceLocal;
28 case StorageMode::kDeviceTransient:
29 return vk::MemoryPropertyFlagBits::eLazilyAllocated;
30 }
31 FML_UNREACHABLE();
32 }
33
34 static VmaAllocationCreateFlags ToVmaAllocationBufferCreateFlags(
35 StorageMode mode,
36 bool readback) {
37 VmaAllocationCreateFlags flags = 0;
38 switch (mode) {
39 case StorageMode::kHostVisible:
40 if (!readback) {
41 flags |= VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT;
42 } else {
43 flags |= VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT;
44 }
45 flags |= VMA_ALLOCATION_CREATE_MAPPED_BIT;
46 return flags;
47 case StorageMode::kDevicePrivate:
48 FML_DCHECK(!readback);
49 return flags;
50 case StorageMode::kDeviceTransient:
51 FML_DCHECK(!readback);
52 return flags;
53 }
54 FML_UNREACHABLE();
55 }
56
57 static PoolVMA CreateBufferPool(VmaAllocator allocator) {
58 vk::BufferCreateInfo buffer_info;
59 buffer_info.usage = vk::BufferUsageFlagBits::eVertexBuffer |
60 vk::BufferUsageFlagBits::eIndexBuffer |
61 vk::BufferUsageFlagBits::eUniformBuffer |
62 vk::BufferUsageFlagBits::eStorageBuffer |
63 vk::BufferUsageFlagBits::eTransferSrc |
64 vk::BufferUsageFlagBits::eTransferDst;
65 buffer_info.size = 1u; // doesn't matter
66 buffer_info.sharingMode = vk::SharingMode::eExclusive;
67 auto buffer_info_native =
68 static_cast<vk::BufferCreateInfo::NativeType>(buffer_info);
69
70 VmaAllocationCreateInfo allocation_info = {};
71 allocation_info.usage = VMA_MEMORY_USAGE_AUTO;
72 allocation_info.preferredFlags = static_cast<VkMemoryPropertyFlags>(
73 ToVKBufferMemoryPropertyFlags(StorageMode::kHostVisible));
74 allocation_info.flags = ToVmaAllocationBufferCreateFlags(
75 StorageMode::kHostVisible, /*readback=*/false);
76
77 uint32_t memTypeIndex;
78 auto result = vk::Result{vmaFindMemoryTypeIndexForBufferInfo(
79 allocator, &buffer_info_native, &allocation_info, &memTypeIndex)};
80 if (result != vk::Result::eSuccess) {
81 return {};
82 }
83
84 VmaPoolCreateInfo pool_create_info = {};
85 pool_create_info.memoryTypeIndex = memTypeIndex;
86 pool_create_info.flags = VMA_POOL_CREATE_IGNORE_BUFFER_IMAGE_GRANULARITY_BIT;
87
88 VmaPool pool = {};
89 result = vk::Result{::vmaCreatePool(allocator, &pool_create_info, &pool)};
90 if (result != vk::Result::eSuccess) {
91 return {};
92 }
93 return {allocator, pool};
94 }
95
96 AllocatorVK::AllocatorVK(std::weak_ptr<Context> context,
97 uint32_t vulkan_api_version,
98 const vk::PhysicalDevice& physical_device,
99 const std::shared_ptr<DeviceHolderVK>& device_holder,
100 const vk::Instance& instance,
101 const CapabilitiesVK& capabilities)
102 : context_(std::move(context)), device_holder_(device_holder) {
103 auto limits = physical_device.getProperties().limits;
104 max_texture_size_.width = max_texture_size_.height =
105 limits.maxImageDimension2D;
106 physical_device.getMemoryProperties(&memory_properties_);
107
108 VmaVulkanFunctions proc_table = {};
109
110 #define BIND_VMA_PROC(x) proc_table.x = VULKAN_HPP_DEFAULT_DISPATCHER.x;
111 #define BIND_VMA_PROC_KHR(x) \
112 proc_table.x##KHR = VULKAN_HPP_DEFAULT_DISPATCHER.x \
113 ? VULKAN_HPP_DEFAULT_DISPATCHER.x \
114 : VULKAN_HPP_DEFAULT_DISPATCHER.x##KHR;
115 BIND_VMA_PROC(vkGetInstanceProcAddr);
116 BIND_VMA_PROC(vkGetDeviceProcAddr);
117 BIND_VMA_PROC(vkGetPhysicalDeviceProperties);
118 BIND_VMA_PROC(vkGetPhysicalDeviceMemoryProperties);
119 BIND_VMA_PROC(vkAllocateMemory);
120 BIND_VMA_PROC(vkFreeMemory);
121 BIND_VMA_PROC(vkMapMemory);
122 BIND_VMA_PROC(vkUnmapMemory);
123 BIND_VMA_PROC(vkFlushMappedMemoryRanges);
124 BIND_VMA_PROC(vkInvalidateMappedMemoryRanges);
125 BIND_VMA_PROC(vkBindBufferMemory);
126 BIND_VMA_PROC(vkBindImageMemory);
127 BIND_VMA_PROC(vkGetBufferMemoryRequirements);
128 BIND_VMA_PROC(vkGetImageMemoryRequirements);
129 BIND_VMA_PROC(vkCreateBuffer);
130 BIND_VMA_PROC(vkDestroyBuffer);
131 BIND_VMA_PROC(vkCreateImage);
132 BIND_VMA_PROC(vkDestroyImage);
133 BIND_VMA_PROC(vkCmdCopyBuffer);
134 BIND_VMA_PROC_KHR(vkGetBufferMemoryRequirements2);
135 BIND_VMA_PROC_KHR(vkGetImageMemoryRequirements2);
136 BIND_VMA_PROC_KHR(vkBindBufferMemory2);
137 BIND_VMA_PROC_KHR(vkBindImageMemory2);
138 BIND_VMA_PROC_KHR(vkGetPhysicalDeviceMemoryProperties2);
139 #undef BIND_VMA_PROC_KHR
140 #undef BIND_VMA_PROC
141
142 VmaAllocatorCreateInfo allocator_info = {};
143 allocator_info.vulkanApiVersion = vulkan_api_version;
144 allocator_info.physicalDevice = physical_device;
145 allocator_info.device = device_holder->GetDevice();
146 allocator_info.instance = instance;
147 allocator_info.pVulkanFunctions = &proc_table;
148
149 VmaAllocator allocator = {};
150 auto result = vk::Result{::vmaCreateAllocator(&allocator_info, &allocator)};
151 if (result != vk::Result::eSuccess) {
152 VALIDATION_LOG << "Could not create memory allocator";
153 return;
154 }
155 staging_buffer_pool_.reset(CreateBufferPool(allocator));
156 created_buffer_pool_ &= staging_buffer_pool_.is_valid();
157 allocator_.reset(allocator);
158 supports_memoryless_textures_ =
159 capabilities.SupportsDeviceTransientTextures();
160 is_valid_ = true;
161 }
162
163 AllocatorVK::~AllocatorVK() = default;
164
165 // |Allocator|
166 bool AllocatorVK::IsValid() const {
167 return is_valid_;
168 }
169
170 // |Allocator|
171 ISize AllocatorVK::GetMaxTextureSizeSupported() const {
172 return max_texture_size_;
173 }
174
175 int32_t AllocatorVK::FindMemoryTypeIndex(
176 uint32_t memory_type_bits_requirement,
177 vk::PhysicalDeviceMemoryProperties& memory_properties) {
178 int32_t type_index = -1;
179 vk::MemoryPropertyFlagBits required_properties =
180 vk::MemoryPropertyFlagBits::eDeviceLocal;
181
182 const uint32_t memory_count = memory_properties.memoryTypeCount;
183 for (uint32_t memory_index = 0; memory_index < memory_count; ++memory_index) {
184 const uint32_t memory_type_bits = (1 << memory_index);
185 const bool is_required_memory_type =
186 memory_type_bits_requirement & memory_type_bits;
187
188 const auto properties =
189 memory_properties.memoryTypes[memory_index].propertyFlags;
190 const bool has_required_properties =
191 (properties & required_properties) == required_properties;
192
193 if (is_required_memory_type && has_required_properties) {
194 return static_cast<int32_t>(memory_index);
195 }
196 }
197
198 return type_index;
199 }
200
201 vk::ImageUsageFlags AllocatorVK::ToVKImageUsageFlags(
202 PixelFormat format,
203 TextureUsageMask usage,
204 StorageMode mode,
205 bool supports_memoryless_textures) {
206 vk::ImageUsageFlags vk_usage;
207
208 switch (mode) {
209 case StorageMode::kHostVisible:
210 case StorageMode::kDevicePrivate:
211 break;
212 case StorageMode::kDeviceTransient:
213 if (supports_memoryless_textures) {
214 vk_usage |= vk::ImageUsageFlagBits::eTransientAttachment;
215 }
216 break;
217 }
218
219 if (usage & TextureUsage::kRenderTarget) {
220 if (PixelFormatIsDepthStencil(format)) {
221 vk_usage |= vk::ImageUsageFlagBits::eDepthStencilAttachment;
222 } else {
223 vk_usage |= vk::ImageUsageFlagBits::eColorAttachment;
224 vk_usage |= vk::ImageUsageFlagBits::eInputAttachment;
225 }
226 }
227
228 if (usage & TextureUsage::kShaderRead) {
229 vk_usage |= vk::ImageUsageFlagBits::eSampled;
230 }
231
232 if (usage & TextureUsage::kShaderWrite) {
233 vk_usage |= vk::ImageUsageFlagBits::eStorage;
234 }
235
236 if (mode != StorageMode::kDeviceTransient) {
237 // Add transfer usage flags to support blit passes only if image isn't
238 // device transient.
239 vk_usage |= vk::ImageUsageFlagBits::eTransferSrc |
240 vk::ImageUsageFlagBits::eTransferDst;
241 }
242
243 return vk_usage;
244 }
245
246 static constexpr VmaMemoryUsage ToVMAMemoryUsage() {
247 return VMA_MEMORY_USAGE_AUTO;
248 }
249
250 static constexpr vk::Flags<vk::MemoryPropertyFlagBits>
251 ToVKTextureMemoryPropertyFlags(StorageMode mode,
252 bool supports_memoryless_textures) {
253 switch (mode) {
254 case StorageMode::kHostVisible:
255 return vk::MemoryPropertyFlagBits::eHostVisible |
256 vk::MemoryPropertyFlagBits::eDeviceLocal;
257 case StorageMode::kDevicePrivate:
258 return vk::MemoryPropertyFlagBits::eDeviceLocal;
259 case StorageMode::kDeviceTransient:
260 if (supports_memoryless_textures) {
261 return vk::MemoryPropertyFlagBits::eLazilyAllocated |
262 vk::MemoryPropertyFlagBits::eDeviceLocal;
263 }
264 return vk::MemoryPropertyFlagBits::eDeviceLocal;
265 }
266 FML_UNREACHABLE();
267 }
268
269 static VmaAllocationCreateFlags ToVmaAllocationCreateFlags(StorageMode mode) {
270 VmaAllocationCreateFlags flags = 0;
271 switch (mode) {
272 case StorageMode::kHostVisible:
273 return flags;
274 case StorageMode::kDevicePrivate:
275 return flags;
276 case StorageMode::kDeviceTransient:
277 return flags;
278 }
279 FML_UNREACHABLE();
280 }
281
282 class AllocatedTextureSourceVK final : public TextureSourceVK {
283 public:
284 AllocatedTextureSourceVK(const ContextVK& context,
285 const TextureDescriptor& desc,
286 VmaAllocator allocator,
287 vk::Device device,
288 bool supports_memoryless_textures)
289 : TextureSourceVK(desc), resource_(context.GetResourceManager()) {
290 FML_DCHECK(desc.format != PixelFormat::kUnknown);
291 vk::StructureChain<vk::ImageCreateInfo, vk::ImageCompressionControlEXT>
292 image_info_chain;
293 auto& image_info = image_info_chain.get();
294 image_info.flags = ToVKImageCreateFlags(desc.type);
295 image_info.imageType = vk::ImageType::e2D;
296 image_info.format = ToVKImageFormat(desc.format);
297 image_info.extent = VkExtent3D{
298 static_cast<uint32_t>(desc.size.width), // width
299 static_cast<uint32_t>(desc.size.height), // height
300 1u // depth
301 };
302 image_info.samples = ToVKSampleCount(desc.sample_count);
303 image_info.mipLevels = desc.mip_count;
304 image_info.arrayLayers = ToArrayLayerCount(desc.type);
305 image_info.tiling = vk::ImageTiling::eOptimal;
306 image_info.initialLayout = vk::ImageLayout::eUndefined;
307 image_info.usage = AllocatorVK::ToVKImageUsageFlags(
308 desc.format, desc.usage, desc.storage_mode,
309 supports_memoryless_textures);
310 image_info.sharingMode = vk::SharingMode::eExclusive;
311
312 vk::ImageCompressionFixedRateFlagsEXT frc_rates[1] = {
313 vk::ImageCompressionFixedRateFlagBitsEXT::eNone};
314
315 const auto frc_rate =
316 CapabilitiesVK::Cast(*context.GetCapabilities())
317 .GetSupportedFRCRate(desc.compression_type,
318 FRCFormatDescriptor{image_info});
319 if (frc_rate.has_value()) {
320 // This array must not be in a temporary scope.
321 frc_rates[0] = frc_rate.value();
322
323 auto& compression_info =
324 image_info_chain.get<vk::ImageCompressionControlEXT>();
325 compression_info.pFixedRateFlags = frc_rates;
326 compression_info.compressionControlPlaneCount = 1u;
327 compression_info.flags =
328 vk::ImageCompressionFlagBitsEXT::eFixedRateExplicit;
329 } else {
330 image_info_chain.unlink<vk::ImageCompressionControlEXT>();
331 }
332
333 VmaAllocationCreateInfo alloc_nfo = {};
334
335 alloc_nfo.usage = ToVMAMemoryUsage();
336 alloc_nfo.preferredFlags =
337 static_cast<VkMemoryPropertyFlags>(ToVKTextureMemoryPropertyFlags(
338 desc.storage_mode, supports_memoryless_textures));
339 alloc_nfo.flags = ToVmaAllocationCreateFlags(desc.storage_mode);
340
341 auto create_info_native =
342 static_cast<vk::ImageCreateInfo::NativeType>(image_info);
343
344 VkImage vk_image = VK_NULL_HANDLE;
345 VmaAllocation allocation = {};
346 VmaAllocationInfo allocation_info = {};
347 {
348 auto result = vk::Result{::vmaCreateImage(allocator, //
349 &create_info_native, //
350 &alloc_nfo, //
351 &vk_image, //
352 &allocation, //
353 &allocation_info //
354 )};
355 if (result != vk::Result::eSuccess) {
356 VALIDATION_LOG << "Unable to allocate Vulkan Image: "
357 << vk::to_string(result)
358 << " Type: " << TextureTypeToString(desc.type)
359 << " Mode: " << StorageModeToString(desc.storage_mode)
360 << " Usage: " << TextureUsageMaskToString(desc.usage)
361 << " [VK]Flags: " << vk::to_string(image_info.flags)
362 << " [VK]Format: " << vk::to_string(image_info.format)
363 << " [VK]Usage: " << vk::to_string(image_info.usage)
364 << " [VK]Mem. Flags: "
365 << vk::to_string(vk::MemoryPropertyFlags(
366 alloc_nfo.preferredFlags));
367 return;
368 }
369 }
370
371 auto image = vk::Image{vk_image};
372
373 vk::ImageViewCreateInfo view_info = {};
374 view_info.image = image;
375 view_info.viewType = ToVKImageViewType(desc.type);
376 view_info.format = image_info.format;
377 view_info.subresourceRange.aspectMask = ToVKImageAspectFlags(desc.format);
378 view_info.subresourceRange.levelCount = image_info.mipLevels;
379 view_info.subresourceRange.layerCount = ToArrayLayerCount(desc.type);
380
381 // Vulkan does not have an image format that is equivalent to
382 // `MTLPixelFormatA8Unorm`, so we use `R8Unorm` instead. Given that the
383 // shaders expect that alpha channel to be set in the cases, we swizzle.
384 // See: https://github.com/flutter/flutter/issues/115461 for more details.
385 if (desc.format == PixelFormat::kA8UNormInt) {
386 view_info.components.a = vk::ComponentSwizzle::eR;
387 view_info.components.r = vk::ComponentSwizzle::eA;
388 }
389
390 auto [result, image_view] = device.createImageViewUnique(view_info);
391 if (result != vk::Result::eSuccess) {
392 VALIDATION_LOG << "Unable to create an image view for allocation: "
393 << vk::to_string(result);
394 return;
395 }
396 // Create a specialized view for render target attachments.
397 view_info.subresourceRange.levelCount = 1u;
398 auto [rt_result, rt_image_view] = device.createImageViewUnique(view_info);
399 if (rt_result != vk::Result::eSuccess) {
400 VALIDATION_LOG << "Unable to create an image view for allocation: "
401 << vk::to_string(rt_result);
402 return;
403 }
404
405 resource_.Swap(ImageResource(ImageVMA{allocator, allocation, image},
406 std::move(image_view),
407 std::move(rt_image_view)));
408 is_valid_ = true;
409 }
410
411 ~AllocatedTextureSourceVK() = default;
412
413 bool IsValid() const { return is_valid_; }
414
415 vk::Image GetImage() const override { return resource_->image.get().image; }
416
417 vk::ImageView GetImageView() const override {
418 return resource_->image_view.get();
419 }
420
421 vk::ImageView GetRenderTargetView() const override {
422 return resource_->rt_image_view.get();
423 }
424
425 bool IsSwapchainImage() const override { return false; }
426
427 private:
428 struct ImageResource {
429 UniqueImageVMA image;
430 vk::UniqueImageView image_view;
431 vk::UniqueImageView rt_image_view;
432
433 ImageResource() = default;
434
435 ImageResource(ImageVMA p_image,
436 vk::UniqueImageView p_image_view,
437 vk::UniqueImageView p_rt_image_view)
438 : image(p_image),
439 image_view(std::move(p_image_view)),
440 rt_image_view(std::move(p_rt_image_view)) {}
441
442 ImageResource(ImageResource&& o) = default;
443
444 ImageResource(const ImageResource&) = delete;
445
446 ImageResource& operator=(const ImageResource&) = delete;
447 };
448
449 UniqueResourceVKT<ImageResource> resource_;
450 bool is_valid_ = false;
451
452 AllocatedTextureSourceVK(const AllocatedTextureSourceVK&) = delete;
453
454 AllocatedTextureSourceVK& operator=(const AllocatedTextureSourceVK&) = delete;
455 };
456
457 // |Allocator|
458 std::shared_ptr<Texture> AllocatorVK::OnCreateTexture(
459 const TextureDescriptor& desc) {
460 if (!IsValid()) {
461 return nullptr;
462 }
463 auto device_holder = device_holder_.lock();
464 if (!device_holder) {
465 return nullptr;
466 }
467 auto context = context_.lock();
468 if (!context) {
469 return nullptr;
470 }
471 auto source = std::make_shared<AllocatedTextureSourceVK>(
472 ContextVK::Cast(*context), //
473 desc, //
474 allocator_.get(), //
475 device_holder->GetDevice(), //
476 supports_memoryless_textures_ //
477 );
478 if (!source->IsValid()) {
479 return nullptr;
480 }
481 return std::make_shared<TextureVK>(context_, std::move(source));
482 }
483
484 // |Allocator|
485 std::shared_ptr<DeviceBuffer> AllocatorVK::OnCreateBuffer(
486 const DeviceBufferDescriptor& desc) {
487 vk::BufferCreateInfo buffer_info;
488 buffer_info.usage = vk::BufferUsageFlagBits::eVertexBuffer |
489 vk::BufferUsageFlagBits::eIndexBuffer |
490 vk::BufferUsageFlagBits::eUniformBuffer |
491 vk::BufferUsageFlagBits::eStorageBuffer |
492 vk::BufferUsageFlagBits::eTransferSrc |
493 vk::BufferUsageFlagBits::eTransferDst;
494 buffer_info.size = desc.size;
495 buffer_info.sharingMode = vk::SharingMode::eExclusive;
496 auto buffer_info_native =
497 static_cast<vk::BufferCreateInfo::NativeType>(buffer_info);
498
499 VmaAllocationCreateInfo allocation_info = {};
500 allocation_info.usage = ToVMAMemoryUsage();
501 allocation_info.preferredFlags = static_cast<VkMemoryPropertyFlags>(
502 ToVKBufferMemoryPropertyFlags(desc.storage_mode));
503 allocation_info.flags =
504 ToVmaAllocationBufferCreateFlags(desc.storage_mode, desc.readback);
505 if (created_buffer_pool_ && desc.storage_mode == StorageMode::kHostVisible &&
506 !desc.readback) {
507 allocation_info.pool = staging_buffer_pool_.get().pool;
508 }
509
510 VkBuffer buffer = {};
511 VmaAllocation buffer_allocation = {};
512 VmaAllocationInfo buffer_allocation_info = {};
513 auto result = vk::Result{::vmaCreateBuffer(allocator_.get(), //
514 &buffer_info_native, //
515 &allocation_info, //
516 &buffer, //
517 &buffer_allocation, //
518 &buffer_allocation_info //
519 )};
520
521 if (result != vk::Result::eSuccess) {
522 VALIDATION_LOG << "Unable to allocate a device buffer: "
523 << vk::to_string(result);
524 return {};
525 }
526
527 return std::make_shared<DeviceBufferVK>(
528 desc, //
529 context_, //
530 UniqueBufferVMA{BufferVMA{allocator_.get(), //
531 buffer_allocation, //
532 vk::Buffer{buffer}}}, //
533 buffer_allocation_info //
534 );
535 }
536
537 Bytes AllocatorVK::DebugGetHeapUsage() const {
538 auto count = memory_properties_.memoryHeapCount;
539 std::vector<VmaBudget> budgets(count);
540 vmaGetHeapBudgets(allocator_.get(), budgets.data());
541 size_t total_usage = 0;
542 for (auto i = 0u; i < count; i++) {
543 const VmaBudget& budget = budgets[i];
544 total_usage += budget.usage;
545 }
546 return Bytes{static_cast<double>(total_usage)};
547 }
548
549 void AllocatorVK::DebugTraceMemoryStatistics() const {
550 #ifdef IMPELLER_DEBUG
551 FML_TRACE_COUNTER("flutter", "AllocatorVK",
552 reinterpret_cast<int64_t>(this), // Trace Counter ID
553 "MemoryBudgetUsageMB",
554 DebugGetHeapUsage().ConvertTo<MebiBytes>().GetSize());
555 #endif // IMPELLER_DEBUG
556 }
557
558 } // namespace impeller
impeller::ContextVK::GetCapabilities
const std::shared_ptr< const Capabilities > & GetCapabilities() const override
Get the capabilities of Impeller context. All optionally supported feature of the platform,...
Definition: context_vk.cc:555
impeller::ISize
ISize64 ISize
Definition: size.h:140
impeller::TextureSourceVK
Abstract base class that represents a vkImage and an vkImageView.
Definition: texture_source_vk.h:28
impeller::ToVKSampleCount
constexpr vk::SampleCountFlagBits ToVKSampleCount(SampleCount sample_count)
Definition: formats_vk.h:201
BIND_VMA_PROC_KHR
#define BIND_VMA_PROC_KHR(x)
allocator_vk.h
impeller::PixelFormatIsDepthStencil
constexpr bool PixelFormatIsDepthStencil(PixelFormat format)
Definition: formats_vk.h:393
impeller::AllocatedTextureSourceVK::GetImageView
vk::ImageView GetImageView() const override
Retrieve the image view used for sampling/blitting/compute with this texture source.
Definition: allocator_vk.cc:417
impeller::ToVKTextureMemoryPropertyFlags
static constexpr vk::Flags< vk::MemoryPropertyFlagBits > ToVKTextureMemoryPropertyFlags(StorageMode mode, bool supports_memoryless_textures)
Definition: allocator_vk.cc:251
impeller::TextureDescriptor::format
PixelFormat format
Definition: texture_descriptor.h:41
impeller::ToArrayLayerCount
constexpr uint32_t ToArrayLayerCount(TextureType type)
Definition: formats_vk.h:518
impeller::TextureDescriptor::mip_count
size_t mip_count
Definition: texture_descriptor.h:43
formats.h
impeller::ToVKImageCreateFlags
constexpr vk::ImageCreateFlags ToVKImageCreateFlags(TextureType type)
Definition: formats_vk.h:546
impeller::PoolVMA
Definition: vma.h:37
formats_vk.h
impeller::StorageMode::kHostVisible
@ kHostVisible
impeller::TextureDescriptor::sample_count
SampleCount sample_count
Definition: texture_descriptor.h:45
impeller::TextureDescriptor::usage
TextureUsageMask usage
Definition: texture_descriptor.h:44
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:99
capabilities_vk.h
impeller::TextureDescriptor::type
TextureType type
Definition: texture_descriptor.h:40
impeller::Mask< TextureUsage >
impeller::ImageVMA
Definition: vma.h:104
impeller::StorageMode::kDeviceTransient
@ kDeviceTransient
impeller::StorageMode
StorageMode
Specified where the allocation resides and how it is used.
Definition: formats.h:32
impeller::ToVKImageFormat
constexpr vk::Format ToVKImageFormat(PixelFormat format)
Definition: formats_vk.h:133
impeller::AllocatedTextureSourceVK::IsValid
bool IsValid() const
Definition: allocator_vk.cc:413
impeller::StorageMode::kDevicePrivate
@ kDevicePrivate
impeller::StorageModeToString
constexpr const char * StorageModeToString(StorageMode mode)
Definition: formats.h:60
impeller::FRCFormatDescriptor
A pixel format and usage that is sufficient to check if images of that format and usage are suitable ...
Definition: capabilities_vk.h:151
impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK
AllocatedTextureSourceVK(const ContextVK &context, const TextureDescriptor &desc, VmaAllocator allocator, vk::Device device, bool supports_memoryless_textures)
Definition: allocator_vk.cc:284
impeller::AllocationSize< 1u >
BIND_VMA_PROC
#define BIND_VMA_PROC(x)
impeller::ToVKImageViewType
constexpr vk::ImageViewType ToVKImageViewType(TextureType type)
Definition: formats_vk.h:532
impeller::ToVKImageAspectFlags
constexpr vk::ImageAspectFlags ToVKImageAspectFlags(PixelFormat format)
Definition: formats_vk.h:492
impeller::TSize::width
Type width
Definition: size.h:22
texture_vk.h
impeller::TextureUsageMaskToString
std::string TextureUsageMaskToString(TextureUsageMask mask)
Definition: formats.cc:81
impeller::ContextVK
Definition: context_vk.h:42
impeller::TextureDescriptor::size
ISize size
Definition: texture_descriptor.h:42
impeller::ToVMAMemoryUsage
static constexpr VmaMemoryUsage ToVMAMemoryUsage()
Definition: allocator_vk.cc:246
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91
impeller::TextureTypeToString
constexpr const char * TextureTypeToString(TextureType type)
Definition: formats.h:269
std
Definition: comparable.h:95
device_buffer_vk.h
impeller::AllocatedTextureSourceVK::IsSwapchainImage
bool IsSwapchainImage() const override
Determines if swapchain image. That is, an image used as the root render target.
Definition: allocator_vk.cc:425
impeller::TextureDescriptor::storage_mode
StorageMode storage_mode
Definition: texture_descriptor.h:39
impeller::TSize::height
Type height
Definition: size.h:23
impeller::CreateBufferPool
static PoolVMA CreateBufferPool(VmaAllocator allocator)
Definition: allocator_vk.cc:57
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition: texture_descriptor.h:38
allocation_size.h
impeller::AllocatedTextureSourceVK::GetImage
vk::Image GetImage() const override
Get the image handle for this texture source.
Definition: allocator_vk.cc:415
impeller::UniqueBufferVMA
fml::UniqueObject< BufferVMA, BufferVMATraits > UniqueBufferVMA
Definition: vma.h:98
impeller::ToVKBufferMemoryPropertyFlags
static constexpr vk::Flags< vk::MemoryPropertyFlagBits > ToVKBufferMemoryPropertyFlags(StorageMode mode)
Definition: allocator_vk.cc:22
impeller::AllocatedTextureSourceVK
Definition: allocator_vk.cc:282
impeller::TextureDescriptor::compression_type
CompressionType compression_type
Definition: texture_descriptor.h:46
impeller::ToVmaAllocationBufferCreateFlags
static VmaAllocationCreateFlags ToVmaAllocationBufferCreateFlags(StorageMode mode, bool readback)
Definition: allocator_vk.cc:34
impeller
Definition: allocation.cc:12
impeller::ToVmaAllocationCreateFlags
static VmaAllocationCreateFlags ToVmaAllocationCreateFlags(StorageMode mode)
Definition: allocator_vk.cc:269
impeller::AllocatedTextureSourceVK::GetRenderTargetView
vk::ImageView GetRenderTargetView() const override
Retrieve the image view used for render target attachments with this texture source.
Definition: allocator_vk.cc:421
impeller::UniqueImageVMA
fml::UniqueObject< ImageVMA, ImageVMATraits > UniqueImageVMA
Definition: vma.h:133