Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
shader_library_mtl.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_SHADER_LIBRARY_MTL_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_SHADER_LIBRARY_MTL_H_
7
8#include <Foundation/Foundation.h>
9#include <Metal/Metal.h>
10
11#include <memory>
12#include <string>
13#include <unordered_map>
14
15#include "flutter/fml/macros.h"
20
21namespace impeller {
22
23class ShaderLibraryMTL final : public ShaderLibrary {
24 public:
26
27 // |ShaderLibrary|
29
30 // |ShaderLibrary|
31 bool IsValid() const override;
32
33 private:
34 friend class ContextMTL;
35
36 UniqueID library_id_;
37 mutable RWMutex libraries_mutex_;
38 NSMutableArray<id<MTLLibrary>>* libraries_ IPLR_GUARDED_BY(libraries_mutex_) =
39 nullptr;
40 ShaderFunctionMap functions_;
41 bool is_valid_ = false;
42
43 explicit ShaderLibraryMTL(NSArray<id<MTLLibrary>>* libraries);
44
45 // |ShaderLibrary|
46 std::shared_ptr<const ShaderFunction> GetFunction(std::string_view name,
47 ShaderStage stage) override;
48
49 // |ShaderLibrary|
50 void RegisterFunction(std::string name,
51 ShaderStage stage,
52 std::shared_ptr<fml::Mapping> code,
54
55 // |ShaderLibrary|
56 void UnregisterFunction(std::string name, ShaderStage stage) override;
57
58 id<MTLDevice> GetDevice() const;
59
60 void RegisterLibrary(id<MTLLibrary> library);
61
62 ShaderLibraryMTL(const ShaderLibraryMTL&) = delete;
63
64 ShaderLibraryMTL& operator=(const ShaderLibraryMTL&) = delete;
65};
66
67} // namespace impeller
68
69#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_SHADER_LIBRARY_MTL_H_
void RegisterFunction(std::string name, ShaderStage stage, std::shared_ptr< fml::Mapping > code, RegistrationCallback callback) override
std::shared_ptr< const ShaderFunction > GetFunction(std::string_view name, ShaderStage stage) override
void UnregisterFunction(std::string name, ShaderStage stage) override
bool IsValid() const override
std::function< void(bool)> RegistrationCallback
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
const char * name
Definition fuchsia.cc:50
std::unordered_map< ShaderKey, std::shared_ptr< const ShaderFunction >, ShaderKey::Hash, ShaderKey::Equal > ShaderFunctionMap
Definition shader_key.h:44
#define IPLR_GUARDED_BY(x)