vk/0.170.2: Update VkResult
authorChad Versace <chad.versace@intel.com>
Wed, 7 Oct 2015 18:36:51 +0000 (11:36 -0700)
committerChad Versace <chad.versace@intel.com>
Wed, 7 Oct 2015 18:36:51 +0000 (11:36 -0700)
Version 0.170.2 removes most of the error enums. In many cases, I had to
replace an error with a less accurate (or even incorrect) one.
In other cases, the error path is replaced with an assertion.

include/vulkan/vulkan.h
src/vulkan/anv_device.c
src/vulkan/anv_formats.c
src/vulkan/anv_image.c
src/vulkan/anv_query.c
src/vulkan/anv_util.c
src/vulkan/anv_wsi_wayland.c
src/vulkan/anv_wsi_x11.c
src/vulkan/gen7_pipeline.c

index dcba29cb42632bfe60d7d01a1dee341ac9e3a131..1a572136340377a8f69183ce05ceeccd2b5c12b1 100644 (file)
@@ -128,41 +128,17 @@ typedef enum {
     VK_EVENT_SET = 4,
     VK_EVENT_RESET = 5,
     VK_INCOMPLETE = 6,
-    VK_ERROR_UNKNOWN = -1,
-    VK_ERROR_UNAVAILABLE = -2,
+    VK_ERROR_OUT_OF_HOST_MEMORY = -1,
+    VK_ERROR_OUT_OF_DEVICE_MEMORY = -2,
     VK_ERROR_INITIALIZATION_FAILED = -3,
-    VK_ERROR_OUT_OF_HOST_MEMORY = -4,
-    VK_ERROR_OUT_OF_DEVICE_MEMORY = -5,
-    VK_ERROR_DEVICE_ALREADY_CREATED = -6,
-    VK_ERROR_DEVICE_LOST = -7,
-    VK_ERROR_INVALID_POINTER = -8,
-    VK_ERROR_INVALID_VALUE = -9,
-    VK_ERROR_INVALID_HANDLE = -10,
-    VK_ERROR_INVALID_ORDINAL = -11,
-    VK_ERROR_INVALID_MEMORY_SIZE = -12,
-    VK_ERROR_INVALID_EXTENSION = -13,
-    VK_ERROR_INVALID_FLAGS = -14,
-    VK_ERROR_INVALID_ALIGNMENT = -15,
-    VK_ERROR_INVALID_FORMAT = -16,
-    VK_ERROR_INVALID_IMAGE = -17,
-    VK_ERROR_INVALID_DESCRIPTOR_SET_DATA = -18,
-    VK_ERROR_INVALID_QUEUE_TYPE = -19,
-    VK_ERROR_UNSUPPORTED_SHADER_IL_VERSION = -20,
-    VK_ERROR_BAD_SHADER_CODE = -21,
-    VK_ERROR_BAD_PIPELINE_DATA = -22,
-    VK_ERROR_NOT_MAPPABLE = -23,
-    VK_ERROR_MEMORY_MAP_FAILED = -24,
-    VK_ERROR_MEMORY_UNMAP_FAILED = -25,
-    VK_ERROR_INCOMPATIBLE_DEVICE = -26,
-    VK_ERROR_INCOMPATIBLE_DRIVER = -27,
-    VK_ERROR_INCOMPLETE_COMMAND_BUFFER = -28,
-    VK_ERROR_BUILDING_COMMAND_BUFFER = -29,
-    VK_ERROR_MEMORY_NOT_BOUND = -30,
-    VK_ERROR_INCOMPATIBLE_QUEUE = -31,
-    VK_ERROR_INVALID_LAYER = -32,
-    VK_RESULT_BEGIN_RANGE = VK_ERROR_INVALID_LAYER,
+    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 b12fabc2007fce9df91fb42d883a81c9aec77eb2..4e677054afe4c668247c015a8e8ee6100fe985bf 100644 (file)
@@ -43,42 +43,49 @@ anv_physical_device_init(struct anv_physical_device *device,
 
    fd = open(path, O_RDWR | O_CLOEXEC);
    if (fd < 0)
-      return vk_errorf(VK_ERROR_UNAVAILABLE, "failed to open %s: %m", path);
+      return vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
+                       "failed to open %s: %m", path);
 
    device->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
    device->instance = instance;
    device->path = path;
-   
+
    device->chipset_id = anv_gem_get_param(fd, I915_PARAM_CHIPSET_ID);
    if (!device->chipset_id) {
-      result = vk_errorf(VK_ERROR_UNAVAILABLE, "failed to get chipset id: %m");
+      result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
+                         "failed to get chipset id: %m");
       goto fail;
    }
 
    device->name = brw_get_device_name(device->chipset_id);
    device->info = brw_get_device_info(device->chipset_id, -1);
    if (!device->info) {
-      result = vk_errorf(VK_ERROR_UNAVAILABLE, "failed to get device info");
+      result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
+                         "failed to get device info");
       goto fail;
    }
    
    if (anv_gem_get_aperture(fd, &device->aperture_size) == -1) {
-      result = vk_errorf(VK_ERROR_UNAVAILABLE, "failed to get aperture size: %m");
+      result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
+                         "failed to get aperture size: %m");
       goto fail;
    }
 
    if (!anv_gem_get_param(fd, I915_PARAM_HAS_WAIT_TIMEOUT)) {
-      result = vk_errorf(VK_ERROR_UNAVAILABLE, "kernel missing gem wait");
+      result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
+                         "kernel missing gem wait");
       goto fail;
    }
 
    if (!anv_gem_get_param(fd, I915_PARAM_HAS_EXECBUF2)) {
-      result = vk_errorf(VK_ERROR_UNAVAILABLE, "kernel missing execbuf2");
+      result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
+                         "kernel missing execbuf2");
       goto fail;
    }
 
    if (!anv_gem_get_param(fd, I915_PARAM_HAS_LLC)) {
-      result = vk_errorf(VK_ERROR_UNAVAILABLE, "non-llc gpu");
+      result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
+                         "non-llc gpu");
       goto fail;
    }
    
@@ -148,7 +155,7 @@ VkResult anv_CreateInstance(
          }
       }
       if (!found)
-         return vk_error(VK_ERROR_INVALID_EXTENSION);
+         return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
    }
 
    if (pCreateInfo->pAllocCb) {
@@ -581,7 +588,7 @@ VkResult anv_CreateDevice(
          }
       }
       if (!found)
-         return vk_error(VK_ERROR_INVALID_EXTENSION);
+         return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
    }
 
    anv_set_dispatch_gen(physical_device->info->gen);
@@ -639,7 +646,7 @@ VkResult anv_CreateDevice(
  fail_device:
    anv_device_free(device, device);
 
-   return vk_error(VK_ERROR_UNAVAILABLE);
+   return vk_error(VK_ERROR_INITIALIZATION_FAILED);
 }
 
 void anv_DestroyDevice(
@@ -720,7 +727,7 @@ VkResult anv_EnumerateInstanceLayerProperties(
    }
 
    /* None supported at this time */
-   return vk_error(VK_ERROR_INVALID_LAYER);
+   return vk_error(VK_ERROR_LAYER_NOT_PRESENT);
 }
 
 VkResult anv_EnumerateDeviceLayerProperties(
@@ -734,7 +741,7 @@ VkResult anv_EnumerateDeviceLayerProperties(
    }
 
    /* None supported at this time */
-   return vk_error(VK_ERROR_INVALID_LAYER);
+   return vk_error(VK_ERROR_LAYER_NOT_PRESENT);
 }
 
 VkResult anv_GetDeviceQueue(
@@ -769,13 +776,19 @@ VkResult anv_QueueSubmit(
       assert(cmd_buffer->level == VK_CMD_BUFFER_LEVEL_PRIMARY);
 
       ret = anv_gem_execbuffer(device, &cmd_buffer->execbuf2.execbuf);
-      if (ret != 0)
-         return vk_errorf(VK_ERROR_UNKNOWN, "execbuf2 failed: %m");
+      if (ret != 0) {
+         /* We don't know the real error. */
+         return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
+                          "execbuf2 failed: %m");
+      }
 
       if (fence) {
          ret = anv_gem_execbuffer(device, &fence->execbuf);
-         if (ret != 0)
-            return vk_errorf(VK_ERROR_UNKNOWN, "execbuf2 failed: %m");
+         if (ret != 0) {
+            /* We don't know the real error. */
+            return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
+                             "execbuf2 failed: %m");
+         }
       }
 
       for (uint32_t i = 0; i < cmd_buffer->execbuf2.bo_count; i++)
@@ -838,14 +851,16 @@ VkResult anv_DeviceWaitIdle(
 
    ret = anv_gem_execbuffer(device, &execbuf);
    if (ret != 0) {
-      result = vk_errorf(VK_ERROR_UNKNOWN, "execbuf2 failed: %m");
+      /* We don't know the real error. */
+      result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY, "execbuf2 failed: %m");
       goto fail;
    }
 
    timeout = INT64_MAX;
    ret = anv_gem_wait(device, bo->gem_handle, &timeout);
    if (ret != 0) {
-      result = vk_errorf(VK_ERROR_UNKNOWN, "execbuf2 failed: %m");
+      /* We don't know the real error. */
+      result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY, "execbuf2 failed: %m");
       goto fail;
    }
 
@@ -901,10 +916,8 @@ VkResult anv_AllocMemory(
 
    assert(pAllocInfo->sType == VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO);
 
-   if (pAllocInfo->memoryTypeIndex != 0) {
-      /* We support exactly one memory heap. */
-      return vk_error(VK_ERROR_INVALID_VALUE);
-   }
+   /* We support exactly one memory heap. */
+   assert(pAllocInfo->memoryTypeIndex == 0);
 
    /* FINISHME: Fail if allocation request exceeds heap size. */
 
@@ -1243,10 +1256,13 @@ VkResult anv_WaitForFences(
    for (uint32_t i = 0; i < fenceCount; i++) {
       ANV_FROM_HANDLE(anv_fence, fence, pFences[i]);
       ret = anv_gem_wait(device, fence->bo.gem_handle, &t);
-      if (ret == -1 && errno == ETIME)
+      if (ret == -1 && errno == ETIME) {
          return VK_TIMEOUT;
-      else if (ret == -1)
-         return vk_errorf(VK_ERROR_UNKNOWN, "gem wait failed: %m");
+      } else if (ret == -1) {
+         /* We don't know the real error. */
+         return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
+                          "gem wait failed: %m");
+      }
    }
 
    return VK_SUCCESS;
index f5bae0ae0aae3f4b779d571bc518aeed135d0da0..944e05f1476fdd0f1d03c967c70b22ec8ab80420 100644 (file)
@@ -254,8 +254,7 @@ anv_physical_device_get_format_properties(struct anv_physical_device *physical_d
    int gen;
    VkFormatFeatureFlags flags;
 
-   if (format == NULL)
-      return VK_ERROR_INVALID_VALUE;
+   assert(format != NULL);
 
    gen = physical_device->info->gen * 10;
    if (physical_device->info->is_haswell)
index 8522d0e831842709a54cf56ea3e0ca90f90b1c3c..014a9b9b342544c452a3429f1c7ecd48d9da630c 100644 (file)
@@ -102,10 +102,7 @@ static const struct anv_tile_info {
    [WMAJOR] = { 128, 32, 4096 },
 };
 
-/**
- * Return -1 on failure.
- */
-static int8_t
+static uint8_t
 anv_image_choose_tile_mode(const struct anv_image_create_info *anv_info)
 {
    if (anv_info->force_tile_mode)
@@ -117,11 +114,8 @@ anv_image_choose_tile_mode(const struct anv_image_create_info *anv_info)
 
    switch (anv_info->vk_info->tiling) {
    case VK_IMAGE_TILING_LINEAR:
-      if (unlikely(anv_info->vk_info->format == VK_FORMAT_S8_UINT)) {
-         return -1;
-      } else {
-         return LINEAR;
-      }
+      assert(anv_info->vk_info->format != VK_FORMAT_S8_UINT);
+      return LINEAR;
    case VK_IMAGE_TILING_OPTIMAL:
       if (unlikely(anv_info->vk_info->format == VK_FORMAT_S8_UINT)) {
          return WMAJOR;
@@ -153,10 +147,7 @@ anv_image_make_surface(const struct anv_image_create_info *create_info,
    const VkExtent3D *restrict extent = &create_info->vk_info->extent;
    const uint32_t levels = create_info->vk_info->mipLevels;
    const uint32_t array_size = create_info->vk_info->arraySize;
-
-   const int8_t tile_mode = anv_image_choose_tile_mode(create_info);
-   if (tile_mode == -1)
-      return vk_error(VK_ERROR_INVALID_IMAGE);
+   const uint8_t tile_mode = anv_image_choose_tile_mode(create_info);
 
    const struct anv_tile_info *tile_info =
        &anv_tile_info_table[tile_mode];
@@ -305,12 +296,10 @@ anv_image_create(VkDevice _device,
    const struct anv_surf_type_limits *limits =
       &anv_surf_type_limits[surf_type];
 
-   if (extent->width > limits->width ||
-       extent->height > limits->height ||
-       extent->depth > limits->depth) {
-      /* TODO(chadv): What is the correct error? */
-      return vk_errorf(VK_ERROR_INVALID_MEMORY_SIZE, "image extent is too large");
-   }
+   /* Errors should be caught by VkImageFormatProperties. */
+   assert(extent->width <= limits->width);
+   assert(extent->height <= limits->height);
+   assert(extent->depth <= limits->depth);
 
    image = anv_device_alloc(device, sizeof(*image), 8,
                             VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
index 9464531b8c5cac9f9406424bfd76ae7c516b2d30..68535b40cacfa407d0eeeefc2e2eafa7e9b9a7f9 100644 (file)
@@ -120,8 +120,11 @@ VkResult anv_GetQueryPoolResults(
 
    if (flags & VK_QUERY_RESULT_WAIT_BIT) {
       ret = anv_gem_wait(device, pool->bo.gem_handle, &timeout);
-      if (ret == -1)
-         return vk_errorf(VK_ERROR_UNKNOWN, "gem_wait failed %m");
+      if (ret == -1) {
+         /* We don't know the real error. */
+         return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
+                          "gem_wait failed %m");
+      }
    }
 
    for (uint32_t i = 0; i < queryCount; i++) {
index 4c8fadcc805ec7777bb419919297fb6dacac45c1..628e399cb3e2ca322eae62bf368943179c1c9784 100644 (file)
@@ -92,39 +92,20 @@ __vk_errorf(VkResult error, const char *file, int line, const char *format, ...)
 
    const char *error_str;
    switch ((int32_t)error) {
-   ERROR_CASE(VK_ERROR_UNKNOWN)
-   ERROR_CASE(VK_ERROR_UNAVAILABLE)
-   ERROR_CASE(VK_ERROR_INITIALIZATION_FAILED)
+
+   /* Core errors */
    ERROR_CASE(VK_ERROR_OUT_OF_HOST_MEMORY)
    ERROR_CASE(VK_ERROR_OUT_OF_DEVICE_MEMORY)
-   ERROR_CASE(VK_ERROR_DEVICE_ALREADY_CREATED)
+   ERROR_CASE(VK_ERROR_INITIALIZATION_FAILED)
    ERROR_CASE(VK_ERROR_DEVICE_LOST)
-   ERROR_CASE(VK_ERROR_INVALID_POINTER)
-   ERROR_CASE(VK_ERROR_INVALID_VALUE)
-   ERROR_CASE(VK_ERROR_INVALID_HANDLE)
-   ERROR_CASE(VK_ERROR_INVALID_ORDINAL)
-   ERROR_CASE(VK_ERROR_INVALID_MEMORY_SIZE)
-   ERROR_CASE(VK_ERROR_INVALID_EXTENSION)
-   ERROR_CASE(VK_ERROR_INVALID_FLAGS)
-   ERROR_CASE(VK_ERROR_INVALID_ALIGNMENT)
-   ERROR_CASE(VK_ERROR_INVALID_FORMAT)
-   ERROR_CASE(VK_ERROR_INVALID_IMAGE)
-   ERROR_CASE(VK_ERROR_INVALID_DESCRIPTOR_SET_DATA)
-   ERROR_CASE(VK_ERROR_INVALID_QUEUE_TYPE)
-   ERROR_CASE(VK_ERROR_UNSUPPORTED_SHADER_IL_VERSION)
-   ERROR_CASE(VK_ERROR_BAD_SHADER_CODE)
-   ERROR_CASE(VK_ERROR_BAD_PIPELINE_DATA)
-   ERROR_CASE(VK_ERROR_NOT_MAPPABLE)
    ERROR_CASE(VK_ERROR_MEMORY_MAP_FAILED)
-   ERROR_CASE(VK_ERROR_MEMORY_UNMAP_FAILED)
-   ERROR_CASE(VK_ERROR_INCOMPATIBLE_DEVICE)
+   ERROR_CASE(VK_ERROR_LAYER_NOT_PRESENT)
+   ERROR_CASE(VK_ERROR_EXTENSION_NOT_PRESENT)
    ERROR_CASE(VK_ERROR_INCOMPATIBLE_DRIVER)
-   ERROR_CASE(VK_ERROR_INCOMPLETE_COMMAND_BUFFER)
-   ERROR_CASE(VK_ERROR_BUILDING_COMMAND_BUFFER)
-   ERROR_CASE(VK_ERROR_MEMORY_NOT_BOUND)
-   ERROR_CASE(VK_ERROR_INCOMPATIBLE_QUEUE)
-   ERROR_CASE(VK_ERROR_INVALID_LAYER)
+
+   /* Extension errors */
    ERROR_CASE(VK_ERROR_OUT_OF_DATE_WSI)
+
    default:
       assert(!"Unknown error");
       error_str = "unknown error";
index a601ad1851f3ea6e7139f914b5c9b992b93f3c0d..ba3ce8a2c657e4f025c93c61f1f648e83de5ab03 100644 (file)
@@ -322,10 +322,11 @@ wsi_wl_get_surface_info(struct anv_wsi_implementation *impl,
 {
    struct wsi_wayland *wsi = (struct wsi_wayland *)impl;
 
-   if (pDataSize == NULL)
-      return vk_error(VK_ERROR_INVALID_POINTER);
+   assert(pDataSize != NULL);
 
    switch (infoType) {
+   default:
+      unreachable("bad VkSurfaceInfoTypeWSI");
    case VK_SURFACE_INFO_TYPE_PROPERTIES_WSI: {
       VkSurfacePropertiesWSI *props = pData;
 
@@ -384,8 +385,6 @@ wsi_wl_get_surface_info(struct anv_wsi_implementation *impl,
       memcpy(pData, present_modes, *pDataSize);
 
       return VK_SUCCESS;
-   default:
-      return vk_error(VK_ERROR_INVALID_VALUE);
    }
 }
 
@@ -423,6 +422,8 @@ wsi_wl_get_swap_chain_info(struct anv_swap_chain *anv_chain,
    size_t size;
 
    switch (infoType) {
+   default:
+      unreachable("bad VkSwapChainInfoTypeWSI");
    case VK_SWAP_CHAIN_INFO_TYPE_IMAGES_WSI: {
       VkSwapChainImagePropertiesWSI *images = pData;
 
@@ -441,9 +442,6 @@ wsi_wl_get_swap_chain_info(struct anv_swap_chain *anv_chain,
 
       return VK_SUCCESS;
    }
-
-   default:
-      return vk_error(VK_ERROR_INVALID_VALUE);
    }
 }
 
@@ -615,14 +613,16 @@ wsi_wl_image_init(struct wsi_wl_swap_chain *chain, struct wsi_wl_image *image)
                                 image->memory->bo.gem_handle,
                                 surface->stride, I915_TILING_X);
    if (ret) {
-      result = vk_error(VK_ERROR_UNKNOWN);
+      /* FINISHME: Choose a better error. */
+      result = vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
       goto fail_mem;
    }
 
    int fd = anv_gem_handle_to_fd(chain->base.device,
                                  image->memory->bo.gem_handle);
    if (fd == -1) {
-      result = vk_error(VK_ERROR_UNKNOWN);
+      /* FINISHME: Choose a better error. */
+      result = vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
       goto fail_mem;
    }
 
@@ -769,8 +769,13 @@ anv_wl_init_wsi(struct anv_instance *instance)
 
    int ret = pthread_mutex_init(&wsi->mutex, NULL);
    if (ret != 0) {
-      result = (ret == ENOMEM) ? VK_ERROR_OUT_OF_HOST_MEMORY :
-                                 VK_ERROR_UNKNOWN;
+      if (ret == ENOMEM) {
+         result = VK_ERROR_OUT_OF_HOST_MEMORY;
+      } else {
+         /* FINISHME: Choose a better error. */
+         result = VK_ERROR_OUT_OF_HOST_MEMORY;
+      }
+
       goto fail_alloc;
    }
 
index 03aef4cbf23d38d7a37054802fb3b76f567f2837..d226caf0eea5b081b7f4beca28a2fefe815df1f8 100644 (file)
@@ -54,10 +54,11 @@ x11_get_surface_info(struct anv_wsi_implementation *impl,
                      VkSurfaceInfoTypeWSI infoType,
                      size_t* pDataSize, void* pData)
 {
-   if (pDataSize == NULL)
-      return vk_error(VK_ERROR_INVALID_POINTER);
+   assert(pDataSize != NULL);
 
    switch (infoType) {
+   default:
+      unreachable("bad VkSurfaceInfoTypeWSI");
    case VK_SURFACE_INFO_TYPE_PROPERTIES_WSI: {
       VkSurfacePropertiesWSI *props = pData;
 
@@ -77,12 +78,9 @@ x11_get_surface_info(struct anv_wsi_implementation *impl,
       xcb_get_geometry_reply_t *geom = xcb_get_geometry_reply(conn, cookie,
                                                               &err);
       if (!geom) {
-         if (err->error_code == XCB_DRAWABLE) {
-            return vk_error(VK_ERROR_INVALID_HANDLE);
-         } else {
-            return vk_error(VK_ERROR_UNKNOWN);
-         }
+         /* FINISHME: Choose a more accurate error. */
          free(err);
+         return VK_ERROR_OUT_OF_DATE_WSI;
       }
 
       VkExtent2D extent = { geom->width, geom->height };
@@ -122,10 +120,7 @@ x11_get_surface_info(struct anv_wsi_implementation *impl,
 
       assert(*pDataSize >= sizeof(present_modes));
       memcpy(pData, present_modes, *pDataSize);
-
       return VK_SUCCESS;
-   default:
-      return vk_error(VK_ERROR_INVALID_VALUE);
    }
 }
 
@@ -158,6 +153,8 @@ x11_get_swap_chain_info(struct anv_swap_chain *anv_chain,
    size_t size;
 
    switch (infoType) {
+   default:
+      unreachable("bad VkSwapChainInfoType");
    case VK_SWAP_CHAIN_INFO_TYPE_IMAGES_WSI: {
       VkSwapChainImagePropertiesWSI *images = pData;
 
@@ -173,12 +170,8 @@ x11_get_swap_chain_info(struct anv_swap_chain *anv_chain,
          images[i].image = anv_image_to_handle(chain->images[i].image);
 
       *pDataSize = size;
-
       return VK_SUCCESS;
    }
-
-   default:
-      return vk_error(VK_ERROR_INVALID_VALUE);
    }
 }
 
@@ -196,13 +189,9 @@ x11_acquire_next_image(struct anv_swap_chain *anv_chain,
       xcb_get_geometry_reply_t *geom =
          xcb_get_geometry_reply(chain->conn, image->geom_cookie, &err);
       if (!geom) {
-         if (err->error_code == XCB_DRAWABLE) {
-            /* Probably the best thing to do if our drawable goes away */
-            return vk_error(VK_ERROR_OUT_OF_DATE_WSI);
-         } else {
-            return vk_error(VK_ERROR_UNKNOWN);
-         }
+         /* Probably the best thing to do if our drawable goes away */
          free(err);
+         return vk_error(VK_ERROR_OUT_OF_DATE_WSI);
       }
 
       if (geom->width != chain->extent.width ||
@@ -366,13 +355,17 @@ x11_create_swap_chain(struct anv_wsi_implementation *impl,
       int ret = anv_gem_set_tiling(device, memory->bo.gem_handle,
                                    surface->stride, I915_TILING_X);
       if (ret) {
-         result = vk_errorf(VK_ERROR_UNKNOWN, "set_tiling failed: %m");
+         /* FINISHME: Choose a better error. */
+         result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
+                            "set_tiling failed: %m");
          goto fail;
       }
 
       int fd = anv_gem_handle_to_fd(device, memory->bo.gem_handle);
       if (fd == -1) {
-         result = vk_errorf(VK_ERROR_UNKNOWN, "handle_to_fd failed: %m");
+         /* FINISHME: Choose a better error. */
+         result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
+                            "handle_to_fd failed: %m");
          goto fail;
       }
 
@@ -400,7 +393,8 @@ x11_create_swap_chain(struct anv_wsi_implementation *impl,
 
    chain->gc = xcb_generate_id(chain->conn);
    if (!chain->gc) {
-      result = vk_error(VK_ERROR_UNKNOWN);
+      /* FINISHME: Choose a better error. */
+      result = vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
       goto fail;
    }
 
index 599432ed68ab59107df2de7a0f5de2a1dfcece73..affe04c526f03c888bd6e4d76080fbd1af8eaac9 100644 (file)
@@ -567,6 +567,5 @@ VkResult gen7_compute_pipeline_create(
     VkPipeline*                                 pPipeline)
 {
    anv_finishme("primitive_id needs sbe swizzling setup");
-
-   return vk_error(VK_ERROR_UNAVAILABLE);
+   abort();
 }