layers: Add extension-enabled check to vkDestroySurfaceKHR().
authorIan Elliott <ianelliott@google.com>
Fri, 29 Apr 2016 19:03:17 +0000 (13:03 -0600)
committerTobin Ehlis <tobine@google.com>
Mon, 2 May 2016 19:43:32 +0000 (13:43 -0600)
Because the WSI functions are statically exported (i.e. no need to call gpa()
functions), the swapchain layer is supposed to issue an error if any WSI
function is called without its corresponding extension being enabled.  For
example, the VK_KHR_swapchain extension must be enabled before the
vkCreateSwapchainKHR() function is called.

layers/swapchain.cpp

index b999d66..a91674b 100644 (file)
@@ -859,6 +859,14 @@ vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocatio
     layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);
     std::unique_lock<std::mutex> lock(global_lock);
     SwpSurface *pSurface = &my_data->surfaceMap[surface];
+    SwpInstance *pInstance = &(my_data->instanceMap[instance]);
+
+    // Validate that the platform extension was enabled:
+    if (pInstance && !pInstance->surfaceExtensionEnabled) {
+        skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, pInstance, "VkInstance", SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED,
+                              "%s() called even though the %s extension was not enabled for this VkInstance.", __FUNCTION__,
+                              VK_KHR_SURFACE_EXTENSION_NAME);
+    }
 
     // Regardless of skipCall value, do some internal cleanup:
     if (pSurface) {