21namespace ContextFactory {
30 sk_cfp<id<MTLCommandQueue>>
queue =
31 sk_ret_cfp((id<MTLCommandQueue>)(backendContext.
fQueue.get()));
32 auto queueManager = std::make_unique<MtlQueueManager>(std::move(
queue), sharedContext.
get());
38 std::move(queueManager),
45 std::string_view label,
49 NSString* nsSource = [[NSString alloc] initWithBytesNoCopy:
const_cast<char*
>(msl.data())
51 encoding:NSUTF8StringEncoding
56 MTLCompileOptions*
options = [[MTLCompileOptions alloc]
init];
59 if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
60 options.languageVersion = MTLLanguageVersion2_3;
64 }
else if (@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)) {
65 options.languageVersion = MTLLanguageVersion2_0;
66#if defined(SK_BUILD_FOR_IOS)
67 }
else if (@available(macOS 10.12, iOS 10.0, tvOS 10.0, *)) {
68 options.languageVersion = MTLLanguageVersion1_2;
74 sk_cfp<id<MTLLibrary>> compiledLibrary(
75 [sharedContext->
device() newLibraryWithSource:(NSString* _Nonnull)nsSource
78 if (!compiledLibrary) {
79 std::string mslStr(msl);
81 mslStr.c_str(),
error.debugDescription.UTF8String,
false);
85 NSString* nsLabel = [[NSString alloc] initWithBytesNoCopy:
const_cast<char*
>(label.data())
87 encoding:NSUTF8StringEncoding
89 compiledLibrary.get().label = nsLabel;
90 return compiledLibrary;
virtual void compileError(const char *shader, const char *errors)
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 &)
unsigned int MtlPixelFormat
size_t MtlFormatBytesPerBlock(MtlPixelFormat format)
SkTextureCompressionType MtlFormatToCompressionType(MtlPixelFormat format)
sk_cfp< id< MTLLibrary > > MtlCompileShaderLibrary(const MtlSharedContext *sharedContext, std::string_view label, std::string_view msl, ShaderErrorHandler *errorHandler)
SkTextureCompressionType MtlFormatToCompressionType(MTLPixelFormat mtlFormat)
size_t MtlFormatBytesPerBlock(MTLPixelFormat mtlFormat)
sk_cfp< CFTypeRef > fQueue
#define TRACE_EVENT0(category_group, name)