Flutter Engine
The Flutter Engine
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
19
20namespace impeller {
21
22class ShaderLibraryMTL final : public ShaderLibrary {
23 public:
25
26 // |ShaderLibrary|
28
29 // |ShaderLibrary|
30 bool IsValid() const override;
31
32 private:
33 friend class ContextMTL;
34
35 UniqueID library_id_;
36 mutable RWMutex libraries_mutex_;
37 NSMutableArray<id<MTLLibrary>>* libraries_ IPLR_GUARDED_BY(libraries_mutex_) =
38 nullptr;
39 ShaderFunctionMap functions_;
40 bool is_valid_ = false;
41
42 explicit ShaderLibraryMTL(NSArray<id<MTLLibrary>>* libraries);
43
44 // |ShaderLibrary|
45 std::shared_ptr<const ShaderFunction> GetFunction(std::string_view name,
46 ShaderStage stage) override;
47
48 // |ShaderLibrary|
49 void RegisterFunction(std::string name,
50 ShaderStage stage,
51 std::shared_ptr<fml::Mapping> code,
53
54 // |ShaderLibrary|
55 void UnregisterFunction(std::string name, ShaderStage stage) override;
56
57 id<MTLDevice> GetDevice() const;
58
59 void RegisterLibrary(id<MTLLibrary> library);
60
61 ShaderLibraryMTL(const ShaderLibraryMTL&) = delete;
62
63 ShaderLibraryMTL& operator=(const ShaderLibraryMTL&) = delete;
64};
65
66} // namespace impeller
67
68#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_SHADER_LIBRARY_MTL_H_
bool IsValid() const override
std::function< void(bool)> RegistrationCallback
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
FunctionPtr GetFunction(const Library &lib, const char *name)
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
std::unordered_map< ShaderKey, std::shared_ptr< const ShaderFunction >, ShaderKey::Hash, ShaderKey::Equal > ShaderFunctionMap
Definition: shader_key.h:43
#define IPLR_GUARDED_BY(x)
Definition: thread_safety.h:19