Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
impeller::ShaderStageCompatibilityChecker< VertexShaderT, FragmentShaderT > Class Template Reference

#include <shader_stage_compatibility_checker.h>

Static Public Member Functions

static constexpr bool CompileTimeStrEqual (const char *str1, const char *str2)
 
static constexpr bool Check ()
 

Detailed Description

template<typename VertexShaderT, typename FragmentShaderT>
class impeller::ShaderStageCompatibilityChecker< VertexShaderT, FragmentShaderT >

This is a classed use to check that the input slots of fragment shaders match the output slots of the vertex shaders. If they don't match it will result in linker errors when creating the pipeline. It's not used at runtime.

Definition at line 14 of file shader_stage_compatibility_checker.h.

Member Function Documentation

◆ Check()

template<typename VertexShaderT , typename FragmentShaderT >
static constexpr bool impeller::ShaderStageCompatibilityChecker< VertexShaderT, FragmentShaderT >::Check ( )
inlinestaticconstexpr

Returns true if the shader input slots for the fragment shader match the ones declared as outputs in the vertex shader.

Definition at line 24 of file shader_stage_compatibility_checker.h.

24 {
25 constexpr size_t num_outputs = VertexShaderT::kAllShaderStageOutputs.size();
26 constexpr size_t num_inputs = FragmentShaderT::kAllShaderStageInputs.size();
27
28 if (num_inputs > num_outputs) {
29 return false;
30 }
31
32 for (size_t i = 0; i < num_inputs; ++i) {
33 const ShaderStageIOSlot* input_slot =
34 FragmentShaderT::kAllShaderStageInputs[i];
35 for (size_t j = 0; j < num_outputs; ++j) {
36 const ShaderStageIOSlot* output_slot =
37 VertexShaderT::kAllShaderStageOutputs[j];
38 if (input_slot->location == output_slot->location) {
39 if (!CompileTimeStrEqual(input_slot->name, output_slot->name) ||
40 input_slot->set != output_slot->set ||
41 input_slot->binding != output_slot->binding ||
42 input_slot->type != output_slot->type ||
43 input_slot->bit_width != output_slot->bit_width ||
44 input_slot->vec_size != output_slot->vec_size ||
45 input_slot->columns != output_slot->columns ||
46 input_slot->offset != output_slot->offset) {
47 return false;
48 }
49 }
50 }
51 }
52
53 return true;
54 }
static constexpr bool CompileTimeStrEqual(const char *str1, const char *str2)

◆ CompileTimeStrEqual()

template<typename VertexShaderT , typename FragmentShaderT >
static constexpr bool impeller::ShaderStageCompatibilityChecker< VertexShaderT, FragmentShaderT >::CompileTimeStrEqual ( const char *  str1,
const char *  str2 
)
inlinestaticconstexpr

Definition at line 16 of file shader_stage_compatibility_checker.h.

17 {
18 return *str1 == *str2 &&
19 (*str1 == '\0' || CompileTimeStrEqual(str1 + 1, str2 + 1));
20 }

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