blob: 526c5b367dbcda8944429cd08c1d95ceb5f38bd5 [file] [log] [blame]
/*
* Copyright 2021 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef skgpu_MtlUtils_DEFINED
#define skgpu_MtlUtils_DEFINED
#include "experimental/graphite/src/ResourceTypes.h"
#include "include/core/SkImageInfo.h"
#include "include/ports/SkCFObject.h"
#include "src/sksl/ir/SkSLProgram.h"
#import <Metal/Metal.h>
namespace SkSL {
class String;
}
namespace skgpu {
class ShaderErrorHandler;
namespace mtl {
class Gpu;
bool FormatIsDepthOrStencil(MTLPixelFormat);
bool FormatIsDepth(MTLPixelFormat);
bool FormatIsStencil(MTLPixelFormat);
MTLPixelFormat SkColorTypeToFormat(SkColorType);
MTLPixelFormat DepthStencilFlagsToFormat(Mask<DepthStencilFlags>);
/**
* Produces MSL code generated by SkSLC
*/
bool SkSLToMSL(const Gpu* gpu,
const SkSL::String& sksl,
SkSL::ProgramKind kind,
const SkSL::Program::Settings& settings,
SkSL::String* msl,
SkSL::Program::Inputs* outInputs,
ShaderErrorHandler* errorHandler);
sk_cfp<id<MTLLibrary>> CompileShaderLibrary(const Gpu* gpu,
const SkSL::String& msl,
ShaderErrorHandler* errorHandler);
#ifdef SK_BUILD_FOR_IOS
bool IsAppInBackground();
#endif
} // namespace skgpu::mtl
} // namespace skgpu
#endif // skgpu_MtlUtils_DEFINED