#include <shader_archive_writer.h>
Definition at line 18 of file shader_archive_writer.h.
◆ ShaderArchiveWriter()
impeller::ShaderArchiveWriter::ShaderArchiveWriter |
( |
| ) |
|
|
default |
◆ ~ShaderArchiveWriter()
impeller::ShaderArchiveWriter::~ShaderArchiveWriter |
( |
| ) |
|
|
default |
◆ AddShader()
bool impeller::ShaderArchiveWriter::AddShader |
( |
ArchiveShaderType |
type, |
|
|
std::string |
name, |
|
|
std::shared_ptr< fml::Mapping > |
mapping |
|
) |
| |
◆ AddShaderAtPath()
bool impeller::ShaderArchiveWriter::AddShaderAtPath |
( |
const std::string & |
path | ) |
|
Definition at line 31 of file shader_archive_writer.cc.
32 std::filesystem::path path(std_path);
34 if (path.stem().empty()) {
35 FML_LOG(ERROR) <<
"File path stem was empty for " << path;
39 if (path.extension() !=
".gles" && path.extension() !=
".vkspv") {
40 FML_LOG(ERROR) <<
"File path doesn't have a known shader extension "
46 path = path.replace_extension();
50 if (!shader_type.has_value()) {
51 FML_LOG(ERROR) <<
"Could not infer shader type from file extension: "
52 << path.extension().string();
57 path = path.replace_extension();
59 const auto shader_name = path.stem().string();
60 if (shader_name.empty()) {
61 FML_LOG(ERROR) <<
"Shader name was empty.";
65 auto file_mapping = fml::FileMapping::CreateReadOnly(std_path);
67 FML_LOG(ERROR) <<
"File doesn't exist at path: " << path;
71 return AddShader(shader_type.value(), shader_name, std::move(file_mapping));
References AddShader(), and impeller::InferShaderTypefromFileExtension().
Referenced by impeller::Main().
◆ CreateMapping()
std::shared_ptr< fml::Mapping > impeller::ShaderArchiveWriter::CreateMapping |
( |
| ) |
const |
Definition at line 98 of file shader_archive_writer.cc.
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;
107 desc->stage =
ToStage(shader_description.type);
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>();
113 builder->Finish(fb::ShaderArchive::Pack(*builder.get(), &shader_archive),
114 fb::ShaderArchiveIdentifier());
115 return std::make_shared<fml::NonOwnedMapping>(builder->GetBufferPointer(),
117 [builder](
auto,
auto) {});
References impeller::ToStage().
Referenced by impeller::Main(), and impeller::testing::TEST().
The documentation for this class was generated from the following files: