Move the rest of Vulkan driver workarounds into helper function in GrVkCaps

Move workaround for fSRGBsupport before config table init in GrVkCaps

No-Tree-Checks: true

Bug: skia:
Change-Id: Ic9dfc9d09b3fd1d6c8491f6da0d46d03c125a10f
Reviewed-On: https://skia-review.googlesource.com/111440
Reviewed-By: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-on: https://skia-review.googlesource.com/111462
Reviewed-by: Hal Canary <halcanary@google.com>
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index a439bfa..e56d0e8 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -85,6 +85,16 @@
 
     this->initGrCaps(properties, memoryProperties, featureFlags);
     this->initShaderCaps(properties, featureFlags);
+
+    if (!contextOptions.fDisableDriverCorrectnessWorkarounds) {
+#if defined(SK_CPU_X86)
+        // We need to do this before initing the config table since it uses fSRGBSupport
+        if (kImagination_VkVendor == properties.vendorID) {
+            fSRGBSupport = false;
+        }
+#endif
+    }
+
     this->initConfigTable(vkInterface, physDev, properties);
     this->initStencilFormat(vkInterface, physDev);
 
@@ -112,10 +122,6 @@
         fCrossContextTextureSupport = false;
     }
 
-    if (kARM_VkVendor == properties.vendorID) {
-        fInstanceAttribSupport = false;
-    }
-
 #if defined(SK_BUILD_FOR_WIN)
     if (kNvidia_VkVendor == properties.vendorID) {
         fMustSleepOnTearDown = true;
@@ -125,6 +131,45 @@
         fMustSleepOnTearDown = true;
     }
 #endif
+
+    // AMD seems to have issues binding new VkPipelines inside a secondary command buffer.
+    // Current workaround is to use a different secondary command buffer for each new VkPipeline.
+    if (kAMD_VkVendor == properties.vendorID) {
+        fNewCBOnPipelineChange = true;
+    }
+
+    ////////////////////////////////////////////////////////////////////////////
+    // GrCaps workarounds
+    ////////////////////////////////////////////////////////////////////////////
+
+    if (kARM_VkVendor == properties.vendorID) {
+        fInstanceAttribSupport = false;
+    }
+
+    // AMD advertises support for MAX_UINT vertex input attributes, but in reality only supports 32.
+    if (kAMD_VkVendor == properties.vendorID) {
+        fMaxVertexAttributes = SkTMin(fMaxVertexAttributes, 32);
+    }
+
+    if (kIntel_VkVendor == properties.vendorID) {
+        fCanUseWholeSizeOnFlushMappedMemory = false;
+    }
+
+    ////////////////////////////////////////////////////////////////////////////
+    // GrShaderCaps workarounds
+    ////////////////////////////////////////////////////////////////////////////
+
+    if (kAMD_VkVendor == properties.vendorID) {
+        // Currently DualSourceBlending is not working on AMD. vkCreateGraphicsPipeline fails when
+        // using a draw with dual source. Looking into whether it is driver bug or issue with our
+        // SPIR-V. Bug skia:6405
+        fShaderCaps->fDualSourceBlendingSupport = false;
+    }
+
+    if (kImagination_VkVendor == properties.vendorID) {
+        fShaderCaps->fAtan2ImplementedAsAtanYOverX = true;
+    }
+
 }
 
 int get_max_sample_count(VkSampleCountFlags flags) {
@@ -159,10 +204,6 @@
     // we ever find that need.
     static const uint32_t kMaxVertexAttributes = 64;
     fMaxVertexAttributes = SkTMin(properties.limits.maxVertexInputAttributes, kMaxVertexAttributes);
-    // AMD advertises support for MAX_UINT vertex input attributes, but in reality only supports 32.
-    if (kAMD_VkVendor == properties.vendorID) {
-        fMaxVertexAttributes = SkTMin(fMaxVertexAttributes, 32);
-    }
 
     // We could actually query and get a max size for each config, however maxImageDimension2D will
     // give the minimum max size across all configs. So for simplicity we will use that for now.
@@ -178,21 +219,7 @@
     fOversizedStencilSupport = true;
     fSampleShadingSupport = SkToBool(featureFlags & kSampleRateShading_GrVkFeatureFlag);
 
-    // AMD seems to have issues binding new VkPipelines inside a secondary command buffer.
-    // Current workaround is to use a different secondary command buffer for each new VkPipeline.
-    if (kAMD_VkVendor == properties.vendorID) {
-        fNewCBOnPipelineChange = true;
-    }
 
-    if (kIntel_VkVendor == properties.vendorID) {
-        fCanUseWholeSizeOnFlushMappedMemory = false;
-    }
-
-#if defined(SK_CPU_X86)
-    if (kImagination_VkVendor == properties.vendorID) {
-        fSRGBSupport = false;
-    }
-#endif
 }
 
 void GrVkCaps::initShaderCaps(const VkPhysicalDeviceProperties& properties, uint32_t featureFlags) {
@@ -225,10 +252,6 @@
         }
     }
 
-    if (kImagination_VkVendor == properties.vendorID) {
-        shaderCaps->fAtan2ImplementedAsAtanYOverX = true;
-    }
-
     // Vulkan is based off ES 3.0 so the following should all be supported
     shaderCaps->fUsesPrecisionModifiers = true;
     shaderCaps->fFlatInterpolationSupport = true;
@@ -244,12 +267,6 @@
     shaderCaps->fGSInvocationsSupport = shaderCaps->fGeometryShaderSupport;
 
     shaderCaps->fDualSourceBlendingSupport = SkToBool(featureFlags & kDualSrcBlend_GrVkFeatureFlag);
-    if (kAMD_VkVendor == properties.vendorID) {
-        // Currently DualSourceBlending is not working on AMD. vkCreateGraphicsPipeline fails when
-        // using a draw with dual source. Looking into whether it is driver bug or issue with our
-        // SPIR-V. Bug skia:6405
-        shaderCaps->fDualSourceBlendingSupport = false;
-    }
 
     shaderCaps->fIntegerSupport = true;
     shaderCaps->fTexelBufferSupport = true;