| 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 #pragma once
6
7 #include <functional>
8 #include <optional>
9 #include <set>
10
11 #include "flutter/fml/macros.h"
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
30 class CommandEncoderFactoryVK {
31 public:
32 CommandEncoderFactoryVK(const std::weak_ptr<const ContextVK>& context);
33
34 std::shared_ptr<CommandEncoderVK> Create();
35
36 void SetLabel(const std::string& label);
37
38 private:
39 std::weak_ptr<const ContextVK> context_;
40 std::optional<std::string> label_;
41
42 FML_DISALLOW_COPY_AND_ASSIGN(CommandEncoderFactoryVK);
43 };
44
45 class CommandEncoderVK {
46 public:
47 using SubmitCallback = std::function<void(bool)>;
48
49 // Visible for testing.
50 CommandEncoderVK(std::weak_ptr<const DeviceHolder> device_holder,
51 std::shared_ptr<TrackedObjectsVK> tracked_objects,
52 const std::shared_ptr<QueueVK>& queue,
53 std::shared_ptr<FenceWaiterVK> fence_waiter);
54
55 ~CommandEncoderVK();
56
57 bool IsValid() const;
58
59 bool Submit(SubmitCallback callback = {});
60
61 bool Track(std::shared_ptr<SharedObjectVK> object);
62
63 bool Track(std::shared_ptr<const Buffer> buffer);
64
65 bool IsTracking(const std::shared_ptr<const Buffer>& texture) const;
66
67 bool Track(const std::shared_ptr<const Texture>& texture);
68
69 bool IsTracking(const std::shared_ptr<const Texture>& texture) const;
70
71 bool Track(std::shared_ptr<const TextureSourceVK> texture);
72
73 vk::CommandBuffer GetCommandBuffer() const;
74
75 void PushDebugGroup(const char* label) const;
76
77 void PopDebugGroup() const;
78
79 void InsertDebugMarker(const char* label) const;
80
81 std::optional<vk::DescriptorSet> AllocateDescriptorSet(
82 const vk::DescriptorSetLayout& layout,
83 size_t command_count);
84
85 private:
86 friend class ContextVK;
87
88 std::weak_ptr<const DeviceHolder> device_holder_;
89 std::shared_ptr<TrackedObjectsVK> tracked_objects_;
90 std::shared_ptr<QueueVK> queue_;
91 const std::shared_ptr<FenceWaiterVK> fence_waiter_;
92 bool is_valid_ = true;
93
94 void Reset();
95
96 FML_DISALLOW_COPY_AND_ASSIGN(CommandEncoderVK);
97 };
98
99 } // namespace impeller
impeller::CommandEncoderVK::Submit
bool Submit(SubmitCallback callback={})
Definition: command_encoder_vk.cc:158
shared_object_vk.h
impeller::CommandEncoderVK::PushDebugGroup
void PushDebugGroup(const char *label) const
Definition: command_encoder_vk.cc:295
device_holder.h
impeller::CommandEncoderFactoryVK
Definition: command_encoder_vk.h:30
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:142
vk.h
command_pool_vk.h
impeller::CommandEncoderVK::AllocateDescriptorSet
std::optional< vk::DescriptorSet > AllocateDescriptorSet(const vk::DescriptorSetLayout &layout, size_t command_count)
Definition: command_encoder_vk.cc:284
impeller::CommandEncoderFactoryVK::SetLabel
void SetLabel(const std::string &label)
Definition: command_encoder_vk.cc:97
impeller::CommandEncoderVK::SubmitCallback
std::function< void(bool)> SubmitCallback
Definition: command_encoder_vk.h:47
impeller::CommandEncoderVK::Track
bool Track(std::shared_ptr< SharedObjectVK > object)
Definition: command_encoder_vk.cc:232
queue_vk.h
impeller::CommandEncoderFactoryVK::CommandEncoderFactoryVK
CommandEncoderFactoryVK(const std::weak_ptr< const ContextVK > &context)
Definition: command_encoder_vk.cc:93
impeller::CommandEncoderVK::InsertDebugMarker
void InsertDebugMarker(const char *label) const
Definition: command_encoder_vk.cc:315
impeller::CommandEncoderVK::PopDebugGroup
void PopDebugGroup() const
Definition: command_encoder_vk.cc:306
impeller::ContextVK
Definition: context_vk.h:36
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:248
context_vk.h
impeller::CommandEncoderVK::IsValid
bool IsValid() const
Definition: command_encoder_vk.cc:154
impeller::CommandEncoderVK
Definition: command_encoder_vk.h:45
impeller
Definition: aiks_context.cc:10
impeller::CommandEncoderVK::GetCommandBuffer
vk::CommandBuffer GetCommandBuffer() const
Definition: command_encoder_vk.cc:218
impeller::CommandEncoderFactoryVK::Create
std::shared_ptr< CommandEncoderVK > Create()
Definition: command_encoder_vk.cc:101