| Flutter Impeller |

command_buffer_vk.cc
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 #include "impeller/renderer/backend/vulkan/command_buffer_vk.h"
6
7 #include <memory>
8 #include <utility>
9
10 #include "fml/logging.h"
11 #include "impeller/renderer/backend/vulkan/blit_pass_vk.h"
12 #include "impeller/renderer/backend/vulkan/command_encoder_vk.h"
13 #include "impeller/renderer/backend/vulkan/compute_pass_vk.h"
14 #include "impeller/renderer/backend/vulkan/context_vk.h"
15 #include "impeller/renderer/backend/vulkan/render_pass_vk.h"
16 #include "impeller/renderer/command_buffer.h"
17 #include "impeller/renderer/render_target.h"
18
19 namespace impeller {
20
21 CommandBufferVK::CommandBufferVK(
22 std::weak_ptr<const Context> context,
23 std::shared_ptr<CommandEncoderFactoryVK> encoder_factory)
24 : CommandBuffer(std::move(context)),
25 encoder_factory_(std::move(encoder_factory)) {}
26
27 CommandBufferVK::~CommandBufferVK() = default;
28
29 void CommandBufferVK::SetLabel(const std::string& label) const {
30 if (!encoder_) {
31 encoder_factory_->SetLabel(label);
32 } else {
33 auto context = context_.lock();
34 if (!context || !encoder_) {
35 return;
36 }
37 ContextVK::Cast(*context).SetDebugName(encoder_->GetCommandBuffer(), label);
38 }
39 }
40
41 bool CommandBufferVK::IsValid() const {
42 return true;
43 }
44
45 const std::shared_ptr<CommandEncoderVK>& CommandBufferVK::GetEncoder() {
46 if (!encoder_) {
47 encoder_ = encoder_factory_->Create();
48 }
49 return encoder_;
50 }
51
52 bool CommandBufferVK::OnSubmitCommands(CompletionCallback callback) {
53 FML_UNREACHABLE()
54 }
55
56 void CommandBufferVK::OnWaitUntilScheduled() {}
57
58 std::shared_ptr<RenderPass> CommandBufferVK::OnCreateRenderPass(
59 RenderTarget target) {
60 auto context = context_.lock();
61 if (!context) {
62 return nullptr;
63 }
64 auto pass =
65 std::shared_ptr<RenderPassVK>(new RenderPassVK(context, //
66 target, //
67 shared_from_this() //
68 ));
69 if (!pass->IsValid()) {
70 return nullptr;
71 }
72 return pass;
73 }
74
75 std::shared_ptr<BlitPass> CommandBufferVK::OnCreateBlitPass() {
76 if (!IsValid()) {
77 return nullptr;
78 }
79 auto pass = std::shared_ptr<BlitPassVK>(new BlitPassVK(shared_from_this()));
80 if (!pass->IsValid()) {
81 return nullptr;
82 }
83 return pass;
84 }
85
86 std::shared_ptr<ComputePass> CommandBufferVK::OnCreateComputePass() {
87 if (!IsValid()) {
88 return nullptr;
89 }
90 auto context = context_.lock();
91 if (!context) {
92 return nullptr;
93 }
94 auto pass =
95 std::shared_ptr<ComputePassVK>(new ComputePassVK(context, //
96 shared_from_this() //
97 ));
98 if (!pass->IsValid()) {
99 return nullptr;
100 }
101 return pass;
102 }
103
104 } // namespace impeller
impeller::CommandBufferVK::GetEncoder
const std::shared_ptr< CommandEncoderVK > & GetEncoder()
Definition: command_buffer_vk.cc:45
compute_pass_vk.h
command_encoder_vk.h
render_pass_vk.h
command_buffer_vk.h
impeller::CommandBuffer::context_
std::weak_ptr< const Context > context_
Definition: command_buffer.h:94
impeller::CommandBufferVK::~CommandBufferVK
~CommandBufferVK() override
impeller::ContextVK::SetDebugName
bool SetDebugName(T handle, std::string_view label) const
Definition: context_vk.h:108
blit_pass_vk.h
command_buffer.h
std
Definition: comparable.h:95
impeller::BackendCast< ContextVK, Context >::Cast
static ContextVK & Cast(Context &base)
Definition: backend_cast.h:13
render_target.h
context_vk.h
impeller
Definition: aiks_blend_unittests.cc:18