72 std::string_view label,
76 NSString* nsSource = [[NSString alloc] initWithBytesNoCopy:
const_cast<char*
>(msl.data())
78 encoding:NSUTF8StringEncoding
83 MTLCompileOptions*
options = [[MTLCompileOptions alloc] init];
86 if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
87 options.languageVersion = MTLLanguageVersion2_3;
91 }
else if (@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)) {
92 options.languageVersion = MTLLanguageVersion2_0;
93#if defined(SK_BUILD_FOR_IOS)
94 }
else if (@available(macOS 10.12, iOS 10.0, tvOS 10.0, *)) {
95 options.languageVersion = MTLLanguageVersion1_2;
101 sk_cfp<id<MTLLibrary>> compiledLibrary(
102 [sharedContext->
device() newLibraryWithSource:(NSString* _Nonnull)nsSource
105 if (!compiledLibrary) {
106 std::string mslStr(msl);
108 mslStr.c_str(),
error.debugDescription.UTF8String,
false);
112 NSString* nsLabel = [[NSString alloc] initWithBytesNoCopy:
const_cast<char*
>(label.data())
114 encoding:NSUTF8StringEncoding
116 compiledLibrary.get().label = nsLabel;
117 return compiledLibrary;
static std::unique_ptr< Context > MakeContext(sk_sp< SharedContext >, std::unique_ptr< QueueManager >, const ContextOptions &)
static sk_sp< SharedContext > Make(const MtlBackendContext &, const ContextOptions &)
id< MTLDevice > device() const
const uint8_t uint32_t uint32_t GError ** error
uint32_t uint32_t * format
SK_API std::unique_ptr< Context > MakeMetal(const MtlBackendContext &, const ContextOptions &)
sk_cfp< CFTypeRef > fQueue