[Mesa-dev] [PATCH] radv: use enum_to_str util functions.

Eric Engestrom eric.engestrom at imgtec.com
Wed Mar 1 17:25:36 UTC 2017


On Wednesday, 2017-03-01 12:09:14 +0000, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
> 
> Port of e9dcb17962f7e58a81c93bae7bd33885675b1043
> vulkan/util: Add generator for enum_to_str functions
> 
> Cc: Bas Nieuwenhuizen <basni at google.com>
> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>

Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>

> ---
>  src/amd/vulkan/Makefile.am |  3 +++
>  src/amd/vulkan/radv_util.c | 36 ++----------------------------------
>  2 files changed, 5 insertions(+), 34 deletions(-)
> 
> diff --git a/src/amd/vulkan/Makefile.am b/src/amd/vulkan/Makefile.am
> index 740f2f92e7..dfb94078c1 100644
> --- a/src/amd/vulkan/Makefile.am
> +++ b/src/amd/vulkan/Makefile.am
> @@ -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/util/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 \
> diff --git a/src/amd/vulkan/radv_util.c b/src/amd/vulkan/radv_util.c
> index 684956e9a4..b892eb7885 100644
> --- a/src/amd/vulkan/radv_util.c
> +++ b/src/amd/vulkan/radv_util.c
> @@ -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);
> -- 
> 2.11.1
> 


More information about the mesa-dev mailing list