8#ifndef skgpu_graphite_MtlCaps_DEFINED
9#define skgpu_graphite_MtlCaps_DEFINED
13#import <Metal/Metal.h>
59 bool isMac()
const {
return fGPUFamily == GPUFamily::kMac; }
60 bool isApple()
const {
return fGPUFamily == GPUFamily::kApple; }
74 void initGPUFamily(
const id<MTLDevice>);
76 void initCaps(
const id<MTLDevice>);
77 void initShaderCaps();
78 void initFormatTable(
const id<MTLDevice>);
80 enum class GPUFamily {
84 static bool GetGPUFamily(id<MTLDevice>
device, GPUFamily* gpuFamily,
int*
group);
88 return fColorTypeToFormatTable[idx];
92 const ColorTypeInfo* getColorTypeInfo(
SkColorType,
const TextureInfo&)
const override;
94 bool onIsTexturable(
const TextureInfo&)
const override;
95 bool isTexturable(MTLPixelFormat)
const;
96 bool isRenderable(MTLPixelFormat, uint32_t numSamples)
const;
97 uint32_t maxRenderTargetSampleCount(MTLPixelFormat)
const;
99 bool supportsWritePixels(
const TextureInfo&)
const override;
100 bool supportsReadPixels(
const TextureInfo&)
const override;
102 std::pair<
SkColorType,
bool > supportedWritePixelsColorType(
104 const TextureInfo& dstTextureInfo,
106 std::pair<
SkColorType,
bool > supportedReadPixelsColorType(
108 const TextureInfo& srcTextureInfo,
111 MTLStorageMode getDefaultMSAAStorageMode(
Discardable discardable)
const;
115 for (
int i = 0;
i < fColorTypeInfoCount; ++
i) {
117 return fColorTypeInfos[
i].fFlags;
124 kTexturable_Flag = 0x01,
125 kRenderable_Flag = 0x02,
127 kResolve_Flag = 0x08,
128 kStorage_Flag = 0x10,
130 static const uint16_t kAllFlags =
131 kTexturable_Flag | kRenderable_Flag | kMSAA_Flag | kResolve_Flag | kStorage_Flag;
135 std::unique_ptr<ColorTypeInfo[]> fColorTypeInfos;
136 int fColorTypeInfoCount = 0;
138#ifdef SK_BUILD_FOR_MAC
139 inline static constexpr size_t kNumMtlFormats = 23;
141 inline static constexpr size_t kNumMtlFormats = 21;
144 static size_t GetFormatIndex(MTLPixelFormat);
145 FormatInfo fFormatTable[kNumMtlFormats];
147 const FormatInfo& getFormatInfo(
const MTLPixelFormat pixelFormat)
const {
148 size_t index = GetFormatIndex(pixelFormat);
149 return fFormatTable[index];
153 void setColorType(
SkColorType, std::initializer_list<MTLPixelFormat> formats);
156 std::vector<uint32_t> fColorSampleCounts;
158 GPUFamily fGPUFamily;
static constexpr int kSkColorTypeCnt
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
void buildKeyForTexture(SkISize dimensions, const TextureInfo &, ResourceType, Shareable, GraphiteResourceKey *) const override
TextureInfo getDefaultMSAATextureInfo(const TextureInfo &singleSampledInfo, Discardable discardable) const override
TextureInfo getTextureInfoForSampledCopy(const TextureInfo &textureInfo, Mipmapped mipmapped) const override
TextureInfo getDefaultCompressedTextureInfo(SkTextureCompressionType, Mipmapped mipmapped, Protected) const override
bool extractGraphicsDescs(const UniqueKey &, GraphicsPipelineDesc *, RenderPassDesc *, const RendererProvider *) const override
bool isStorage(const TextureInfo &) const override
TextureInfo getDefaultSampledTextureInfo(SkColorType, Mipmapped mipmapped, Protected, Renderable) const override
MtlCaps(const id< MTLDevice >, const ContextOptions &)
TextureInfo getDefaultDepthStencilTextureInfo(SkEnumBitMask< DepthStencilFlags >, uint32_t sampleCount, Protected) const override
TextureInfo getDefaultStorageTextureInfo(SkColorType) const override
UniqueKey makeComputePipelineKey(const ComputePipelineDesc &) const override
uint64_t getRenderPassDescKey(const RenderPassDesc &) const
bool isRenderable(const TextureInfo &) const override
uint32_t channelMask(const TextureInfo &) const override
UniqueKey makeGraphicsPipelineKey(const GraphicsPipelineDesc &, const RenderPassDesc &) const override