1 /* 2 * Copyright 2021 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 #ifndef skgpu_MtlTypes_DEFINED 9 #define skgpu_MtlTypes_DEFINED 10 11 #include "include/ports/SkCFObject.h" 12 13 /////////////////////////////////////////////////////////////////////////////// 14 15 #ifdef __APPLE__ 16 17 #include <CoreFoundation/CoreFoundation.h> 18 #include <TargetConditionals.h> 19 20 #if TARGET_OS_SIMULATOR 21 #define SK_API_AVAILABLE_CA_METAL_LAYER SK_API_AVAILABLE(macos(10.11), ios(13.0)) 22 #else // TARGET_OS_SIMULATOR 23 #define SK_API_AVAILABLE_CA_METAL_LAYER SK_API_AVAILABLE(macos(10.11), ios(8.0)) 24 #endif // TARGET_OS_SIMULATOR 25 26 #endif // __APPLE__ 27 28 29 namespace skgpu::mtl { 30 31 /** 32 * Declares typedefs for Metal types used in Graphite cpp code 33 */ 34 using PixelFormat = unsigned int; 35 using TextureUsage = unsigned int; 36 using StorageMode = unsigned int; 37 using Handle = const void*; 38 39 struct TextureInfo { 40 uint32_t fSampleCount = 1; 41 uint32_t fLevelCount = 0; 42 43 // Since we aren't in an Obj-C header we can't directly use Mtl types here. Each of these can 44 // cast to their mapped Mtl types list below. 45 PixelFormat fFormat = 0; // MTLPixelFormat fFormat = MTLPixelFormatInvalid; 46 TextureUsage fUsage = 0; // MTLTextureUsage fUsage = MTLTextureUsageUnknown; 47 StorageMode fStorageMode = 0; // MTLStorageMode fStorageMode = MTLStorageModeShared; 48 bool fFramebufferOnly = false; 49 50 TextureInfo() = default; 51 TextureInfo(Handle mtlTexture); TextureInfoTextureInfo52 TextureInfo(uint32_t sampleCount, 53 uint32_t levelCount, 54 PixelFormat format, 55 TextureUsage usage, 56 StorageMode storageMode, 57 bool framebufferOnly) 58 : fSampleCount(sampleCount) 59 , fLevelCount(levelCount) 60 , fFormat(format) 61 , fUsage(usage) 62 , fStorageMode(storageMode) 63 , fFramebufferOnly(framebufferOnly) {} 64 }; 65 66 } // namespace skgpu::mtl 67 68 #endif // skgpu_MtlTypes_DEFINED 69