Debian Codegraph @

src/gpu/graphite/mtl/MtlGraphiteUtils.h

raw
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_graphite_MtlGraphiteTypesPriv_DEFINED
9 #define skgpu_graphite_MtlGraphiteTypesPriv_DEFINED
10
11 #include "include/core/SkString.h"
12 #include "include/ports/SkCFObject.h"
13
14 class SkStream;
15 class SkWStream;
16
17 ///////////////////////////////////////////////////////////////////////////////
18
19 #include <TargetConditionals.h>
20
21 // We're using the MSL version as shorthand for the Metal SDK version here
22 #if defined(SK_BUILD_FOR_MAC)
23 #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 130000
24 #define SKGPU_GRAPHITE_METAL_SDK_VERSION 300
25 #elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 120000
26 #define SKGPU_GRAPHITE_METAL_SDK_VERSION 240
27 #elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
28 #define SKGPU_GRAPHITE_METAL_SDK_VERSION 230
29 #else
30 #error Must use at least 11.00 SDK to build Metal backend for MacOS
31 #endif
32 #else
33 #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 160000 || __TV_OS_VERSION_MAX_ALLOWED >= 160000
34 #define SKGPU_GRAPHITE_METAL_SDK_VERSION 300
35 #elif __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000 || __TV_OS_VERSION_MAX_ALLOWED >= 150000
36 #define SKGPU_GRAPHITE_METAL_SDK_VERSION 240
37 #elif __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 || __TV_OS_VERSION_MAX_ALLOWED >= 140000
38 #define SKGPU_GRAPHITE_METAL_SDK_VERSION 230
39 #else
40 #error Must use at least 14.00 SDK to build Metal backend for iOS
41 #endif
42 #endif
43
44 #import <Metal/Metal.h>
45
46 namespace skgpu {
47 class ShaderErrorHandler;
48 }
49
50 namespace skgpu::graphite {
51
52 class MtlSharedContext;
53 enum class TextureFormat : uint8_t;
54
55 sk_cfp<id<MTLLibrary>> MtlCompileShaderLibrary(const MtlSharedContext* sharedContext,
56 std::string_view label,
57 std::string_view msl,
58 ShaderErrorHandler* errorHandler);
59
60 TextureFormat MTLPixelFormatToTextureFormat(MTLPixelFormat);
61 MTLPixelFormat TextureFormatToMTLPixelFormat(TextureFormat);
62
63 } // namespace skgpu::graphite
64
65 #endif // skgpu_graphite_MtlGraphiteTypesPriv_DEFINED