| Flutter Impeller |

command_encoder_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_COMMAND_ENCODER_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_COMMAND_ENCODER_VK_H_
7
8 #include <cstdint>
9 #include <functional>
10 #include <optional>
11
12 #include "impeller/renderer/backend/vulkan/command_pool_vk.h"
13 #include "impeller/renderer/backend/vulkan/context_vk.h"
14 #include "impeller/renderer/backend/vulkan/descriptor_pool_vk.h"
15 #include "impeller/renderer/backend/vulkan/device_holder.h"
16 #include "impeller/renderer/backend/vulkan/queue_vk.h"
17 #include "impeller/renderer/backend/vulkan/shared_object_vk.h"
18 #include "impeller/renderer/backend/vulkan/vk.h"
19
20 namespace impeller {
21
22 class ContextVK;
23 class DeviceBuffer;
24 class Buffer;
25 class Texture;
26 class TextureSourceVK;
27 class TrackedObjectsVK;
28 class FenceWaiterVK;
29 class GPUProbe;
30
31 class CommandEncoderFactoryVK {
32 public:
33 explicit CommandEncoderFactoryVK(
34 const std::weak_ptr<const ContextVK>& context);
35
36 std::shared_ptr<CommandEncoderVK> Create();
37
38 void SetLabel(const std::string& label);
39
40 private:
41 std::weak_ptr<const ContextVK> context_;
42 std::optional<std::string> label_;
43
44 CommandEncoderFactoryVK(const CommandEncoderFactoryVK&) = delete;
45
46 CommandEncoderFactoryVK& operator=(const CommandEncoderFactoryVK&) = delete;
47 };
48
49 class CommandEncoderVK {
50 public:
51 using SubmitCallback = std::function<void(bool)>;
52
53 // Visible for testing.
54 CommandEncoderVK(std::weak_ptr<const DeviceHolder> device_holder,
55 std::shared_ptr<TrackedObjectsVK> tracked_objects,
56 const std::shared_ptr<QueueVK>& queue,
57 std::shared_ptr<FenceWaiterVK> fence_waiter);
58
59 ~CommandEncoderVK();
60
61 bool IsValid() const;
62
63 bool Submit(SubmitCallback callback = {});
64
65 bool Track(std::shared_ptr<SharedObjectVK> object);
66
67 bool Track(std::shared_ptr<const Buffer> buffer);
68
69 bool IsTracking(const std::shared_ptr<const Buffer>& texture) const;
70
71 bool Track(const std::shared_ptr<const Texture>& texture);
72
73 bool IsTracking(const std::shared_ptr<const Texture>& texture) const;
74
75 bool Track(std::shared_ptr<const TextureSourceVK> texture);
76
77 vk::CommandBuffer GetCommandBuffer() const;
78
79 void PushDebugGroup(const char* label) const;
80
81 void PopDebugGroup() const;
82
83 void InsertDebugMarker(const char* label) const;
84
85 fml::StatusOr<std::vector<vk::DescriptorSet>> AllocateDescriptorSets(
86 uint32_t buffer_count,
87 uint32_t sampler_count,
88 uint32_t subpass_count,
89 const std::vector<vk::DescriptorSetLayout>& layouts);
90
91 private:
92 friend class ContextVK;
93
94 std::weak_ptr<const DeviceHolder> device_holder_;
95 std::shared_ptr<TrackedObjectsVK> tracked_objects_;
96 std::shared_ptr<QueueVK> queue_;
97 const std::shared_ptr<FenceWaiterVK> fence_waiter_;
98 bool is_valid_ = true;
99
100 void Reset();
101
102 CommandEncoderVK(const CommandEncoderVK&) = delete;
103
104 CommandEncoderVK& operator=(const CommandEncoderVK&) = delete;
105 };
106
107 } // namespace impeller
108
109 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_COMMAND_ENCODER_VK_H_
impeller::CommandEncoderVK::Submit
bool Submit(SubmitCallback callback={})
Definition: command_encoder_vk.cc:166
shared_object_vk.h
impeller::CommandEncoderVK::PushDebugGroup
void PushDebugGroup(const char *label) const
Definition: command_encoder_vk.cc:311
device_holder.h
impeller::CommandEncoderFactoryVK
Definition: command_encoder_vk.h:31
impeller::CommandEncoderVK::CommandEncoderVK
CommandEncoderVK(std::weak_ptr< const DeviceHolder > device_holder, std::shared_ptr< TrackedObjectsVK > tracked_objects, const std::shared_ptr< QueueVK > &queue, std::shared_ptr< FenceWaiterVK > fence_waiter)
Definition: command_encoder_vk.cc:150
vk.h
command_pool_vk.h
impeller::CommandEncoderFactoryVK::SetLabel
void SetLabel(const std::string &label)
Definition: command_encoder_vk.cc:105
impeller::CommandEncoderVK::SubmitCallback
std::function< void(bool)> SubmitCallback
Definition: command_encoder_vk.h:51
impeller::CommandEncoderVK::Track
bool Track(std::shared_ptr< SharedObjectVK > object)
Definition: command_encoder_vk.cc:245
queue_vk.h
impeller::CommandEncoderFactoryVK::CommandEncoderFactoryVK
CommandEncoderFactoryVK(const std::weak_ptr< const ContextVK > &context)
Definition: command_encoder_vk.cc:101
impeller::CommandEncoderVK::InsertDebugMarker
void InsertDebugMarker(const char *label) const
Definition: command_encoder_vk.cc:331
impeller::CommandEncoderVK::PopDebugGroup
void PopDebugGroup() const
Definition: command_encoder_vk.cc:322
impeller::ContextVK
Definition: context_vk.h:40
impeller::CommandEncoderVK::~CommandEncoderVK
~CommandEncoderVK()
descriptor_pool_vk.h
impeller::CommandEncoderVK::IsTracking
bool IsTracking(const std::shared_ptr< const Buffer > &texture) const
Definition: command_encoder_vk.cc:261
context_vk.h
impeller::CommandEncoderVK::IsValid
bool IsValid() const
Definition: command_encoder_vk.cc:162
impeller::CommandEncoderVK
Definition: command_encoder_vk.h:49
impeller
Definition: aiks_context.cc:10
impeller::CommandEncoderVK::GetCommandBuffer
vk::CommandBuffer GetCommandBuffer() const
Definition: command_encoder_vk.cc:231
impeller::CommandEncoderVK::AllocateDescriptorSets
fml::StatusOr< std::vector< vk::DescriptorSet > > AllocateDescriptorSets(uint32_t buffer_count, uint32_t sampler_count, uint32_t subpass_count, const std::vector< vk::DescriptorSetLayout > &layouts)
Definition: command_encoder_vk.cc:298
impeller::CommandEncoderFactoryVK::Create
std::shared_ptr< CommandEncoderVK > Create()
Definition: command_encoder_vk.cc:109