| Flutter Impeller |

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
8 #include "flutter/fml/macros.h"
9 #include "flutter/fml/memory/ref_ptr.h"
10 #include "impeller/core/allocator.h"
11 #include "impeller/renderer/backend/vulkan/context_vk.h"
12 #include "impeller/renderer/backend/vulkan/device_buffer_vk.h"
13 #include "impeller/renderer/backend/vulkan/device_holder.h"
14 #include "impeller/renderer/backend/vulkan/vk.h"
15
16 #include <array>
17 #include <cstdint>
18 #include <memory>
19
20 namespace impeller {
21
22 class AllocatorVK final : public Allocator {
23 public:
24 // |Allocator|
25 ~AllocatorVK() override;
26
27 private:
28 friend class ContextVK;
29
30 UniqueAllocatorVMA allocator_;
31 UniquePoolVMA staging_buffer_pool_;
32 std::weak_ptr<Context> context_;
33 std::weak_ptr<DeviceHolder> device_holder_;
34 ISize max_texture_size_;
35 bool is_valid_ = false;
36 bool supports_memoryless_textures_ = false;
37 bool supports_framebuffer_fetch_ = false;
38 // TODO(jonahwilliams): figure out why CI can't create these buffer pools.
39 bool created_buffer_pool_ = true;
40 uint32_t frame_count_ = 0;
41 std::thread::id raster_thread_id_;
42
43 AllocatorVK(std::weak_ptr<Context> context,
44 uint32_t vulkan_api_version,
45 const vk::PhysicalDevice& physical_device,
46 const std::shared_ptr<DeviceHolder>& device_holder,
47 const vk::Instance& instance,
48 const CapabilitiesVK& capabilities);
49
50 // |Allocator|
51 bool IsValid() const;
52
53 // |Allocator|
54 void DidAcquireSurfaceFrame() override;
55
56 // |Allocator|
57 std::shared_ptr<DeviceBuffer> OnCreateBuffer(
58 const DeviceBufferDescriptor& desc) override;
59
60 // |Allocator|
61 std::shared_ptr<Texture> OnCreateTexture(
62 const TextureDescriptor& desc) override;
63
64 // |Allocator|
65 ISize GetMaxTextureSizeSupported() const override;
66
67 AllocatorVK(const AllocatorVK&) = delete;
68
69 AllocatorVK& operator=(const AllocatorVK&) = delete;
70 };
71
72 } // namespace impeller
73
74 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_ALLOCATOR_VK_H_
device_holder.h
impeller::DeviceBufferDescriptor
Definition: device_buffer_descriptor.h:14
impeller::UniquePoolVMA
fml::UniqueObject< PoolVMA, PoolVMATraits > UniquePoolVMA
Definition: vma.h:63
impeller::AllocatorVK::~AllocatorVK
~AllocatorVK() override
vk.h
impeller::TSize< int64_t >
impeller::AllocatorVK
Definition: allocator_vk.h:22
impeller::Allocator
An object that allocates device memory.
Definition: allocator.h:22
impeller::CapabilitiesVK
The Vulkan layers and extensions wrangler.
Definition: capabilities_vk.h:33
impeller::ContextVK
Definition: context_vk.h:40
impeller::UniqueAllocatorVMA
fml::UniqueObject< VmaAllocator, AllocatorVMATraits > UniqueAllocatorVMA
Definition: vma.h:31
allocator.h
device_buffer_vk.h
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition: texture_descriptor.h:37
context_vk.h
impeller
Definition: aiks_context.cc:10