Format the world (or just HWUI)

Test: No code changes, just ran through clang-format
Change-Id: Id23aa4ec7eebc0446fe3a30260f33e7fd455bb8c
diff --git a/libs/hwui/renderthread/VulkanManager.cpp b/libs/hwui/renderthread/VulkanManager.cpp
index 2195143..3272d69 100644
--- a/libs/hwui/renderthread/VulkanManager.cpp
+++ b/libs/hwui/renderthread/VulkanManager.cpp
@@ -31,11 +31,10 @@
 namespace uirenderer {
 namespace renderthread {
 
-#define GET_PROC(F) m ## F = (PFN_vk ## F) vkGetInstanceProcAddr(instance, "vk" #F)
-#define GET_DEV_PROC(F) m ## F = (PFN_vk ## F) vkGetDeviceProcAddr(device, "vk" #F)
+#define GET_PROC(F) m##F = (PFN_vk##F)vkGetInstanceProcAddr(instance, "vk" #F)
+#define GET_DEV_PROC(F) m##F = (PFN_vk##F)vkGetDeviceProcAddr(device, "vk" #F)
 
-VulkanManager::VulkanManager(RenderThread& thread) : mRenderThread(thread) {
-}
+VulkanManager::VulkanManager(RenderThread& thread) : mRenderThread(thread) {}
 
 void VulkanManager::destroy() {
     if (!hasVkContext()) return;
@@ -51,12 +50,14 @@
 }
 
 void VulkanManager::initialize() {
-    if (hasVkContext()) { return; }
+    if (hasVkContext()) {
+        return;
+    }
 
     auto canPresent = [](VkInstance, VkPhysicalDevice, uint32_t) { return true; };
 
     mBackendContext.reset(GrVkBackendContext::Create(vkGetInstanceProcAddr, vkGetDeviceProcAddr,
-            &mPresentQueueIndex, canPresent));
+                                                     &mPresentQueueIndex, canPresent));
 
     // Get all the addresses of needed vulkan functions
     VkInstance instance = mBackendContext->fInstance;
@@ -99,15 +100,15 @@
         // this needs to be on the render queue
         commandPoolInfo.queueFamilyIndex = mBackendContext->fGraphicsQueueIndex;
         commandPoolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
-        SkDEBUGCODE(VkResult res =) mCreateCommandPool(mBackendContext->fDevice,
-                &commandPoolInfo, nullptr, &mCommandPool);
+        SkDEBUGCODE(VkResult res =) mCreateCommandPool(mBackendContext->fDevice, &commandPoolInfo,
+                                                       nullptr, &mCommandPool);
         SkASSERT(VK_SUCCESS == res);
     }
 
     mGetDeviceQueue(mBackendContext->fDevice, mPresentQueueIndex, 0, &mPresentQueue);
 
-    mRenderThread.setGrContext(GrContext::Create(kVulkan_GrBackend,
-            (GrBackendContext) mBackendContext.get()));
+    mRenderThread.setGrContext(
+            GrContext::Create(kVulkan_GrBackend, (GrBackendContext)mBackendContext.get()));
     DeviceInfo::initialize(mRenderThread.getGrContext()->caps()->maxRenderTargetSize());
 
     if (Properties::enablePartialUpdates && Properties::useBufferAge) {
@@ -127,13 +128,13 @@
         surface->mCurrentBackbufferIndex = 0;
     }
 
-    VulkanSurface::BackbufferInfo* backbuffer = surface->mBackbuffers +
-            surface->mCurrentBackbufferIndex;
+    VulkanSurface::BackbufferInfo* backbuffer =
+            surface->mBackbuffers + surface->mCurrentBackbufferIndex;
 
     // Before we reuse a backbuffer, make sure its fences have all signaled so that we can safely
     // reuse its commands buffers.
-    VkResult res = mWaitForFences(mBackendContext->fDevice, 2, backbuffer->mUsageFences,
-            true, UINT64_MAX);
+    VkResult res =
+            mWaitForFences(mBackendContext->fDevice, 2, backbuffer->mUsageFences, true, UINT64_MAX);
     if (res != VK_SUCCESS) {
         return nullptr;
     }
@@ -141,7 +142,6 @@
     return backbuffer;
 }
 
-
 SkSurface* VulkanManager::getBackbufferSurface(VulkanSurface* surface) {
     VulkanSurface::BackbufferInfo* backbuffer = getAvailableBackbuffer(surface);
     SkASSERT(backbuffer);
@@ -154,7 +154,8 @@
     // The acquire will signal the attached mAcquireSemaphore. We use this to know the image has
     // finished presenting and that it is safe to begin sending new commands to the returned image.
     res = mAcquireNextImageKHR(mBackendContext->fDevice, surface->mSwapchain, UINT64_MAX,
-            backbuffer->mAcquireSemaphore, VK_NULL_HANDLE, &backbuffer->mImageIndex);
+                               backbuffer->mAcquireSemaphore, VK_NULL_HANDLE,
+                               &backbuffer->mImageIndex);
 
     if (VK_ERROR_SURFACE_LOST_KHR == res) {
         // need to figure out how to create a new vkSurface without the platformData*
@@ -172,7 +173,8 @@
 
         // acquire the image
         res = mAcquireNextImageKHR(mBackendContext->fDevice, surface->mSwapchain, UINT64_MAX,
-                backbuffer->mAcquireSemaphore, VK_NULL_HANDLE, &backbuffer->mImageIndex);
+                                   backbuffer->mAcquireSemaphore, VK_NULL_HANDLE,
+                                   &backbuffer->mImageIndex);
 
         if (VK_SUCCESS != res) {
             return nullptr;
@@ -182,25 +184,25 @@
     // set up layout transfer from initial to color attachment
     VkImageLayout layout = surface->mImageInfos[backbuffer->mImageIndex].mImageLayout;
     SkASSERT(VK_IMAGE_LAYOUT_UNDEFINED == layout || VK_IMAGE_LAYOUT_PRESENT_SRC_KHR == layout);
-    VkPipelineStageFlags srcStageMask = (VK_IMAGE_LAYOUT_UNDEFINED == layout) ?
-                                        VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT :
-                                        VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+    VkPipelineStageFlags srcStageMask = (VK_IMAGE_LAYOUT_UNDEFINED == layout)
+                                                ? VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT
+                                                : VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
     VkPipelineStageFlags dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
-    VkAccessFlags srcAccessMask = (VK_IMAGE_LAYOUT_UNDEFINED == layout) ?
-                                  0 : VK_ACCESS_MEMORY_READ_BIT;
+    VkAccessFlags srcAccessMask =
+            (VK_IMAGE_LAYOUT_UNDEFINED == layout) ? 0 : VK_ACCESS_MEMORY_READ_BIT;
     VkAccessFlags dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
 
     VkImageMemoryBarrier imageMemoryBarrier = {
-        VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,    // sType
-        NULL,                                      // pNext
-        srcAccessMask,                             // outputMask
-        dstAccessMask,                             // inputMask
-        layout,                                    // oldLayout
-        VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,  // newLayout
-        mPresentQueueIndex,                        // srcQueueFamilyIndex
-        mBackendContext->fGraphicsQueueIndex,      // dstQueueFamilyIndex
-        surface->mImages[backbuffer->mImageIndex], // image
-        { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 }  // subresourceRange
+            VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,     // sType
+            NULL,                                       // pNext
+            srcAccessMask,                              // outputMask
+            dstAccessMask,                              // inputMask
+            layout,                                     // oldLayout
+            VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,   // newLayout
+            mPresentQueueIndex,                         // srcQueueFamilyIndex
+            mBackendContext->fGraphicsQueueIndex,       // dstQueueFamilyIndex
+            surface->mImages[backbuffer->mImageIndex],  // image
+            {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}     // subresourceRange
     };
     mResetCommandBuffer(backbuffer->mTransitionCmdBuffers[0], 0);
 
@@ -210,8 +212,8 @@
     info.flags = 0;
     mBeginCommandBuffer(backbuffer->mTransitionCmdBuffers[0], &info);
 
-    mCmdPipelineBarrier(backbuffer->mTransitionCmdBuffers[0], srcStageMask, dstStageMask, 0,
-            0, nullptr, 0, nullptr, 1, &imageMemoryBarrier);
+    mCmdPipelineBarrier(backbuffer->mTransitionCmdBuffers[0], srcStageMask, dstStageMask, 0, 0,
+                        nullptr, 0, nullptr, 1, &imageMemoryBarrier);
 
     mEndCommandBuffer(backbuffer->mTransitionCmdBuffers[0]);
 
@@ -235,7 +237,7 @@
     GrVkImageInfo* imageInfo;
     sk_sp<SkSurface> skSurface = surface->mImageInfos[backbuffer->mImageIndex].mSurface;
     skSurface->getRenderTargetHandle((GrBackendObject*)&imageInfo,
-            SkSurface::kFlushRead_BackendHandleAccess);
+                                     SkSurface::kFlushRead_BackendHandleAccess);
     imageInfo->updateImageLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
 
     surface->mBackbuffer = std::move(skSurface);
@@ -246,14 +248,14 @@
     if (surface->mBackbuffers) {
         for (uint32_t i = 0; i < surface->mImageCount + 1; ++i) {
             mWaitForFences(mBackendContext->fDevice, 2, surface->mBackbuffers[i].mUsageFences, true,
-                    UINT64_MAX);
+                           UINT64_MAX);
             surface->mBackbuffers[i].mImageIndex = -1;
             mDestroySemaphore(mBackendContext->fDevice, surface->mBackbuffers[i].mAcquireSemaphore,
-                    nullptr);
+                              nullptr);
             mDestroySemaphore(mBackendContext->fDevice, surface->mBackbuffers[i].mRenderSemaphore,
-                    nullptr);
+                              nullptr);
             mFreeCommandBuffers(mBackendContext->fDevice, mCommandPool, 2,
-                    surface->mBackbuffers[i].mTransitionCmdBuffers);
+                                surface->mBackbuffers[i].mTransitionCmdBuffers);
             mDestroyFence(mBackendContext->fDevice, surface->mBackbuffers[i].mUsageFences[0], 0);
             mDestroyFence(mBackendContext->fDevice, surface->mBackbuffers[i].mUsageFences[1], 0);
         }
@@ -290,11 +292,11 @@
 
 void VulkanManager::createBuffers(VulkanSurface* surface, VkFormat format, VkExtent2D extent) {
     mGetSwapchainImagesKHR(mBackendContext->fDevice, surface->mSwapchain, &surface->mImageCount,
-            nullptr);
+                           nullptr);
     SkASSERT(surface->mImageCount);
     surface->mImages = new VkImage[surface->mImageCount];
-    mGetSwapchainImagesKHR(mBackendContext->fDevice, surface->mSwapchain,
-            &surface->mImageCount, surface->mImages);
+    mGetSwapchainImagesKHR(mBackendContext->fDevice, surface->mSwapchain, &surface->mImageCount,
+                           surface->mImages);
 
     SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
 
@@ -303,7 +305,7 @@
     for (uint32_t i = 0; i < surface->mImageCount; ++i) {
         GrVkImageInfo info;
         info.fImage = surface->mImages[i];
-        info.fAlloc = { VK_NULL_HANDLE, 0, 0, 0 };
+        info.fAlloc = {VK_NULL_HANDLE, 0, 0, 0};
         info.fImageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
         info.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
         info.fFormat = format;
@@ -312,8 +314,8 @@
         GrBackendRenderTarget backendRT(extent.width, extent.height, 0, 0, info);
 
         VulkanSurface::ImageInfo& imageInfo = surface->mImageInfos[i];
-        imageInfo.mSurface = SkSurface::MakeFromBackendRenderTarget(mRenderThread.getGrContext(),
-                backendRT, kTopLeft_GrSurfaceOrigin, nullptr, &props);
+        imageInfo.mSurface = SkSurface::MakeFromBackendRenderTarget(
+                mRenderThread.getGrContext(), backendRT, kTopLeft_GrSurfaceOrigin, nullptr, &props);
     }
 
     SkASSERT(mCommandPool != VK_NULL_HANDLE);
@@ -343,16 +345,16 @@
     for (uint32_t i = 0; i < surface->mImageCount + 1; ++i) {
         SkDEBUGCODE(VkResult res);
         surface->mBackbuffers[i].mImageIndex = -1;
-        SkDEBUGCODE(res = ) mCreateSemaphore(mBackendContext->fDevice, &semaphoreInfo, nullptr,
-                &surface->mBackbuffers[i].mAcquireSemaphore);
-        SkDEBUGCODE(res = ) mCreateSemaphore(mBackendContext->fDevice, &semaphoreInfo, nullptr,
-                &surface->mBackbuffers[i].mRenderSemaphore);
-        SkDEBUGCODE(res = ) mAllocateCommandBuffers(mBackendContext->fDevice, &commandBuffersInfo,
-                surface->mBackbuffers[i].mTransitionCmdBuffers);
-        SkDEBUGCODE(res = ) mCreateFence(mBackendContext->fDevice, &fenceInfo, nullptr,
-                &surface->mBackbuffers[i].mUsageFences[0]);
-        SkDEBUGCODE(res = ) mCreateFence(mBackendContext->fDevice, &fenceInfo, nullptr,
-                &surface->mBackbuffers[i].mUsageFences[1]);
+        SkDEBUGCODE(res =) mCreateSemaphore(mBackendContext->fDevice, &semaphoreInfo, nullptr,
+                                            &surface->mBackbuffers[i].mAcquireSemaphore);
+        SkDEBUGCODE(res =) mCreateSemaphore(mBackendContext->fDevice, &semaphoreInfo, nullptr,
+                                            &surface->mBackbuffers[i].mRenderSemaphore);
+        SkDEBUGCODE(res =) mAllocateCommandBuffers(mBackendContext->fDevice, &commandBuffersInfo,
+                                                   surface->mBackbuffers[i].mTransitionCmdBuffers);
+        SkDEBUGCODE(res =) mCreateFence(mBackendContext->fDevice, &fenceInfo, nullptr,
+                                        &surface->mBackbuffers[i].mUsageFences[0]);
+        SkDEBUGCODE(res =) mCreateFence(mBackendContext->fDevice, &fenceInfo, nullptr,
+                                        &surface->mBackbuffers[i].mUsageFences[1]);
         SkASSERT(VK_SUCCESS == res);
     }
     surface->mCurrentBackbufferIndex = surface->mImageCount;
@@ -362,35 +364,36 @@
     // check for capabilities
     VkSurfaceCapabilitiesKHR caps;
     VkResult res = mGetPhysicalDeviceSurfaceCapabilitiesKHR(mBackendContext->fPhysicalDevice,
-            surface->mVkSurface, &caps);
+                                                            surface->mVkSurface, &caps);
     if (VK_SUCCESS != res) {
         return false;
     }
 
     uint32_t surfaceFormatCount;
     res = mGetPhysicalDeviceSurfaceFormatsKHR(mBackendContext->fPhysicalDevice, surface->mVkSurface,
-            &surfaceFormatCount, nullptr);
+                                              &surfaceFormatCount, nullptr);
     if (VK_SUCCESS != res) {
         return false;
     }
 
     FatVector<VkSurfaceFormatKHR, 4> surfaceFormats(surfaceFormatCount);
     res = mGetPhysicalDeviceSurfaceFormatsKHR(mBackendContext->fPhysicalDevice, surface->mVkSurface,
-            &surfaceFormatCount, surfaceFormats.data());
+                                              &surfaceFormatCount, surfaceFormats.data());
     if (VK_SUCCESS != res) {
         return false;
     }
 
     uint32_t presentModeCount;
     res = mGetPhysicalDeviceSurfacePresentModesKHR(mBackendContext->fPhysicalDevice,
-            surface->mVkSurface, &presentModeCount, nullptr);
+                                                   surface->mVkSurface, &presentModeCount, nullptr);
     if (VK_SUCCESS != res) {
         return false;
     }
 
     FatVector<VkPresentModeKHR, VK_PRESENT_MODE_RANGE_SIZE_KHR> presentModes(presentModeCount);
     res = mGetPhysicalDeviceSurfacePresentModesKHR(mBackendContext->fPhysicalDevice,
-            surface->mVkSurface, &presentModeCount, presentModes.data());
+                                                   surface->mVkSurface, &presentModeCount,
+                                                   presentModes.data());
     if (VK_SUCCESS != res) {
         return false;
     }
@@ -420,12 +423,12 @@
                                    VK_IMAGE_USAGE_TRANSFER_DST_BIT;
     SkASSERT((caps.supportedUsageFlags & usageFlags) == usageFlags);
     SkASSERT(caps.supportedTransforms & caps.currentTransform);
-    SkASSERT(caps.supportedCompositeAlpha & (VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR |
-                                             VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR));
+    SkASSERT(caps.supportedCompositeAlpha &
+             (VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR | VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR));
     VkCompositeAlphaFlagBitsKHR composite_alpha =
-        (caps.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR) ?
-                                        VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR :
-                                        VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
+            (caps.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR)
+                    ? VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR
+                    : VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
 
     // Pick our surface format. For now, just make sure it matches our sRGB request:
     VkFormat surfaceFormat = VK_FORMAT_UNDEFINED;
@@ -470,7 +473,7 @@
     swapchainCreateInfo.imageArrayLayers = 1;
     swapchainCreateInfo.imageUsage = usageFlags;
 
-    uint32_t queueFamilies[] = { mBackendContext->fGraphicsQueueIndex, mPresentQueueIndex };
+    uint32_t queueFamilies[] = {mBackendContext->fGraphicsQueueIndex, mPresentQueueIndex};
     if (mBackendContext->fGraphicsQueueIndex != mPresentQueueIndex) {
         swapchainCreateInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
         swapchainCreateInfo.queueFamilyIndexCount = 2;
@@ -488,7 +491,7 @@
     swapchainCreateInfo.oldSwapchain = surface->mSwapchain;
 
     res = mCreateSwapchainKHR(mBackendContext->fDevice, &swapchainCreateInfo, nullptr,
-            &surface->mSwapchain);
+                              &surface->mSwapchain);
     if (VK_SUCCESS != res) {
         return false;
     }
@@ -507,7 +510,6 @@
     return true;
 }
 
-
 VulkanSurface* VulkanManager::createSurface(ANativeWindow* window) {
     initialize();
 
@@ -524,21 +526,20 @@
     surfaceCreateInfo.flags = 0;
     surfaceCreateInfo.window = window;
 
-    VkResult res = mCreateAndroidSurfaceKHR(mBackendContext->fInstance, &surfaceCreateInfo,
-            nullptr, &surface->mVkSurface);
+    VkResult res = mCreateAndroidSurfaceKHR(mBackendContext->fInstance, &surfaceCreateInfo, nullptr,
+                                            &surface->mVkSurface);
     if (VK_SUCCESS != res) {
         delete surface;
         return nullptr;
     }
 
-SkDEBUGCODE(
-    VkBool32 supported;
-    res = mGetPhysicalDeviceSurfaceSupportKHR(mBackendContext->fPhysicalDevice,
-            mPresentQueueIndex, surface->mVkSurface, &supported);
-    // All physical devices and queue families on Android must be capable of presentation with any
-    // native window.
-    SkASSERT(VK_SUCCESS == res && supported);
-);
+    SkDEBUGCODE(VkBool32 supported; res = mGetPhysicalDeviceSurfaceSupportKHR(
+                                            mBackendContext->fPhysicalDevice, mPresentQueueIndex,
+                                            surface->mVkSurface, &supported);
+                // All physical devices and queue families on Android must be capable of
+                // presentation with any
+                // native window.
+                SkASSERT(VK_SUCCESS == res && supported););
 
     if (!createSwapchain(surface)) {
         destroySurface(surface);
@@ -573,11 +574,9 @@
     VkAccessFlags flags = 0;
     if (VK_IMAGE_LAYOUT_GENERAL == layout) {
         flags = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
-                VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT |
-                VK_ACCESS_TRANSFER_WRITE_BIT |
-                VK_ACCESS_TRANSFER_READ_BIT |
-                VK_ACCESS_SHADER_READ_BIT |
-                VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_HOST_READ_BIT;
+                VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT |
+                VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_HOST_WRITE_BIT |
+                VK_ACCESS_HOST_READ_BIT;
     } else if (VK_IMAGE_LAYOUT_PREINITIALIZED == layout) {
         flags = VK_ACCESS_HOST_WRITE_BIT;
     } else if (VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL == layout) {
@@ -600,12 +599,12 @@
         mDeviceWaitIdle(mBackendContext->fDevice);
     }
 
-    VulkanSurface::BackbufferInfo* backbuffer = surface->mBackbuffers +
-            surface->mCurrentBackbufferIndex;
+    VulkanSurface::BackbufferInfo* backbuffer =
+            surface->mBackbuffers + surface->mCurrentBackbufferIndex;
     GrVkImageInfo* imageInfo;
     SkSurface* skSurface = surface->mImageInfos[backbuffer->mImageIndex].mSurface.get();
     skSurface->getRenderTargetHandle((GrBackendObject*)&imageInfo,
-            SkSurface::kFlushRead_BackendHandleAccess);
+                                     SkSurface::kFlushRead_BackendHandleAccess);
     // Check to make sure we never change the actually wrapped image
     SkASSERT(imageInfo->fImage == surface->mImages[backbuffer->mImageIndex]);
 
@@ -618,16 +617,16 @@
     VkAccessFlags dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
 
     VkImageMemoryBarrier imageMemoryBarrier = {
-        VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,    // sType
-        NULL,                                      // pNext
-        srcAccessMask,                             // outputMask
-        dstAccessMask,                             // inputMask
-        layout,                                    // oldLayout
-        VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,           // newLayout
-        mBackendContext->fGraphicsQueueIndex,      // srcQueueFamilyIndex
-        mPresentQueueIndex,                        // dstQueueFamilyIndex
-        surface->mImages[backbuffer->mImageIndex], // image
-        { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 }  // subresourceRange
+            VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,     // sType
+            NULL,                                       // pNext
+            srcAccessMask,                              // outputMask
+            dstAccessMask,                              // inputMask
+            layout,                                     // oldLayout
+            VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,            // newLayout
+            mBackendContext->fGraphicsQueueIndex,       // srcQueueFamilyIndex
+            mPresentQueueIndex,                         // dstQueueFamilyIndex
+            surface->mImages[backbuffer->mImageIndex],  // image
+            {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}     // subresourceRange
     };
 
     mResetCommandBuffer(backbuffer->mTransitionCmdBuffers[1], 0);
@@ -636,8 +635,8 @@
     info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
     info.flags = 0;
     mBeginCommandBuffer(backbuffer->mTransitionCmdBuffers[1], &info);
-    mCmdPipelineBarrier(backbuffer->mTransitionCmdBuffers[1], srcStageMask, dstStageMask, 0,
-            0, nullptr, 0, nullptr, 1, &imageMemoryBarrier);
+    mCmdPipelineBarrier(backbuffer->mTransitionCmdBuffers[1], srcStageMask, dstStageMask, 0, 0,
+                        nullptr, 0, nullptr, 1, &imageMemoryBarrier);
     mEndCommandBuffer(backbuffer->mTransitionCmdBuffers[1]);
 
     surface->mImageInfos[backbuffer->mImageIndex].mImageLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
@@ -661,16 +660,15 @@
     // Submit present operation to present queue. We use a semaphore here to make sure all rendering
     // to the image is complete and that the layout has been change to present on the graphics
     // queue.
-    const VkPresentInfoKHR presentInfo =
-    {
-        VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, // sType
-        NULL, // pNext
-        1, // waitSemaphoreCount
-        &backbuffer->mRenderSemaphore, // pWaitSemaphores
-        1, // swapchainCount
-        &surface->mSwapchain, // pSwapchains
-        &backbuffer->mImageIndex, // pImageIndices
-        NULL // pResults
+    const VkPresentInfoKHR presentInfo = {
+            VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,  // sType
+            NULL,                                // pNext
+            1,                                   // waitSemaphoreCount
+            &backbuffer->mRenderSemaphore,       // pWaitSemaphores
+            1,                                   // swapchainCount
+            &surface->mSwapchain,                // pSwapchains
+            &backbuffer->mImageIndex,            // pImageIndices
+            NULL                                 // pResults
     };
 
     mQueuePresentKHR(mPresentQueue, &presentInfo);
@@ -682,10 +680,10 @@
 }
 
 int VulkanManager::getAge(VulkanSurface* surface) {
-    VulkanSurface::BackbufferInfo* backbuffer = surface->mBackbuffers +
-            surface->mCurrentBackbufferIndex;
-    if (mSwapBehavior == SwapBehavior::Discard
-            || surface->mImageInfos[backbuffer->mImageIndex].mInvalid) {
+    VulkanSurface::BackbufferInfo* backbuffer =
+            surface->mBackbuffers + surface->mCurrentBackbufferIndex;
+    if (mSwapBehavior == SwapBehavior::Discard ||
+        surface->mImageInfos[backbuffer->mImageIndex].mInvalid) {
         return 0;
     }
     uint16_t lastUsed = surface->mImageInfos[backbuffer->mImageIndex].mLastUsed;