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_MtlUtils_DEFINED 9 #define skgpu_MtlUtils_DEFINED 10 11 #include "experimental/graphite/src/ResourceTypes.h" 12 #include "include/core/SkImageInfo.h" 13 #include "include/ports/SkCFObject.h" 14 #include "src/sksl/ir/SkSLProgram.h" 15 16 #import <Metal/Metal.h> 17 18 namespace skgpu { 19 class ShaderErrorHandler; 20 21 namespace mtl { 22 23 class Gpu; 24 25 bool FormatIsDepthOrStencil(MTLPixelFormat); 26 bool FormatIsDepth(MTLPixelFormat); 27 bool FormatIsStencil(MTLPixelFormat); 28 29 MTLPixelFormat SkColorTypeToFormat(SkColorType); 30 31 MTLPixelFormat DepthStencilFlagsToFormat(Mask<DepthStencilFlags>); 32 33 /** 34 * Produces MSL code generated by SkSLC 35 */ 36 bool SkSLToMSL(const Gpu* gpu, 37 const std::string& sksl, 38 SkSL::ProgramKind kind, 39 const SkSL::Program::Settings& settings, 40 std::string* msl, 41 SkSL::Program::Inputs* outInputs, 42 ShaderErrorHandler* errorHandler); 43 44 sk_cfp<id<MTLLibrary>> CompileShaderLibrary(const Gpu* gpu, 45 const std::string& msl, 46 ShaderErrorHandler* errorHandler); 47 48 #ifdef SK_BUILD_FOR_IOS 49 bool IsAppInBackground(); 50 #endif 51 } // namespace skgpu::mtl 52 } // namespace skgpu 53 54 #endif // skgpu_MtlUtils_DEFINED 55