31 std::stringstream stream;
35 stream <<
"_unknown_";
41 stream <<
"_fragment_";
44 stream <<
"_compute_";
51ShaderLibraryGLES::ShaderLibraryGLES(
52 const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries) {
54 auto iterator = [&functions, library_id = library_id_](
auto type,
60 functions[ShaderKey{key_name, stage}] = std::shared_ptr<ShaderFunctionGLES>{
61 new ShaderFunctionGLES(library_id,
69 for (
auto library : shader_libraries) {
71 if (!blob_library.ok()) {
73 << blob_library.status().ToString();
76 blob_library->IterateAllShaders(iterator);
79 functions_ = functions;
92std::shared_ptr<const ShaderFunction> ShaderLibraryGLES::GetFunction(
93 std::string_view
name,
97 if (
auto found = functions_.find(
key); found != functions_.end()) {
104void ShaderLibraryGLES::RegisterFunction(std::string
name,
106 std::shared_ptr<fml::Mapping> code,
113 code->GetMapping() ==
nullptr) {
117 const auto key = ShaderKey{
name, stage};
118 WriterLock lock(functions_mutex_);
119 if (functions_.count(
key) != 0) {
121 <<
" has already been registered.";
124 functions_[
key] = std::shared_ptr<ShaderFunctionGLES>(
new ShaderFunctionGLES(
135void ShaderLibraryGLES::UnregisterFunction(std::string
name,
137 ReaderLock lock(functions_mutex_);
139 const auto key = ShaderKey{
name, stage};
141 auto found = functions_.find(
key);
142 if (found == functions_.end()) {
144 <<
" was not found, so it couldn't be unregistered.";
148 functions_.erase(found);
Wraps a closure that is invoked in the destructor unless released by the caller.
static absl::StatusOr< ShaderArchive > Create(std::shared_ptr< fml::Mapping > payload)
~ShaderLibraryGLES() override
bool IsValid() const override
FlutterDesktopBinaryReply callback
#define FML_UNREACHABLE()
static std::string GLESShaderNameToShaderKeyName(const std::string &name, ShaderStage stage)
constexpr ShaderStage ToShaderStage(RuntimeShaderStage stage)
std::unordered_map< ShaderKey, std::shared_ptr< const ShaderFunction >, ShaderKey::Hash, ShaderKey::Equal > ShaderFunctionMap