1 /* 2 * Copyright 2021 Google Inc. 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_MtlTypesPriv_DEFINED 9 #define skgpu_MtlTypesPriv_DEFINED 10 11 #include "experimental/graphite/include/GraphiteTypes.h" 12 #include "experimental/graphite/include/mtl/MtlTypes.h" 13 14 /////////////////////////////////////////////////////////////////////////////// 15 16 #ifdef __APPLE__ 17 18 #include <TargetConditionals.h> 19 20 // We're using the MSL version as shorthand for the Metal SDK version here 21 #if defined(SK_BUILD_FOR_MAC) 22 #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 110000 23 #define GR_METAL_SDK_VERSION 230 24 #elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 120000 25 #define GR_METAL_SDK_VERSION 240 26 #else 27 #error Must use at least 11.00 SDK to build Metal backend for MacOS 28 #endif 29 #else 30 #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 || __TV_OS_VERSION_MAX_ALLOWED >= 140000 31 #define GR_METAL_SDK_VERSION 230 32 #elif __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000 || __TV_OS_VERSION_MAX_ALLOWED >= 150000 33 #define GR_METAL_SDK_VERSION 240 34 #else 35 #error Must use at least 14.00 SDK to build Metal backend for iOS 36 #endif 37 #endif 38 39 #endif // __APPLE__ 40 41 namespace skgpu::mtl { 42 43 struct TextureSpec { TextureSpecTextureSpec44 TextureSpec() 45 : fFormat(0) 46 , fUsage(0) 47 , fStorageMode(0) 48 , fFramebufferOnly(false) {} TextureSpecTextureSpec49 TextureSpec(const TextureInfo& info) 50 : fFormat(info.fFormat) 51 , fUsage(info.fUsage) 52 , fStorageMode(info.fStorageMode) 53 , fFramebufferOnly(info.fFramebufferOnly) {} 54 55 bool operator==(const TextureSpec& that) const { 56 return fFormat == that.fFormat && 57 fUsage == that.fUsage && 58 fStorageMode == that.fStorageMode && 59 fFramebufferOnly == that.fFramebufferOnly; 60 } 61 62 PixelFormat fFormat; 63 TextureUsage fUsage; 64 StorageMode fStorageMode; 65 bool fFramebufferOnly; 66 }; 67 68 TextureInfo TextureSpecToTextureInfo(const TextureSpec& mtlSpec, 69 uint32_t sampleCount, 70 uint32_t levelCount); 71 72 } // namespace skgpu::mtl 73 74 #endif // skgpu_MtlTypesPriv_DEFINED 75