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  };
29 
31  std::string name;
32  size_t ext_res_0 = 0u;
33  size_t set = 0u;
34  size_t binding = 0u;
35  size_t size_in_bytes = 0u;
36  std::vector<ShaderUniformStructField> fields;
37  };
38 
40  std::string name;
41  size_t ext_res_0 = 0u;
42  size_t set = 0u;
43  size_t binding = 0u;
44  };
45 
46  ShaderBundleData(std::string entrypoint,
47  spv::ExecutionModel stage,
48  TargetPlatform target_platform);
49 
51 
52  void AddUniformStruct(ShaderUniformStruct uniform_struct);
53 
54  void AddUniformTexture(ShaderUniformTexture uniform_texture);
55 
57 
58  void SetShaderData(std::shared_ptr<fml::Mapping> shader);
59 
60  void SetSkSLData(std::shared_ptr<fml::Mapping> sksl);
61 
62  std::unique_ptr<fb::shaderbundle::BackendShaderT> CreateFlatbuffer() const;
63 
64  private:
65  const std::string entrypoint_;
66  const spv::ExecutionModel stage_;
67  const TargetPlatform target_platform_;
68  std::vector<ShaderUniformStruct> uniform_structs_;
69  std::vector<ShaderUniformTexture> uniform_textures_;
70  std::vector<InputDescription> inputs_;
71  std::shared_ptr<fml::Mapping> shader_;
72  std::shared_ptr<fml::Mapping> sksl_;
73 
74  ShaderBundleData(const ShaderBundleData&) = delete;
75 
76  ShaderBundleData& operator=(const ShaderBundleData&) = delete;
77 };
78 
79 } // namespace compiler
80 } // namespace impeller
81 
82 #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)