diff options
| author | Ian Elliott <ianelliott@google.com> | 2015-12-30 13:14:36 -0700 |
|---|---|---|
| committer | Jon Ashburn <jon@lunarg.com> | 2016-01-06 12:23:09 -0700 |
| commit | c141cbcb282d29d30db673be95eafebbd636e631 (patch) | |
| tree | c2d3f5baef995f4e0717464fc27768e7b4c95e7f /layers/swapchain.cpp | |
| parent | 5b9fefd671e1a0298b6f0448f2ae3a92fb654abc (diff) | |
| download | usermoji-c141cbcb282d29d30db673be95eafebbd636e631.tar.xz | |
Swapchain: Rework the way that pCount is dealt with.
Diffstat (limited to 'layers/swapchain.cpp')
| -rw-r--r-- | layers/swapchain.cpp | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/layers/swapchain.cpp b/layers/swapchain.cpp index 9f77fc67..3bebd733 100644 --- a/layers/swapchain.cpp +++ b/layers/swapchain.cpp @@ -1052,8 +1052,8 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormats // Record the result of this preliminary query: pPhysicalDevice->surfaceFormatCount = *pSurfaceFormatCount; } - if ((result == VK_SUCCESS) && pPhysicalDevice && pSurfaceFormats && - pSurfaceFormatCount && (*pSurfaceFormatCount > 0)) { + else if ((result == VK_SUCCESS) && pPhysicalDevice && pSurfaceFormats && + pSurfaceFormatCount) { // Compare the preliminary value of *pSurfaceFormatCount with the // value this time: if (*pSurfaceFormatCount != pPhysicalDevice->surfaceFormatCount) { @@ -1063,16 +1063,18 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormats "pSurfaceFormats", pPhysicalDevice->surfaceFormatCount); } - // Record the result of this query: - pPhysicalDevice->surfaceFormatCount = *pSurfaceFormatCount; - pPhysicalDevice->pSurfaceFormats = (VkSurfaceFormatKHR *) - malloc(*pSurfaceFormatCount * sizeof(VkSurfaceFormatKHR)); - if (pPhysicalDevice->pSurfaceFormats) { - for (uint32_t i = 0 ; i < *pSurfaceFormatCount ; i++) { - pPhysicalDevice->pSurfaceFormats[i] = pSurfaceFormats[i]; + else if (*pSurfaceFormatCount > 0) { + // Record the result of this query: + pPhysicalDevice->surfaceFormatCount = *pSurfaceFormatCount; + pPhysicalDevice->pSurfaceFormats = (VkSurfaceFormatKHR *) + malloc(*pSurfaceFormatCount * sizeof(VkSurfaceFormatKHR)); + if (pPhysicalDevice->pSurfaceFormats) { + for (uint32_t i = 0 ; i < *pSurfaceFormatCount ; i++) { + pPhysicalDevice->pSurfaceFormats[i] = pSurfaceFormats[i]; + } + } else { + pPhysicalDevice->surfaceFormatCount = 0; } - } else { - pPhysicalDevice->surfaceFormatCount = 0; } } @@ -1123,8 +1125,8 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresent // Record the result of this preliminary query: pPhysicalDevice->presentModeCount = *pPresentModeCount; } - if ((result == VK_SUCCESS) && pPhysicalDevice && pPresentModes && - pPresentModeCount && (*pPresentModeCount > 0)) { + else if ((result == VK_SUCCESS) && pPhysicalDevice && pPresentModes && + pPresentModeCount) { // Compare the preliminary value of *pPresentModeCount with the // value this time: if (*pPresentModeCount != pPhysicalDevice->presentModeCount) { @@ -1134,16 +1136,18 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresent "pPresentModes", pPhysicalDevice->presentModeCount); } - // Record the result of this query: - pPhysicalDevice->presentModeCount = *pPresentModeCount; - pPhysicalDevice->pPresentModes = (VkPresentModeKHR *) - malloc(*pPresentModeCount * sizeof(VkPresentModeKHR)); - if (pPhysicalDevice->pSurfaceFormats) { - for (uint32_t i = 0 ; i < *pPresentModeCount ; i++) { - pPhysicalDevice->pPresentModes[i] = pPresentModes[i]; + else if (*pPresentModeCount > 0) { + // Record the result of this query: + pPhysicalDevice->presentModeCount = *pPresentModeCount; + pPhysicalDevice->pPresentModes = (VkPresentModeKHR *) + malloc(*pPresentModeCount * sizeof(VkPresentModeKHR)); + if (pPhysicalDevice->pSurfaceFormats) { + for (uint32_t i = 0 ; i < *pPresentModeCount ; i++) { + pPhysicalDevice->pPresentModes[i] = pPresentModes[i]; + } + } else { + pPhysicalDevice->presentModeCount = 0; } - } else { - pPhysicalDevice->presentModeCount = 0; } } @@ -1611,8 +1615,8 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR( // Record the result of this preliminary query: pSwapchain->imageCount = *pSwapchainImageCount; } - if ((result == VK_SUCCESS) && pSwapchain && pSwapchainImages && - pSwapchainImageCount && (*pSwapchainImageCount > 0)) { + else if ((result == VK_SUCCESS) && pSwapchain && pSwapchainImages && + pSwapchainImageCount) { // Compare the preliminary value of *pSwapchainImageCount with the // value this time: if (*pSwapchainImageCount != pSwapchain->imageCount) { @@ -1622,12 +1626,14 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR( "pSwapchainImages", pSwapchain->imageCount); } - // Record the images and their state: - pSwapchain->imageCount = *pSwapchainImageCount; - for (uint32_t i = 0 ; i < *pSwapchainImageCount ; i++) { - pSwapchain->images[i].image = pSwapchainImages[i]; - pSwapchain->images[i].pSwapchain = pSwapchain; - pSwapchain->images[i].ownedByApp = false; + else if (*pSwapchainImageCount > 0) { + // Record the images and their state: + pSwapchain->imageCount = *pSwapchainImageCount; + for (uint32_t i = 0 ; i < *pSwapchainImageCount ; i++) { + pSwapchain->images[i].image = pSwapchainImages[i]; + pSwapchain->images[i].pSwapchain = pSwapchain; + pSwapchain->images[i].ownedByApp = false; + } } } |
