#include <shader_library_mtl.h>
Definition at line 23 of file shader_library_mtl.h.
◆ ShaderLibraryMTL()
impeller::ShaderLibraryMTL::ShaderLibraryMTL |
( |
| ) |
|
◆ ~ShaderLibraryMTL()
impeller::ShaderLibraryMTL::~ShaderLibraryMTL |
( |
| ) |
|
|
overridedefault |
◆ GetFunction()
Implements impeller::ShaderLibrary.
Definition at line 41 of file shader_library_mtl.mm.
43 {
45 return nullptr;
46 }
47
50 return nullptr;
51 }
52
54
56 id<MTLLibrary> library = nil;
57
58 {
59 ReaderLock lock(libraries_mutex_);
60
61 if (
auto found = functions_.find(
key); found != functions_.end()) {
62 return found->second;
63 }
64
66 library = libraries_[i];
69 break;
70 }
71 }
72
74 return nullptr;
75 }
76
79 << " was for an unexpected shader stage.";
80 return nullptr;
81 }
82
83 auto func = std::shared_ptr<ShaderFunctionMTL>(new ShaderFunctionMTL(
85 functions_[
key] = func;
86
87 return func;
88 }
89}
bool IsValid() const override
Dart_NativeFunction function
static MTLFunctionType ToMTLFunctionType(ShaderStage stage)
◆ IsValid()
bool impeller::ShaderLibraryMTL::IsValid |
( |
| ) |
const |
|
overridevirtual |
◆ RegisterFunction()
Reimplemented from impeller::ShaderLibrary.
Definition at line 100 of file shader_library_mtl.mm.
103 {
106 }
107 auto failure_callback = std::make_shared<fml::ScopedCleanupClosure>(
110 return;
111 }
112 if (code ==
nullptr ||
code->GetMapping() ==
nullptr) {
113 return;
114 }
115 auto device = GetDevice();
117 return;
118 }
119
120 auto source = [[NSString alloc] initWithBytes:
code->GetMapping()
122 encoding:NSUTF8StringEncoding];
123
124 auto weak_this = weak_from_this();
127 completionHandler:^(id<MTLLibrary> library, NSError*
error) {
128 auto strong_this = weak_this.lock();
129 if (!strong_this) {
131 "dynamic shader stage could be registered.";
132 return;
133 }
134 if (!library) {
136 <<
error.localizedDescription.UTF8String;
137 return;
138 }
140 ->RegisterLibrary(library);
141 failure_callback->Release();
143 }];
144}
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
const uint8_t uint32_t uint32_t GError ** error
◆ UnregisterFunction()
void impeller::ShaderLibraryMTL::UnregisterFunction |
( |
std::string |
name, |
|
|
ShaderStage |
stage |
|
) |
| |
|
overrideprivatevirtual |
Implements impeller::ShaderLibrary.
Definition at line 147 of file shader_library_mtl.mm.
147 {
148 ReaderLock lock(libraries_mutex_);
149
150
151
152 bool found_library = false;
153 for (
size_t i = [libraries_
count] - 1; i >= 0; i--) {
155 [libraries_[i] newFunctionWithName:@(
name.data())];
157 [libraries_ removeObjectAtIndex:i];
158 found_library = true;
159 break;
160 }
161 }
162 if (!found_library) {
164 << " was not found, so it couldn't be unregistered.";
165 }
166
167
168
170
171 auto found = functions_.find(
key);
172 if (found == functions_.end()) {
174 << " was not found, so it couldn't be unregistered.";
175 return;
176 }
177
178 functions_.erase(found);
179}
◆ ContextMTL
The documentation for this class was generated from the following files: