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 
20 
21 namespace impeller {
22 
23 class ContextVK;
24 class DeviceBuffer;
25 class Buffer;
26 class Texture;
27 class TextureSourceVK;
28 class TrackedObjectsVK;
29 class FenceWaiterVK;
30 class GPUProbe;
31 
33  public:
34  explicit CommandEncoderFactoryVK(
35  const std::weak_ptr<const ContextVK>& context);
36 
37  std::shared_ptr<CommandEncoderVK> Create();
38 
39  void SetLabel(const std::string& label);
40 
41  private:
42  std::weak_ptr<const ContextVK> context_;
43  std::optional<std::string> label_;
44 
46 
47  CommandEncoderFactoryVK& operator=(const CommandEncoderFactoryVK&) = delete;
48 };
49 
51  public:
52  using SubmitCallback = std::function<void(bool)>;
53 
54  // Visible for testing.
55  CommandEncoderVK(std::weak_ptr<const DeviceHolderVK> device_holder,
56  std::shared_ptr<TrackedObjectsVK> tracked_objects,
57  const std::shared_ptr<QueueVK>& queue,
58  std::shared_ptr<FenceWaiterVK> fence_waiter);
59 
61 
62  bool IsValid() const;
63 
64  bool Track(std::shared_ptr<SharedObjectVK> object);
65 
66  bool Track(std::shared_ptr<const DeviceBuffer> buffer);
67 
68  bool IsTracking(const std::shared_ptr<const DeviceBuffer>& texture) const;
69 
70  bool Track(const std::shared_ptr<const Texture>& texture);
71 
72  bool IsTracking(const std::shared_ptr<const Texture>& texture) const;
73 
74  bool Track(std::shared_ptr<const TextureSourceVK> texture);
75 
76  vk::CommandBuffer GetCommandBuffer() const;
77 
78  void PushDebugGroup(std::string_view label) const;
79 
80  void PopDebugGroup() const;
81 
82  void InsertDebugMarker(std::string_view label) const;
83 
84  bool EndCommandBuffer() const;
85 
86  fml::StatusOr<vk::DescriptorSet> AllocateDescriptorSets(
87  const vk::DescriptorSetLayout& layout,
88  const ContextVK& context);
89 
90  private:
91  friend class ContextVK;
92  friend class CommandQueueVK;
93 
94  std::weak_ptr<const DeviceHolderVK> device_holder_;
95  std::shared_ptr<TrackedObjectsVK> tracked_objects_;
96  std::shared_ptr<QueueVK> queue_;
97  const std::shared_ptr<FenceWaiterVK> fence_waiter_;
98  std::shared_ptr<HostBuffer> host_buffer_;
99  bool is_valid_ = true;
100 
101  void Reset();
102 
103  CommandEncoderVK(const CommandEncoderVK&) = delete;
104 
105  CommandEncoderVK& operator=(const CommandEncoderVK&) = delete;
106 };
107 
108 } // namespace impeller
109 
110 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_COMMAND_ENCODER_VK_H_
shared_object_vk.h
impeller::CommandEncoderVK::InsertDebugMarker
void InsertDebugMarker(std::string_view label) const
Definition: command_encoder_vk.cc:195
impeller::CommandEncoderFactoryVK
Definition: command_encoder_vk.h:32
vk.h
device_holder_vk.h
command_pool_vk.h
impeller::CommandEncoderFactoryVK::SetLabel
void SetLabel(const std::string &label)
Definition: command_encoder_vk.cc:23
impeller::CommandEncoderVK::SubmitCallback
std::function< void(bool)> SubmitCallback
Definition: command_encoder_vk.h:52
impeller::CommandEncoderVK::Track
bool Track(std::shared_ptr< SharedObjectVK > object)
Definition: command_encoder_vk.cc:112
impeller::CommandEncoderVK::EndCommandBuffer
bool EndCommandBuffer() const
Definition: command_encoder_vk.cc:84
impeller::CommandEncoderVK::IsTracking
bool IsTracking(const std::shared_ptr< const DeviceBuffer > &texture) const
Definition: command_encoder_vk.cc:128
impeller::CommandEncoderVK::PushDebugGroup
void PushDebugGroup(std::string_view label) const
Definition: command_encoder_vk.cc:175
queue_vk.h
impeller::CommandQueueVK
Definition: command_queue_vk.h:14
impeller::CommandEncoderFactoryVK::CommandEncoderFactoryVK
CommandEncoderFactoryVK(const std::weak_ptr< const ContextVK > &context)
Definition: command_encoder_vk.cc:19
impeller::CommandEncoderVK::AllocateDescriptorSets
fml::StatusOr< vk::DescriptorSet > AllocateDescriptorSets(const vk::DescriptorSetLayout &layout, const ContextVK &context)
Definition: command_encoder_vk.cc:164
impeller::CommandEncoderVK::PopDebugGroup
void PopDebugGroup() const
Definition: command_encoder_vk.cc:186
impeller::ContextVK
Definition: context_vk.h:42
impeller::CommandEncoderVK::~CommandEncoderVK
~CommandEncoderVK()
command_queue_vk.h
descriptor_pool_vk.h
impeller::CommandEncoderVK::CommandEncoderVK
CommandEncoderVK(std::weak_ptr< const DeviceHolderVK > 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:68
context_vk.h
impeller::CommandEncoderVK::IsValid
bool IsValid() const
Definition: command_encoder_vk.cc:80
impeller::CommandEncoderVK
Definition: command_encoder_vk.h:50
impeller
Definition: aiks_blur_unittests.cc:20
impeller::CommandEncoderVK::GetCommandBuffer
vk::CommandBuffer GetCommandBuffer() const
Definition: command_encoder_vk.cc:98
impeller::CommandEncoderFactoryVK::Create
std::shared_ptr< CommandEncoderVK > Create()
Definition: command_encoder_vk.cc:27