| Flutter Impeller |

command_buffer.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/command_buffer.h"
6
7 #include "impeller/renderer/compute_pass.h"
8 #include "impeller/renderer/render_pass.h"
9 #include "impeller/renderer/render_target.h"
10
11 namespace impeller {
12
13 CommandBuffer::CommandBuffer(std::weak_ptr<const Context> context)
14 : context_(std::move(context)) {}
15
16 CommandBuffer::~CommandBuffer() = default;
17
18 bool CommandBuffer::SubmitCommands(const CompletionCallback& callback) {
19 if (!IsValid()) {
20 // Already committed or was never valid. Either way, this is caller error.
21 if (callback) {
22 callback(Status::kError);
23 }
24 return false;
25 }
26 return OnSubmitCommands(callback);
27 }
28
29 bool CommandBuffer::SubmitCommands() {
30 return SubmitCommands(nullptr);
31 }
32
33 void CommandBuffer::WaitUntilCompleted() {
34 return OnWaitUntilCompleted();
35 }
36
37 void CommandBuffer::WaitUntilScheduled() {
38 return OnWaitUntilScheduled();
39 }
40
41 std::shared_ptr<RenderPass> CommandBuffer::CreateRenderPass(
42 const RenderTarget& render_target) {
43 auto pass = OnCreateRenderPass(render_target);
44 if (pass && pass->IsValid()) {
45 pass->SetLabel("RenderPass");
46 return pass;
47 }
48 return nullptr;
49 }
50
51 std::shared_ptr<BlitPass> CommandBuffer::CreateBlitPass() {
52 auto pass = OnCreateBlitPass();
53 if (pass && pass->IsValid()) {
54 pass->SetLabel("BlitPass");
55 return pass;
56 }
57 return nullptr;
58 }
59
60 std::shared_ptr<ComputePass> CommandBuffer::CreateComputePass() {
61 if (!IsValid()) {
62 return nullptr;
63 }
64 auto pass = OnCreateComputePass();
65 if (pass && pass->IsValid()) {
66 pass->SetLabel("ComputePass");
67 return pass;
68 }
69 return nullptr;
70 }
71
72 } // namespace impeller
impeller::CommandBuffer::CreateBlitPass
std::shared_ptr< BlitPass > CreateBlitPass()
Create a blit pass to record blit commands into.
Definition: command_buffer.cc:51
impeller::CommandBuffer::OnWaitUntilCompleted
virtual void OnWaitUntilCompleted()=0
impeller::CommandBuffer::CreateComputePass
std::shared_ptr< ComputePass > CreateComputePass()
Create a compute pass to record compute commands into.
Definition: command_buffer.cc:60
impeller::CommandBuffer::CommandBuffer
CommandBuffer(std::weak_ptr< const Context > context)
Definition: command_buffer.cc:13
impeller::CommandBuffer::IsValid
virtual bool IsValid() const =0
impeller::CommandBuffer::OnCreateComputePass
virtual std::shared_ptr< ComputePass > OnCreateComputePass()=0
impeller::CommandBuffer::OnSubmitCommands
virtual bool OnSubmitCommands(CompletionCallback callback)=0
impeller::CommandBuffer::OnCreateRenderPass
virtual std::shared_ptr< RenderPass > OnCreateRenderPass(RenderTarget render_target)=0
impeller::CommandBuffer::WaitUntilCompleted
void WaitUntilCompleted()
Block the current thread until the GPU has completed execution of the commands.
Definition: command_buffer.cc:33
impeller::CommandBuffer::CreateRenderPass
std::shared_ptr< RenderPass > CreateRenderPass(const RenderTarget &render_target)
Create a render pass to record render commands into.
Definition: command_buffer.cc:41
impeller::CommandBuffer::OnWaitUntilScheduled
virtual void OnWaitUntilScheduled()=0
impeller::CommandBuffer::OnCreateBlitPass
virtual std::shared_ptr< BlitPass > OnCreateBlitPass()=0
impeller::CommandBuffer::~CommandBuffer
virtual ~CommandBuffer()
impeller::CommandBuffer::Status::kError
@ kError
impeller::CommandBuffer::WaitUntilScheduled
void WaitUntilScheduled()
Block the current thread until the GPU has completed scheduling execution of the commands.
Definition: command_buffer.cc:37
impeller::RenderTarget
Definition: render_target.h:38
command_buffer.h
compute_pass.h
impeller
Definition: allocation.cc:12
std
Definition: comparable.h:95
render_pass.h
render_target.h