loader: Modify debug_marker terminators
authorMark Young <marky@lunarg.com>
Fri, 2 Dec 2016 22:02:52 +0000 (15:02 -0700)
committerMark Young <marky@lunarg.com>
Fri, 2 Dec 2016 23:40:28 +0000 (16:40 -0700)
Modify the 2 debug marker terminators we use so that they don't call
into the ICD unless the ICD commands exist.

Change-Id: I72a96475f21d0fca572f3c5e6f5676782a8a4bf3

loader/extensions.c

index 0a9f918..5503df5 100644 (file)
@@ -51,30 +51,33 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_DebugMarkerSetObjectTagEXT(
     struct loader_device *dev;
     struct loader_icd_term *icd_term =
         loader_get_icd_and_device(device, &dev, &icd_index);
-    // If this is a physical device, we have to replace it with the proper one
-    // for the next call.
-    if (pTagInfo->objectType ==
-        VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) {
-        struct loader_physical_device_term *phys_dev_term =
-            (struct loader_physical_device_term *)(uintptr_t)pTagInfo->object;
-        pTagInfo->object = (uint64_t)(uintptr_t)phys_dev_term->phys_dev;
-
-        // If this is a KHR_surface, and the ICD has created its own, we have to
-        // replace it with the proper one for the next call.
-    } else if (pTagInfo->objectType ==
-               VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT) {
-        if (NULL != icd_term && NULL != icd_term->CreateSwapchainKHR) {
-            VkIcdSurface *icd_surface =
-                (VkIcdSurface *)(uintptr_t)pTagInfo->object;
-            if (NULL != icd_surface->real_icd_surfaces) {
-                pTagInfo->object =
-                    (uint64_t)icd_surface->real_icd_surfaces[icd_index];
+    if (NULL != icd_term && NULL != icd_term->DebugMarkerSetObjectTagEXT) {
+        // If this is a physical device, we have to replace it with the proper
+        // one for the next call.
+        if (pTagInfo->objectType ==
+            VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) {
+            struct loader_physical_device_term *phys_dev_term =
+                (struct loader_physical_device_term *)(uintptr_t)
+                    pTagInfo->object;
+            pTagInfo->object = (uint64_t)(uintptr_t)phys_dev_term->phys_dev;
+
+            // If this is a KHR_surface, and the ICD has created its own, we
+            // have to replace it with the proper one for the next call.
+        } else if (pTagInfo->objectType ==
+                   VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT) {
+            if (NULL != icd_term && NULL != icd_term->CreateSwapchainKHR) {
+                VkIcdSurface *icd_surface =
+                    (VkIcdSurface *)(uintptr_t)pTagInfo->object;
+                if (NULL != icd_surface->real_icd_surfaces) {
+                    pTagInfo->object =
+                        (uint64_t)icd_surface->real_icd_surfaces[icd_index];
+                }
             }
         }
+        return icd_term->DebugMarkerSetObjectTagEXT(device, pTagInfo);
+    } else {
+        return VK_SUCCESS;
     }
-    assert(icd_term != NULL && icd_term->DebugMarkerSetObjectTagEXT &&
-           "loader: null DebugMarkerSetObjectTagEXT ICD pointer");
-    return icd_term->DebugMarkerSetObjectTagEXT(device, pTagInfo);
 }
 
 VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectNameEXT(
@@ -97,31 +100,34 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_DebugMarkerSetObjectNameEXT(
     struct loader_device *dev;
     struct loader_icd_term *icd_term =
         loader_get_icd_and_device(device, &dev, &icd_index);
-    // If this is a physical device, we have to replace it with the proper one
-    // for the next call.
-    if (pNameInfo->objectType ==
-        VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) {
-        struct loader_physical_device_term *phys_dev_term =
-            (struct loader_physical_device_term *)(uintptr_t)pNameInfo->object;
-        pNameInfo->object = (uint64_t)(uintptr_t)phys_dev_term->phys_dev;
-
-        // If this is a KHR_surface, and the ICD has created its own, we have to
-        // replace it with the proper one for the next call.
-    } else if (pNameInfo->objectType ==
-               VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT) {
-        if (NULL != icd_term && NULL != icd_term->CreateSwapchainKHR) {
-            VkIcdSurface *icd_surface =
-                (VkIcdSurface *)(uintptr_t)pNameInfo->object;
-            if (NULL != icd_surface->real_icd_surfaces) {
-                pNameInfo->object =
-                    (uint64_t)(
-                        uintptr_t)icd_surface->real_icd_surfaces[icd_index];
+    if (NULL != icd_term && NULL != icd_term->DebugMarkerSetObjectNameEXT) {
+        // If this is a physical device, we have to replace it with the proper
+        // one for the next call.
+        if (pNameInfo->objectType ==
+            VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) {
+            struct loader_physical_device_term *phys_dev_term =
+                (struct loader_physical_device_term *)(uintptr_t)
+                    pNameInfo->object;
+            pNameInfo->object = (uint64_t)(uintptr_t)phys_dev_term->phys_dev;
+
+            // If this is a KHR_surface, and the ICD has created its own, we
+            // have to replace it with the proper one for the next call.
+        } else if (pNameInfo->objectType ==
+                   VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT) {
+            if (NULL != icd_term && NULL != icd_term->CreateSwapchainKHR) {
+                VkIcdSurface *icd_surface =
+                    (VkIcdSurface *)(uintptr_t)pNameInfo->object;
+                if (NULL != icd_surface->real_icd_surfaces) {
+                    pNameInfo->object =
+                        (uint64_t)(
+                            uintptr_t)icd_surface->real_icd_surfaces[icd_index];
+                }
             }
         }
+        return icd_term->DebugMarkerSetObjectNameEXT(device, pNameInfo);
+    } else {
+        return VK_SUCCESS;
     }
-    assert(icd_term != NULL && icd_term->DebugMarkerSetObjectNameEXT &&
-           "loader: null DebugMarkerSetObjectNameEXT ICD pointer");
-    return icd_term->DebugMarkerSetObjectNameEXT(device, pNameInfo);
 }
 
 // Definitions for the VK_NV_external_memory_capabilities extension