diff options
| author | Petr Kraus <petr_kraus@email.cz> | 2020-04-08 20:57:14 +0200 |
|---|---|---|
| committer | Mark Lobodzinski <mark@lunarg.com> | 2020-04-10 13:02:51 -0600 |
| commit | a7aff240f9ca6fae712139bb11303d5231fd8206 (patch) | |
| tree | 746978f0247613051565057637ee0f149d503ebb /icd/generated/mock_icd.cpp | |
| parent | 2fd41fab58c82eaf24cc8b55a81638a655a221fa (diff) | |
| download | usermoji-a7aff240f9ca6fae712139bb11303d5231fd8206.tar.xz | |
icd: Fix vkGetSwapchainImages behavior
- add missing lock
- return correct values via return and count
Diffstat (limited to 'icd/generated/mock_icd.cpp')
| -rw-r--r-- | icd/generated/mock_icd.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/icd/generated/mock_icd.cpp b/icd/generated/mock_icd.cpp index cad7dd81..7a34a144 100644 --- a/icd/generated/mock_icd.cpp +++ b/icd/generated/mock_icd.cpp @@ -21,6 +21,7 @@ #include "mock_icd.h" #include <stdlib.h> +#include <algorithm> #include <vector> #include "vk_typemap_helper.h" namespace vkmock { @@ -2141,13 +2142,19 @@ static VKAPI_ATTR VkResult VKAPI_CALL GetSwapchainImagesKHR( uint32_t* pSwapchainImageCount, VkImage* pSwapchainImages) { + constexpr uint32_t icd_image_count = 1; + if (!pSwapchainImages) { - *pSwapchainImageCount = 1; - } else if (*pSwapchainImageCount > 0) { - pSwapchainImages[0] = (VkImage)global_unique_handle++; - if (*pSwapchainImageCount != 1) { - return VK_INCOMPLETE; + *pSwapchainImageCount = icd_image_count; + } else { + unique_lock_t lock(global_lock); + for (uint32_t img_i = 0; img_i < (std::min)(*pSwapchainImageCount, icd_image_count); ++img_i){ + // For simplicity always returns new handles, which is wrong + pSwapchainImages[img_i] = (VkImage)global_unique_handle++; } + + if (*pSwapchainImageCount < icd_image_count) return VK_INCOMPLETE; + else if (*pSwapchainImageCount > icd_image_count) *pSwapchainImageCount = icd_image_count; } return VK_SUCCESS; } |
