Flutter Impeller
runtime_stage_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_RUNTIME_STAGE_DATA_H_
6 #define FLUTTER_IMPELLER_COMPILER_RUNTIME_STAGE_DATA_H_
7 
8 #include <memory>
9 #include <vector>
10 
11 #include "flutter/fml/macros.h"
12 #include "flutter/fml/mapping.h"
15 #include "runtime_stage_types_flatbuffers.h"
16 #include "spirv_parser.hpp"
17 
18 namespace impeller {
19 namespace compiler {
20 
22  std::string name;
23  size_t location = 0u;
24  spirv_cross::SPIRType::BaseType type = spirv_cross::SPIRType::BaseType::Float;
25  size_t rows = 0u;
26  size_t columns = 0u;
27  size_t bit_width = 0u;
28  std::optional<size_t> array_elements = std::nullopt;
29 };
30 
32  std::string name;
33  size_t location;
34  size_t set;
35  size_t binding;
36  spirv_cross::SPIRType::BaseType type =
37  spirv_cross::SPIRType::BaseType::Unknown;
38  size_t bit_width;
39  size_t vec_size;
40  size_t columns;
41  size_t offset;
42 };
43 
45  public:
46  struct Shader {
47  Shader() = default;
48 
49  std::string entrypoint;
50  spv::ExecutionModel stage;
51  std::vector<UniformDescription> uniforms;
52  std::vector<InputDescription> inputs;
53  std::shared_ptr<fml::Mapping> shader;
55 
56  Shader(const Shader&) = delete;
57  Shader& operator=(const Shader&) = delete;
58  };
59 
61 
63 
64  void AddShader(const std::shared_ptr<Shader>& data);
65 
66  std::unique_ptr<fb::RuntimeStagesT> CreateFlatbuffer() const;
67 
68  std::shared_ptr<fml::Mapping> CreateJsonMapping() const;
69 
70  std::shared_ptr<fml::Mapping> CreateMapping() const;
71 
72  private:
73  std::map<RuntimeStageBackend, std::shared_ptr<Shader>> data_;
74 
75  RuntimeStageData(const RuntimeStageData&) = delete;
76 
77  RuntimeStageData& operator=(const RuntimeStageData&) = delete;
78 };
79 
80 } // namespace compiler
81 } // namespace impeller
82 
83 #endif // FLUTTER_IMPELLER_COMPILER_RUNTIME_STAGE_DATA_H_
impeller::compiler::InputDescription::offset
size_t offset
Definition: runtime_stage_data.h:41
impeller::compiler::InputDescription::binding
size_t binding
Definition: runtime_stage_data.h:35
impeller::compiler::RuntimeStageData::~RuntimeStageData
~RuntimeStageData()
impeller::compiler::RuntimeStageData::CreateJsonMapping
std::shared_ptr< fml::Mapping > CreateJsonMapping() const
Definition: runtime_stage_data.cc:219
impeller::compiler::RuntimeStageData::Shader::Shader
Shader()=default
impeller::compiler::InputDescription::name
std::string name
Definition: runtime_stage_data.h:32
impeller::compiler::UniformDescription::type
spirv_cross::SPIRType::BaseType type
Definition: runtime_stage_data.h:24
impeller::compiler::RuntimeStageData
Definition: runtime_stage_data.h:44
impeller::compiler::UniformDescription::array_elements
std::optional< size_t > array_elements
Definition: runtime_stage_data.h:28
impeller::compiler::UniformDescription::columns
size_t columns
Definition: runtime_stage_data.h:26
impeller::compiler::UniformDescription::location
size_t location
Definition: runtime_stage_data.h:23
impeller::compiler::RuntimeStageData::AddShader
void AddShader(const std::shared_ptr< Shader > &data)
Definition: runtime_stage_data.cc:27
impeller::compiler::InputDescription::vec_size
size_t vec_size
Definition: runtime_stage_data.h:39
runtime_types.h
impeller::compiler::RuntimeStageData::CreateMapping
std::shared_ptr< fml::Mapping > CreateMapping() const
Definition: runtime_stage_data.cc:387
impeller::compiler::UniformDescription::name
std::string name
Definition: runtime_stage_data.h:22
impeller::compiler::UniformDescription::rows
size_t rows
Definition: runtime_stage_data.h:25
impeller::RuntimeStageBackend
RuntimeStageBackend
Definition: runtime_types.h:14
impeller::compiler::InputDescription::type
spirv_cross::SPIRType::BaseType type
Definition: runtime_stage_data.h:36
impeller::compiler::InputDescription::bit_width
size_t bit_width
Definition: runtime_stage_data.h:38
impeller::compiler::RuntimeStageData::Shader
Definition: runtime_stage_data.h:46
impeller::compiler::UniformDescription::bit_width
size_t bit_width
Definition: runtime_stage_data.h:27
impeller::compiler::InputDescription::set
size_t set
Definition: runtime_stage_data.h:34
impeller::compiler::InputDescription::columns
size_t columns
Definition: runtime_stage_data.h:40
impeller::compiler::RuntimeStageData::Shader::inputs
std::vector< InputDescription > inputs
Definition: runtime_stage_data.h:52
impeller::compiler::RuntimeStageData::Shader::entrypoint
std::string entrypoint
Definition: runtime_stage_data.h:49
impeller::compiler::UniformDescription
Definition: runtime_stage_data.h:21
impeller::compiler::InputDescription
Definition: runtime_stage_data.h:31
impeller::compiler::RuntimeStageData::Shader::operator=
Shader & operator=(const Shader &)=delete
impeller::compiler::RuntimeStageData::Shader::backend
RuntimeStageBackend backend
Definition: runtime_stage_data.h:54
impeller::compiler::RuntimeStageData::Shader::uniforms
std::vector< UniformDescription > uniforms
Definition: runtime_stage_data.h:51
impeller::compiler::RuntimeStageData::RuntimeStageData
RuntimeStageData()
impeller::compiler::InputDescription::location
size_t location
Definition: runtime_stage_data.h:33
impeller::compiler::RuntimeStageData::Shader::stage
spv::ExecutionModel stage
Definition: runtime_stage_data.h:50
impeller::compiler::RuntimeStageData::CreateFlatbuffer
std::unique_ptr< fb::RuntimeStagesT > CreateFlatbuffer() const
Definition: runtime_stage_data.cc:296
impeller
Definition: aiks_context.cc:10
types.h
impeller::compiler::RuntimeStageData::Shader::shader
std::shared_ptr< fml::Mapping > shader
Definition: runtime_stage_data.h:53