| Flutter Impeller |

Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
impeller::ComputePass Class Referenceabstract

Compute passes encode compute shader into the underlying command buffer. More...

`#include <compute_pass.h>`

Inheritance diagram for impeller::ComputePass:

## Public Member Functions
virtual | ~ComputePass ()
virtual bool | IsValid () const =0
void | SetLabel (const std::string &label)
void | SetGridSize (const ISize &size)
void | SetThreadGroupSize (const ISize &size)
HostBuffer & | GetTransientsBuffer ()
bool | AddCommand (ComputeCommand command)
| Record a command for subsequent encoding to the underlying command buffer. No work is encoded into the command buffer at this time. More...
bool | EncodeCommands () const
| Encode the recorded commands to the underlying command buffer. More...

## Protected Member Functions
| ComputePass (std::weak_ptr< const Context > context)
virtual void | OnSetLabel (const std::string &label)=0
virtual bool | OnEncodeCommands (const Context &context, const ISize &grid_size, const ISize &thread_group_size) const =0

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

## Detailed Description

Compute passes encode compute shader into the underlying command buffer.

See also
  `CommandBuffer`

Definition at line 25 of file compute_pass.h.

## Constructor & Destructor Documentation

## ◆ ~ComputePass()

impeller::ComputePass::~ComputePass | ( |  | ) |
| virtual default

## ◆ ComputePass()

impeller::ComputePass::ComputePass | ( | std::weak_ptr< const Context > | context | ) |
| explicit protected

Definition at line 14 of file compute_pass.cc.

15 : context_(std::move(context)), transients_buffer_(HostBuffer::Create()) {}

## Member Function Documentation

## ◆ AddCommand()

bool impeller::ComputePass::AddCommand | ( | ComputeCommand | command | ) |

Record a command for subsequent encoding to the underlying command buffer. No work is encoded into the command buffer at this time.

Parameters

  [in] | command | The command

Returns
  If the command was valid for subsequent commitment.

Definition at line 39 of file compute_pass.cc.

39 {
40 if (!command) {
41 VALIDATION_LOG
42 << "Attempted to add an invalid command to the compute pass.";
43 return false;
44 }
45
46 commands_.emplace_back(std::move(command));
47 return true;
48 }

References commands_, and VALIDATION_LOG.

## ◆ EncodeCommands()

bool impeller::ComputePass::EncodeCommands | ( |  | ) | const

Encode the recorded commands to the underlying command buffer.

Parameters

  transients_allocator | The transients allocator.

Returns
  If the commands were encoded to the underlying command buffer.

Definition at line 50 of file compute_pass.cc.

50 {
51 if (grid_size_.IsEmpty() || thread_group_size_.IsEmpty()) {
52 FML_DLOG(WARNING) << "Attempted to encode a compute pass with an empty "
53 "grid or thread group size.";
54 return false;
55 }
56 auto context = context_.lock();
57 // The context could have been collected in the meantime.
58 if (!context) {
59 return false;
60 }
61 return OnEncodeCommands(*context, grid_size_, thread_group_size_);
62 }

References context_, impeller::TSize< T >::IsEmpty(), and OnEncodeCommands().

## ◆ GetTransientsBuffer()

HostBuffer & impeller::ComputePass::GetTransientsBuffer | ( |  | ) |

Definition at line 19 of file compute_pass.cc.

19 {
20 return *transients_buffer_;
21 }

## ◆ IsValid()

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

## ◆ OnEncodeCommands()

virtual bool impeller::ComputePass::OnEncodeCommands | ( | const Context & | context,
|  | const ISize & | grid_size,
|  | const ISize & | thread_group_size
| ) |  | const
| protected pure virtual

Referenced by EncodeCommands().

## ◆ OnSetLabel()

virtual void impeller::ComputePass::OnSetLabel | ( | const std::string & | label | ) |
| protected pure virtual

Referenced by SetLabel().

## ◆ SetGridSize()

void impeller::ComputePass::SetGridSize | ( | const ISize & | size | ) |

Definition at line 31 of file compute_pass.cc.

31 {
32 grid_size_ = size;
33 }

## ◆ SetLabel()

void impeller::ComputePass::SetLabel | ( | const std::string & | label | ) |

Definition at line 23 of file compute_pass.cc.

23 {
24 if (label.empty()) {
25 return;
26 }
27 transients_buffer_->SetLabel(SPrintF("%s Transients", label.c_str()));
28 OnSetLabel(label);
29 }

References OnSetLabel(), and impeller::SPrintF().

## ◆ SetThreadGroupSize()

void impeller::ComputePass::SetThreadGroupSize | ( | const ISize & | size | ) |

Definition at line 35 of file compute_pass.cc.

35 {
36 thread_group_size_ = size;
37 }

## Member Data Documentation

## ◆ commands_

std::vector<ComputeCommand> impeller::ComputePass::commands_
| protected

Definition at line 62 of file compute_pass.h.

Referenced by AddCommand().

## ◆ context_

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

Definition at line 61 of file compute_pass.h.

Referenced by EncodeCommands().

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

- impeller/renderer/compute_pass.h
- impeller/renderer/compute_pass.cc

impeller::ComputePass::commands_
std::vector< ComputeCommand > commands_
Definition: compute_pass.h:62
impeller::HostBuffer::Create
static std::shared_ptr< HostBuffer > Create()
Definition: host_buffer.cc:18
impeller::SPrintF
std::string SPrintF(const char *format,...)
Definition: strings.cc:12
impeller::ComputePass::context_
const std::weak_ptr< const Context > context_
Definition: compute_pass.h:61
impeller::ComputePass::OnSetLabel
virtual void OnSetLabel(const std::string &label)=0
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:60
impeller::TSize::IsEmpty
constexpr bool IsEmpty() const
Definition: size.h:105
impeller::ComputePass::OnEncodeCommands
virtual bool OnEncodeCommands(const Context &context, const ISize &grid_size, const ISize &thread_group_size) const =0