| Flutter Impeller |

Public Member Functions | Public Attributes | List of all members
impeller::ComputeCommand Struct Reference

An object used to specify compute work to the GPU along with references to resources the GPU will used when doing said work. More...

`#include <compute_command.h>`

Inheritance diagram for impeller::ComputeCommand:

## Public Member Functions
bool | BindResource (ShaderStage stage, const ShaderUniformSlot &slot, const ShaderMetadata &metadata, BufferView view) override
bool | BindResource (ShaderStage stage, const SampledImageSlot &slot, const ShaderMetadata &metadata, std::shared_ptr< const Texture > texture, std::shared_ptr< const Sampler > sampler) override
constexpr | operator bool () const
Public Member Functions inherited from impeller::ResourceBinder
virtual | ~ResourceBinder ()=default

## Public Attributes
std::shared_ptr< Pipeline< ComputePipelineDescriptor > > | pipeline
Bindings | bindings

## Detailed Description

An object used to specify compute work to the GPU along with references to resources the GPU will used when doing said work.

To construct a valid command, follow these steps:

- Specify a valid pipeline.
- (Optional) Specify a debug label.

Command are very lightweight objects and can be created frequently and on demand. The resources referenced in commands views into buffers managed by other allocators and resource managers.

Definition at line 36 of file compute_command.h.

## Member Function Documentation

## ◆ BindResource() [1/2]

bool impeller::ComputeCommand::BindResource | ( | ShaderStage | stage,
|  | const SampledImageSlot & | slot,
|  | const ShaderMetadata & | metadata,
|  | std::shared_ptr< const Texture > | texture,
|  | std::shared_ptr< const Sampler > | sampler
| ) |  |
| override virtual

Implements impeller::ResourceBinder.

Definition at line 31 of file compute_command.cc.

35 {
36 if (stage != ShaderStage::kCompute) {
37 VALIDATION_LOG << "Use Command for non-compute shader stages.";
38 return false;
39 }
40 if (!sampler || !sampler->IsValid()) {
41 return false;
42 }
43 if (!texture || !texture->IsValid()) {
44 return false;
45 }
46
47 bindings.sampled_images.emplace_back(TextureAndSampler{
48 .slot = slot,
49 .texture = {&metadata, std::move(texture)},
50 .sampler = std::move(sampler),
51 });
52
53 return false;
54 }

References bindings, impeller::kCompute, impeller::Bindings::sampled_images, impeller::TextureAndSampler::slot, and VALIDATION_LOG.

## ◆ BindResource() [2/2]

bool impeller::ComputeCommand::BindResource | ( | ShaderStage | stage,
|  | const ShaderUniformSlot & | slot,
|  | const ShaderMetadata & | metadata,
|  | BufferView | view
| ) |  |
| override virtual

Implements impeller::ResourceBinder.

Definition at line 14 of file compute_command.cc.

17 {
18 if (stage != ShaderStage::kCompute) {
19 VALIDATION_LOG << "Use Command for non-compute shader stages.";
20 return false;
21 }
22 if (!view) {
23 return false;
24 }
25
26 bindings.buffers.emplace_back(
27 BufferAndUniformSlot{.slot = slot, .view = {&metadata, std::move(view)}});
28 return true;
29 }

References bindings, impeller::Bindings::buffers, impeller::kCompute, impeller::BufferAndUniformSlot::slot, and VALIDATION_LOG.

## ◆ operator bool()

constexpr impeller::ComputeCommand::operator bool | ( |  | ) | const
| inline explicit constexpr

Definition at line 67 of file compute_command.h.

67 {
68 return pipeline && pipeline->IsValid();
69 }

References pipeline.

## Member Data Documentation

## ◆ bindings

Bindings impeller::ComputeCommand::bindings

The buffer, texture, and sampler bindings used by the compute pipeline stage.

Definition at line 45 of file compute_command.h.

Referenced by BindResource(), and impeller::UpdateBindingLayouts().

## ◆ pipeline

std::shared_ptr<Pipeline<ComputePipelineDescriptor> > impeller::ComputeCommand::pipeline

The pipeline to use for this command.

Definition at line 40 of file compute_command.h.

Referenced by operator bool(), impeller::ComputeTessellator::Tessellate(), and impeller::testing::TEST_P().

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

- impeller/renderer/compute_command.h
- impeller/renderer/compute_command.cc

impeller::ComputeCommand::pipeline
std::shared_ptr< Pipeline< ComputePipelineDescriptor > > pipeline
Definition: compute_command.h:40
impeller::Bindings::sampled_images
std::vector< TextureAndSampler > sampled_images
Definition: command.h:74
impeller::ComputeCommand::bindings
Bindings bindings
Definition: compute_command.h:45
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:67
impeller::Bindings::buffers
std::vector< BufferAndUniformSlot > buffers
Definition: command.h:75
impeller::ShaderStage::kCompute
@ kCompute