11#include "flutter/fml/logging.h"
18 const std::string& suffix) {
19 if (suffix.size() >
string.size()) {
23 if (suffix.empty() || suffix.empty()) {
27 return string.rfind(suffix) == (
string.size() - suffix.size());
49 if (
name ==
"vertex") {
53 if (
name ==
"fragment") {
57 if (
name ==
"compute") {
65 if (source_language ==
"glsl") {
68 if (source_language ==
"hlsl") {
79 return "MetalDesktop";
85 return "OpenGLDesktop";
89 return "RuntimeStageMetal";
91 return "RuntimeStageGLES";
93 return "RuntimeStageVulkan";
101 switch (source_language) {
112 const std::string& file_name,
115 const std::string& entry_point_name) {
117 return entry_point_name;
120 std::stringstream stream;
121 std::filesystem::path file_path(file_name);
131 stream <<
"fragment";
160 using Status = shaderc_compilation_status;
162 case Status::shaderc_compilation_status_success:
164 case Status::shaderc_compilation_status_invalid_stage:
165 return "Invalid shader stage specified";
166 case Status::shaderc_compilation_status_compilation_error:
167 return "Compilation error";
168 case Status::shaderc_compilation_status_internal_error:
169 return "Internal error";
170 case Status::shaderc_compilation_status_null_result_object:
171 return "Internal error. Null result object";
172 case Status::shaderc_compilation_status_invalid_assembly:
173 return "Invalid assembly";
174 case Status::shaderc_compilation_status_validation_error:
175 return "Validation error";
176 case Status::shaderc_compilation_status_transformation_error:
177 return "Transform error";
178 case Status::shaderc_compilation_status_configuration_error:
179 return "Configuration error";
181 return "Unknown internal error";
187 return shaderc_shader_kind::shaderc_vertex_shader;
189 return shaderc_shader_kind::shaderc_fragment_shader;
191 return shaderc_shader_kind::shaderc_compute_shader;
195 return shaderc_shader_kind::shaderc_glsl_infer_from_source;
201 return spv::ExecutionModel::ExecutionModelVertex;
203 return spv::ExecutionModel::ExecutionModelFragment;
205 return spv::ExecutionModel::ExecutionModelGLCompute;
209 return spv::ExecutionModel::ExecutionModelMax;
217 return spirv_cross::CompilerMSL::Options::Platform::iOS;
219 return spirv_cross::CompilerMSL::Options::Platform::macOS;
227 return spirv_cross::CompilerMSL::Options::Platform::macOS;
#define FML_UNREACHABLE()
std::string ConvertToEntrypointName(std::string_view string)
Ensure that the entrypoint name is a valid identifier in the target language.
std::string ToLowerCase(std::string_view string)
static bool StringEndWith(const std::string &string, const std::string &suffix)
std::string SourceLanguageToString(SourceLanguage source_language)
std::string TargetPlatformToString(TargetPlatform platform)
std::string TargetPlatformSLExtension(TargetPlatform platform)
shaderc_shader_kind ToShaderCShaderKind(SourceType type)
std::string SourceTypeToString(SourceType type)
SourceType SourceTypeFromString(std::string name)
SourceType SourceTypeFromFileName(const std::string &file_name)
std::string EntryPointFunctionNameFromSourceName(const std::string &file_name, SourceType type, SourceLanguage source_language, const std::string &entry_point_name)
bool TargetPlatformIsMetal(TargetPlatform platform)
bool TargetPlatformIsOpenGL(TargetPlatform platform)
std::string ShaderCErrorToString(shaderc_compilation_status status)
bool TargetPlatformIsVulkan(TargetPlatform platform)
std::string Utf8FromPath(const std::filesystem::path &path)
Converts a native format path to a utf8 string.
bool TargetPlatformBundlesSkSL(TargetPlatform platform)
spirv_cross::CompilerMSL::Options::Platform TargetPlatformToMSLPlatform(TargetPlatform platform)
SourceLanguage ToSourceLanguage(const std::string &source_language)
bool TargetPlatformNeedsReflection(TargetPlatform platform)
spv::ExecutionModel ToExecutionModel(SourceType type)