• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 GrMtlTypesPriv_DEFINED
9 #define GrMtlTypesPriv_DEFINED
10 
11 #include "include/gpu/GrTypes.h"
12 #include "include/gpu/mtl/GrMtlTypes.h"
13 
14 ///////////////////////////////////////////////////////////////////////////////
15 
16 #ifdef __APPLE__
17 
18 #include <TargetConditionals.h>
19 
20 #if defined(SK_BUILD_FOR_MAC)
21 #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
22 #define GR_METAL_SDK_VERSION 230
23 #elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 101500
24 #define GR_METAL_SDK_VERSION 220
25 #elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
26 #define GR_METAL_SDK_VERSION 210
27 #else
28 #error Must use at least 10.14 SDK to build Metal backend for MacOS
29 #endif
30 #else
31 #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 || __TV_OS_VERSION_MAX_ALLOWED >= 140000
32 #define GR_METAL_SDK_VERSION 230
33 #elif __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 || __TV_OS_VERSION_MAX_ALLOWED >= 130000
34 #define GR_METAL_SDK_VERSION 220
35 #elif __IPHONE_OS_VERSION_MAX_ALLOWED >= 120000 || __TV_OS_VERSION_MAX_ALLOWED >= 120000
36 #define GR_METAL_SDK_VERSION 210
37 #else
38 #error Must use at least 12.00 SDK to build Metal backend for iOS
39 #endif
40 #endif
41 
42 #if __has_feature(objc_arc) && __has_attribute(objc_externally_retained)
43 #define GR_NORETAIN __attribute__((objc_externally_retained))
44 #define GR_NORETAIN_BEGIN \
45     _Pragma("clang attribute push (__attribute__((objc_externally_retained)), apply_to=any(function,objc_method))")
46 #define GR_NORETAIN_END _Pragma("clang attribute pop")
47 #else
48 #define GR_NORETAIN
49 #define GR_NORETAIN_BEGIN
50 #define GR_NORETAIN_END
51 #endif
52 
53 struct GrMtlTextureSpec {
GrMtlTextureSpecGrMtlTextureSpec54     GrMtlTextureSpec()
55             : fFormat(0)
56             , fUsage(0)
57             , fStorageMode(0) {}
GrMtlTextureSpecGrMtlTextureSpec58     GrMtlTextureSpec(const GrMtlSurfaceInfo& info)
59             : fFormat(info.fFormat)
60             , fUsage(info.fUsage)
61             , fStorageMode(info.fStorageMode) {}
62 
63     GrMTLPixelFormat fFormat;
64     GrMTLTextureUsage fUsage;
65     GrMTLStorageMode fStorageMode;
66 };
67 
68 GrMtlSurfaceInfo GrMtlTextureSpecToSurfaceInfo(const GrMtlTextureSpec& mtlSpec,
69                                                uint32_t sampleCount,
70                                                uint32_t levelCount,
71                                                GrProtected isProtected);
72 
73 #endif  // __APPLE__
74 
75 #endif  // GrMtlTypesPriv_DEFINED
76