bug-14538: Remove validation error codes
authorCourtney Goeltzenleuchter <courtney@LunarG.com>
Tue, 15 Sep 2015 00:01:17 +0000 (18:01 -0600)
committerCourtney Goeltzenleuchter <courtney@LunarG.com>
Thu, 17 Sep 2015 21:32:11 +0000 (15:32 -0600)
https://cvs.khronos.org/bugzilla/show_bug.cgi?id=14538

demos/cube.c
demos/tri.c
demos/vulkaninfo.c
icd/nulldrv/nulldrv.c
include/vulkan.h
layers/param_checker.cpp
layers/shader_checker.cpp
loader/loader.c
loader/wsi_swapchain.c

index 608c480174cccd82426c5ec927dd7d63337bf2fd..aa74335585456bc6ae520cde82519729ed06197d 100644 (file)
@@ -2308,7 +2308,7 @@ static void demo_init_vk(struct demo *demo)
                  "(ICD).\n\nPlease look at the Getting Started guide for "
                  "additional information.\n",
                  "vkCreateInstance Failure");
-    } else if (err == VK_ERROR_INVALID_EXTENSION) {
+    } else if (err == VK_ERROR_EXTENSION_NOT_PRESENT) {
         ERR_EXIT("Cannot find a specified extension library"
                  ".\nMake sure your layers path is set appropriately\n",
                  "vkCreateInstance Failure");
index 8aa942eda2499a98481507ea5e8422b88dc7b850..57661395c4a75d612f3289d9b0f402eb94e2eb18 100644 (file)
@@ -1833,7 +1833,7 @@ static void demo_init_vk(struct demo *demo)
                  "(ICD).\n\nPlease look at the Getting Started guide for "
                  "additional information.\n",
                  "vkCreateInstance Failure");
-    } else if (err == VK_ERROR_INVALID_EXTENSION) {
+    } else if (err == VK_ERROR_EXTENSION_NOT_PRESENT) {
         ERR_EXIT("Cannot find a specified extension library"
                  ".\nMake sure your layers path is set appropriately\n",
                  "vkCreateInstance Failure");
index 234dbba95a8ec8415fb25f9564f4537c5935b954..fc2a33baf5185de3cf130ca0315a0f14900e3132 100644 (file)
@@ -137,15 +137,13 @@ static const char *vk_result_string(VkResult err)
     STR(VK_TIMEOUT);
     STR(VK_EVENT_SET);
     STR(VK_EVENT_RESET);
-    STR(VK_ERROR_UNKNOWN);
     STR(VK_ERROR_INITIALIZATION_FAILED);
     STR(VK_ERROR_OUT_OF_HOST_MEMORY);
     STR(VK_ERROR_OUT_OF_DEVICE_MEMORY);
     STR(VK_ERROR_DEVICE_LOST);
-    STR(VK_ERROR_INVALID_EXTENSION);
+    STR(VK_ERROR_LAYER_NOT_PRESENT);
+    STR(VK_ERROR_EXTENSION_NOT_PRESENT);
     STR(VK_ERROR_MEMORY_MAP_FAILED);
-    STR(VK_ERROR_MEMORY_UNMAP_FAILED);
-    STR(VK_ERROR_INCOMPATIBLE_DEVICE);
     STR(VK_ERROR_INCOMPATIBLE_DRIVER);
 #undef STR
     default: return "UNKNOWN_RESULT";
@@ -475,7 +473,7 @@ static void app_dev_init(struct app_dev *dev, struct app_gpu *gpu)
         }
         if (!extension_found) {
             printf("Cannot find extension: %s\n", known_extensions[i]);
-            ERR_EXIT(VK_ERROR_INVALID_EXTENSION);
+            ERR_EXIT(VK_ERROR_EXTENSION_NOT_PRESENT);
         }
     }
 
@@ -614,7 +612,7 @@ static void app_create_instance(struct app_instance *inst)
         }
         if (!extension_found) {
             printf("Cannot find extension: %s\n", known_extensions[i]);
-            ERR_EXIT(VK_ERROR_INVALID_EXTENSION);
+            ERR_EXIT(VK_ERROR_EXTENSION_NOT_PRESENT);
         }
     }
 
@@ -1095,7 +1093,7 @@ int main(int argc, char **argv)
         ERR_EXIT(err);
     if (gpu_count > MAX_GPUS) {
         printf("Too many GPUS found \n");
-        ERR_EXIT(VK_ERROR_UNKNOWN);
+        ERR_EXIT(-1);
     }
     err = vkEnumeratePhysicalDevices(inst.instance, &gpu_count, objs);
     if (err)
index 2f4713734f55305aa74c6863f1b38608ea958a26..68014411831a3b466799a6b3b5f08dd42e95bbfa 100644 (file)
@@ -202,7 +202,7 @@ static VkResult nulldrv_dev_create(struct nulldrv_gpu *gpu,
                     info->ppEnabledExtensionNames[i]);
 
         if (ext == NULLDRV_EXT_INVALID)
-            return VK_ERROR_INVALID_EXTENSION;
+            return VK_ERROR_EXTENSION_NOT_PRESENT;
 
         dev->exts[ext] = true;
     }
@@ -1667,7 +1667,7 @@ ICD_EXPORT VkResult VKAPI vkMapMemory(
 
     *ppData = ptr;
 
-    return (ptr) ? VK_SUCCESS : VK_ERROR_UNKNOWN;
+    return (ptr) ? VK_SUCCESS : VK_ERROR_MEMORY_MAP_FAILED;
 }
 
 ICD_EXPORT void VKAPI vkUnmapMemory(
index 1df07a06b5584c0625efa4d3d261a480cc7da528..89c93a26632e0f954b314af05041b2fc1a47308d 100644 (file)
@@ -150,20 +150,17 @@ typedef enum {
     VK_EVENT_SET = 4,
     VK_EVENT_RESET = 5,
     VK_INCOMPLETE = 6,
-    VK_ERROR_UNKNOWN = -1,
-    VK_ERROR_OUT_OF_HOST_MEMORY = -2,
-    VK_ERROR_OUT_OF_DEVICE_MEMORY = -3,
-    VK_ERROR_INITIALIZATION_FAILED = -4,
-    VK_ERROR_DEVICE_LOST = -5,
-    VK_ERROR_MEMORY_MAP_FAILED = -6,
-    VK_ERROR_MEMORY_UNMAP_FAILED = -7,
-    VK_ERROR_INCOMPATIBLE_DEVICE = -8,
-    VK_ERROR_INCOMPATIBLE_DRIVER = -9,
-    VK_ERROR_INVALID_EXTENSION = -10,
-    VK_ERROR_INVALID_LAYER = -11,
-    VK_RESULT_BEGIN_RANGE = VK_ERROR_INVALID_LAYER,
+    VK_ERROR_OUT_OF_HOST_MEMORY = -1,
+    VK_ERROR_OUT_OF_DEVICE_MEMORY = -2,
+    VK_ERROR_INITIALIZATION_FAILED = -3,
+    VK_ERROR_DEVICE_LOST = -4,
+    VK_ERROR_MEMORY_MAP_FAILED = -5,
+    VK_ERROR_LAYER_NOT_PRESENT = -6,
+    VK_ERROR_EXTENSION_NOT_PRESENT = -7,
+    VK_ERROR_INCOMPATIBLE_DRIVER = -8,
+    VK_RESULT_BEGIN_RANGE = VK_ERROR_INCOMPATIBLE_DRIVER,
     VK_RESULT_END_RANGE = VK_INCOMPLETE,
-    VK_RESULT_NUM = (VK_INCOMPLETE - VK_ERROR_INVALID_LAYER + 1),
+    VK_RESULT_NUM = (VK_INCOMPLETE - VK_ERROR_INCOMPATIBLE_DRIVER + 1),
     VK_RESULT_MAX_ENUM = 0x7FFFFFFF
 } VkResult;
 
index 74041192d215b08fd62b54cbb9e7e8f48b7fdc5f..c93f4875966dc9c2f702fa4864a079d846af6105 100644 (file)
@@ -185,9 +185,9 @@ std::string EnumeratorString(VkResult const& enumerator)
             return "VK_RESULT_MAX_ENUM";
             break;
         }
-        case VK_ERROR_INVALID_LAYER:
+        case VK_ERROR_LAYER_NOT_PRESENT:
         {
-            return "VK_ERROR_INVALID_LAYER";
+            return "VK_ERROR_LAYER_NOT_PRESENT";
             break;
         }
         case VK_ERROR_INCOMPATIBLE_DRIVER:
@@ -195,11 +195,6 @@ std::string EnumeratorString(VkResult const& enumerator)
             return "VK_ERROR_INCOMPATIBLE_DRIVER";
             break;
         }
-        case VK_ERROR_MEMORY_UNMAP_FAILED:
-        {
-            return "VK_ERROR_MEMORY_UNMAP_FAILED";
-            break;
-        }
         case VK_ERROR_MEMORY_MAP_FAILED:
         {
             return "VK_ERROR_MEMORY_MAP_FAILED";
@@ -215,11 +210,6 @@ std::string EnumeratorString(VkResult const& enumerator)
             return "VK_ERROR_OUT_OF_HOST_MEMORY";
             break;
         }
-        case VK_ERROR_UNKNOWN:
-        {
-            return "VK_ERROR_UNKNOWN";
-            break;
-        }
         case VK_ERROR_INITIALIZATION_FAILED:
         {
             return "VK_ERROR_INITIALIZATION_FAILED";
@@ -255,19 +245,14 @@ std::string EnumeratorString(VkResult const& enumerator)
             return "VK_UNSUPPORTED";
             break;
         }
-        case VK_ERROR_INCOMPATIBLE_DEVICE:
-        {
-            return "VK_ERROR_INCOMPATIBLE_DEVICE";
-            break;
-        }
         case VK_SUCCESS:
         {
             return "VK_SUCCESS";
             break;
         }
-        case VK_ERROR_INVALID_EXTENSION:
+        case VK_ERROR_EXTENSION_NOT_PRESENT:
         {
-            return "VK_ERROR_INVALID_EXTENSION";
+            return "VK_ERROR_EXTENSION_NOT_PRESENT";
             break;
         }
         case VK_ERROR_DEVICE_LOST:
index 632947ab58b412bc4a6acb20e54e5e938b66811d..678b5671f2943bc7150833563a7c143c1d37f474 100644 (file)
@@ -976,7 +976,7 @@ vkCreateGraphicsPipelines(VkDevice device,
         return get_dispatch_table(shader_checker_device_table_map, device)->CreateGraphicsPipelines(device, pipelineCache, count, pCreateInfos, pPipelines);
     }
     else {
-        return VK_ERROR_UNKNOWN;
+        return VK_ERROR_VALIDATION_FAILED;
     }
 }
 
index 29f8e958d8910a76b090a7fe52f094db07a96f41..c0965289774f647933274d792acf3da13da5c1da 100644 (file)
@@ -622,7 +622,7 @@ static VkResult loader_add_layer_names_to_list(
         layer_prop = loader_get_layer_property(search_target, search_list);
         if (!layer_prop) {
             loader_log(VK_DBG_REPORT_ERROR_BIT, 0, "Unable to find layer %s", search_target);
-            err = VK_ERROR_INVALID_LAYER;
+            err = VK_ERROR_LAYER_NOT_PRESENT;
             continue;
         }
 
@@ -2190,8 +2190,7 @@ VkResult loader_enable_instance_layers(
 {
     VkResult err;
 
-    if (inst == NULL)
-        return VK_ERROR_UNKNOWN;
+    assert(inst && "Cannot have null instance");
 
     if (!loader_init_layer_list(inst, &inst->activated_layer_list)) {
         loader_log(VK_DBG_REPORT_ERROR_BIT, 0, "Failed to alloc Instance activated layer list");
@@ -2323,8 +2322,7 @@ static VkResult loader_enable_device_layers(
 {
     VkResult err;
 
-    if (dev == NULL)
-        return VK_ERROR_UNKNOWN;
+    assert(dev && "Cannot have null device");
 
     if (dev->activated_layer_list.list == NULL || dev->activated_layer_list.capacity == 0) {
         loader_init_layer_list(inst, &dev->activated_layer_list);
@@ -2467,7 +2465,7 @@ VkResult loader_validate_layers(
         prop = loader_get_layer_property(ppEnabledLayerNames[i],
                                   list);
         if (!prop) {
-            return VK_ERROR_INVALID_LAYER;
+            return VK_ERROR_LAYER_NOT_PRESENT;
         }
     }
 
@@ -2513,7 +2511,7 @@ VkResult loader_validate_instance_extensions(
 
         if (!extension_prop) {
             /* Didn't find extension name in any of the global layers, error out */
-            return VK_ERROR_INVALID_EXTENSION;
+            return VK_ERROR_EXTENSION_NOT_PRESENT;
         }
     }
     return VK_SUCCESS;
@@ -2560,7 +2558,7 @@ VkResult loader_validate_device_extensions(
 
         if (!extension_prop) {
             /* Didn't find extension name in any of the device layers, error out */
-            return VK_ERROR_INVALID_EXTENSION;
+            return VK_ERROR_EXTENSION_NOT_PRESENT;
         }
     }
     return VK_SUCCESS;
@@ -2698,7 +2696,7 @@ VkResult loader_init_physical_device_info(
 {
     struct loader_icd *icd;
     uint32_t n, count = 0;
-    VkResult res = VK_ERROR_UNKNOWN;
+    VkResult res;
 
     icd = ptr_instance->icds;
     while (icd) {
@@ -3122,7 +3120,7 @@ LOADER_EXPORT VkResult VKAPI vkEnumerateInstanceExtensionProperties(
 
     if (global_ext_list == NULL) {
         loader_platform_thread_unlock_mutex(&loader_lock);
-        return VK_ERROR_INVALID_LAYER;
+        return VK_ERROR_LAYER_NOT_PRESENT;
     }
 
     if (pProperties == NULL) {
index a59f389b8224fed91a3908afbafb557ffef5fcef..e6f2387f9b8a840443d39a0c2fd8f5044401942b 100644 (file)
@@ -95,17 +95,16 @@ VkResult VKAPI loader_GetPhysicalDeviceSurfaceSupportKHR(
 {
     uint32_t gpu_index;
     struct loader_icd *icd = loader_get_icd(physicalDevice, &gpu_index);
-    VkResult res = VK_ERROR_UNKNOWN;
+
+    assert(pSupported && "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported");
     *pSupported = false;
 
-    if (icd->GetPhysicalDeviceSurfaceSupportKHR) {
-        res = icd->GetPhysicalDeviceSurfaceSupportKHR(physicalDevice,
-                                                      queueNodeIndex,
-                                                      pSurfaceDescription,
-                                                      pSupported);
-    }
+    assert(icd->GetPhysicalDeviceSurfaceSupportKHR && "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer");
 
-    return res;
+    return icd->GetPhysicalDeviceSurfaceSupportKHR(physicalDevice,
+                                                  queueNodeIndex,
+                                                  pSurfaceDescription,
+                                                  pSupported);
 }