From: Jason Ekstrand Date: Tue, 8 Sep 2015 19:13:07 +0000 (-0700) Subject: vk/error: Handle ERROR_OUT_OF_DATE_WSI X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8040dc4ca5e05a24c30ad3a428498cf82ded6bf6;p=mesa.git vk/error: Handle ERROR_OUT_OF_DATE_WSI --- diff --git a/src/vulkan/anv_util.c b/src/vulkan/anv_util.c index 94f14f98f8f..4c8fadcc805 100644 --- a/src/vulkan/anv_util.c +++ b/src/vulkan/anv_util.c @@ -88,52 +88,58 @@ __vk_errorf(VkResult error, const char *file, int line, const char *format, ...) va_list ap; char buffer[256]; - static const char *error_names[] = { - "VK_ERROR_UNKNOWN", - "VK_ERROR_UNAVAILABLE", - "VK_ERROR_INITIALIZATION_FAILED", - "VK_ERROR_OUT_OF_HOST_MEMORY", - "VK_ERROR_OUT_OF_DEVICE_MEMORY", - "VK_ERROR_DEVICE_ALREADY_CREATED", - "VK_ERROR_DEVICE_LOST", - "VK_ERROR_INVALID_POINTER", - "VK_ERROR_INVALID_VALUE", - "VK_ERROR_INVALID_HANDLE", - "VK_ERROR_INVALID_ORDINAL", - "VK_ERROR_INVALID_MEMORY_SIZE", - "VK_ERROR_INVALID_EXTENSION", - "VK_ERROR_INVALID_FLAGS", - "VK_ERROR_INVALID_ALIGNMENT", - "VK_ERROR_INVALID_FORMAT", - "VK_ERROR_INVALID_IMAGE", - "VK_ERROR_INVALID_DESCRIPTOR_SET_DATA", - "VK_ERROR_INVALID_QUEUE_TYPE", - "VK_ERROR_UNSUPPORTED_SHADER_IL_VERSION", - "VK_ERROR_BAD_SHADER_CODE", - "VK_ERROR_BAD_PIPELINE_DATA", - "VK_ERROR_NOT_MAPPABLE", - "VK_ERROR_MEMORY_MAP_FAILED", - "VK_ERROR_MEMORY_UNMAP_FAILED", - "VK_ERROR_INCOMPATIBLE_DEVICE", - "VK_ERROR_INCOMPATIBLE_DRIVER", - "VK_ERROR_INCOMPLETE_COMMAND_BUFFER", - "VK_ERROR_BUILDING_COMMAND_BUFFER", - "VK_ERROR_MEMORY_NOT_BOUND", - "VK_ERROR_INCOMPATIBLE_QUEUE", - "VK_ERROR_INVALID_LAYER", - }; - - assert(error <= VK_ERROR_UNKNOWN && error >= VK_ERROR_INVALID_LAYER); +#define ERROR_CASE(error) case error: error_str = #error; break; + + const char *error_str; + switch ((int32_t)error) { + ERROR_CASE(VK_ERROR_UNKNOWN) + ERROR_CASE(VK_ERROR_UNAVAILABLE) + ERROR_CASE(VK_ERROR_INITIALIZATION_FAILED) + 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_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_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) + ERROR_CASE(VK_ERROR_OUT_OF_DATE_WSI) + default: + assert(!"Unknown error"); + error_str = "unknown error"; + } + +#undef ERROR_CASE if (format) { va_start(ap, format); vsnprintf(buffer, sizeof(buffer), format, ap); va_end(ap); - fprintf(stderr, "%s:%d: %s (%s)\n", file, line, - buffer, error_names[-error - 1]); + fprintf(stderr, "%s:%d: %s (%s)\n", file, line, buffer, error_str); } else { - fprintf(stderr, "%s:%d: %s\n", file, line, error_names[-error - 1]); + fprintf(stderr, "%s:%d: %s\n", file, line, error_str); } return error; diff --git a/src/vulkan/anv_wsi_x11.c b/src/vulkan/anv_wsi_x11.c index be4677ae7ed..f481a017001 100644 --- a/src/vulkan/anv_wsi_x11.c +++ b/src/vulkan/anv_wsi_x11.c @@ -189,7 +189,7 @@ x11_acquire_next_image(struct anv_swap_chain *anv_chain, if (geom->width != chain->extent.width || geom->height != chain->extent.height) { free(geom); - return VK_ERROR_OUT_OF_DATE_WSI; + return vk_error(VK_ERROR_OUT_OF_DATE_WSI); } free(geom); }