fix for GrVkGpu not always unreffing all command pools

Bug: skia:
Change-Id: I2a122aa25f5a8bedb413b2dca3b53637f8ddd604
Reviewed-on: https://skia-review.googlesource.com/c/176975
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/gpu/vk/GrVkResourceProvider.cpp b/src/gpu/vk/GrVkResourceProvider.cpp
index 2b54878..99b4d12 100644
--- a/src/gpu/vk/GrVkResourceProvider.cpp
+++ b/src/gpu/vk/GrVkResourceProvider.cpp
@@ -330,6 +330,11 @@
 }
 
 void GrVkResourceProvider::destroyResources(bool deviceLost) {
+    SkTaskGroup* taskGroup = fGpu->getContext()->contextPriv().getTaskGroup();
+    if (taskGroup) {
+        taskGroup->wait();
+    }
+
     // Release all copy pipelines
     for (int i = 0; i < fCopyPipelines.count(); ++i) {
         fCopyPipelines[i]->unref(fGpu);
@@ -381,6 +386,11 @@
 }
 
 void GrVkResourceProvider::abandonResources() {
+    SkTaskGroup* taskGroup = fGpu->getContext()->contextPriv().getTaskGroup();
+    if (taskGroup) {
+        taskGroup->wait();
+    }
+
     // Abandon all command pools
     for (int i = 0; i < fActiveCommandPools.count(); ++i) {
         SkASSERT(fActiveCommandPools[i]->unique());