| Flutter Impeller |

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 <string>
12
13 #include "flutter/fml/macros.h"
14 #include "shaderc/shaderc.hpp"
15 #include "spirv_cross.hpp"
16 #include "spirv_msl.hpp"
17
18 namespace impeller {
19 namespace compiler {
20
21 enum class SourceType {
22 kUnknown,
23 kVertexShader,
24 kFragmentShader,
25 kComputeShader,
26 };
27
28 enum class TargetPlatform {
29 kUnknown,
30 kMetalDesktop,
31 kMetalIOS,
32 kOpenGLES,
33 kOpenGLDesktop,
34 kVulkan,
35 kRuntimeStageMetal,
36 kRuntimeStageGLES,
37 kRuntimeStageVulkan,
38 kSkSL,
39 };
40
41 enum class SourceLanguage {
42 kUnknown,
43 kGLSL,
44 kHLSL,
45 };
46
47 /// A shader config parsed as part of a ShaderBundleConfig.
48 struct ShaderConfig {
49 std::string source_file_name;
50 SourceType type;
51 SourceLanguage language;
52 std::string entry_point;
53 };
54
55 using ShaderBundleConfig = std::unordered_map<std::string, ShaderConfig>;
56
57 bool TargetPlatformIsMetal(TargetPlatform platform);
58
59 bool TargetPlatformIsOpenGL(TargetPlatform platform);
60
61 bool TargetPlatformIsVulkan(TargetPlatform platform);
62
63 SourceType SourceTypeFromFileName(const std::string& file_name);
64
65 SourceType SourceTypeFromString(std::string name);
66
67 std::string SourceTypeToString(SourceType type);
68
69 std::string TargetPlatformToString(TargetPlatform platform);
70
71 SourceLanguage ToSourceLanguage(const std::string& source_language);
72
73 std::string SourceLanguageToString(SourceLanguage source_language);
74
75 std::string TargetPlatformSLExtension(TargetPlatform platform);
76
77 std::string EntryPointFunctionNameFromSourceName(
78 const std::string& file_name,
79 SourceType type,
80 SourceLanguage source_language,
81 const std::string& entry_point_name);
82
83 bool TargetPlatformNeedsReflection(TargetPlatform platform);
84
85 bool TargetPlatformBundlesSkSL(TargetPlatform platform);
86
87 std::string ShaderCErrorToString(shaderc_compilation_status status);
88
89 shaderc_shader_kind ToShaderCShaderKind(SourceType type);
90
91 spv::ExecutionModel ToExecutionModel(SourceType type);
92
93 spirv_cross::CompilerMSL::Options::Platform TargetPlatformToMSLPlatform(
94 TargetPlatform platform);
95
96 } // namespace compiler
97 } // namespace impeller
98
99 #endif // FLUTTER_IMPELLER_COMPILER_TYPES_H_
impeller::compiler::ShaderConfig::entry_point
std::string entry_point
Definition: types.h:52
impeller::compiler::ShaderConfig::language
SourceLanguage language
Definition: types.h:51
impeller::compiler::SourceType::kUnknown
@ kUnknown
impeller::compiler::TargetPlatformSLExtension
std::string TargetPlatformSLExtension(TargetPlatform platform)
Definition: types.cc:246
impeller::compiler::TargetPlatform::kMetalDesktop
@ kMetalDesktop
impeller::compiler::TargetPlatformToMSLPlatform
spirv_cross::CompilerMSL::Options::Platform TargetPlatformToMSLPlatform(TargetPlatform platform)
Definition: types.cc:212
impeller::compiler::SourceLanguageToString
std::string SourceLanguageToString(SourceLanguage source_language)
Definition: types.cc:100
impeller::compiler::TargetPlatformNeedsReflection
bool TargetPlatformNeedsReflection(TargetPlatform platform)
Definition: types.cc:141
impeller::compiler::TargetPlatform::kMetalIOS
@ kMetalIOS
impeller::compiler::TargetPlatform
TargetPlatform
Definition: types.h:28
impeller::compiler::SourceLanguage::kGLSL
@ kGLSL
impeller::compiler::ShaderConfig::type
SourceType type
Definition: types.h:50
impeller::compiler::ToSourceLanguage
SourceLanguage ToSourceLanguage(const std::string &source_language)
Definition: types.cc:64
impeller::compiler::SourceLanguage::kHLSL
@ kHLSL
impeller::compiler::TargetPlatform::kVulkan
@ kVulkan
impeller::compiler::SourceType::kFragmentShader
@ kFragmentShader
impeller::compiler::TargetPlatform::kRuntimeStageVulkan
@ kRuntimeStageVulkan
impeller::compiler::SourceType::kComputeShader
@ kComputeShader
impeller::compiler::TargetPlatformIsOpenGL
bool TargetPlatformIsOpenGL(TargetPlatform platform)
Definition: types.cc:266
impeller::compiler::EntryPointFunctionNameFromSourceName
std::string EntryPointFunctionNameFromSourceName(const std::string &file_name, SourceType type, SourceLanguage source_language, const std::string &entry_point_name)
Definition: types.cc:111
impeller::compiler::TargetPlatformIsMetal
bool TargetPlatformIsMetal(TargetPlatform platform)
Definition: types.cc:284
impeller::compiler::TargetPlatformIsVulkan
bool TargetPlatformIsVulkan(TargetPlatform platform)
Definition: types.cc:302
impeller::compiler::SourceType
SourceType
Definition: types.h:21
impeller::compiler::SourceLanguage::kUnknown
@ kUnknown
impeller::compiler::ToExecutionModel
spv::ExecutionModel ToExecutionModel(SourceType type)
Definition: types.cc:198
impeller::compiler::SourceTypeFromFileName
SourceType SourceTypeFromFileName(const std::string &file_name)
Definition: types.cc:30
impeller::compiler::ShaderBundleConfig
std::unordered_map< std::string, ShaderConfig > ShaderBundleConfig
Definition: types.h:55
impeller::compiler::SourceLanguage
SourceLanguage
Definition: types.h:41
impeller::compiler::TargetPlatform::kOpenGLDesktop
@ kOpenGLDesktop
impeller::compiler::SourceTypeFromString
SourceType SourceTypeFromString(std::string name)
Definition: types.cc:46
impeller::compiler::TargetPlatformToString
std::string TargetPlatformToString(TargetPlatform platform)
Definition: types.cc:74
impeller::compiler::TargetPlatform::kUnknown
@ kUnknown
impeller::compiler::SourceTypeToString
std::string SourceTypeToString(SourceType type)
Definition: types.cc:232
impeller::compiler::ShaderConfig::source_file_name
std::string source_file_name
Definition: types.h:49
impeller::compiler::TargetPlatform::kOpenGLES
@ kOpenGLES
impeller::compiler::TargetPlatform::kRuntimeStageMetal
@ kRuntimeStageMetal
impeller::compiler::SourceType::kVertexShader
@ kVertexShader
impeller::compiler::ToShaderCShaderKind
shaderc_shader_kind ToShaderCShaderKind(SourceType type)
Definition: types.cc:184
impeller::compiler::TargetPlatformBundlesSkSL
bool TargetPlatformBundlesSkSL(TargetPlatform platform)
Definition: types.cc:320
impeller
Definition: aiks_context.cc:10
impeller::compiler::ShaderConfig
A shader config parsed as part of a ShaderBundleConfig.
Definition: types.h:48
impeller::compiler::ShaderCErrorToString
std::string ShaderCErrorToString(shaderc_compilation_status status)
Definition: types.cc:159
impeller::compiler::TargetPlatform::kSkSL
@ kSkSL
impeller::compiler::TargetPlatform::kRuntimeStageGLES
@ kRuntimeStageGLES