8#ifndef GrMtlCaps_DEFINED
9#define GrMtlCaps_DEFINED
15#import <Metal/Metal.h>
35 int sampleCount = 1)
const override;
58 return fPreferredStencilFormat;
61 bool canCopyAsBlit(MTLPixelFormat dstFormat,
int dstSampleCount,
62 MTLPixelFormat srcFormat,
int srcSampleCount,
64 bool areDstSrcSameObj)
const;
67 MTLPixelFormat srcFormat,
int srcSampleCount,
68 bool srcIsRenderTarget,
const SkISize srcDimensions,
71 bool areDstSrcSameObj)
const;
77 return fColorTypeToFormatTable[idx];
89 bool isMac()
const {
return fGPUFamily == GPUFamily::kMac; }
90 bool isApple()
const {
return fGPUFamily == GPUFamily::kApple; }
99#if defined(GR_TEST_UTILS)
100 std::vector<GrTest::TestFormatColorTypeCombination> getTestingCombinations()
const override;
105 void initGPUFamily(id<MTLDevice>
device);
107 void initStencilFormat(id<MTLDevice>
device);
109 void initGrCaps(id<MTLDevice>
device);
110 void initShaderCaps();
112 void applyDriverCorrectnessWorkarounds(
const GrContextOptions&,
const id<MTLDevice>);
114 void initFormatTable();
116 bool onSurfaceSupportsWritePixels(
const GrSurface*)
const override;
128 struct ColorTypeInfo {
131 kUploadData_Flag = 0x1,
134 kRenderable_Flag = 0x2,
144 for (
int i = 0;
i < fColorTypeInfoCount; ++
i) {
146 return fColorTypeInfos[
i].fFlags;
153 kTexturable_Flag = 0x1,
154 kRenderable_Flag = 0x2,
158 static const uint16_t kAllFlags = kTexturable_Flag | kRenderable_Flag |
159 kMSAA_Flag | kResolve_Flag;
163 std::unique_ptr<ColorTypeInfo[]> fColorTypeInfos;
164 int fColorTypeInfoCount = 0;
166#ifdef SK_BUILD_FOR_IOS
167 inline static constexpr size_t kNumMtlFormats = 18;
169 inline static constexpr size_t kNumMtlFormats = 19;
171 static size_t GetFormatIndex(MTLPixelFormat);
172 FormatInfo fFormatTable[kNumMtlFormats];
174 const FormatInfo& getFormatInfo(
const MTLPixelFormat pixelFormat)
const {
175 size_t index = GetFormatIndex(pixelFormat);
176 return fFormatTable[index];
180 void setColorType(
GrColorType, std::initializer_list<MTLPixelFormat> formats);
182 enum class GPUFamily {
186 bool getGPUFamily(id<MTLDevice>
device, GPUFamily* gpuFamily,
int*
group);
187 bool getGPUFamilyFromFeatureSet(id<MTLDevice>
device, GrMtlCaps::GPUFamily* gpuFamily,
190 GPUFamily fGPUFamily;
195 MTLPixelFormat fPreferredStencilFormat;
197 bool fStoreAndMultisampleResolveSupport : 1;
static const int kGrColorTypeCnt
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
GrCaps(const GrContextOptions &)
SurfaceReadPixelsSupport surfaceSupportsReadPixels(const GrSurface *) const override
bool isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat &format, int sampleCount=1) const override
int maxRenderTargetSampleCount(const GrBackendFormat &) const override
bool storeAndMultisampleResolveSupport() const
DstCopyRestrictions getDstCopyRestrictions(const GrRenderTargetProxy *src, GrColorType ct) const override
bool isFormatSRGB(const GrBackendFormat &) const override
MTLPixelFormat preferredStencilFormat() const
MTLPixelFormat getFormatFromColorType(GrColorType colorType) const
bool canCopyAsBlit(MTLPixelFormat dstFormat, int dstSampleCount, MTLPixelFormat srcFormat, int srcSampleCount, const SkIRect &srcRect, const SkIPoint &dstPoint, bool areDstSrcSameObj) const
bool isFormatTexturable(const GrBackendFormat &, GrTextureType) const override
int getRenderTargetSampleCount(int requestedCount, const GrBackendFormat &) const override
bool canCopyAsResolve(MTLPixelFormat dstFormat, int dstSampleCount, MTLPixelFormat srcFormat, int srcSampleCount, bool srcIsRenderTarget, const SkISize srcDimensions, const SkIRect &srcRect, const SkIPoint &dstPoint, bool areDstSrcSameObj) const
GrBackendFormat getBackendFormatFromCompressionType(SkTextureCompressionType) const override
SupportedWrite supportedWritePixelsColorType(GrColorType surfaceColorType, const GrBackendFormat &surfaceFormat, GrColorType srcColorType) const override
skgpu::Swizzle getWriteSwizzle(const GrBackendFormat &, GrColorType) const override
uint64_t computeFormatKey(const GrBackendFormat &) const override
GrMtlCaps(const GrContextOptions &contextOptions, id< MTLDevice > device)
size_t getMinBufferAlignment() const
bool isFormatRenderable(const GrBackendFormat &format, int sampleCount) const override
bool isFormatCopyable(const GrBackendFormat &) const override
void onDumpJSON(SkJSONWriter *) const override
MTLPixelFormat getStencilPixelFormat(const GrProgramDesc &desc) const
bool renderTargetSupportsDiscardableMSAA(const GrMtlRenderTarget *) const
GrProgramDesc makeDesc(GrRenderTarget *, const GrProgramInfo &, ProgramDescOverrideFlags) const override
uint32_t uint32_t * format