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