Vulkan: Don't store device handles in wrapped objects.

BUG=angleproject:1684

Change-Id: I0ec11ec79f2e9893600a8ffd8cdbfc6040fb6f70
Reviewed-on: https://chromium-review.googlesource.com/426402
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/RendererVk.cpp b/src/libANGLE/renderer/vulkan/RendererVk.cpp
index 97cd393..f776828 100644
--- a/src/libANGLE/renderer/vulkan/RendererVk.cpp
+++ b/src/libANGLE/renderer/vulkan/RendererVk.cpp
@@ -106,8 +106,15 @@
         mGlslangWrapper = nullptr;
     }
 
-    mCommandBuffer.reset(nullptr);
-    mCommandPool.reset(nullptr);
+    if (mCommandBuffer.valid())
+    {
+        mCommandBuffer.destroy(mDevice);
+    }
+
+    if (mCommandPool.valid())
+    {
+        mCommandPool.destroy(mDevice);
+    }
 
     if (mDevice)
     {
@@ -417,10 +424,9 @@
     commandPoolInfo.flags            = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
     commandPoolInfo.queueFamilyIndex = mCurrentQueueFamilyIndex;
 
-    mCommandPool.reset(new vk::CommandPool(mDevice));
-    ANGLE_TRY(mCommandPool->init(commandPoolInfo));
+    ANGLE_TRY(mCommandPool.init(mDevice, commandPoolInfo));
 
-    mCommandBuffer.reset(new vk::CommandBuffer(mDevice, mCommandPool.get()));
+    mCommandBuffer.setCommandPool(&mCommandPool);
 
     return vk::NoError();
 }
@@ -553,7 +559,7 @@
 
 vk::CommandBuffer *RendererVk::getCommandBuffer()
 {
-    return mCommandBuffer.get();
+    return &mCommandBuffer;
 }
 
 vk::Error RendererVk::submitAndFinishCommandBuffer(const vk::CommandBuffer &commandBuffer)
@@ -612,17 +618,17 @@
     return vk::NoError();
 }
 
-vk::ErrorOrResult<vk::StagingImage> RendererVk::createStagingImage(TextureDimension dimension,
-                                                                   const vk::Format &format,
-                                                                   const gl::Extents &extent)
+vk::Error RendererVk::createStagingImage(TextureDimension dimension,
+                                         const vk::Format &format,
+                                         const gl::Extents &extent,
+                                         vk::StagingImage *imageOut)
 {
     ASSERT(mHostVisibleMemoryIndex != std::numeric_limits<uint32_t>::max());
 
-    vk::StagingImage stagingImage(mDevice);
-    ANGLE_TRY(stagingImage.init(mCurrentQueueFamilyIndex, mHostVisibleMemoryIndex, dimension,
-                                format.native, extent));
+    ANGLE_TRY(imageOut->init(mDevice, mCurrentQueueFamilyIndex, mHostVisibleMemoryIndex, dimension,
+                             format.native, extent));
 
-    return std::move(stagingImage);
+    return vk::NoError();
 }
 
 GlslangWrapper *RendererVk::getGlslangWrapper()