Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
allocator_vk.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_ALLOCATOR_VK_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_ALLOCATOR_VK_H_
7
13
14#include <cstdint>
15#include <memory>
16
17namespace impeller {
18
19class AllocatorVK final : public Allocator {
20 public:
21 // |Allocator|
22 ~AllocatorVK() override;
23
24 // Visible for testing
25 size_t DebugGetHeapUsage() const;
26
27 /// @brief Select a matching memory type for the given
28 /// [memory_type_bits_requirement], or -1 if none is found.
29 ///
30 /// This only returns memory types with deviceLocal allocations.
31 static int32_t FindMemoryTypeIndex(
32 uint32_t memory_type_bits_requirement,
33 vk::PhysicalDeviceMemoryProperties& memory_properties);
34
35 // Visible for testing.
36 static vk::ImageUsageFlags ToVKImageUsageFlags(
39 StorageMode mode,
40 bool supports_memoryless_textures);
41
42 private:
43 friend class ContextVK;
44
45 UniqueAllocatorVMA allocator_;
46 UniquePoolVMA staging_buffer_pool_;
47 std::weak_ptr<Context> context_;
48 std::weak_ptr<DeviceHolderVK> device_holder_;
49 ISize max_texture_size_;
50 bool is_valid_ = false;
51 bool supports_memoryless_textures_ = false;
52 // TODO(jonahwilliams): figure out why CI can't create these buffer pools.
53 bool created_buffer_pool_ = true;
54 vk::PhysicalDeviceMemoryProperties memory_properties_;
55
56 AllocatorVK(std::weak_ptr<Context> context,
57 uint32_t vulkan_api_version,
58 const vk::PhysicalDevice& physical_device,
59 const std::shared_ptr<DeviceHolderVK>& device_holder,
60 const vk::Instance& instance,
61 const CapabilitiesVK& capabilities);
62
63 // |Allocator|
64 bool IsValid() const;
65
66 // |Allocator|
67 std::shared_ptr<DeviceBuffer> OnCreateBuffer(
68 const DeviceBufferDescriptor& desc) override;
69
70 // |Allocator|
71 std::shared_ptr<Texture> OnCreateTexture(
72 const TextureDescriptor& desc) override;
73
74 // |Allocator|
75 ISize GetMaxTextureSizeSupported() const override;
76
77 // |Allocator|
78 void DebugTraceMemoryStatistics() const override;
79
80 AllocatorVK(const AllocatorVK&) = delete;
81
82 AllocatorVK& operator=(const AllocatorVK&) = delete;
83};
84
85} // namespace impeller
86
87#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_ALLOCATOR_VK_H_
std::shared_ptr< DeviceBuffer > OnCreateBuffer(const DeviceBufferDescriptor &desc) override
static int32_t FindMemoryTypeIndex(uint32_t memory_type_bits_requirement, vk::PhysicalDeviceMemoryProperties &memory_properties)
Select a matching memory type for the given [memory_type_bits_requirement], or -1 if none is found.
ISize GetMaxTextureSizeSupported() const override
std::shared_ptr< Texture > OnCreateTexture(const TextureDescriptor &desc) override
void DebugTraceMemoryStatistics() const override
Write debug memory usage information to the dart timeline in debug and profile modes.
static vk::ImageUsageFlags ToVKImageUsageFlags(PixelFormat format, TextureUsageMask usage, StorageMode mode, bool supports_memoryless_textures)
size_t DebugGetHeapUsage() const
An object that allocates device memory.
Definition allocator.h:22
The Vulkan layers and extensions wrangler.
VkPhysicalDevice physical_device
Definition main.cc:51
VkInstance instance
Definition main.cc:48
uint32_t uint32_t * format
StorageMode
Specified where the allocation resides and how it is used.
Definition formats.h:33
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition formats.h:100
static void usage(char *argv0)
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...