| 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(bool block_on_schedule,
19 const CompletionCallback& callback) {
20 if (!IsValid()) {
21 // Already committed or was never valid. Either way, this is caller error.
22 if (callback) {
23 callback(Status::kError);
24 }
25 return false;
26 }
27 return OnSubmitCommands(block_on_schedule, callback);
28 }
29
30 bool CommandBuffer::SubmitCommands(bool block_on_schedule) {
31 return SubmitCommands(block_on_schedule, nullptr);
32 }
33
34 void CommandBuffer::WaitUntilCompleted() {
35 return OnWaitUntilCompleted();
36 }
37
38 void CommandBuffer::WaitUntilScheduled() {
39 return OnWaitUntilScheduled();
40 }
41
42 std::shared_ptr<RenderPass> CommandBuffer::CreateRenderPass(
43 const RenderTarget& render_target) {
44 auto pass = OnCreateRenderPass(render_target);
45 if (pass && pass->IsValid()) {
46 pass->SetLabel("RenderPass");
47 return pass;
48 }
49 return nullptr;
50 }
51
52 std::shared_ptr<BlitPass> CommandBuffer::CreateBlitPass() {
53 auto pass = OnCreateBlitPass();
54 if (pass && pass->IsValid()) {
55 pass->SetLabel("BlitPass");
56 return pass;
57 }
58 return nullptr;
59 }
60
61 std::shared_ptr<ComputePass> CommandBuffer::CreateComputePass() {
62 if (!IsValid()) {
63 return nullptr;
64 }
65 auto pass = OnCreateComputePass();
66 if (pass && pass->IsValid()) {
67 pass->SetLabel("ComputePass");
68 return pass;
69 }
70 return nullptr;
71 }
72
73 } // namespace impeller
impeller::CommandBuffer::CreateBlitPass
std::shared_ptr< BlitPass > CreateBlitPass()
Create a blit pass to record blit commands into.
Definition: command_buffer.cc:52
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:61
impeller::CommandBuffer::CommandBuffer
CommandBuffer(std::weak_ptr< const Context > context)
Definition: command_buffer.cc:13
impeller::CommandBuffer::OnSubmitCommands
virtual bool OnSubmitCommands(bool block_on_schedule, CompletionCallback callback)=0
Submit the command buffer to the GPU for execution.
impeller::CommandBuffer::IsValid
virtual bool IsValid() const =0
impeller::CommandBuffer::OnCreateComputePass
virtual std::shared_ptr< ComputePass > OnCreateComputePass()=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:34
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:42
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:38
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