Flutter Engine
The Flutter Engine
types.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_TYPES_H_
6#define FLUTTER_IMPELLER_COMPILER_TYPES_H_
7
8#include <codecvt>
9#include <locale>
10#include <map>
11#include <optional>
12#include <string>
13
14#include "shaderc/shaderc.hpp"
15#include "spirv_cross.hpp"
16#include "spirv_msl.hpp"
17
18namespace impeller {
19namespace compiler {
20
21enum class SourceType {
22 kUnknown,
26};
27
28enum class TargetPlatform {
29 kUnknown,
34 kVulkan,
38 kSkSL,
39};
40
41enum class SourceLanguage {
42 kUnknown,
43 kGLSL,
44 kHLSL,
45};
46
48 std::string name;
49 size_t location = 0u;
50 size_t binding = 0u;
51 spirv_cross::SPIRType::BaseType type = spirv_cross::SPIRType::BaseType::Float;
52 size_t rows = 0u;
53 size_t columns = 0u;
54 size_t bit_width = 0u;
55 std::optional<size_t> array_elements = std::nullopt;
56 std::vector<uint8_t> struct_layout = {};
57 size_t struct_float_count = 0u;
58};
59
61 std::string name;
62 size_t location;
63 size_t set;
64 size_t binding;
65 spirv_cross::SPIRType::BaseType type =
66 spirv_cross::SPIRType::BaseType::Unknown;
67 size_t bit_width;
68 size_t vec_size;
69 size_t columns;
70 size_t offset;
71};
72
73/// A shader config parsed as part of a ShaderBundleConfig.
75 std::string source_file_name;
78 std::string entry_point;
79};
80
81using ShaderBundleConfig = std::unordered_map<std::string, ShaderConfig>;
82
84
86
88
89SourceType SourceTypeFromFileName(const std::string& file_name);
90
92
94
95std::string TargetPlatformToString(TargetPlatform platform);
96
97SourceLanguage ToSourceLanguage(const std::string& source_language);
98
99std::string SourceLanguageToString(SourceLanguage source_language);
100
101std::string TargetPlatformSLExtension(TargetPlatform platform);
102
104 const std::string& file_name,
106 SourceLanguage source_language,
107 const std::string& entry_point_name);
108
110
112
113std::string ShaderCErrorToString(shaderc_compilation_status status);
114
115shaderc_shader_kind ToShaderCShaderKind(SourceType type);
116
117spv::ExecutionModel ToExecutionModel(SourceType type);
118
119spirv_cross::CompilerMSL::Options::Platform TargetPlatformToMSLPlatform(
120 TargetPlatform platform);
121
122} // namespace compiler
123} // namespace impeller
124
125#endif // FLUTTER_IMPELLER_COMPILER_TYPES_H_
GLenum type
@ kVulkan
Definition: embedder.h:86
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
std::string SourceLanguageToString(SourceLanguage source_language)
Definition: types.cc:100
std::string TargetPlatformToString(TargetPlatform platform)
Definition: types.cc:74
std::string TargetPlatformSLExtension(TargetPlatform platform)
Definition: types.cc:246
shaderc_shader_kind ToShaderCShaderKind(SourceType type)
Definition: types.cc:184
std::string SourceTypeToString(SourceType type)
Definition: types.cc:232
std::unordered_map< std::string, ShaderConfig > ShaderBundleConfig
Definition: types.h:81
SourceType SourceTypeFromString(std::string name)
Definition: types.cc:46
SourceType SourceTypeFromFileName(const std::string &file_name)
Definition: types.cc:30
std::string EntryPointFunctionNameFromSourceName(const std::string &file_name, SourceType type, SourceLanguage source_language, const std::string &entry_point_name)
Definition: types.cc:111
bool TargetPlatformIsMetal(TargetPlatform platform)
Definition: types.cc:284
bool TargetPlatformIsOpenGL(TargetPlatform platform)
Definition: types.cc:266
std::string ShaderCErrorToString(shaderc_compilation_status status)
Definition: types.cc:159
bool TargetPlatformIsVulkan(TargetPlatform platform)
Definition: types.cc:302
bool TargetPlatformBundlesSkSL(TargetPlatform platform)
Definition: types.cc:320
spirv_cross::CompilerMSL::Options::Platform TargetPlatformToMSLPlatform(TargetPlatform platform)
Definition: types.cc:212
SourceLanguage ToSourceLanguage(const std::string &source_language)
Definition: types.cc:64
bool TargetPlatformNeedsReflection(TargetPlatform platform)
Definition: types.cc:141
spv::ExecutionModel ToExecutionModel(SourceType type)
Definition: types.cc:198
spirv_cross::SPIRType::BaseType type
Definition: types.h:65
A shader config parsed as part of a ShaderBundleConfig.
Definition: types.h:74
std::string source_file_name
Definition: types.h:75
SourceLanguage language
Definition: types.h:77
spirv_cross::SPIRType::BaseType type
Definition: types.h:51
std::optional< size_t > array_elements
Definition: types.h:55
std::vector< uint8_t > struct_layout
Definition: types.h:56