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_MtlUtilsPriv_DEFINED
9 #define skgpu_MtlUtilsPriv_DEFINED
10
11 #import <Metal/Metal.h>
12
13 #include "include/core/SkTextureCompressionType.h"
14 #include "src/gpu/SkSLToBackend.h"
15 #include "src/sksl/codegen/SkSLMetalCodeGenerator.h"
16
17 namespace SkSL {
18
19 enum class ProgramKind : int8_t;
20 struct ProgramInterface;
21 struct ProgramSettings;
22 struct ShaderCaps;
23
24 } // namespace SkSL
25
26 namespace skgpu {
27
28 class ShaderErrorHandler;
29
SkSLToMSL(const SkSL::ShaderCaps * caps,const std::string & sksl,SkSL::ProgramKind programKind,const SkSL::ProgramSettings & settings,std::string * msl,SkSL::ProgramInterface * outInterface,ShaderErrorHandler * errorHandler)30 inline bool SkSLToMSL(const SkSL::ShaderCaps* caps,
31 const std::string& sksl,
32 SkSL::ProgramKind programKind,
33 const SkSL::ProgramSettings& settings,
34 std::string* msl,
35 SkSL::ProgramInterface* outInterface,
36 ShaderErrorHandler* errorHandler) {
37 return SkSLToBackend(caps, &SkSL::ToMetal, "MSL",
38 sksl, programKind, settings, msl, outInterface, errorHandler);
39 }
40
41 bool MtlFormatIsDepthOrStencil(MTLPixelFormat);
42 bool MtlFormatIsDepth(MTLPixelFormat);
43 bool MtlFormatIsStencil(MTLPixelFormat);
44 bool MtlFormatIsCompressed(MTLPixelFormat);
45
46 uint32_t MtlFormatChannels(MTLPixelFormat);
47
48 size_t MtlFormatBytesPerBlock(MTLPixelFormat);
49
50 SkTextureCompressionType MtlFormatToCompressionType(MTLPixelFormat);
51
52 const char* MtlFormatToString(MTLPixelFormat);
53
54 } // namespace skgpu
55
56 #endif // skgpu_MtlUtilsPriv_DEFINED
57