radv: use enum_to_str util functions.
authorEmil Velikov <emil.velikov@collabora.com>
Wed, 1 Mar 2017 12:09:14 +0000 (12:09 +0000)
committerEmil Velikov <emil.l.velikov@gmail.com>
Sat, 4 Mar 2017 15:05:14 +0000 (15:05 +0000)
Port of e9dcb17962f7e58a81c93bae7bd33885675b1043
vulkan/util: Add generator for enum_to_str functions

Cc: Bas Nieuwenhuizen <basni@google.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
src/amd/vulkan/Makefile.am
src/amd/vulkan/radv_util.c

index 740f2f92e7b77eca9b28a3adf89fd2f5a844700d..3379a3d6a8998ceeefa9f4fcc8155e036392b475 100644 (file)
@@ -34,6 +34,8 @@ AM_CPPFLAGS = \
        -I$(top_builddir)/src \
        -I$(top_srcdir)/src \
        -I$(top_srcdir)/src/vulkan/wsi \
+       -I$(top_builddir)/src/vulkan/util \
+       -I$(top_srcdir)/src/vulkan/util \
        -I$(top_srcdir)/src/amd \
        -I$(top_srcdir)/src/amd/common \
        -I$(top_builddir)/src/compiler \
@@ -92,6 +94,7 @@ libvulkan_common_la_SOURCES = $(VULKAN_SOURCES)
 
 VULKAN_LIB_DEPS += \
        libvulkan_common.la \
+       $(top_builddir)/src/vulkan/libvulkan_util.la \
        $(top_builddir)/src/vulkan/libvulkan_wsi.la \
        $(top_builddir)/src/amd/common/libamd_common.la \
        $(top_builddir)/src/amd/addrlib/libamdgpu_addrlib.la \
index 684956e9a416bf296377fdf47a9aa8c16922d269..b892eb788519b52d9ee804bccf2743b68ffa8a12 100644 (file)
@@ -29,6 +29,7 @@
 #include <assert.h>
 
 #include "radv_private.h"
+#include "vk_enum_to_str.h"
 
 #include "util/u_math.h"
 
@@ -71,40 +72,7 @@ __vk_errorf(VkResult error, const char *file, int line, const char *format, ...)
        va_list ap;
        char buffer[256];
 
-#define ERROR_CASE(error) case error: error_str = #error; break;
-
-       const char *error_str;
-       switch ((int32_t)error) {
-
-               /* Core errors */
-               ERROR_CASE(VK_ERROR_OUT_OF_HOST_MEMORY)
-                       ERROR_CASE(VK_ERROR_OUT_OF_DEVICE_MEMORY)
-                       ERROR_CASE(VK_ERROR_INITIALIZATION_FAILED)
-                       ERROR_CASE(VK_ERROR_DEVICE_LOST)
-                       ERROR_CASE(VK_ERROR_MEMORY_MAP_FAILED)
-                       ERROR_CASE(VK_ERROR_LAYER_NOT_PRESENT)
-                       ERROR_CASE(VK_ERROR_EXTENSION_NOT_PRESENT)
-                       ERROR_CASE(VK_ERROR_FEATURE_NOT_PRESENT)
-                       ERROR_CASE(VK_ERROR_INCOMPATIBLE_DRIVER)
-                       ERROR_CASE(VK_ERROR_TOO_MANY_OBJECTS)
-                       ERROR_CASE(VK_ERROR_FORMAT_NOT_SUPPORTED)
-                       ERROR_CASE(VK_ERROR_FRAGMENTED_POOL)
-
-                       /* Extension errors */
-                       ERROR_CASE(VK_ERROR_SURFACE_LOST_KHR)
-                       ERROR_CASE(VK_ERROR_NATIVE_WINDOW_IN_USE_KHR)
-                       ERROR_CASE(VK_ERROR_OUT_OF_DATE_KHR)
-                       ERROR_CASE(VK_ERROR_INCOMPATIBLE_DISPLAY_KHR)
-                       ERROR_CASE(VK_ERROR_VALIDATION_FAILED_EXT)
-                       ERROR_CASE(VK_ERROR_INVALID_SHADER_NV)
-                       ERROR_CASE(VK_ERROR_OUT_OF_POOL_MEMORY_KHR)
-
-       default:
-               assert(!"Unknown error");
-               error_str = "unknown error";
-       }
-
-#undef ERROR_CASE
+       const char *error_str = vk_Result_to_str(error);
 
        if (format) {
                va_start(ap, format);