| 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 |
|
| 30 |
inline bool SkSLToMSL(const SkSL::ShaderCaps* caps, |
| 31 |
const std::string& sksl, |
| 32 |
SkSL::ProgramKind programKind, |
| 33 |
const SkSL::ProgramSettings& settings, |
| 34 |
SkSL::NativeShader* msl, |
| 35 |
SkSL::ProgramInterface* outInterface, |
| 36 |
ShaderErrorHandler* errorHandler) { |
| 37 |
return SkSLToBackend(caps, |
| 38 |
&SkSL::ToMetal, |
| 39 |
"MSL", |
| 40 |
sksl, |
| 41 |
programKind, |
| 42 |
settings, |
| 43 |
msl, |
| 44 |
outInterface, |
| 45 |
errorHandler); |
| 46 |
} |
| 47 |
|
| 48 |
bool MtlFormatIsCompressed(MTLPixelFormat); |
| 49 |
|
| 50 |
// NOTE: All of these functions are actually only used by Ganesh. When building Graphite in |
| 51 |
// isolation, the linker should drop them. |
| 52 |
|
| 53 |
uint32_t MtlFormatChannels(MTLPixelFormat); |
| 54 |
|
| 55 |
size_t MtlFormatBytesPerBlock(MTLPixelFormat); |
| 56 |
|
| 57 |
SkTextureCompressionType MtlFormatToCompressionType(MTLPixelFormat); |
| 58 |
|
| 59 |
const char* MtlFormatToString(MTLPixelFormat); |
| 60 |
|
| 61 |
} // namespace skgpu |
| 62 |
|
| 63 |
#endif // skgpu_MtlUtilsPriv_DEFINED |