Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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:
impeller::CommandBufferGLES impeller::CommandBufferMTL impeller::CommandBufferVK impeller::testing::CommandBufferMock impeller::testing::MockCommandBuffer

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 (const std::string &label) const =0
 
void WaitUntilScheduled ()
 Force execution of pending GPU commands.
 
std::shared_ptr< RenderPassCreateRenderPass (const RenderTarget &render_target)
 Create a render pass to record render commands into.
 
std::shared_ptr< BlitPassCreateBlitPass ()
 Create a blit pass to record blit commands into.
 
std::shared_ptr< ComputePassCreateComputePass ()
 Create a compute pass to record compute commands into.
 

Protected Member Functions

 CommandBuffer (std::weak_ptr< const Context > context)
 
virtual std::shared_ptr< RenderPassOnCreateRenderPass (RenderTarget render_target)=0
 
virtual std::shared_ptr< BlitPassOnCreateBlitPass ()=0
 
virtual bool OnSubmitCommands (CompletionCallback callback)=0
 
virtual void OnWaitUntilScheduled ()=0
 
virtual std::shared_ptr< ComputePassOnCreateComputePass ()=0
 

Protected Attributes

std::weak_ptr< const Contextcontext_
 

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 Commands 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

Definition at line 55 of file command_buffer.h.

Member Enumeration Documentation

◆ Status

Enumerator
kPending 
kError 
kCompleted 

Definition at line 49 of file command_buffer.h.

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)) {}
std::weak_ptr< const Context > context_

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 47 of file command_buffer.cc.

47 {
48 auto pass = OnCreateBlitPass();
49 if (pass && pass->IsValid()) {
50 pass->SetLabel("BlitPass");
51 return pass;
52 }
53 return nullptr;
54}
virtual std::shared_ptr< BlitPass > OnCreateBlitPass()=0

◆ 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 56 of file command_buffer.cc.

56 {
57 if (!IsValid()) {
58 return nullptr;
59 }
60 auto pass = OnCreateComputePass();
61 if (pass && pass->IsValid()) {
62 pass->SetLabel("ComputePass");
63 return pass;
64 }
65 return nullptr;
66}
virtual bool IsValid() const =0
virtual std::shared_ptr< ComputePass > OnCreateComputePass()=0

◆ CreateRenderPass()

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

Create a render pass to record render commands into.

Parameters
[in]render_targetThe description of the render target this pass will target.
Returns
A valid render pass or null.

Definition at line 37 of file command_buffer.cc.

38 {
39 auto pass = OnCreateRenderPass(render_target);
40 if (pass && pass->IsValid()) {
41 pass->SetLabel("RenderPass");
42 return pass;
43 }
44 return nullptr;
45}
virtual std::shared_ptr< RenderPass > OnCreateRenderPass(RenderTarget render_target)=0

◆ IsValid()

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

◆ OnCreateBlitPass()

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

◆ OnCreateComputePass()

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

◆ OnCreateRenderPass()

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

◆ OnSubmitCommands()

virtual bool impeller::CommandBuffer::OnSubmitCommands ( CompletionCallback  callback)
protectedpure virtual

◆ OnWaitUntilScheduled()

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

◆ SetLabel()

virtual void impeller::CommandBuffer::SetLabel ( const std::string &  label) const
pure virtual

◆ WaitUntilScheduled()

void impeller::CommandBuffer::WaitUntilScheduled ( )

Force execution of pending GPU commands.

Definition at line 33 of file command_buffer.cc.

33 {
34 return OnWaitUntilScheduled();
35}
virtual void OnWaitUntilScheduled()=0

Friends And Related Symbol Documentation

◆ CommandQueue

friend class CommandQueue
friend

Definition at line 110 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 94 of file command_buffer.h.


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