Fix corner cases where vk dependency graph breaks

There are 2 issues with the current implementation of VkReconstruct:

a. When deleting a child handle it does not erase itself from its
   parent. When doing snapshot we enumerate children handles and check
   if they are still "alive". But the handle pool is written in the way
   that it could reuse handles that have been previously destroyed,
   invalidating the "alive" check.
b. Previous dependency graph does not support one handle with multiple
   parents.

In this commit we fix (a) by making child<->parent pointer
bidirectional. When deleting a child it will be erased from its parents.

We fix (b) by rewriting a significant part of dependency graph logic on
snapshot save.

The commit also makes all destroy command to be recursive (except for
vkDestroyShaderModule), which will be handled in later commits.

Also add dependency VkFrameBuffer -> VkImageView.

Bug: 3015153
Test: GfxstreamEnd2EndVkSnapshotImageTest#ImageViewDependency
Change-Id: I7128412acffc17cf8972c53b64f3d1d335e712be
diff --git a/common/end2end/GfxstreamEnd2EndVkSnapshotImageTests.cpp b/common/end2end/GfxstreamEnd2EndVkSnapshotImageTests.cpp
index 879b461..87b2611 100644
--- a/common/end2end/GfxstreamEnd2EndVkSnapshotImageTests.cpp
+++ b/common/end2end/GfxstreamEnd2EndVkSnapshotImageTests.cpp
@@ -118,6 +118,19 @@
 
     ASSERT_THAT(device->bindImageMemory(*image, *imageMemory, 0), IsVkSuccess());
 
+    // b/331677615
+    // Create and delete a buffer handle right before creating image view.
+    // Gfxstream recycle handles. We trick the VkImageView handle to collide with
+    // a destroyed buffer handle and verify there is no bug snapshotting recycled
+    // handles.
+    const vkhpp::BufferCreateInfo bufferCreateInfo = {
+        .size = 1024,
+        .usage = vkhpp::BufferUsageFlagBits::eTransferSrc,
+    };
+    auto buffer = device->createBufferUnique(bufferCreateInfo).value;
+    ASSERT_THAT(buffer, IsValidHandle());
+    buffer.reset();
+
     const vkhpp::ImageViewCreateInfo imageViewCreateInfo = {
         .image = *image,
         .viewType = vkhpp::ImageViewType::e2D,