| 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, const BufferView &view) override
bool | BindResource (ShaderStage stage, const SampledImageSlot &slot, const ShaderMetadata &metadata, const std::shared_ptr< const Texture > &texture, const 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 43 of file compute_command.h.

## Member Function Documentation

## ◆ BindResource() [1/2]

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

Implements impeller::ResourceBinder.

Definition at line 30 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 if (!slot.HasSampler() || !slot.HasTexture()) {
47 return true;
48 }
49
50 bindings.sampled_images[slot.sampler_index] = TextureAndSampler{
51 .slot = slot,
52 .texture = {&metadata, texture},
53 .sampler = {&metadata, sampler},
54 };
55
56 return false;
57 }

References bindings, impeller::SampledImageSlot::HasSampler(), impeller::SampledImageSlot::HasTexture(), impeller::kCompute, impeller::Bindings::sampled_images, impeller::SampledImageSlot::sampler_index, impeller::TextureAndSampler::slot, and VALIDATION_LOG.

## ◆ BindResource() [2/2]

bool impeller::ComputeCommand::BindResource | ( | ShaderStage | stage,
|  | const ShaderUniformSlot & | slot,
|  | const ShaderMetadata & | metadata,
|  | const 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[slot.ext_res_0] = {.slot = slot, .view = {&metadata, view}};
27 return true;
28 }

References bindings, impeller::Bindings::buffers, impeller::ShaderUniformSlot::ext_res_0, impeller::kCompute, and VALIDATION_LOG.

## ◆ operator bool()

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

Definition at line 74 of file compute_command.h.

74 {
75 return pipeline && pipeline->IsValid();
76 }

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 52 of file compute_command.h.

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

## ◆ pipeline

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

The pipeline to use for this command.

Definition at line 47 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:47
impeller::Bindings::buffers
std::map< size_t, BufferAndUniformSlot > buffers
Definition: command.h:79
impeller::ComputeCommand::bindings
Bindings bindings
Definition: compute_command.h:52
impeller::Bindings::sampled_images
std::map< size_t, TextureAndSampler > sampled_images
Definition: command.h:78
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:60
impeller::ShaderStage::kCompute
@ kCompute