1/* 2 * Copyright 2024 Google LLC 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8#import "graphite_metal_context_helper.h" 9 10#import "include/gpu/ganesh/mtl/GrMtlTypes.h" 11#import "include/ports/SkCFObject.h" 12 13#import <Metal/Metal.h> 14 15skgpu::graphite::MtlBackendContext GetMetalContext() { 16 skgpu::graphite::MtlBackendContext backendContext = {}; 17 sk_cfp<id<MTLDevice>> device; 18 device.reset(MTLCreateSystemDefaultDevice()); 19 20 sk_cfp<id<MTLCommandQueue>> queue; 21 queue.reset([*device newCommandQueue]); 22 23 backendContext.fDevice.retain((CFTypeRef)device.get()); 24 backendContext.fQueue.retain((CFTypeRef)queue.get()); 25 return backendContext; 26} 27