11#include "impeller/shader_archive/shader_archive_flatbuffers.h"
21 if (
path ==
".vert") {
23 }
else if (
path ==
".frag") {
25 }
else if (
path ==
".comp") {
34 if (
path.stem().empty()) {
39 if (
path.extension() !=
".gles" &&
path.extension() !=
".vkspv") {
40 FML_LOG(
ERROR) <<
"File path doesn't have a known shader extension "
50 if (!shader_type.has_value()) {
51 FML_LOG(
ERROR) <<
"Could not infer shader type from file extension: "
52 <<
path.extension().string();
59 const auto shader_name =
path.stem().string();
60 if (shader_name.empty()) {
71 return AddShader(shader_type.value(), shader_name, std::move(file_mapping));
76 std::shared_ptr<fml::Mapping> mapping) {
77 if (
name.empty() || !mapping || mapping->GetMapping() ==
nullptr) {
81 shader_descriptions_.emplace_back(
82 ShaderDescription{
type, std::move(
name), std::move(mapping)});
89 return fb::Stage::kVertex;
91 return fb::Stage::kFragment;
93 return fb::Stage::kCompute;
99 fb::ShaderArchiveT shader_archive;
100 for (
const auto& shader_description : shader_descriptions_) {
101 auto mapping = shader_description.mapping;
105 auto desc = std::make_unique<fb::ShaderBlobT>();
106 desc->name = shader_description.name;
108 desc->mapping = {mapping->GetMapping(),
109 mapping->GetMapping() + mapping->GetSize()};
110 shader_archive.items.emplace_back(std::move(
desc));
112 auto builder = std::make_shared<flatbuffers::FlatBufferBuilder>();
114 fb::ShaderArchiveIdentifier());
115 return std::make_shared<fml::NonOwnedMapping>(
builder->GetBufferPointer(),
static std::unique_ptr< FileMapping > CreateReadOnly(const std::string &path)
bool AddShaderAtPath(const std::string &path)
bool AddShader(ArchiveShaderType type, std::string name, std::shared_ptr< fml::Mapping > mapping)
std::shared_ptr< fml::Mapping > CreateMapping() const
#define FML_LOG(severity)
#define FML_UNREACHABLE()
void(ABI *)(Params *, SkRasterPipelineStage *program, F r, F g, F b, F a) Stage
static void * Pack(const T &ctx, SkArenaAlloc *alloc)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
DEF_SWITCHES_START aot vmservice shared library name
std::optional< ArchiveShaderType > InferShaderTypefromFileExtension(const std::filesystem::path &path)
constexpr fb::Stage ToStage(ArchiveShaderType type)