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();
80 enum class GPUFamily {
84 static bool GetGPUFamily(id<MTLDevice>
device, GPUFamily* gpuFamily,
int* group);
85 static bool GetGPUFamilyFromFeatureSet(id<MTLDevice>
device, GPUFamily* gpuFamily,
90 return fColorTypeToFormatTable[idx];
96 bool isTexturable(MTLPixelFormat)
const;
97 bool isRenderable(MTLPixelFormat, uint32_t numSamples)
const;
98 uint32_t maxRenderTargetSampleCount(MTLPixelFormat)
const;
105 const TextureInfo& dstTextureInfo,
109 const TextureInfo& srcTextureInfo,
112 MTLStorageMode getDefaultMSAAStorageMode(
Discardable discardable)
const;
116 for (
int i = 0; i < fColorTypeInfoCount; ++i) {
118 return fColorTypeInfos[i].fFlags;
125 kTexturable_Flag = 0x01,
126 kRenderable_Flag = 0x02,
128 kResolve_Flag = 0x08,
129 kStorage_Flag = 0x10,
131 static const uint16_t kAllFlags =
132 kTexturable_Flag | kRenderable_Flag | kMSAA_Flag | kResolve_Flag | kStorage_Flag;
136 std::unique_ptr<ColorTypeInfo[]> fColorTypeInfos;
137 int fColorTypeInfoCount = 0;
139#ifdef SK_BUILD_FOR_MAC
140 inline static constexpr size_t kNumMtlFormats = 21;
142 inline static constexpr size_t kNumMtlFormats = 20;
145 static size_t GetFormatIndex(MTLPixelFormat);
146 FormatInfo fFormatTable[kNumMtlFormats];
148 const FormatInfo& getFormatInfo(
const MTLPixelFormat pixelFormat)
const {
149 size_t index = GetFormatIndex(pixelFormat);
150 return fFormatTable[index];
154 void setColorType(
SkColorType, std::initializer_list<MTLPixelFormat> formats);
157 std::vector<uint32_t> fColorSampleCounts;
159 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
std::pair< SkColorType, bool > supportedWritePixelsColorType(SkColorType dstColorType, const TextureInfo &dstTextureInfo, SkColorType srcColorType) const override
bool extractGraphicsDescs(const UniqueKey &, GraphicsPipelineDesc *, RenderPassDesc *, const RendererProvider *) const override
bool isStorage(const TextureInfo &) const override
bool supportsReadPixels(const TextureInfo &) const override
TextureInfo getDefaultSampledTextureInfo(SkColorType, Mipmapped mipmapped, Protected, Renderable) const override
bool onIsTexturable(const TextureInfo &) const override
bool supportsWritePixels(const TextureInfo &) const override
TextureInfo getDefaultDepthStencilTextureInfo(SkEnumBitMask< DepthStencilFlags >, uint32_t sampleCount, Protected) const override
std::pair< SkColorType, bool > supportedReadPixelsColorType(SkColorType srcColorType, const TextureInfo &srcTextureInfo, SkColorType dstColorType) 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
const ColorTypeInfo * getColorTypeInfo(SkColorType, const TextureInfo &) const override