30#if defined(GR_TEST_UTILS)
34#if !__has_feature(objc_arc)
35#error This file must be compiled with Arc. Use -fobjc-arc flag
44 this->initGPUFamily(
device);
46 this->initShaderCaps();
48 this->applyDriverCorrectnessWorkarounds(contextOptions,
device);
51 this->initFormatTable();
52 this->initStencilFormat(
device);
55 fStoreAndMultisampleResolveSupport = (fGPUFamily == GPUFamily::kApple &&
64bool GrMtlCaps::getGPUFamilyFromFeatureSet(id<MTLDevice>
device,
68#if GR_METAL_SDK_VERSION < 300
70#if defined(SK_BUILD_FOR_MAC)
72 *gpuFamily = GPUFamily::kMac;
74 if (@available(macOS 10.14, *)) {
75 if ([
device supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily2_v1]) {
79 if ([
device supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v4]) {
85 if (@available(macOS 10.13, *)) {
86 if ([
device supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v3]) {
92 if (@available(macOS 10.12, *)) {
93 if ([
device supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v2]) {
99 if (@available(macOS 10.11, *)) {
100 if ([
device supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v1]) {
105#elif defined(SK_BUILD_FOR_IOS)
107 *gpuFamily = GPUFamily::kApple;
109 if (@available(iOS 12.0, tvOS 12.0, *)) {
110 if ([
device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily5_v1]) {
114 if ([
device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily4_v2]) {
118 if ([
device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v4]) {
122 if ([
device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily2_v5]) {
126 if ([
device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v5]) {
132 if (@available(iOS 11.0, tvOS 11.0, *)) {
133 if ([
device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily4_v1]) {
137 if ([
device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v3]) {
141 if ([
device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily2_v4]) {
145 if ([
device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v4]) {
151 if (@available(iOS 10.0, tvOS 10.0, *)) {
152 if ([
device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v2]) {
156 if ([
device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily2_v3]) {
160 if ([
device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v3]) {
174bool GrMtlCaps::getGPUFamily(id<MTLDevice>
device, GPUFamily* gpuFamily,
int*
group) {
175#if GR_METAL_SDK_VERSION >= 220
176 if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) {
178#if GR_METAL_SDK_VERSION >= 230
179 if ([
device supportsFamily:MTLGPUFamilyApple7]) {
180 *gpuFamily = GPUFamily::kApple;
185#ifdef SK_BUILD_FOR_IOS
186 if ([
device supportsFamily:MTLGPUFamilyApple6]) {
187 *gpuFamily = GPUFamily::kApple;
191 if ([
device supportsFamily:MTLGPUFamilyApple5]) {
192 *gpuFamily = GPUFamily::kApple;
196 if ([
device supportsFamily:MTLGPUFamilyApple4]) {
197 *gpuFamily = GPUFamily::kApple;
201 if ([
device supportsFamily:MTLGPUFamilyApple3]) {
202 *gpuFamily = GPUFamily::kApple;
206 if ([
device supportsFamily:MTLGPUFamilyApple2]) {
207 *gpuFamily = GPUFamily::kApple;
211 if ([
device supportsFamily:MTLGPUFamilyApple1]) {
212 *gpuFamily = GPUFamily::kApple;
219#if GR_METAL_SDK_VERSION >= 300
222 *gpuFamily = GPUFamily::kMac;
228 if ([
device supportsFamily:MTLGPUFamilyMac2] ||
229 [
device supportsFamily:MTLGPUFamilyMacCatalyst2]) {
230 *gpuFamily = GPUFamily::kMac;
234 if ([
device supportsFamily:MTLGPUFamilyMac1] ||
235 [
device supportsFamily:MTLGPUFamilyMacCatalyst1]) {
236 *gpuFamily = GPUFamily::kMac;
248void GrMtlCaps::initGPUFamily(id<MTLDevice>
device) {
249 if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) {
250 if (this->getGPUFamily(
device, &fGPUFamily, &fFamilyGroup)) {
254 if (this->getGPUFamilyFromFeatureSet(
device, &fGPUFamily, &fFamilyGroup)) {
259#ifdef SK_BUILD_FOR_MAC
260 fGPUFamily = GPUFamily::kMac;
263 fGPUFamily = GPUFamily::kApple;
269 MTLPixelFormat srcFormat,
int srcSampleCount,
271 bool areDstSrcSameObj)
const {
272 if (!dstFormat || dstFormat != srcFormat) {
275 if ((dstSampleCount > 1 || srcSampleCount > 1) && (dstSampleCount != srcSampleCount)) {
278 if (areDstSrcSameObj) {
289 MTLPixelFormat srcFormat,
int srcSampleCount,
290 bool srcIsRenderTarget,
const SkISize srcDimensions,
293 bool areDstSrcSameObj)
const {
294 if (areDstSrcSameObj) {
297 if (dstFormat != srcFormat) {
300 if (dstSampleCount > 1 || srcSampleCount == 1 || !srcIsRenderTarget) {
318 if (srcRect.
size() != dstRect.
size()) {
322 int dstSampleCnt = 1;
323 int srcSampleCnt = 1;
325 dstSampleCnt = rtProxy->numSamples();
328 srcSampleCnt = rtProxy->numSamples();
336 srcRect, dstPoint,
dst ==
src)) {
339 bool srcIsRenderTarget =
src->asRenderTargetProxy();
343 srcFormat, srcSampleCnt,
344 srcIsRenderTarget,
src->backingStoreDimensions(), srcRect,
349void GrMtlCaps::initGrCaps(id<MTLDevice>
device) {
350#if defined(GR_TEST_UTILS)
351 this->setDeviceName([[
device name] UTF8String]);
366 if (this->
isMac() || fFamilyGroup >= 3) {
391 if (@available(iOS 9.0, tvOS 9.0, *)) {
392 for (
auto sampleCnt : {2, 4, 8}) {
393 if ([
device supportsTextureSampleCount:sampleCnt]) {
401#ifdef SK_BUILD_FOR_MAC
402 if (@available(macOS 10.12, *)) {
429 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
430 if (this->
isMac() || fFamilyGroup >= 3) {
438 bool supportsMTLEvent =
false;
439 if (@available(macOS 10.14, iOS 12.0, tvOS 12.0, *)) {
440 supportsMTLEvent =
true;
454 case MTLPixelFormatRGBA8Unorm_sRGB:
455 case MTLPixelFormatBGRA8Unorm_sRGB:
472 const FormatInfo& formatInfo = this->getFormatInfo(
format);
473 return SkToBool(FormatInfo::kTexturable_Flag & formatInfo.fFlags);
477 int sampleCount)
const {
482 SkASSERT(mtlFormat != MTLPixelFormatInvalid);
483 const auto&
info = this->getFormatInfo(mtlFormat);
484 if (!
SkToBool(
info.colorTypeFlags(ct) & ColorTypeInfo::kRenderable_Flag)) {
503 const FormatInfo& formatInfo = this->getFormatInfo(
format);
504 if (formatInfo.fFlags & FormatInfo::kMSAA_Flag) {
505 return fSampleCounts[fSampleCounts.
size() - 1];
506 }
else if (formatInfo.fFlags & FormatInfo::kRenderable_Flag) {
520 requestedCount =
std::max(requestedCount, 1);
521 const FormatInfo& formatInfo = this->getFormatInfo(
format);
522 if (!(formatInfo.fFlags & FormatInfo::kRenderable_Flag)) {
525 if (formatInfo.fFlags & FormatInfo::kMSAA_Flag) {
528 if (fSampleCounts[
i] >= requestedCount) {
529 return fSampleCounts[
i];
533 return 1 == requestedCount ? 1 : 0;
536void GrMtlCaps::initShaderCaps() {
549 if (@available(macOS 10.12, iOS 11.0, tvOS 11.0, *)) {
580void GrMtlCaps::applyDriverCorrectnessWorkarounds(
const GrContextOptions&,
const id<MTLDevice>) {
586#define kMTLPixelFormatB5G6R5Unorm MTLPixelFormat(40)
587#define kMTLPixelFormatABGR4Unorm MTLPixelFormat(42)
588#define kMTLPixelFormatETC2_RGB8 MTLPixelFormat(180)
593 MTLPixelFormatRGBA8Unorm,
594 MTLPixelFormatR8Unorm,
595 MTLPixelFormatA8Unorm,
596 MTLPixelFormatBGRA8Unorm,
598 MTLPixelFormatRGBA16Float,
599 MTLPixelFormatR16Float,
600 MTLPixelFormatRG8Unorm,
601 MTLPixelFormatRGB10A2Unorm,
602 MTLPixelFormatBGR10A2Unorm,
604 MTLPixelFormatRGBA8Unorm_sRGB,
605 MTLPixelFormatR16Unorm,
606 MTLPixelFormatRG16Unorm,
608#ifdef SK_BUILD_FOR_MAC
609 MTLPixelFormatBC1_RGBA,
611 MTLPixelFormatRGBA16Unorm,
612 MTLPixelFormatRG16Float,
614 MTLPixelFormatInvalid,
617void GrMtlCaps::setColorType(
GrColorType colorType, std::initializer_list<MTLPixelFormat> formats) {
619 for (
size_t i = 0;
i < kNumMtlFormats; ++
i) {
620 const auto& formatInfo = fFormatTable[
i];
621 for (
int j = 0; j < formatInfo.fColorTypeInfoCount; ++j) {
622 const auto& ctInfo = formatInfo.fColorTypeInfos[j];
625 for (
auto it = formats.begin(); it != formats.end(); ++it) {
636 for (
auto it = formats.begin(); it != formats.end(); ++it) {
637 const auto&
info = this->getFormatInfo(*it);
638 for (
int i = 0;
i <
info.fColorTypeInfoCount; ++
i) {
640 fColorTypeToFormatTable[idx] = *it;
647size_t GrMtlCaps::GetFormatIndex(MTLPixelFormat pixelFormat) {
649 "Size of kMtlFormats array must match static value in header");
650 for (
size_t i = 0;
i < GrMtlCaps::kNumMtlFormats; ++
i) {
655 SK_ABORT(
"Invalid MTLPixelFormat: %d",
static_cast<int>(pixelFormat));
658void GrMtlCaps::initFormatTable() {
661 if (@available(macos 11.0, *)) {
669 info = &fFormatTable[GetFormatIndex(MTLPixelFormatR8Unorm)];
670 info->fFlags = FormatInfo::kAllFlags;
671 info->fColorTypeInfoCount = 3;
672 info->fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info->fColorTypeInfoCount);
676 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
678 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
682 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
684 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
690 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
692 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
699 info = &fFormatTable[GetFormatIndex(MTLPixelFormatA8Unorm)];
700 info->fFlags = FormatInfo::kTexturable_Flag;
701 info->fColorTypeInfoCount = 1;
702 info->fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info->fColorTypeInfoCount);
706 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
708 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
712 if (@available(macOS 11.0, iOS 8.0, tvOS 9.0, *)) {
716 info = &fFormatTable[GetFormatIndex(MTLPixelFormatB5G6R5Unorm)];
717 info->fFlags = FormatInfo::kAllFlags;
718 info->fColorTypeInfoCount = 1;
719 info->fColorTypeInfos =
720 std::make_unique<ColorTypeInfo[]>(
info->fColorTypeInfoCount);
724 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
726 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag |
727 ColorTypeInfo::kRenderable_Flag;
733 info = &fFormatTable[GetFormatIndex(MTLPixelFormatABGR4Unorm)];
734 info->fFlags = FormatInfo::kAllFlags;
735 info->fColorTypeInfoCount = 1;
736 info->fColorTypeInfos =
737 std::make_unique<ColorTypeInfo[]>(
info->fColorTypeInfoCount);
741 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
743 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag |
744 ColorTypeInfo::kRenderable_Flag;
752 info = &fFormatTable[GetFormatIndex(MTLPixelFormatRGBA8Unorm)];
753 info->fFlags = FormatInfo::kAllFlags;
754 info->fColorTypeInfoCount = 2;
755 info->fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info->fColorTypeInfoCount);
759 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
761 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
765 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
767 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
774 info = &fFormatTable[GetFormatIndex(MTLPixelFormatRG8Unorm)];
775 info->fFlags = FormatInfo::kAllFlags;
776 info->fColorTypeInfoCount = 1;
777 info->fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info->fColorTypeInfoCount);
781 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
783 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
789 info = &fFormatTable[GetFormatIndex(MTLPixelFormatBGRA8Unorm)];
790 info->fFlags = FormatInfo::kAllFlags;
791 info->fColorTypeInfoCount = 1;
792 info->fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info->fColorTypeInfoCount);
796 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
798 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
804 info = &fFormatTable[GetFormatIndex(MTLPixelFormatRGBA8Unorm_sRGB)];
805 info->fFlags = FormatInfo::kAllFlags;
806 info->fColorTypeInfoCount = 1;
807 info->fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info->fColorTypeInfoCount);
811 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
813 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
819 info = &fFormatTable[GetFormatIndex(MTLPixelFormatRGB10A2Unorm)];
820 if (this->
isMac() || fFamilyGroup >= 3) {
821 info->fFlags = FormatInfo::kAllFlags;
823 info->fFlags = FormatInfo::kTexturable_Flag;
825 info->fColorTypeInfoCount = 1;
826 info->fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info->fColorTypeInfoCount);
830 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
832 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
837 if (@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)) {
838 info = &fFormatTable[GetFormatIndex(MTLPixelFormatBGR10A2Unorm)];
839 if (this->
isMac() && fFamilyGroup == 1) {
840 info->fFlags = FormatInfo::kTexturable_Flag;
842 info->fFlags = FormatInfo::kAllFlags;
844 info->fColorTypeInfoCount = 1;
845 info->fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info->fColorTypeInfoCount);
849 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
851 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
857 info = &fFormatTable[GetFormatIndex(MTLPixelFormatR16Float)];
858 info->fFlags = FormatInfo::kAllFlags;
859 info->fColorTypeInfoCount = 1;
860 info->fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info->fColorTypeInfoCount);
864 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
866 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
874 info = &fFormatTable[GetFormatIndex(MTLPixelFormatRGBA16Float)];
875 info->fFlags = FormatInfo::kAllFlags;
876 info->fColorTypeInfoCount = 2;
877 info->fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info->fColorTypeInfoCount);
881 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
883 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
887 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
889 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
895 info = &fFormatTable[GetFormatIndex(MTLPixelFormatR16Unorm)];
897 info->fFlags = FormatInfo::kAllFlags;
899 info->fFlags = FormatInfo::kTexturable_Flag | FormatInfo::kRenderable_Flag;
901 info->fColorTypeInfoCount = 1;
902 info->fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info->fColorTypeInfoCount);
906 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
908 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
916 info = &fFormatTable[GetFormatIndex(MTLPixelFormatRG16Unorm)];
918 info->fFlags = FormatInfo::kAllFlags;
920 info->fFlags = FormatInfo::kTexturable_Flag | FormatInfo::kRenderable_Flag;
922 info->fColorTypeInfoCount = 1;
923 info->fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info->fColorTypeInfoCount);
927 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
929 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
933 if (@available(macOS 11.0, iOS 8.0, tvOS 9.0, *)) {
936 info = &fFormatTable[GetFormatIndex(MTLPixelFormatETC2_RGB8)];
937 info->fFlags = FormatInfo::kTexturable_Flag;
941#ifdef SK_BUILD_FOR_MAC
944 info = &fFormatTable[GetFormatIndex(MTLPixelFormatBC1_RGBA)];
945 info->fFlags = FormatInfo::kTexturable_Flag;
952 info = &fFormatTable[GetFormatIndex(MTLPixelFormatRGBA16Unorm)];
954 info->fFlags = FormatInfo::kAllFlags;
956 info->fFlags = FormatInfo::kTexturable_Flag | FormatInfo::kRenderable_Flag;
958 info->fColorTypeInfoCount = 1;
959 info->fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info->fColorTypeInfoCount);
963 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
965 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
971 info = &fFormatTable[GetFormatIndex(MTLPixelFormatRG16Float)];
972 info->fFlags = FormatInfo::kAllFlags;
973 info->fColorTypeInfoCount = 1;
974 info->fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info->fColorTypeInfoCount);
978 auto& ctInfo =
info->fColorTypeInfos[ctIdx++];
980 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
989 std::fill_n(fColorTypeToFormatTable,
kGrColorTypeCnt, MTLPixelFormatInvalid);
992 MTLPixelFormatA8Unorm });
993 if (@available(macOS 11.0, iOS 8.0, tvOS 9.0, *)) {
1005 if (@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)) {
1018void GrMtlCaps::initStencilFormat(id<MTLDevice> physDev) {
1019 fPreferredStencilFormat = MTLPixelFormatStencil8;
1022bool GrMtlCaps::onSurfaceSupportsWritePixels(
const GrSurface*
surface)
const {
1023 if (
auto rt =
surface->asRenderTarget()) {
1039 if (mtlRT->numSamples() > 1 && !mtlRT->resolveAttachment()) {
1052 if (
auto rtProxy =
src->asRenderTargetProxy()) {
1053 if (rtProxy->numSamples() > 1) {
1058 return restrictions;
1061bool GrMtlCaps::onAreColorTypeAndFormatCompatible(
GrColorType ct,
1065 const auto&
info = this->getFormatInfo(mtlFormat);
1066 for (
int i = 0;
i <
info.fColorTypeInfoCount; ++
i) {
1067 if (
info.fColorTypeInfos[
i].fColorType == ct) {
1084 switch (compressionType) {
1088 if (@available(macOS 11.0, *)) {
1101#ifdef SK_BUILD_FOR_MAC
1102 if (this->
isMac()) {
1112 SK_ABORT(
"Invalid compression type");
1118 SkASSERT(mtlFormat != MTLPixelFormatInvalid);
1119 const auto&
info = this->getFormatInfo(mtlFormat);
1120 for (
int i = 0;
i <
info.fColorTypeInfoCount; ++
i) {
1121 const auto& ctInfo =
info.fColorTypeInfos[
i];
1123 return ctInfo.fReadSwizzle;
1127 static_cast<int>(mtlFormat));
1134 SkASSERT(mtlFormat != MTLPixelFormatInvalid);
1135 const auto&
info = this->getFormatInfo(mtlFormat);
1136 for (
int i = 0;
i <
info.fColorTypeInfoCount; ++
i) {
1137 const auto& ctInfo =
info.fColorTypeInfos[
i];
1139 return ctInfo.fWriteSwizzle;
1143 static_cast<int>(mtlFormat));
1149 SkASSERT(mtlFormat != MTLPixelFormatInvalid);
1153 static_assert(
sizeof(MTLPixelFormat) <=
sizeof(uint64_t));
1154 return (uint64_t)mtlFormat;
1165 for (
int i = 0;
i <
info.fColorTypeInfoCount; ++
i) {
1166 const auto& ctInfo =
info.fColorTypeInfos[
i];
1167 if (ctInfo.fColorType == surfaceColorType) {
1168 return {surfaceColorType, offsetAlignment};
1179#ifdef SK_BUILD_FOR_IOS
1193 const auto&
info = this->getFormatInfo(mtlFormat);
1194 for (
int i = 0;
i <
info.fColorTypeInfoCount; ++
i) {
1195 const auto& ctInfo =
info.fColorTypeInfos[
i];
1196 if (ctInfo.fColorType == srcColorType) {
1197 return {srcColorType, offsetAlignment};
1227 b.add32(programInfo.
needsStencil() ? this->preferredStencilFormat() : MTLPixelFormatInvalid);
1242 desc.keyLength() -
desc.initialKeyLength());
1248 return (MTLPixelFormat) readBuffer.
readUInt();
1257#if defined(GR_TEST_UTILS)
1258std::vector<GrTest::TestFormatColorTypeCombination> GrMtlCaps::getTestingCombinations()
const {
1259 std::vector<GrTest::TestFormatColorTypeCombination> combos = {
1268#ifdef SK_BUILD_FOR_MAC
1289#ifdef SK_ENABLE_DUMP_GPU
1302 switch (fGPUFamily) {
1303 case GPUFamily::kMac:
1306 case GPUFamily::kApple:
1313 writer->
appendS32(
"Family Group", fFamilyGroup);
1316 for (
int v : fSampleCounts) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
SkTextureCompressionType GrBackendFormatToCompressionType(const GrBackendFormat &format)
static constexpr MTLPixelFormat kMtlFormats[]
#define kMTLPixelFormatB5G6R5Unorm
#define kMTLPixelFormatETC2_RGB8
static bool format_is_srgb(MTLPixelFormat format)
#define kMTLPixelFormatABGR4Unorm
int GrMtlFormatStencilBits(MTLPixelFormat)
static MTLPixelFormat GrBackendFormatAsMTLPixelFormat(const GrBackendFormat &format)
static constexpr size_t GrColorTypeBytesPerPixel(GrColorType ct)
static const int kGrColorTypeCnt
#define SK_ABORT(message,...)
#define SkDEBUGFAILF(fmt,...)
static constexpr bool SkTextureCompressionTypeIsOpaque(SkTextureCompressionType compression)
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static constexpr bool SkToBool(const T &x)
bool fDynamicStateArrayGeometryProcessorTextureSupport
int fMaxPreferredRenderTargetSize
bool fFinishedProcAsyncCallbackSupport
bool fReadPixelsRowBytesSupport
const GrShaderCaps * shaderCaps() const
std::unique_ptr< GrShaderCaps > fShaderCaps
bool fReuseScratchTextures
bool fNativeDrawIndirectSupport
uint32_t fMaxPushConstantsSize
bool fTransferFromBufferToBufferSupport
bool fTransferFromBufferToTextureSupport
bool fTextureBarrierSupport
bool fBuffersAreInitiallyZero
bool fTransferPixelsToRowBytesSupport
bool preferDiscardableMSAAAttachment() const
bool fBackendSemaphoreSupport
bool fHalfFloatVertexAttributeSupport
bool fClampToBorderSupport
bool fSampleLocationsSupport
bool fOversizedStencilSupport
bool fPerformPartialClearsAsDraws
bool fWritePixelsRowBytesSupport
size_t fTransferBufferRowBytesAlignment
bool fNPOTTextureTileSupport
bool fTransferFromSurfaceToBufferSupport
void finishInitialization(const GrContextOptions &options)
size_t fBufferUpdateDataPreserveAlignment
bool fPreferDiscardableMSAAAttachment
bool fDrawInstancedSupport
size_t fTransferFromBufferToBufferAlignment
bool fCrossContextTextureSupport
bool framebufferOnly() const
SurfaceReadPixelsSupport surfaceSupportsReadPixels(const GrSurface *) const override
bool isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat &format, int sampleCount=1) const override
int maxRenderTargetSampleCount(const GrBackendFormat &) const override
DstCopyRestrictions getDstCopyRestrictions(const GrRenderTargetProxy *src, GrColorType ct) const override
bool isFormatSRGB(const GrBackendFormat &) const override
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)
bool isFormatRenderable(const GrBackendFormat &format, int sampleCount) 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
GrMtlAttachment * resolveAttachment() const
void genKey(skgpu::KeyBuilder *, const GrCaps &) const
static void Build(GrProgramDesc *, const GrProgramInfo &, const GrCaps &)
uint16_t primitiveTypeKey() const
const GrPipeline & pipeline() const
bool isStencilEnabled() const
const GrBackendFormat & backendFormat() const
const GrBackendFormat & backendFormat() const
void appendS32(int32_t value)
void appendNString(char const (&value)[N])
void beginArray(const char *name=nullptr, bool multiline=true)
void beginObject(const char *name=nullptr, bool multiline=true)
void push_back(const T &v)
static constexpr Swizzle RGB1()
uint32_t uint32_t * format
static float max(float r, float g, float b)
DEF_SWITCHES_START aot vmservice shared library name
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
bool MtlFormatIsCompressed(MTLPixelFormat mtlFormat)
size_t MtlFormatBytesPerBlock(MTLPixelFormat mtlFormat)
GrSurfaceProxy::RectsMustMatch fRectsMustMatch
bool fDisableDriverCorrectnessWorkarounds
bool fDstReadInShaderSupport
bool fPreferFlatInterpolation
bool fNonconstantArrayIndexSupport
constexpr int32_t y() const
static constexpr SkIPoint Make(int32_t x, int32_t y)
constexpr int32_t x() const
bool intersect(const SkIRect &r)
constexpr SkISize size() const
constexpr int32_t height() const
static constexpr SkIRect MakeSize(const SkISize &size)
constexpr int32_t width() const
constexpr SkIPoint topLeft() const
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
bool fFBFetchNeedsCustomOutput
bool fExplicitTextureLodSupport
bool fDualSourceBlendingSupport
const char * fFBFetchColorName
bool fShaderDerivativeSupport
bool fFlatInterpolationSupport
bool fInverseHyperbolicSupport
bool fNonsquareMatrixSupport
bool fUsesPrecisionModifiers