| Flutter Impeller |

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
impeller::CommandBuffer Class Referenceabstract

A collection of encoded commands to be submitted to the GPU for execution. A command buffer is obtained from a graphics `Context`. More...

`#include <command_buffer.h>`

Inheritance diagram for impeller::CommandBuffer:

## Public Types
enum class | Status { kPending , kError , kCompleted }
using | CompletionCallback = std::function< void(Status)>

## Public Member Functions
virtual | ~CommandBuffer ()
virtual bool | IsValid () const =0
virtual void | SetLabel (std::string_view label) const =0
void | WaitUntilCompleted ()
| Block the current thread until the GPU has completed execution of the commands. More...
void | WaitUntilScheduled ()
| Block the current thread until the GPU has completed scheduling execution of the commands. More...
std::shared_ptr< RenderPass > | CreateRenderPass (const RenderTarget &render_target)
| Create a render pass to record render commands into. More...
std::shared_ptr< BlitPass > | CreateBlitPass ()
| Create a blit pass to record blit commands into. More...
std::shared_ptr< ComputePass > | CreateComputePass ()
| Create a compute pass to record compute commands into. More...

## Protected Member Functions
| CommandBuffer (std::weak_ptr< const Context > context)
virtual std::shared_ptr< RenderPass > | OnCreateRenderPass (RenderTarget render_target)=0
virtual std::shared_ptr< BlitPass > | OnCreateBlitPass ()=0
virtual bool | OnSubmitCommands (bool block_on_schedule, CompletionCallback callback)=0
| Submit the command buffer to the GPU for execution. More...
virtual void | OnWaitUntilCompleted ()=0
virtual void | OnWaitUntilScheduled ()=0
virtual std::shared_ptr< ComputePass > | OnCreateComputePass ()=0

## Protected Attributes
std::weak_ptr< const Context > | context_

## Friends
class | testing::CommandBufferMock
class | CommandQueue

## Detailed Description

A collection of encoded commands to be submitted to the GPU for execution. A command buffer is obtained from a graphics `Context`.

To submit commands to the GPU, acquire a `RenderPass` from the command buffer and record `Command`s into that pass. A `RenderPass` describes the configuration of the various attachments when the command is submitted.

A command buffer is only meant to be used on a single thread. If a frame workload needs to be encoded from multiple threads, set up and record into multiple command buffers. The order of submission of commands encoded in multiple command buffers can be controlled via either the order in which the command buffers were created, or, using the `ReserveSpotInQueue` command which allows for encoding commands for submission in an order that is different from the encoding order.

Definition at line 45 of file command_buffer.h.

## Member Typedef Documentation

## ◆ CompletionCallback

using impeller::CommandBuffer::CompletionCallback = std::function<void(Status)>

Definition at line 55 of file command_buffer.h.

## Member Enumeration Documentation

## ◆ Status

enum impeller::CommandBuffer::Status
| strong

Enumerator
kPending |
kError |
kCompleted |

Definition at line 49 of file command_buffer.h.

49 {
50 kPending,
51 kError,
52 kCompleted,
53 };

## Constructor & Destructor Documentation

## ◆ ~CommandBuffer()

impeller::CommandBuffer::~CommandBuffer | ( |  | ) |
| virtualdefault

## ◆ CommandBuffer()

impeller::CommandBuffer::CommandBuffer | ( | std::weak_ptr< const Context > | context | ) |
| explicitprotected

Definition at line 13 of file command_buffer.cc.

14 : context_(std::move(context)) {}
impeller::CommandBuffer::context_
std::weak_ptr< const Context > context_
Definition: command_buffer.h:101

## Member Function Documentation

## ◆ CreateBlitPass()

std::shared_ptr< BlitPass > impeller::CommandBuffer::CreateBlitPass | ( |  | ) |

Create a blit pass to record blit commands into.

Returns
  A valid blit pass or null.

Definition at line 52 of file command_buffer.cc.

52 {
53 auto pass = OnCreateBlitPass();
54 if (pass && pass->IsValid()) {
55 pass->SetLabel("BlitPass");
56 return pass;
57 }
58 return nullptr;
59 }
impeller::CommandBuffer::OnCreateBlitPass
virtual std::shared_ptr< BlitPass > OnCreateBlitPass()=0

References OnCreateBlitPass().

## ◆ CreateComputePass()

std::shared_ptr< ComputePass > impeller::CommandBuffer::CreateComputePass | ( |  | ) |

Create a compute pass to record compute commands into.

Returns
  A valid compute pass or null.

Definition at line 61 of file command_buffer.cc.

61 {
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 }
impeller::CommandBuffer::IsValid
virtual bool IsValid() const =0
impeller::CommandBuffer::OnCreateComputePass
virtual std::shared_ptr< ComputePass > OnCreateComputePass()=0

References IsValid(), and OnCreateComputePass().

## ◆ CreateRenderPass()

std::shared_ptr< RenderPass > impeller::CommandBuffer::CreateRenderPass | ( | const RenderTarget & | render_target | ) |

Create a render pass to record render commands into.

Parameters

  [in] | render_target | The description of the render target this pass will target.

Returns
  A valid render pass or null.

Definition at line 42 of file command_buffer.cc.

43 {
44 auto pass = OnCreateRenderPass(render_target);
45 if (pass && pass->IsValid()) {
46 pass->SetLabel("RenderPass");
47 return pass;
48 }
49 return nullptr;
50 }
impeller::CommandBuffer::OnCreateRenderPass
virtual std::shared_ptr< RenderPass > OnCreateRenderPass(RenderTarget render_target)=0

References OnCreateRenderPass().

## ◆ IsValid()

virtual bool impeller::CommandBuffer::IsValid | ( |  | ) | const
| pure virtual

Referenced by CreateComputePass().

## ◆ OnCreateBlitPass()

virtual std::shared_ptr<BlitPass> impeller::CommandBuffer::OnCreateBlitPass | ( |  | ) |
| protectedpure virtual

Referenced by CreateBlitPass().

## ◆ OnCreateComputePass()

virtual std::shared_ptr<ComputePass> impeller::CommandBuffer::OnCreateComputePass | ( |  | ) |
| protectedpure virtual

Referenced by CreateComputePass().

## ◆ OnCreateRenderPass()

virtual std::shared_ptr<RenderPass> impeller::CommandBuffer::OnCreateRenderPass | ( | RenderTarget | render_target | ) |
| protectedpure virtual

Referenced by CreateRenderPass().

## ◆ OnSubmitCommands()

virtual bool impeller::CommandBuffer::OnSubmitCommands | ( | bool | block_on_schedule,
|  | CompletionCallback | callback
| ) |  |
| protectedpure virtual

Submit the command buffer to the GPU for execution.

See also: [SubmitCommands].

## ◆ OnWaitUntilCompleted()

virtual void impeller::CommandBuffer::OnWaitUntilCompleted | ( |  | ) |
| protectedpure virtual

Referenced by WaitUntilCompleted().

## ◆ OnWaitUntilScheduled()

virtual void impeller::CommandBuffer::OnWaitUntilScheduled | ( |  | ) |
| protectedpure virtual

Referenced by WaitUntilScheduled().

## ◆ SetLabel()

virtual void impeller::CommandBuffer::SetLabel | ( | std::string_view | label | ) | const
| pure virtual

## ◆ WaitUntilCompleted()

void impeller::CommandBuffer::WaitUntilCompleted | ( |  | ) |

Block the current thread until the GPU has completed execution of the commands.

Definition at line 34 of file command_buffer.cc.

34 {
35 return OnWaitUntilCompleted();
36 }
impeller::CommandBuffer::OnWaitUntilCompleted
virtual void OnWaitUntilCompleted()=0

References OnWaitUntilCompleted().

## ◆ WaitUntilScheduled()

void impeller::CommandBuffer::WaitUntilScheduled | ( |  | ) |

Block the current thread until the GPU has completed scheduling execution of the commands.

Definition at line 38 of file command_buffer.cc.

38 {
39 return OnWaitUntilScheduled();
40 }
impeller::CommandBuffer::OnWaitUntilScheduled
virtual void OnWaitUntilScheduled()=0

References OnWaitUntilScheduled().

## Friends And Related Function Documentation

## ◆ CommandQueue

friend class CommandQueue
| friend

Definition at line 123 of file command_buffer.h.

## ◆ testing::CommandBufferMock

friend class testing::CommandBufferMock
| friend

Definition at line 46 of file command_buffer.h.

## Member Data Documentation

## ◆ context_

std::weak_ptr<const Context> impeller::CommandBuffer::context_
| protected

Definition at line 101 of file command_buffer.h.

The documentation for this class was generated from the following files:

- impeller/renderer/command_buffer.h
- impeller/renderer/command_buffer.cc