Minor fixes to avoid NVPR in Vulkan and provide good GrVkGpu teardown.

BUG=skia:5097
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1818093002

Review URL: https://codereview.chromium.org/1818093002
diff --git a/src/gpu/GrContextFactory.cpp b/src/gpu/GrContextFactory.cpp
index bcf0c32..fc1af6c 100755
--- a/src/gpu/GrContextFactory.cpp
+++ b/src/gpu/GrContextFactory.cpp
@@ -129,7 +129,11 @@
     glCtx->makeCurrent();
     GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface.get());
 #ifdef SK_VULKAN
-    grCtx.reset(GrContext::Create(kVulkan_GrBackend, p3dctx, fGlobalOptions));
+    if (kEnableNVPR_GLContextOptions & options) {
+        return ContextInfo();
+    } else {
+        grCtx.reset(GrContext::Create(kVulkan_GrBackend, p3dctx, fGlobalOptions));
+    }
 #else
     grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, fGlobalOptions));
 #endif
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 96c74dd..0666f10 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -356,9 +356,11 @@
     fCurrentCmdBuffer->unref(this);
 
     // wait for all commands to finish
+    fResourceProvider.checkCommandBuffers();
     VkResult res = VK_CALL(QueueWaitIdle(fQueue));
-    SkASSERT(res == VK_SUCCESS);
-
+    // VK_ERROR_DEVICE_LOST is acceptable when tearing down (see 4.2.4 in spec)
+    SkASSERT(VK_SUCCESS == res || VK_ERROR_DEVICE_LOST == res);
+ 
     // must call this just before we destroy the VkDevice
     fResourceProvider.destroyResources();