Flutter Impeller
shader_bundle_data.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_IMPELLER_COMPILER_SHADER_BUNDLE_DATA_H_
6 #define FLUTTER_IMPELLER_COMPILER_SHADER_BUNDLE_DATA_H_
7 
8 #include <memory>
9 #include <vector>
10 
11 #include "flutter/fml/mapping.h"
13 #include "impeller/shader_bundle/shader_bundle_flatbuffers.h"
14 
15 namespace impeller {
16 namespace compiler {
17 
19  public:
21  std::string name;
22  spirv_cross::SPIRType::BaseType type =
23  spirv_cross::SPIRType::BaseType::Float;
24  size_t offset_in_bytes = 0u;
25  size_t element_size_in_bytes = 0u;
26  size_t total_size_in_bytes = 0u;
27  std::optional<size_t> array_elements = std::nullopt;
28  // Component count of a single column. For non-matrix types this is the
29  // vector length; for matrices this is the row count.
30  size_t vec_size = 0u;
31  // The number of columns. 1 for scalars and vectors; N for an NxN matrix.
32  size_t columns = 0u;
33  };
34 
36  std::string name;
37  size_t ext_res_0 = 0u;
38  size_t set = 0u;
39  size_t binding = 0u;
40  size_t size_in_bytes = 0u;
41  std::vector<ShaderUniformStructField> fields;
42  };
43 
45  std::string name;
46  size_t ext_res_0 = 0u;
47  size_t set = 0u;
48  size_t binding = 0u;
49  };
50 
51  ShaderBundleData(std::string entrypoint,
52  spv::ExecutionModel stage,
53  TargetPlatform target_platform);
54 
56 
57  void AddUniformStruct(ShaderUniformStruct uniform_struct);
58 
59  void AddUniformTexture(ShaderUniformTexture uniform_texture);
60 
62 
63  void SetShaderData(std::shared_ptr<fml::Mapping> shader);
64 
65  void SetSkSLData(std::shared_ptr<fml::Mapping> sksl);
66 
67  std::unique_ptr<fb::shaderbundle::BackendShaderT> CreateFlatbuffer() const;
68 
69  private:
70  const std::string entrypoint_;
71  const spv::ExecutionModel stage_;
72  const TargetPlatform target_platform_;
73  std::vector<ShaderUniformStruct> uniform_structs_;
74  std::vector<ShaderUniformTexture> uniform_textures_;
75  std::vector<InputDescription> inputs_;
76  std::shared_ptr<fml::Mapping> shader_;
77  std::shared_ptr<fml::Mapping> sksl_;
78 
79  ShaderBundleData(const ShaderBundleData&) = delete;
80 
81  ShaderBundleData& operator=(const ShaderBundleData&) = delete;
82 };
83 
84 } // namespace compiler
85 } // namespace impeller
86 
87 #endif // FLUTTER_IMPELLER_COMPILER_SHADER_BUNDLE_DATA_H_
void AddInputDescription(InputDescription input)
ShaderBundleData(std::string entrypoint, spv::ExecutionModel stage, TargetPlatform target_platform)
std::unique_ptr< fb::shaderbundle::BackendShaderT > CreateFlatbuffer() const
void AddUniformStruct(ShaderUniformStruct uniform_struct)
void SetShaderData(std::shared_ptr< fml::Mapping > shader)
void SetSkSLData(std::shared_ptr< fml::Mapping > sksl)
void AddUniformTexture(ShaderUniformTexture uniform_texture)