diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp index 3348916d25..1d735aa8d6 100644 --- a/src/gpu/vk/GrVkCaps.cpp +++ b/src/gpu/vk/GrVkCaps.cpp @@ -17,6 +17,7 @@ GrVkCaps::GrVkCaps(const GrContextOptions& contextOptions, const GrVkInterface* : INHERITED(contextOptions) { fCanUseGLSLForShaderModule = false; fMustDoCopiesFromOrigin = false; + fAllowInitializationErrorOnTearDown = false; /************************************************************************** * GrDrawTargetCaps fields @@ -69,6 +70,7 @@ void GrVkCaps::init(const GrContextOptions& contextOptions, const GrVkInterface* if (kQualcomm_VkVendor == properties.vendorID) { fMustDoCopiesFromOrigin = true; + fAllowInitializationErrorOnTearDown = true; } this->applyOptionsOverrides(contextOptions); diff --git a/src/gpu/vk/GrVkCaps.h b/src/gpu/vk/GrVkCaps.h index f1ab8d050a..6f46952f43 100644 --- a/src/gpu/vk/GrVkCaps.h +++ b/src/gpu/vk/GrVkCaps.h @@ -66,6 +66,10 @@ public: return fMustDoCopiesFromOrigin; } + bool allowInitializationErrorOnTearDown() const { + return fAllowInitializationErrorOnTearDown; + } + /** * Returns both a supported and most prefered stencil format to use in draws. */ @@ -119,6 +123,11 @@ private: // copyImageToBuffer. This flag says that we must do the copy starting from the origin always. bool fMustDoCopiesFromOrigin; + // On Adreno, there is a bug where vkQueueWaitIdle will once in a while return + // VK_ERROR_INITIALIZATION_FAILED instead of the required VK_SUCCESS or VK_DEVICE_LOST. This + // flag says we will accept VK_ERROR_INITIALIZATION_FAILED as well. + bool fAllowInitializationErrorOnTearDown; + typedef GrCaps INHERITED; }; diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index 82e7394330..4d410a7b3a 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -177,8 +177,15 @@ GrVkGpu::~GrVkGpu() { #endif #endif - // VK_ERROR_DEVICE_LOST is acceptable when tearing down (see 4.2.4 in spec) - SkASSERT(VK_SUCCESS == res || VK_ERROR_DEVICE_LOST == res); +#ifdef SK_DEBUG + if (this->vkCaps().allowInitializationErrorOnTearDown()) { + SkASSERT(VK_SUCCESS == res || + VK_ERROR_DEVICE_LOST == res || + VK_ERROR_INITIALIZATION_FAILED == res); + } else { + SkASSERT(VK_SUCCESS == res || VK_ERROR_DEVICE_LOST == res); + } +#endif // must call this just before we destroy the VkDevice fResourceProvider.destroyResources();