Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | Static Public Attributes | List of all members
impeller::PipelineBuilder< VertexShader_, FragmentShader_ > Struct Template Reference

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

#include <pipeline_builder.h>

Public Types

using VertexShader = VertexShader_
 
using FragmentShader = FragmentShader_
 

Static Public Member Functions

static std::optional< PipelineDescriptorMakeDefaultPipelineDescriptor (const Context &context, const std::vector< Scalar > &constants={})
 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.
 
static bool InitializePipelineDescriptorDefaults (const Context &context, PipelineDescriptor &desc)
 

Static Public Attributes

static constexpr size_t kVertexBufferIndex
 

Detailed Description

template<class VertexShader_, class FragmentShader_>
struct impeller::PipelineBuilder< VertexShader_, FragmentShader_ >

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

Template Parameters
VertexShader_The reflected vertex shader information. Found in a generated header file called <shader_name>.vert.h.
FragmentShader_The reflected fragment shader information. Found in a generated header file called <shader_name>.frag.h.

Definition at line 32 of file pipeline_builder.h.

Member Typedef Documentation

◆ FragmentShader

template<class VertexShader_ , class FragmentShader_ >
using impeller::PipelineBuilder< VertexShader_, FragmentShader_ >::FragmentShader = FragmentShader_

Definition at line 35 of file pipeline_builder.h.

◆ VertexShader

template<class VertexShader_ , class FragmentShader_ >
using impeller::PipelineBuilder< VertexShader_, FragmentShader_ >::VertexShader = VertexShader_

Definition at line 34 of file pipeline_builder.h.

Member Function Documentation

◆ InitializePipelineDescriptorDefaults()

template<class VertexShader_ , class FragmentShader_ >
static bool impeller::PipelineBuilder< VertexShader_, FragmentShader_ >::InitializePipelineDescriptorDefaults ( const Context context,
PipelineDescriptor desc 
)
inlinestatic

Definition at line 62 of file pipeline_builder.h.

64 {
65 // Setup debug instrumentation.
66 desc.SetLabel(SPrintF("%s Pipeline", FragmentShader::kLabel.data()));
67
68 // Resolve pipeline entrypoints.
69 {
70 auto vertex_function = context.GetShaderLibrary()->GetFunction(
71 VertexShader::kEntrypointName, ShaderStage::kVertex);
72 auto fragment_function = context.GetShaderLibrary()->GetFunction(
73 FragmentShader::kEntrypointName, ShaderStage::kFragment);
74
75 if (!vertex_function || !fragment_function) {
76 VALIDATION_LOG << "Could not resolve pipeline entrypoint(s) '"
77 << VertexShader::kEntrypointName << "' and '"
78 << FragmentShader::kEntrypointName
79 << "' for pipeline named '" << VertexShader::kLabel
80 << "'.";
81 return false;
82 }
83
84 desc.AddStageEntrypoint(std::move(vertex_function));
85 desc.AddStageEntrypoint(std::move(fragment_function));
86 }
87
88 // Setup the vertex descriptor from reflected information.
89 {
90 auto vertex_descriptor = std::make_shared<VertexDescriptor>();
91 vertex_descriptor->SetStageInputs(VertexShader::kAllShaderStageInputs,
92 VertexShader::kInterleavedBufferLayout);
93 vertex_descriptor->RegisterDescriptorSetLayouts(
94 VertexShader::kDescriptorSetLayouts);
95 vertex_descriptor->RegisterDescriptorSetLayouts(
96 FragmentShader::kDescriptorSetLayouts);
97 desc.SetVertexDescriptor(std::move(vertex_descriptor));
98 }
99
100 // Setup fragment shader output descriptions.
101 {
102 // Configure the sole color attachments pixel format. This is by
103 // convention.
104 ColorAttachmentDescriptor color0;
105 color0.format = context.GetCapabilities()->GetDefaultColorFormat();
106 color0.blending_enabled = true;
107 desc.SetColorAttachmentDescriptor(0u, color0);
108 }
109
110 // Setup default depth buffer descriptions.
111 {
112 DepthAttachmentDescriptor depth0;
113 depth0.depth_compare = CompareFunction::kAlways;
114 desc.SetDepthStencilAttachmentDescriptor(depth0);
115 desc.SetDepthPixelFormat(
116 context.GetCapabilities()->GetDefaultDepthStencilFormat());
117 }
118
119 // Setup default stencil buffer descriptions.
120 {
121 StencilAttachmentDescriptor stencil0;
122 stencil0.stencil_compare = CompareFunction::kEqual;
123 desc.SetStencilAttachmentDescriptors(stencil0);
124 desc.SetStencilPixelFormat(
125 context.GetCapabilities()->GetDefaultDepthStencilFormat());
126 }
127
128 return true;
129 }
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41
std::string SPrintF(const char *format,...)
Definition strings.cc:12
@ kEqual
Comparison test passes if new_value == current_value.
@ kAlways
Comparison test passes always passes.
#define VALIDATION_LOG
Definition validation.h:73

◆ MakeDefaultPipelineDescriptor()

template<class VertexShader_ , class FragmentShader_ >
static std::optional< PipelineDescriptor > impeller::PipelineBuilder< VertexShader_, FragmentShader_ >::MakeDefaultPipelineDescriptor ( const Context context,
const std::vector< Scalar > &  constants = {} 
)
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 51 of file pipeline_builder.h.

53 {}) {
54 PipelineDescriptor desc;
55 desc.SetSpecializationConstants(constants);
56 if (InitializePipelineDescriptorDefaults(context, desc)) {
57 return {std::move(desc)};
58 }
59 return std::nullopt;
60 }
static bool InitializePipelineDescriptorDefaults(const Context &context, PipelineDescriptor &desc)

Member Data Documentation

◆ kVertexBufferIndex

template<class VertexShader_ , class FragmentShader_ >
constexpr size_t impeller::PipelineBuilder< VertexShader_, FragmentShader_ >::kVertexBufferIndex
staticconstexpr
Initial value:

Definition at line 37 of file pipeline_builder.h.


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