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>
Public Types | |
| enum | Status { Status::kPending, Status::kError, Status::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 |
| bool | SubmitCommands (const CompletionCallback &callback) |
| Schedule the command encoded by render passes within this command buffer on the GPU. The encoding of these commnands is performed immediately on the calling thread. More... | |
| bool | SubmitCommands () |
| virtual bool | EncodeAndSubmit (const std::shared_ptr< RenderPass > &render_pass) |
| Schedule the command encoded by render passes within this command buffer on the GPU. The enqueing of this buffer is performed immediately but encoding is pushed to a worker thread if possible. More... | |
| virtual bool | EncodeAndSubmit (const std::shared_ptr< BlitPass > &blit_pass, const std::shared_ptr< Allocator > &allocator) |
| Schedule the command encoded by blit passes within this command buffer on the GPU. The enqueing of this buffer is performed immediately but encoding is pushed to a worker thread if possible. More... | |
| void | WaitUntilScheduled () |
| Force execution of pending GPU 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 (CompletionCallback callback)=0 |
| virtual void | OnWaitUntilScheduled ()=0 |
| virtual std::shared_ptr< ComputePass > | OnCreateComputePass ()=0 |
Protected Attributes | |
| std::weak_ptr< const Context > | context_ |
Friends | |
| class | testing::CommandBufferMock |
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.
| using impeller::CommandBuffer::CompletionCallback = std::function<void(Status)> |
Definition at line 55 of file command_buffer.h.
|
strong |
| Enumerator | |
|---|---|
| kPending | |
| kError | |
| kCompleted | |
Definition at line 49 of file command_buffer.h.
|
virtualdefault |
|
explicitprotected |
Definition at line 14 of file command_buffer.cc.
| std::shared_ptr< BlitPass > impeller::CommandBuffer::CreateBlitPass | ( | ) |
Create a blit pass to record blit commands into.
Definition at line 76 of file command_buffer.cc.
References OnCreateBlitPass().
| std::shared_ptr< ComputePass > impeller::CommandBuffer::CreateComputePass | ( | ) |
Create a compute pass to record compute commands into.
Definition at line 85 of file command_buffer.cc.
References IsValid(), and OnCreateComputePass().
| std::shared_ptr< RenderPass > impeller::CommandBuffer::CreateRenderPass | ( | const RenderTarget & | render_target | ) |
Create a render pass to record render commands into.
| [in] | render_target | The description of the render target this pass will target. |
Definition at line 66 of file command_buffer.cc.
References OnCreateRenderPass().
|
virtual |
Schedule the command encoded by blit passes within this command buffer on the GPU. The enqueing of this buffer is performed immediately but encoding is pushed to a worker thread if possible.
A command buffer may only be committed once.
Definition at line 52 of file command_buffer.cc.
References IsValid(), and SubmitCommands().
|
virtual |
Schedule the command encoded by render passes within this command buffer on the GPU. The enqueing of this buffer is performed immediately but encoding is pushed to a worker thread if possible.
A command buffer may only be committed once.
Definition at line 39 of file command_buffer.cc.
References IsValid(), and SubmitCommands().
|
pure virtual |
Referenced by CreateComputePass(), EncodeAndSubmit(), and SubmitCommands().
|
protectedpure virtual |
Referenced by CreateBlitPass().
|
protectedpure virtual |
Referenced by CreateComputePass().
|
protectedpure virtual |
Referenced by CreateRenderPass().
|
protectedpure virtual |
Referenced by SubmitCommands().
|
protectedpure virtual |
Referenced by WaitUntilScheduled().
|
pure virtual |
| bool impeller::CommandBuffer::SubmitCommands | ( | ) |
Definition at line 31 of file command_buffer.cc.
Referenced by EncodeAndSubmit().
| bool impeller::CommandBuffer::SubmitCommands | ( | const CompletionCallback & | callback | ) |
Schedule the command encoded by render passes within this command buffer on the GPU. The encoding of these commnands is performed immediately on the calling thread.
A command buffer may only be committed once.
| [in] | callback | The completion callback. |
Definition at line 19 of file command_buffer.cc.
References IsValid(), kError, and OnSubmitCommands().
| void impeller::CommandBuffer::WaitUntilScheduled | ( | ) |
Force execution of pending GPU commands.
Definition at line 35 of file command_buffer.cc.
References OnWaitUntilScheduled().
|
friend |
Definition at line 46 of file command_buffer.h.
|
protected |
Definition at line 130 of file command_buffer.h.