| Flutter Impeller |

command_buffer_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_BUFFER_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_COMMAND_BUFFER_VK_H_
7
8 #include "fml/status_or.h"
9 #include "impeller/base/backend_cast.h"
10 #include "impeller/renderer/backend/vulkan/command_queue_vk.h"
11 #include "impeller/renderer/backend/vulkan/descriptor_pool_vk.h"
12 #include "impeller/renderer/backend/vulkan/device_holder_vk.h"
13 #include "impeller/renderer/backend/vulkan/texture_source_vk.h"
14 #include "impeller/renderer/backend/vulkan/tracked_objects_vk.h"
15 #include "impeller/renderer/backend/vulkan/vk.h"
16 #include "impeller/renderer/command_buffer.h"
17
18 namespace impeller {
19
20 class ContextVK;
21 class CommandEncoderFactoryVK;
22 class CommandEncoderVK;
23
24 class CommandBufferVK final
25 : public CommandBuffer,
26 public BackendCast<CommandBufferVK, CommandBuffer>,
27 public std::enable_shared_from_this<CommandBufferVK> {
28 public:
29 // |CommandBuffer|
30 ~CommandBufferVK() override;
31
32 // Encoder Functionality
33
34 /// @brief Ensure that [object] is kept alive until this command buffer
35 /// completes execution.
36 bool Track(const std::shared_ptr<SharedObjectVK>& object);
37
38 /// @brief Ensure that [buffer] is kept alive until this command buffer
39 /// completes execution.
40 bool Track(const std::shared_ptr<const DeviceBuffer>& buffer);
41
42 /// @brief Ensure that [texture] is kept alive until this command buffer
43 /// completes execution.
44 bool Track(const std::shared_ptr<const Texture>& texture);
45
46 /// @brief Ensure that [texture] is kept alive until this command buffer
47 /// completes execution.
48 bool Track(const std::shared_ptr<const TextureSourceVK>& texture);
49
50 /// @brief Retrieve the native command buffer from this object.
51 vk::CommandBuffer GetCommandBuffer() const;
52
53 /// @brief Push a debug group.
54 ///
55 /// This label is only visible in debuggers like RenderDoc. This function is
56 /// ignored in release builds.
57 void PushDebugGroup(std::string_view label) const;
58
59 /// @brief Pop the previous debug group.
60 ///
61 /// This label is only visible in debuggers like RenderDoc. This function is
62 /// ignored in release builds.
63 void PopDebugGroup() const;
64
65 /// @brief Insert a new debug marker.
66 ///
67 /// This label is only visible in debuggers like RenderDoc. This function is
68 /// ignored in release builds.
69 void InsertDebugMarker(std::string_view label) const;
70
71 /// @brief End recording of the current command buffer.
72 bool EndCommandBuffer() const;
73
74 /// @brief Allocate a new descriptor set for the given [layout].
75 fml::StatusOr<vk::DescriptorSet> AllocateDescriptorSets(
76 const vk::DescriptorSetLayout& layout,
77 const ContextVK& context);
78
79 // Visible for testing.
80 DescriptorPoolVK& GetDescriptorPool() const;
81
82 private:
83 friend class ContextVK;
84 friend class CommandQueueVK;
85
86 std::weak_ptr<const DeviceHolderVK> device_holder_;
87 std::shared_ptr<TrackedObjectsVK> tracked_objects_;
88
89 CommandBufferVK(std::weak_ptr<const Context> context,
90 std::weak_ptr<const DeviceHolderVK> device_holder,
91 std::shared_ptr<TrackedObjectsVK> tracked_objects);
92
93 // |CommandBuffer|
94 void SetLabel(std::string_view label) const override;
95
96 // |CommandBuffer|
97 bool IsValid() const override;
98
99 // |CommandBuffer|
100 bool OnSubmitCommands(CompletionCallback callback) override;
101
102 // |CommandBuffer|
103 void OnWaitUntilCompleted() override;
104
105 // |CommandBuffer|
106 void OnWaitUntilScheduled() override;
107
108 // |CommandBuffer|
109 std::shared_ptr<RenderPass> OnCreateRenderPass(RenderTarget target) override;
110
111 // |CommandBuffer|
112 std::shared_ptr<BlitPass> OnCreateBlitPass() override;
113
114 // |CommandBuffer|
115 std::shared_ptr<ComputePass> OnCreateComputePass() override;
116
117 CommandBufferVK(const CommandBufferVK&) = delete;
118
119 CommandBufferVK& operator=(const CommandBufferVK&) = delete;
120 };
121
122 } // namespace impeller
123
124 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_COMMAND_BUFFER_VK_H_
impeller::CommandBufferVK::InsertDebugMarker
void InsertDebugMarker(std::string_view label) const
Insert a new debug marker.
Definition: command_buffer_vk.cc:192
tracked_objects_vk.h
texture_source_vk.h
impeller::CommandBufferVK::GetDescriptorPool
DescriptorPoolVK & GetDescriptorPool() const
Definition: command_buffer_vk.cc:203
impeller::CommandBuffer::CompletionCallback
std::function< void(Status)> CompletionCallback
Definition: command_buffer.h:55
impeller::CommandBufferVK::Track
bool Track(const std::shared_ptr< SharedObjectVK > &object)
Ensure that [object] is kept alive until this command buffer completes execution.
Definition: command_buffer_vk.cc:126
vk.h
device_holder_vk.h
impeller::CommandBufferVK::GetCommandBuffer
vk::CommandBuffer GetCommandBuffer() const
Retrieve the native command buffer from this object.
Definition: command_buffer_vk.cc:119
impeller::CommandBufferVK::~CommandBufferVK
~CommandBufferVK() override
impeller::DescriptorPoolVK
A per-frame descriptor pool. Descriptors from this pool don't need to be freed individually....
Definition: descriptor_pool_vk.h:27
impeller::CommandBufferVK::EndCommandBuffer
bool EndCommandBuffer() const
End recording of the current command buffer.
Definition: command_buffer_vk.cc:105
backend_cast.h
impeller::CommandBufferVK::AllocateDescriptorSets
fml::StatusOr< vk::DescriptorSet > AllocateDescriptorSets(const vk::DescriptorSetLayout &layout, const ContextVK &context)
Allocate a new descriptor set for the given [layout].
Definition: command_buffer_vk.cc:161
impeller::RenderTarget
Definition: render_target.h:38
impeller::CommandQueueVK
Definition: command_queue_vk.h:14
impeller::CommandBufferVK
Definition: command_buffer_vk.h:24
impeller::ContextVK
Definition: context_vk.h:64
command_buffer.h
impeller::CommandBufferVK::PopDebugGroup
void PopDebugGroup() const
Pop the previous debug group.
Definition: command_buffer_vk.cc:183
impeller::BackendCast
Definition: backend_cast.h:11
command_queue_vk.h
descriptor_pool_vk.h
impeller
Definition: allocation.cc:12
impeller::CommandBuffer
A collection of encoded commands to be submitted to the GPU for execution. A command buffer is obtain...
Definition: command_buffer.h:45
impeller::CommandBufferVK::PushDebugGroup
void PushDebugGroup(std::string_view label) const
Push a debug group.
Definition: command_buffer_vk.cc:172