|
10 | 10 | #include "impeller/core/shader_types.h" |
11 | 11 |
|
12 | 12 | namespace impeller { |
13 | | -/// This is a classed use to check that the input slots of fragment shaders |
14 | | -/// match the output slots of the vertex shaders. |
15 | | -/// If they don't match it will result in linker errors when creating the |
16 | | -/// pipeline. It's not used at runtime. |
| 13 | + |
| 14 | +//------------------------------------------------------------------------------ |
| 15 | +/// @brief Checks, at C++ compile-time, if the two pipeline stages are |
| 16 | +/// compatible. |
| 17 | +/// |
| 18 | +/// Stages may be incompatible if the outputs declared in the vertex |
| 19 | +/// stage don't line up with the inputs declared in the fragment |
| 20 | +/// stage. Additionally, the types of the inputs and outputs need to |
| 21 | +/// be identical. Some drivers like the one on the PowerVR GE8320 |
| 22 | +/// also have bugs the require the precision qualifier of the stage |
| 23 | +/// interfaces to match exactly. |
| 24 | +/// |
| 25 | +/// Not ensuring stage compatibility will cause pipeline creation |
| 26 | +/// errors that will only be caught at runtime. In addition to the |
| 27 | +/// bugs discovered related to precision qualifier, some errors may |
| 28 | +/// only manifest at runtime on some devices. |
| 29 | +/// |
| 30 | +/// This static compile-time C++ check ensures that all the possible |
| 31 | +/// runtime errors will be caught at build time. |
| 32 | +/// |
| 33 | +/// There is no runtime overhead to using this class. |
| 34 | +/// |
| 35 | +/// @tparam VertexShaderT The vertex shader stage metadata. |
| 36 | +/// @tparam FragmentShaderT The fragment shader stage metadata. |
| 37 | +/// |
17 | 38 | template <typename VertexShaderT, typename FragmentShaderT> |
18 | 39 | class ShaderStageCompatibilityChecker { |
19 | 40 | public: |
@@ -59,21 +80,6 @@ class ShaderStageCompatibilityChecker { |
59 | 80 | } |
60 | 81 | }; |
61 | 82 |
|
62 | | -// The following shaders don't define output slots. |
63 | | -// TODO(https://github.com/flutter/flutter/issues/146852): Make impellerc emit |
64 | | -// an empty array for output slots. |
65 | | -struct ClipVertexShader; |
66 | | -struct SolidFillVertexShader; |
67 | | - |
68 | | -template <typename FragmentShaderT> |
69 | | -class ShaderStageCompatibilityChecker<ClipVertexShader, FragmentShaderT> { |
70 | | - public: |
71 | | - static constexpr bool Check() { return true; } |
72 | | -}; |
73 | | -template <typename FragmentShaderT> |
74 | | -class ShaderStageCompatibilityChecker<SolidFillVertexShader, FragmentShaderT> { |
75 | | - public: |
76 | | - static constexpr bool Check() { return true; } |
77 | | -}; |
78 | 83 | } // namespace impeller |
| 84 | + |
79 | 85 | #endif // FLUTTER_IMPELLER_RENDERER_SHADER_STAGE_COMPATIBILITY_CHECKER_H_ |
0 commit comments