40 std::filesystem::path path(std_path);
42 if (path.stem().empty()) {
43 FML_LOG(ERROR) <<
"File path stem was empty for " << path;
47 if (path.extension() !=
".gles" && path.extension() !=
".vkspv") {
48 FML_LOG(ERROR) <<
"File path doesn't have a known shader extension "
54 path = path.replace_extension();
58 if (!shader_type.has_value()) {
59 FML_LOG(ERROR) <<
"Could not infer shader type from file extension: "
60 << path.extension().string();
65 path = path.replace_extension();
67 const auto shader_name = path.stem().string();
68 if (shader_name.empty()) {
69 FML_LOG(ERROR) <<
"Shader name was empty.";
75 FML_LOG(ERROR) <<
"File doesn't exist at path: " << path;
79 return AddShader(shader_type.value(), shader_name, std::move(file_mapping));
108 fb::ShaderArchiveT shader_archive;
109 for (
const auto& shader_description : shader_descriptions_) {
110 auto mapping = shader_description.mapping;
114 auto desc = std::make_unique<fb::ShaderBlobT>();
115 desc->name = shader_description.name;
116 desc->stage =
ToStage(shader_description.type);
117 desc->mapping = {mapping->GetMapping(),
118 mapping->GetMapping() + mapping->GetSize()};
119 shader_archive.items.emplace_back(std::move(desc));
121 auto builder = std::make_shared<flatbuffers::FlatBufferBuilder>();
122 builder->Finish(fb::ShaderArchive::Pack(*builder.get(), &shader_archive),
123 fb::ShaderArchiveIdentifier());
124 return std::make_shared<fml::NonOwnedMapping>(builder->GetBufferPointer(),
126 [builder](
auto,
auto) {});