Flutter Impeller
impeller::ComputePipelineBuilder< ComputeShader_ > Struct Template Reference

An optional (but highly recommended) utility for creating pipelines from reflected shader information. More...

#include <compute_pipeline_builder.h>

Public Types

using ComputeShader = ComputeShader_
 

Static Public Member Functions

static std::optional< ComputePipelineDescriptorMakeDefaultPipelineDescriptor (const Context &context)
 Create a default pipeline descriptor using the combination reflected shader information. The descriptor can be configured further before a pipeline state object is created using it. More...
 
static bool InitializePipelineDescriptorDefaults (const Context &context, ComputePipelineDescriptor &desc)
 

Detailed Description

template<class ComputeShader_>
struct impeller::ComputePipelineBuilder< ComputeShader_ >

An optional (but highly recommended) utility for creating pipelines from reflected shader information.

Template Parameters
Compute_ShaderThe reflected compute shader information. Found in a generated header file called <shader_name>.comp.h.

Definition at line 28 of file compute_pipeline_builder.h.

Member Typedef Documentation

◆ ComputeShader

template<class ComputeShader_ >
using impeller::ComputePipelineBuilder< ComputeShader_ >::ComputeShader = ComputeShader_

Definition at line 30 of file compute_pipeline_builder.h.

Member Function Documentation

◆ InitializePipelineDescriptorDefaults()

template<class ComputeShader_ >
static bool impeller::ComputePipelineBuilder< ComputeShader_ >::InitializePipelineDescriptorDefaults ( const Context context,
ComputePipelineDescriptor desc 
)
inlinestatic

Definition at line 52 of file compute_pipeline_builder.h.

54  {
55  // Setup debug instrumentation.
56  desc.SetLabel(SPrintF("%s Pipeline", ComputeShader::kLabel.data()));
57 
58  // Resolve pipeline entrypoints.
59  {
60  auto compute_function = context.GetShaderLibrary()->GetFunction(
61  ComputeShader::kEntrypointName, ShaderStage::kCompute);
62 
63  if (!compute_function) {
64  VALIDATION_LOG << "Could not resolve compute pipeline entrypoint '"
65  << ComputeShader::kEntrypointName
66  << "' for pipeline named '" << ComputeShader::kLabel
67  << "'.";
68  return false;
69  }
70 
71  if (!desc.RegisterDescriptorSetLayouts(
72  ComputeShader::kDescriptorSetLayouts)) {
73  VALIDATION_LOG << "Could not configure compute descriptor set layout "
74  "for pipeline named '"
75  << ComputeShader::kLabel << "'.";
76  return false;
77  }
78 
79  desc.SetStageEntrypoint(std::move(compute_function));
80  }
81  return true;
82  }

References impeller::Context::GetShaderLibrary(), impeller::kCompute, impeller::ComputePipelineDescriptor::RegisterDescriptorSetLayouts(), impeller::ComputePipelineDescriptor::SetLabel(), impeller::ComputePipelineDescriptor::SetStageEntrypoint(), impeller::SPrintF(), and VALIDATION_LOG.

Referenced by impeller::ComputePipelineBuilder< ComputeShader_ >::MakeDefaultPipelineDescriptor().

◆ MakeDefaultPipelineDescriptor()

template<class ComputeShader_ >
static std::optional<ComputePipelineDescriptor> impeller::ComputePipelineBuilder< ComputeShader_ >::MakeDefaultPipelineDescriptor ( const Context context)
inlinestatic

Create a default pipeline descriptor using the combination reflected shader information. The descriptor can be configured further before a pipeline state object is created using it.

Parameters
[in]contextThe context
Returns
If the combination of reflected shader information is compatible and the requisite functions can be found in the context, a pipeline descriptor.

Definition at line 43 of file compute_pipeline_builder.h.

44  {
45  ComputePipelineDescriptor desc;
46  if (InitializePipelineDescriptorDefaults(context, desc)) {
47  return {std::move(desc)};
48  }
49  return std::nullopt;
50  }

References impeller::ComputePipelineBuilder< ComputeShader_ >::InitializePipelineDescriptorDefaults().

Referenced by impeller::ContentContext::ContentContext().


The documentation for this struct was generated from the following file:
impeller::SPrintF
std::string SPrintF(const char *format,...)
Definition: strings.cc:12
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:60
impeller::ComputePipelineBuilder::InitializePipelineDescriptorDefaults
static bool InitializePipelineDescriptorDefaults(const Context &context, ComputePipelineDescriptor &desc)
Definition: compute_pipeline_builder.h:52
impeller::ShaderStage::kCompute
@ kCompute