| Flutter Impeller |

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 18 of file shader_stage_compatibility_checker.h.

## Member Function Documentation

## ◆ Check()

template<typename VertexShaderT , typename FragmentShaderT >

static constexpr bool impeller::ShaderStageCompatibilityChecker< VertexShaderT, FragmentShaderT >::Check | ( |  | ) |
| inline static constexpr

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

Definition at line 28 of file shader_stage_compatibility_checker.h.

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

References impeller::ShaderStageIOSlot::binding, impeller::ShaderStageIOSlot::bit_width, impeller::ShaderStageIOSlot::columns, impeller::ShaderStageCompatibilityChecker< VertexShaderT, FragmentShaderT >::CompileTimeStrEqual(), impeller::ShaderStageIOSlot::location, impeller::ShaderStageIOSlot::name, impeller::ShaderStageIOSlot::offset, impeller::ShaderStageIOSlot::set, impeller::ShaderStageIOSlot::type, and impeller::ShaderStageIOSlot::vec_size.

## ◆ CompileTimeStrEqual()

template<typename VertexShaderT , typename FragmentShaderT >

static constexpr bool impeller::ShaderStageCompatibilityChecker< VertexShaderT, FragmentShaderT >::CompileTimeStrEqual | ( | const char * | str1,
|  | const char * | str2
| ) |  |
| inline static constexpr

Definition at line 20 of file shader_stage_compatibility_checker.h.

21 {
22 return *str1 == *str2 &&
23 (*str1 == '\0' || CompileTimeStrEqual(str1 + 1, str2 + 1));
24 }

Referenced by impeller::ShaderStageCompatibilityChecker< VertexShaderT, FragmentShaderT >::Check().

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

- impeller/renderer/shader_stage_compatibility_checker.h

impeller::ShaderStageCompatibilityChecker::CompileTimeStrEqual
static constexpr bool CompileTimeStrEqual(const char *str1, const char *str2)
Definition: shader_stage_compatibility_checker.h:20