diff options
| author | Mark Young <marky@lunarg.com> | 2016-07-01 15:18:27 -0600 |
|---|---|---|
| committer | Mark Young <marky@lunarg.com> | 2016-09-01 08:14:27 -0600 |
| commit | ffb06194c4792cf350d7fa5737fda6e8e38cb0de (patch) | |
| tree | f2413bb6405ba2068b28376eaad87ac722c58a50 /layers | |
| parent | 48fc62a1db1480fbf3007fb5e50fecb239b394d5 (diff) | |
| download | usermoji-ffb06194c4792cf350d7fa5737fda6e8e38cb0de.tar.xz | |
loader: gh888 Add KHR/EXT extensions in vulkan.h
Add the KHR_display_swapchain device extension to the loader
and the core_validation layers. This fulfills the work required in
JIRA LOAD-7 and gh 90.
Add debug_marker to the extension list.
Change-Id: I1fb70e5d44bc8c1f70fd6d1cfbd106a155081b25
Diffstat (limited to 'layers')
| -rw-r--r-- | layers/core_validation.cpp | 25 | ||||
| -rw-r--r-- | layers/swapchain.cpp | 66 | ||||
| -rw-r--r-- | layers/swapchain.h | 3 |
3 files changed, 91 insertions, 3 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 16303868..13b3d4b7 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -86,6 +86,7 @@ static const VkDeviceMemory MEMTRACKER_SWAP_CHAIN_IMAGE_KEY = (VkDeviceMemory)(- struct devExts { bool wsi_enabled; + bool wsi_display_swapchain_enabled; unordered_map<VkSwapchainKHR, unique_ptr<SWAPCHAIN_NODE>> swapchainMap; unordered_map<VkImage, VkSwapchainKHR> imageToSwapchainMap; }; @@ -4220,10 +4221,13 @@ static void checkDeviceRegisterExtensions(const VkDeviceCreateInfo *pCreateInfo, // by more than one thread? layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); dev_data->device_extensions.wsi_enabled = false; + dev_data->device_extensions.wsi_display_swapchain_enabled = false; for (i = 0; i < pCreateInfo->enabledExtensionCount; i++) { if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) dev_data->device_extensions.wsi_enabled = true; + if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME) == 0) + dev_data->device_extensions.wsi_display_swapchain_enabled = true; } } @@ -10995,6 +10999,16 @@ VKAPI_ATTR VkResult VKAPI_CALL QueuePresentKHR(VkQueue queue, const VkPresentInf return result; } +VKAPI_ATTR VkResult VKAPI_CALL CreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, + const VkSwapchainCreateInfoKHR *pCreateInfos, + const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchains) { + layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); + std::unique_lock<std::mutex> lock(global_lock); + VkResult result = + dev_data->device_dispatch_table->CreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, pAllocator, pSwapchains); + return result; +} + VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex) { layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); @@ -11433,9 +11447,10 @@ intercept_khr_swapchain_command(const char *name, VkDevice dev) { { "vkAcquireNextImageKHR", reinterpret_cast<PFN_vkVoidFunction>(AcquireNextImageKHR) }, { "vkQueuePresentKHR", reinterpret_cast<PFN_vkVoidFunction>(QueuePresentKHR) }, }; + layer_data *dev_data = nullptr; if (dev) { - layer_data *dev_data = get_my_data_ptr(get_dispatch_key(dev), layer_data_map); + dev_data = get_my_data_ptr(get_dispatch_key(dev), layer_data_map); if (!dev_data->device_extensions.wsi_enabled) return nullptr; } @@ -11445,6 +11460,14 @@ intercept_khr_swapchain_command(const char *name, VkDevice dev) { return khr_swapchain_commands[i].proc; } + if (dev_data) { + if (!dev_data->device_extensions.wsi_display_swapchain_enabled) + return nullptr; + } + + if (!strcmp("vkCreateSharedSwapchainsKHR", name)) + return reinterpret_cast<PFN_vkVoidFunction>(CreateSharedSwapchainsKHR); + return nullptr; } diff --git a/layers/swapchain.cpp b/layers/swapchain.cpp index 24496253..792b0634 100644 --- a/layers/swapchain.cpp +++ b/layers/swapchain.cpp @@ -64,15 +64,18 @@ static void checkDeviceRegisterExtensions(VkPhysicalDevice physicalDevice, const } my_device_data->deviceMap[device].device = device; my_device_data->deviceMap[device].swapchainExtensionEnabled = false; + my_device_data->deviceMap[device].displaySwapchainExtensionEnabled = false; // Record whether the WSI device extension was enabled for this VkDevice. // No need to check if the extension was advertised by // vkEnumerateDeviceExtensionProperties(), since the loader handles that. for (i = 0; i < pCreateInfo->enabledExtensionCount; i++) { if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) { - my_device_data->deviceMap[device].swapchainExtensionEnabled = true; } + if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME) == 0) { + my_device_data->deviceMap[device].displaySwapchainExtensionEnabled = true; + } } } @@ -2247,7 +2250,66 @@ VKAPI_ATTR VkResult VKAPI_CALL QueuePresentKHR(VkQueue queue, const VkPresentInf return VK_ERROR_VALIDATION_FAILED_EXT; } -VKAPI_ATTR void VKAPI_CALL GetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue) { +VKAPI_ATTR VkResult VKAPI_CALL CreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, + const VkSwapchainCreateInfoKHR *pCreateInfos, + const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchains) { + VkResult result = VK_SUCCESS; + bool skip_call = false; + layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); + std::unique_lock<std::mutex> lock(global_lock); + SwpDevice *pDevice = nullptr; + { + auto it = my_data->deviceMap.find(device); + pDevice = (it == my_data->deviceMap.end()) ? nullptr : &it->second; + } + + // Validate that the swapchain extension was enabled: + if (pDevice && !pDevice->displaySwapchainExtensionEnabled) { + skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, + reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, swapchain_layer_name, + "vkCreateSharedSwapchainsKHR() called even though the %s extension was not enabled for this VkDevice.", + VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME); + } + if (!pCreateInfos || !pSwapchains) { + skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, + reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_NULL_POINTER, swapchain_layer_name, + "vkCreateSharedSwapchainsKHR() called with NULL pointer"); + } + if (swapchainCount == 0) { + skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, + reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_INVALID_COUNT, swapchain_layer_name, + "vkCreateSharedSwapchainsKHR() called with invalid swapchain count of %d.", swapchainCount); + } else { + SwpSwapchain *pSwapchain = nullptr; + for (uint32_t iii = 0; iii < swapchainCount; iii++) { + if (pCreateInfos[iii].sType != VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR) { + skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, + reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_WRONG_STYPE, swapchain_layer_name, + "vkCreateSharedSwapchainsKHR() called with invalid stype in pCreateInfos[%d].", iii); + } + auto it = my_data->swapchainMap.find(pSwapchains[iii]); + pSwapchain = (it == my_data->swapchainMap.end()) ? nullptr : &it->second; + if (nullptr == pSwapchain) { + skip_call |= + log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, + reinterpret_cast<uint64_t>(device), __LINE__, SWAPCHAIN_INVALID_HANDLE, swapchain_layer_name, + "vkCreateSharedSwapchainsKHR() called with invalid Swapchain Handle in pCreateInfos[%d].", iii); + } + } + } + lock.unlock(); + + if (!skip_call) { + // Call down the call chain: + result = my_data->device_dispatch_table->CreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, pAllocator, + pSwapchains); + return result; + } + return VK_ERROR_VALIDATION_FAILED_EXT; +} + +VKAPI_ATTR void VKAPI_CALL +GetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue) { bool skip_call = false; layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); diff --git a/layers/swapchain.h b/layers/swapchain.h index 1f739f6f..9b84f20b 100644 --- a/layers/swapchain.h +++ b/layers/swapchain.h @@ -221,6 +221,9 @@ struct SwpDevice { // Set to true if VK_KHR_SWAPCHAIN_EXTENSION_NAME was enabled: bool swapchainExtensionEnabled; + // Set to true if VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME was enabled: + bool displaySwapchainExtensionEnabled; + // When vkCreateSwapchainKHR is called, the VkSwapchainKHR's are // remembered: unordered_map<VkSwapchainKHR, SwpSwapchain *> swapchains; |
