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

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>
This commit is contained in:
Greg Daniel 2018-03-01 13:13:44 -05:00 committed by Skia Commit-Bot
parent 8fb750d512
commit bce5eb99e6

View File

@ -112,10 +112,6 @@ void GrVkCaps::applyDriverCorrectnessWorkarounds(const VkPhysicalDevicePropertie
fCrossContextTextureSupport = false;
}
if (kARM_VkVendor == properties.vendorID) {
fInstanceAttribSupport = false;
}
#if defined(SK_BUILD_FOR_WIN)
if (kNvidia_VkVendor == properties.vendorID) {
fMustSleepOnTearDown = true;
@ -125,6 +121,51 @@ void GrVkCaps::applyDriverCorrectnessWorkarounds(const VkPhysicalDevicePropertie
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;
}
#if defined(SK_CPU_X86)
if (kImagination_VkVendor == properties.vendorID) {
fSRGBSupport = false;
}
#endif
////////////////////////////////////////////////////////////////////////////
// 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 +200,6 @@ void GrVkCaps::initGrCaps(const VkPhysicalDeviceProperties& properties,
// 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.
@ -181,21 +218,7 @@ void GrVkCaps::initGrCaps(const VkPhysicalDeviceProperties& properties,
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) {
@ -228,10 +251,6 @@ void GrVkCaps::initShaderCaps(const VkPhysicalDeviceProperties& properties, uint
}
}
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;
@ -247,12 +266,6 @@ void GrVkCaps::initShaderCaps(const VkPhysicalDeviceProperties& properties, uint
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;