39#ifdef SK_BUILD_FOR_ANDROID
40#include <sys/system_properties.h>
45 VkPhysicalDevice physDev,
47 uint32_t instanceVersion,
48 uint32_t physicalDeviceVersion,
86 this->init(contextOptions, vkInterface, physDev, features, physicalDeviceVersion,
extensions,
95enum class FormatCompatibilityClass {
117 return FormatCompatibilityClass::k32_4_1;
120 return FormatCompatibilityClass::k8_1_1;
129 return FormatCompatibilityClass::k16_2_1;
133 return FormatCompatibilityClass::k64_8_1;
136 return FormatCompatibilityClass::k24_3_1;
139 return FormatCompatibilityClass::k10x6_64_6_1;
142 return FormatCompatibilityClass::kETC2_RGB_8_16;
145 return FormatCompatibilityClass::kBC1_RGB_8_16_1;
148 return FormatCompatibilityClass::kBC1_RGBA_8_16;
156 VkFormat srcFormat,
int srcSampleCnt,
bool srcHasYcbcr)
const {
157 if ((dstSampleCnt > 1 || srcSampleCnt > 1) && dstSampleCnt != srcSampleCnt) {
161 if (dstHasYcbcr || srcHasYcbcr) {
171 bool dstHasYcbcr,
VkFormat srcFormat,
int srcSampleCnt,
172 bool srcIsLinear,
bool srcHasYcbcr)
const {
182 if (dstSampleCnt > 1 || srcSampleCnt > 1) {
186 if (dstHasYcbcr || srcHasYcbcr) {
194 VkFormat srcFormat,
int srcSampleCnt,
bool srcHasYcbcr)
const {
196 if (srcSampleCnt <= 1) {
201 if (dstSampleCnt > 1) {
206 if (srcFormat != dstFormat) {
210 if (dstHasYcbcr || srcHasYcbcr) {
227 bool srcIsLinear =
false;
228 bool dstIsLinear =
false;
230 int dstSampleCnt = 0;
231 int srcSampleCnt = 0;
236 if (rtProxy->wrapsVkSecondaryCB()) {
240 rtProxy->supportsVkInputAttachment()) {
243 dstSampleCnt = rtProxy->numSamples();
250 if (rtProxy->wrapsVkSecondaryCB()) {
254 rtProxy->supportsVkInputAttachment()) {
257 srcSampleCnt = rtProxy->numSamples();
263 bool dstHasYcbcr =
false;
265 if (ycbcr->isValid()) {
270 bool srcHasYcbcr =
false;
272 if (ycbcr->isValid()) {
283 const bool copyScales = srcRect.
size() != dstRect.
size();
284 if (!copyScales && (this->
canCopyImage(dstFormat, dstSampleCnt, dstHasYcbcr,
285 srcFormat, srcSampleCnt, srcHasYcbcr) ||
287 srcFormat, srcSampleCnt, srcHasYcbcr))) {
290 return this->
canCopyAsBlit(dstFormat, dstSampleCnt, dstIsLinear, dstHasYcbcr,
291 srcFormat, srcSampleCnt, srcIsLinear, srcHasYcbcr);
297 VkPhysicalDevice physDev,
299 uint32_t physicalDeviceVersion,
303 GR_VK_CALL(vkInterface, GetPhysicalDeviceProperties(physDev, &properties));
305#if defined(GR_TEST_UTILS)
310 GR_VK_CALL(vkInterface, GetPhysicalDeviceMemoryProperties(physDev, &memoryProperties));
315 fSupportsSwapchain =
true;
320 fSupportsPhysicalDeviceProperties2 =
true;
325 fSupportsMemoryRequirements2 =
true;
330 fSupportsBindMemory2 =
true;
335 fSupportsMaintenance1 =
true;
340 fSupportsMaintenance2 =
true;
345 fSupportsMaintenance3 =
true;
350 this->supportsMemoryRequirements2())) {
351 fSupportsDedicatedAllocation =
true;
356 this->supportsPhysicalDeviceProperties2() &&
358 this->supportsDedicatedAllocation())) {
359 fSupportsExternalMemory =
true;
362#ifdef SK_BUILD_FOR_ANDROID
368 this->supportsExternalMemory() &&
369 this->supportsBindMemory2()) {
370 fSupportsAndroidHWBExternalMemory =
true;
379 if (ycbcrFeatures && ycbcrFeatures->samplerYcbcrConversion &&
382 this->supportsMaintenance1() && this->supportsBindMemory2() &&
383 this->supportsMemoryRequirements2() && this->supportsPhysicalDeviceProperties2()))) {
384 fSupportsYcbcrConversion =
true;
394 fAvoidUpdateBuffers =
true;
395 fShouldAlwaysUseDedicatedImageMemory =
true;
399 fSupportsDRMFormatModifiers =
true;
403 fSupportsDeviceFaultInfo =
true;
419 if (kARM_VkVendor == properties.
vendorID) {
429 this->initGrCaps(vkInterface, physDev, properties, memoryProperties, features,
extensions);
430 this->initShaderCaps(properties, features);
432 if (kQualcomm_VkVendor == properties.
vendorID) {
440 if (properties.
vendorID == kNvidia_VkVendor || properties.
vendorID == kAMD_VkVendor) {
443 fGpuOnlyBuffersMorePerformant =
true;
450 fShouldPersistentlyMapCpuToGpuBuffers =
false;
453 if (kQualcomm_VkVendor == properties.
vendorID) {
456 fAvoidUpdateBuffers =
true;
460 if (properties.
vendorID == kQualcomm_VkVendor) {
467 SkASSERT(fMaxDrawIndirectDrawCount == 1 || features.features.multiDrawIndirect);
470#ifdef SK_BUILD_FOR_UNIX
471 if (kNvidia_VkVendor == properties.
vendorID) {
473 fShouldAlwaysUseDedicatedImageMemory =
true;
477 this->initFormatTable(contextOptions, vkInterface, physDev, properties, features,
extensions);
478 this->initStencilFormat(vkInterface, physDev);
481 fMaxPerPoolCachedSecondaryCommandBuffers =
486 this->applyDriverCorrectnessWorkarounds(properties);
493#if defined(SK_BUILD_FOR_WIN)
494 if (kNvidia_VkVendor == properties.
vendorID || kIntel_VkVendor == properties.
vendorID) {
495 fMustSyncCommandBuffersWithQueue =
true;
497#elif defined(SK_BUILD_FOR_ANDROID)
498 if (kImagination_VkVendor == properties.
vendorID) {
499 fMustSyncCommandBuffersWithQueue =
true;
506 int androidAPIVersion = 0;
507#if defined(SK_BUILD_FOR_ANDROID)
508 char androidAPIVersionStr[PROP_VALUE_MAX];
509 int strLength = __system_property_get(
"ro.build.version.sdk", androidAPIVersionStr);
512 androidAPIVersion = (strLength == 0) ? 0 : atoi(androidAPIVersionStr);
517 if (androidAPIVersion <= 28) {
523 if (kARM_VkVendor == properties.
vendorID && androidAPIVersion <= 28) {
524 fShouldAlwaysUseDedicatedImageMemory =
true;
529 if (kARM_VkVendor == properties.
vendorID && androidAPIVersion <= 28) {
530 fPreferPrimaryOverSecondaryCommandBuffers =
false;
540 if (properties.
vendorID == kQualcomm_VkVendor && androidAPIVersion <= 28) {
542 fSupportsDiscardableMSAAForDMSAA =
false;
547 if (kARM_VkVendor == properties.
vendorID) {
554 if (kQualcomm_VkVendor == properties.
vendorID || kAMD_VkVendor == properties.
vendorID) {
555 fMustInvalidatePrimaryCmdBufferStateAfterClearAttachments =
true;
562 if (properties.
vendorID == kQualcomm_VkVendor ||
563 properties.
vendorID == kARM_VkVendor ||
564 (properties.
vendorID == kGoogle_VkVendor &&
565 properties.
deviceID == kSwiftshader_DeviceID)) {
566 fMustLoadFullImageWithDiscardableMSAA =
true;
574 if (properties.
vendorID == kGoogle_VkVendor && properties.
deviceID == kSwiftshader_DeviceID) {
582 if (kARM_VkVendor == properties.
vendorID) {
587 if (kAMD_VkVendor == properties.
vendorID) {
593 if (kQualcomm_VkVendor == properties.
vendorID) {
597#ifdef SK_BUILD_FOR_WIN
608 if (kIntel_VkVendor == properties.
vendorID &&
609 GetIntelGen(GetIntelGPUType(properties.
deviceID)) >= 9) {
616 if (properties.
vendorID == kARM_VkVendor && androidAPIVersion <= 28) {
624 if (kImagination_VkVendor == properties.
vendorID) {
630 if (kARM_VkVendor == properties.
vendorID) {
636 VkPhysicalDevice physDev,
645 static const uint32_t kMaxVertexAttributes = 64;
647 kMaxVertexAttributes);
681 this->supportsPhysicalDeviceProperties2()) {
686 blendProps.
pNext =
nullptr;
690 props.
pNext = &blendProps;
692 GR_VK_CALL(vkInterface, GetPhysicalDeviceProperties2(physDev, &props));
702 if (blendFeatures && blendFeatures->advancedBlendCoherentOperations ==
VK_TRUE) {
710 if (kARM_VkVendor == properties.
vendorID) {
756 VkPhysicalDevice physDev,
760 GR_VK_CALL(interface, GetPhysicalDeviceFormatProperties(physDev,
format, &props));
765 VkPhysicalDevice physDev) {
819 for (
size_t i = 0;
i < kNumVkFormats; ++
i) {
820 const auto& formatInfo = fFormatTable[
i];
821 for (
int j = 0; j < formatInfo.fColorTypeInfoCount; ++j) {
822 const auto& ctInfo = formatInfo.fColorTypeInfos[j];
824 !
SkToBool(ctInfo.fFlags & ColorTypeInfo::kWrappedOnly_Flag)) {
826 for (
auto it = formats.begin(); it != formats.end(); ++it) {
837 for (
auto it = formats.begin(); it != formats.end(); ++it) {
838 const auto&
info = this->getFormatInfo(*it);
839 for (
int i = 0;
i <
info.fColorTypeInfoCount; ++
i) {
841 fColorTypeToFormatTable[idx] = *it;
848const GrVkCaps::FormatInfo& GrVkCaps::getFormatInfo(
VkFormat format)
const {
850 return nonConstThis->getFormatInfo(
format);
855 "Size of VkFormats array must match static value in header");
858 return fFormatTable[
i];
861 static FormatInfo kInvalidFormat;
862 return kInvalidFormat;
867 VkPhysicalDevice physDev,
872 "Size of VkFormats array must match static value in header");
881 info.init(contextOptions, interface, physDev, properties,
format);
882 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
883 info.fColorTypeInfoCount = 2;
884 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
889 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
890 ctInfo.fColorType = ct;
891 ctInfo.fTransferColorType = ct;
892 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
897 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
898 ctInfo.fColorType = ct;
899 ctInfo.fTransferColorType = ct;
900 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
910 info.init(contextOptions, interface, physDev, properties,
format);
911 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
912 info.fColorTypeInfoCount = 3;
913 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
918 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
919 ctInfo.fColorType = ct;
920 ctInfo.fTransferColorType = ct;
921 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
926 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
927 ctInfo.fColorType = ct;
928 ctInfo.fTransferColorType = ct;
929 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
936 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
937 ctInfo.fColorType = ct;
938 ctInfo.fTransferColorType = ct;
939 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
948 info.init(contextOptions, interface, physDev, properties,
format);
949 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
950 info.fColorTypeInfoCount = 2;
951 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
956 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
957 ctInfo.fColorType = ct;
958 ctInfo.fTransferColorType = ct;
959 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
965 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
966 ctInfo.fColorType = ct;
968 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
977 info.init(contextOptions, interface, physDev, properties,
format);
978 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
979 info.fColorTypeInfoCount = 1;
980 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
985 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
986 ctInfo.fColorType = ct;
987 ctInfo.fTransferColorType = ct;
988 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
996 info.init(contextOptions, interface, physDev, properties,
format);
997 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
998 info.fColorTypeInfoCount = 2;
999 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
1004 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1005 ctInfo.fColorType = ct;
1006 ctInfo.fTransferColorType = ct;
1007 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
1013 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1014 ctInfo.fColorType = ct;
1016 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
1024 info.init(contextOptions, interface, physDev, properties,
format);
1025 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
1026 info.fColorTypeInfoCount = 2;
1027 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
1032 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1033 ctInfo.fColorType = ct;
1034 ctInfo.fTransferColorType = ct;
1035 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
1040 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1041 ctInfo.fColorType = ct;
1042 ctInfo.fTransferColorType = ct;
1043 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
1051 info.init(contextOptions, interface, physDev, properties,
format);
1052 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
1053 info.fColorTypeInfoCount = 1;
1054 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
1059 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1060 ctInfo.fColorType = ct;
1061 ctInfo.fTransferColorType = ct;
1062 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
1072 info.init(contextOptions, interface, physDev, properties,
format);
1073 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
1074 info.fColorTypeInfoCount = 1;
1075 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
1080 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1081 ctInfo.fColorType = ct;
1084 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
1092 info.init(contextOptions, interface, physDev, properties,
format);
1093 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
1094 info.fColorTypeInfoCount = 1;
1095 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
1100 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1101 ctInfo.fColorType = ct;
1102 ctInfo.fTransferColorType = ct;
1103 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
1111 info.init(contextOptions, interface, physDev, properties,
format);
1112 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
1113 info.fColorTypeInfoCount = 1;
1114 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
1119 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1120 ctInfo.fColorType = ct;
1121 ctInfo.fTransferColorType = ct;
1122 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
1130 info.init(contextOptions, interface, physDev, properties,
format);
1131 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
1132 info.fColorTypeInfoCount = 1;
1133 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
1138 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1139 ctInfo.fColorType = ct;
1140 ctInfo.fTransferColorType = ct;
1141 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
1146 bool supportsRGBA10x6 =
false;
1148 auto rgba10x6Feature =
1149 skgpu::GetExtensionFeatureStruct<VkPhysicalDeviceRGBA10X6FormatsFeaturesEXT>(
1154 supportsRGBA10x6 = rgba10x6Feature && rgba10x6Feature->formatRgba10x6WithoutYCbCrSampler;
1158 if (supportsRGBA10x6) {
1161 info.init(contextOptions, interface, physDev, properties,
format);
1162 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
1163 info.fColorTypeInfoCount = 1;
1164 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
1169 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1170 ctInfo.fColorType = ct;
1171 ctInfo.fTransferColorType = ct;
1172 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
1181 info.init(contextOptions, interface, physDev, properties,
format);
1182 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
1183 info.fColorTypeInfoCount = 1;
1184 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
1189 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1190 ctInfo.fColorType = ct;
1191 ctInfo.fTransferColorType = ct;
1192 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
1203 info.init(contextOptions, interface, physDev, properties,
format);
1204 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
1205 info.fColorTypeInfoCount = 1;
1206 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
1211 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1212 ctInfo.fColorType = ct;
1213 ctInfo.fTransferColorType = ct;
1214 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
1222 info.init(contextOptions, interface, physDev, properties,
format);
1223 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
1224 info.fColorTypeInfoCount = 1;
1225 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
1230 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1231 ctInfo.fColorType = ct;
1232 ctInfo.fTransferColorType = ct;
1233 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
1241 info.init(contextOptions, interface, physDev, properties,
format);
1242 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
1243 info.fColorTypeInfoCount = 1;
1244 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
1249 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1250 ctInfo.fColorType = ct;
1251 ctInfo.fTransferColorType = ct;
1252 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
1262 info.init(contextOptions, interface, physDev, properties,
format);
1263 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
1264 info.fColorTypeInfoCount = 1;
1265 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
1270 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1271 ctInfo.fColorType = ct;
1272 ctInfo.fTransferColorType = ct;
1273 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
1281 info.init(contextOptions, interface, physDev, properties,
format);
1282 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
1283 info.fColorTypeInfoCount = 1;
1284 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
1289 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1290 ctInfo.fColorType = ct;
1291 ctInfo.fTransferColorType = ct;
1292 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
1300 info.init(contextOptions, interface, physDev, properties,
format);
1301 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
1302 info.fColorTypeInfoCount = 1;
1303 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
1308 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1309 ctInfo.fColorType = ct;
1310 ctInfo.fTransferColorType = ct;
1311 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
1319 if (fSupportsYcbcrConversion) {
1320 info.init(contextOptions, interface, physDev, properties,
format);
1322 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
1323 info.fColorTypeInfoCount = 1;
1324 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
1329 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1330 ctInfo.fColorType = ct;
1331 ctInfo.fTransferColorType = ct;
1332 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kWrappedOnly_Flag;
1340 if (fSupportsYcbcrConversion) {
1341 info.init(contextOptions, interface, physDev, properties,
format);
1343 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
1344 info.fColorTypeInfoCount = 1;
1345 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
1350 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1351 ctInfo.fColorType = ct;
1352 ctInfo.fTransferColorType = ct;
1353 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kWrappedOnly_Flag;
1361 if (fSupportsYcbcrConversion) {
1362 info.init(contextOptions, interface, physDev, properties,
format);
1364 if (
SkToBool(
info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
1365 info.fColorTypeInfoCount = 1;
1366 info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(
info.fColorTypeInfoCount);
1371 auto& ctInfo =
info.fColorTypeInfos[ctIdx++];
1372 ctInfo.fColorType = ct;
1373 ctInfo.fTransferColorType = ct;
1374 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kWrappedOnly_Flag;
1382 info.init(contextOptions, interface, physDev, properties,
format);
1391 info.init(contextOptions, interface, physDev, properties,
format);
1400 info.init(contextOptions, interface, physDev, properties,
format);
1458void GrVkCaps::FormatInfo::initSampleCounts(
const GrContextOptions& contextOptions,
1460 VkPhysicalDevice physDev,
1468 GR_VK_CALL(interface, GetPhysicalDeviceImageFormatProperties(physDev,
1477 fColorSampleCounts.push_back(1);
1479 if (kImagination_VkVendor == physProps.
vendorID) {
1483 if (kIntel_VkVendor == physProps.
vendorID) {
1484 if (GetIntelGen(GetIntelGPUType(physProps.
deviceID)) < 12 ||
1491 fColorSampleCounts.push_back(2);
1494 fColorSampleCounts.push_back(4);
1497 fColorSampleCounts.push_back(8);
1500 fColorSampleCounts.push_back(16);
1508 VkPhysicalDevice physDev,
1513 GR_VK_CALL(interface, GetPhysicalDeviceFormatProperties(physDev,
format, &props));
1516 if (fOptimalFlags & kRenderable_Flag) {
1517 this->initSampleCounts(contextOptions, interface, physDev, properties,
format);
1567 const FormatInfo&
info = this->getFormatInfo(
format);
1568 return SkToBool(FormatInfo::kTexturable_Flag &
info.fOptimalFlags);
1572 int sampleCount)
const {
1580 const auto&
info = this->getFormatInfo(vkFormat);
1581 if (!
SkToBool(
info.colorTypeFlags(ct) & ColorTypeInfo::kRenderable_Flag)) {
1610 requestedCount =
std::max(1, requestedCount);
1612 const FormatInfo&
info = this->getFormatInfo(
format);
1614 int count =
info.fColorSampleCounts.size();
1620 if (1 == requestedCount) {
1621 SkASSERT(!
info.fColorSampleCounts.empty() &&
info.fColorSampleCounts[0] == 1);
1626 if (
info.fColorSampleCounts[
i] >= requestedCount) {
1627 return info.fColorSampleCounts[
i];
1642 const FormatInfo&
info = this->getFormatInfo(
format);
1644 const auto&
table =
info.fColorSampleCounts;
1645 if (
table.empty()) {
1656 case 2:
return 2 * v;
1658 default:
return 4 * v;
1679 const auto&
info = this->getFormatInfo(vkFormat);
1680 for (
int i = 0;
i <
info.fColorTypeInfoCount; ++
i) {
1681 const auto& ctInfo =
info.fColorTypeInfos[
i];
1682 if (ctInfo.fColorType == surfaceColorType) {
1683 return {ctInfo.fTransferColorType, offsetAlignment};
1695 auto texImage = tex->textureImage();
1700 if (texImage->ycbcrConversionInfo().isValid()) {
1708 }
else if (
auto rt =
surface->asRenderTarget()) {
1709 if (rt->numSamples() > 1) {
1718 const auto&
info = this->getFormatInfo(vkFormat);
1719 for (
int i = 0;
i <
info.fColorTypeInfoCount; ++
i) {
1720 if (
info.fColorTypeInfos[
i].fColorType == surfaceColorType) {
1721 return info.fColorTypeInfos[
i].fTransferColorType;
1727bool GrVkCaps::onSurfaceSupportsWritePixels(
const GrSurface*
surface)
const {
1728 if (
auto rt =
surface->asRenderTarget()) {
1733 auto texImage = tex->textureImage();
1738 if (texImage->ycbcrConversionInfo().isValid()) {
1745bool GrVkCaps::onAreColorTypeAndFormatCompatible(
GrColorType ct,
1763 const auto&
info = this->getFormatInfo(vkFormat);
1764 for (
int i = 0;
i <
info.fColorTypeInfoCount; ++
i) {
1765 if (
info.fColorTypeInfos[
i].fColorType == ct) {
1805 switch (compressionType) {
1841 const auto&
info = this->getFormatInfo(vkFormat);
1842 for (
int i = 0;
i <
info.fColorTypeInfoCount; ++
i) {
1843 const auto& ctInfo =
info.fColorTypeInfos[
i];
1845 return ctInfo.fReadSwizzle;
1848 SkDEBUGFAILF(
"Illegal color type (%d) and format (%d) combination.",
1857 const auto&
info = this->getFormatInfo(vkFormat);
1858 for (
int i = 0;
i <
info.fColorTypeInfoCount; ++
i) {
1859 const auto& ctInfo =
info.fColorTypeInfos[
i];
1861 return ctInfo.fWriteSwizzle;
1864 SkDEBUGFAILF(
"Illegal color type (%d) and format (%d) combination.",
1893 return (uint64_t)vkFormat;
1917 const auto&
info = this->getFormatInfo(vkFormat);
1918 for (
int i = 0;
i <
info.fColorTypeInfoCount; ++
i) {
1919 const auto& ctInfo =
info.fColorTypeInfos[
i];
1920 if (ctInfo.fColorType == srcColorType) {
1921 return {ctInfo.fTransferColorType, offsetAlignment};
1946 constexpr size_t numInts = (
sizeof(
key) + 3) / 4;
1947 uint32_t tmp[numInts];
1948 memcpy(tmp, &
key,
sizeof(
key));
1950 for (
size_t i = 0;
i < numInts; ++
i) {
1993 bool forceLoadFromResolve =
1995 SkASSERT(!forceLoadFromResolve || needsResolve);
2016 if (!rp->isExternal()) {
2022 &attachmentsDescriptor,
2024 SkASSERT(rp->isCompatible(attachmentsDescriptor, attachmentFlags, selfDepFlags,
2032 &attachmentsDescriptor,
2039 loadFromResolve, 0);
2067 return std::find(array.begin(), array.end(), deviceID) != array.end();
2071GrVkCaps::IntelGPUType GrVkCaps::GetIntelGPUType(uint32_t deviceID) {
2076 static constexpr std::array<uint32_t, 25> kSkyLakeIDs = {
2077 {0x1902, 0x1906, 0x190A, 0x190B, 0x190E, 0x1912, 0x1913,
2078 0x1915, 0x1916, 0x1917, 0x191A, 0x191B, 0x191D, 0x191E,
2079 0x1921, 0x1923, 0x1926, 0x1927, 0x192A, 0x192B, 0x192D,
2080 0x1932, 0x193A, 0x193B, 0x193D}};
2081 static constexpr std::array<uint32_t, 14> kIceLakeIDs = {
2082 {0x8A50, 0x8A51, 0x8A52, 0x8A53, 0x8A54, 0x8A56, 0x8A57,
2083 0x8A58, 0x8A59, 0x8A5A, 0x8A5B, 0x8A5C, 0x8A5D, 0x8A71}};
2084 static constexpr std::array<uint32_t, 5> kRocketLakeIDs = {
2085 {0x4c8a, 0x4c8b, 0x4c8c, 0x4c90, 0x4c9a}};
2086 static constexpr std::array<uint32_t, 11> kTigerLakeIDs = {
2087 {0x9A40, 0x9A49, 0x9A59, 0x9A60, 0x9A68, 0x9A70,
2088 0x9A78, 0x9AC0, 0x9AC9, 0x9AD9, 0x9AF8}};
2089 static constexpr std::array<uint32_t, 10> kAlderLakeIDs = {
2090 {0x4680, 0x4681, 0x4682, 0x4683, 0x4690,
2091 0x4691, 0x4692, 0x4693, 0x4698, 0x4699}};
2094 return IntelGPUType::kSkyLake;
2097 return IntelGPUType::kIceLake;
2100 return IntelGPUType::kRocketLake;
2103 return IntelGPUType::kTigerLake;
2106 return IntelGPUType::kAlderLake;
2108 return IntelGPUType::kOther;
2111#if defined(GR_TEST_UTILS)
2112std::vector<GrTest::TestFormatColorTypeCombination> GrVkCaps::getTestingCombinations()
const {
2113 std::vector<GrTest::TestFormatColorTypeCombination> combos = {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
SkTextureCompressionType GrBackendFormatToCompressionType(const GrBackendFormat &format)
@ kRequiresTextureBarrier
static const int kGrColorTypeCnt
@ kVkRTSupportsInputAttachment
static bool format_is_srgb(VkFormat format)
static size_t align_to_4(size_t v)
bool stencil_format_supported(const skgpu::VulkanInterface *interface, VkPhysicalDevice physDev, VkFormat format)
static bool backend_format_is_external(const GrBackendFormat &format)
static FormatCompatibilityClass format_compatibility_class(VkFormat format)
static bool intel_deviceID_present(const std::array< uint32_t, N > &array, uint32_t deviceID)
static constexpr VkFormat kVkFormats[]
bool GrVkFormatIsSupported(VkFormat format)
#define GR_VK_CALL(IFACE, X)
#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)
int find(T *array, int N, T item)
bool fSupportsProtectedContent
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 preferDiscardableMSAAAttachment() const
bool fBackendSemaphoreSupport
@ kAdvancedCoherent_BlendEquationSupport
@ kAdvanced_BlendEquationSupport
@ kBasic_BlendEquationSupport
bool fHalfFloatVertexAttributeSupport
bool fSampleLocationsSupport
bool fOversizedStencilSupport
@ kVulkanHasResolveLoadSubpass
bool fReuseScratchBuffers
bool fWritePixelsRowBytesSupport
bool fShouldCollapseSrcOverToSrcWhenAble
bool fNPOTTextureTileSupport
bool fSupportsAHardwareBufferImages
bool fTransferFromSurfaceToBufferSupport
void finishInitialization(const GrContextOptions &options)
bool fAvoidWritePixelsFastPath
BlendEquationSupport fBlendEquationSupport
bool fPreferDiscardableMSAAAttachment
bool fConservativeRasterSupport
bool fDrawInstancedSupport
bool fCrossContextTextureSupport
bool fPreferFullscreenClears
void genKey(skgpu::KeyBuilder *, const GrCaps &) const
static void Build(GrProgramDesc *, const GrProgramInfo &, const GrCaps &)
uint16_t primitiveTypeKey() const
int targetsNumSamples() const
const GrPipeline & pipeline() const
bool targetHasVkResolveAttachmentWithInput() const
bool isStencilEnabled() const
GrLoadOp colorLoadOp() const
GrStencilSettings nonGLStencilSettings() const
GrXferBarrierFlags renderPassBarriers() const
bool supportsVkInputAttachment() const
void genKey(skgpu::KeyBuilder *b, bool includeRefsAndMasks) const
virtual GrTextureProxy * asTextureProxy()
bool canCopyAsResolve(VkFormat dstConfig, int dstSampleCnt, bool dstHasYcbcr, VkFormat srcConfig, int srcSamplecnt, bool srcHasYcbcr) const
bool isVkFormatTexturable(VkFormat) const
bool programInfoWillUseDiscardableMSAA(const GrProgramInfo &) const
bool canCopyAsBlit(VkFormat dstConfig, int dstSampleCnt, bool dstIsLinear, bool dstHasYcbcr, VkFormat srcConfig, int srcSampleCnt, bool srcIsLinear, bool srcHasYcbcr) const
bool formatCanBeDstofBlit(VkFormat format, bool linearTiled) const
uint64_t computeFormatKey(const GrBackendFormat &) const override
bool isFormatRenderable(const GrBackendFormat &format, int sampleCount) const override
SurfaceReadPixelsSupport surfaceSupportsReadPixels(const GrSurface *) const override
int maxRenderTargetSampleCount(const GrBackendFormat &) const override
VkShaderStageFlags getPushConstantStageFlags() const
bool renderTargetSupportsDiscardableMSAA(const GrVkRenderTarget *) const
bool isFormatTexturable(const GrBackendFormat &, GrTextureType) const override
GrProgramDesc makeDesc(GrRenderTarget *, const GrProgramInfo &, ProgramDescOverrideFlags) const override
void addExtraSamplerKey(skgpu::KeyBuilder *, GrSamplerState, const GrBackendFormat &) const override
int getFragmentUniformSet() const
bool isFormatSRGB(const GrBackendFormat &) const override
VkFormat getFormatFromColorType(GrColorType colorType) const
GrColorType transferColorType(VkFormat, GrColorType surfaceColorType) const
bool isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat &format, int sampleCount=1) const override
bool supportsDiscardableMSAAForDMSAA() const
GrBackendFormat getBackendFormatFromCompressionType(SkTextureCompressionType) const override
int getRenderTargetSampleCount(int requestedCount, const GrBackendFormat &) const override
GrInternalSurfaceFlags getExtraSurfaceFlagsForDeferredRT() const override
bool formatCanBeSrcofBlit(VkFormat format, bool linearTiled) const
SupportedWrite supportedWritePixelsColorType(GrColorType surfaceColorType, const GrBackendFormat &surfaceFormat, GrColorType srcColorType) const override
bool canCopyImage(VkFormat dstFormat, int dstSampleCnt, bool dstHasYcbcr, VkFormat srcFormat, int srcSamplecnt, bool srcHasYcbcr) const
skgpu::Swizzle getWriteSwizzle(const GrBackendFormat &, GrColorType) const override
int getFragmentUniformBinding() const
GrVkCaps(const GrContextOptions &, const skgpu::VulkanInterface *, VkPhysicalDevice, const VkPhysicalDeviceFeatures2 &, uint32_t instanceVersion, uint32_t physicalDeviceVersion, const skgpu::VulkanExtensions &, skgpu::Protected)
@ kShader_PersistentCacheKeyType
bool supportsInputAttachmentUsage() const
static void GenKey(skgpu::KeyBuilder *, AttachmentFlags, const AttachmentsDescriptor &, SelfDependencyFlags selfDepFlags, LoadFromResolve, uint64_t externalRenderPass)
@ kForNonCoherentAdvBlend
static void ReconstructAttachmentsDescriptor(const GrVkCaps &vkCaps, const GrProgramInfo &programInfo, GrVkRenderPass::AttachmentsDescriptor *desc, GrVkRenderPass::AttachmentFlags *flags)
GrVkImage * resolveAttachment() const
const GrVkRenderPass * getSimpleRenderPass(bool withResolve, bool withStencil, SelfDependencyFlags selfDepFlags, LoadFromResolve)
static SK_END_REQUIRE_DENSE Key GenerateKey(GrSamplerState, const skgpu::VulkanYcbcrConversionInfo &)
static constexpr Swizzle BGRA()
static constexpr Swizzle RGB1()
FlutterSemanticsFlag flags
uint32_t uint32_t * format
static float max(float r, float g, float b)
static float min(float r, float g, float b)
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
static constexpr size_t VkFormatBytesPerBlock(VkFormat vkFormat)
static constexpr bool VkFormatNeedsYcbcrSampler(VkFormat format)
static constexpr bool VkFormatIsCompressed(VkFormat vkFormat)
T * GetExtensionFeatureStruct(const VkPhysicalDeviceFeatures2 &features, VkStructureType type)
static void usage(char *argv0)
bool fAllowMSAAOnNewIntel
bool fDisableDriverCorrectnessWorkarounds
int fMaxCachedVulkanSecondaryCommandBuffers
bool fBitManipulationSupport
bool fPreferFlatInterpolation
bool fNonconstantArrayIndexSupport
constexpr SkISize size() const
bool fExplicitTextureLodSupport
bool fDualSourceBlendingSupport
bool fMustDeclareFragmentFrontFacing
@ kAutomatic_AdvBlendEqInteraction
bool fShaderDerivativeSupport
bool fFlatInterpolationSupport
bool fInverseHyperbolicSupport
const char * fVersionDeclString
bool fNonsquareMatrixSupport
bool fUsesPrecisionModifiers
VkBool32 advancedBlendAllOperations
VkPhysicalDeviceFeatures features
uint32_t maxPushConstantsSize
uint32_t maxImageDimension2D
VkBool32 standardSampleLocations
uint32_t maxDescriptorSetInputAttachments
float maxSamplerAnisotropy
uint32_t maxPerStageDescriptorSamplers
uint32_t maxDrawIndirectCount
uint32_t maxPerStageDescriptorSampledImages
uint32_t maxVertexInputAttributes
char deviceName[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE]
VkPhysicalDeviceLimits limits
#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME
#define VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME
VkFlags VkSampleCountFlags
@ VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT
@ VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT
@ VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT
@ VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT
@ VK_FORMAT_FEATURE_BLIT_SRC_BIT
@ VK_FORMAT_FEATURE_BLIT_DST_BIT
#define VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME
#define VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME
@ VK_SHADER_STAGE_VERTEX_BIT
@ VK_SHADER_STAGE_FRAGMENT_BIT
VkFlags VkImageUsageFlags
#define VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME
@ VK_IMAGE_TILING_OPTIMAL
#define VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME
@ VK_IMAGE_USAGE_TRANSFER_DST_BIT
@ VK_IMAGE_USAGE_SAMPLED_BIT
@ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
@ VK_IMAGE_USAGE_TRANSFER_SRC_BIT
#define VK_EXT_RGBA10X6_FORMATS_EXTENSION_NAME
#define VK_KHR_MAINTENANCE3_EXTENSION_NAME
VkFlags VkFormatFeatureFlags
VkFlags VkShaderStageFlags
#define VK_MAKE_VERSION(major, minor, patch)
#define VK_KHR_MAINTENANCE1_EXTENSION_NAME
#define VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME
#define VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME
#define VK_EXT_DEVICE_FAULT_EXTENSION_NAME
#define VK_KHR_BIND_MEMORY_2_EXTENSION_NAME
#define VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME
@ VK_FORMAT_R16G16B16A16_UNORM
@ VK_FORMAT_R8G8B8A8_SRGB
@ VK_FORMAT_D24_UNORM_S8_UINT
@ VK_FORMAT_B8G8R8A8_UNORM
@ VK_FORMAT_R16G16_SFLOAT
@ VK_FORMAT_B4G4R4A4_UNORM_PACK16
@ VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16
@ VK_FORMAT_R5G6B5_UNORM_PACK16
@ VK_FORMAT_R4G4B4A4_UNORM_PACK16
@ VK_FORMAT_A2B10G10R10_UNORM_PACK32
@ VK_FORMAT_R8G8B8A8_UNORM
@ VK_FORMAT_BC1_RGB_UNORM_BLOCK
@ VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16
@ VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM
@ VK_FORMAT_R16G16B16A16_SFLOAT
@ VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK
@ VK_FORMAT_A2R10G10B10_UNORM_PACK32
@ VK_FORMAT_BC1_RGBA_UNORM_BLOCK
@ VK_FORMAT_G8_B8R8_2PLANE_420_UNORM
@ VK_FORMAT_B5G6R5_UNORM_PACK16
@ VK_FORMAT_D32_SFLOAT_S8_UINT
#define VK_KHR_SWAPCHAIN_EXTENSION_NAME
#define VK_KHR_MAINTENANCE2_EXTENSION_NAME
@ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2
@ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES
@ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RGBA10X6_FORMATS_FEATURES_EXT
@ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_FEATURES_EXT
@ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_PROPERTIES_EXT
#define VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME