From: Erik Faye-Lund Date: Mon, 20 Aug 2018 11:08:55 +0000 (+0200) Subject: virgl: introduce $VIRGL_DEBUG=verbose X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4ab06cc56e66118c4834ed8bbeed05e727bc34f7;p=mesa.git virgl: introduce $VIRGL_DEBUG=verbose This adds an environment-varaible that can be used for driver-specific flags, as well as a flag for it to enable verbose output. While we're at it, quiet some overly chatty debug-output by default. Signed-off-by: Erik Faye-Lund Reviewed-By: Gert Wollny --- diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c index dc1dd2d3c29..edc03f5dcf2 100644 --- a/src/gallium/drivers/virgl/virgl_context.c +++ b/src/gallium/drivers/virgl/virgl_context.c @@ -1115,8 +1115,10 @@ static void virgl_get_sample_position(struct pipe_context *ctx, } out_value[0] = ((bits >> 4) & 0xf) / 16.0f; out_value[1] = (bits & 0xf) / 16.0f; - debug_printf("VIRGL: sample postion [%2d/%2d] = (%f, %f)\n", - index, sample_count, out_value[0], out_value[1]); + + if (virgl_debug & VIRGL_DEBUG_VERBOSE) + debug_printf("VIRGL: sample postion [%2d/%2d] = (%f, %f)\n", + index, sample_count, out_value[0], out_value[1]); } struct pipe_context *virgl_context_create(struct pipe_screen *pscreen, diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c index d56484e0dd0..a13c3982ec3 100644 --- a/src/gallium/drivers/virgl/virgl_encode.c +++ b/src/gallium/drivers/virgl/virgl_encode.c @@ -261,7 +261,8 @@ int virgl_encode_shader_state(struct virgl_context *ctx, bret = tgsi_dump_str(tokens, TGSI_DUMP_FLOAT_AS_HEX, str, str_total_size); if (bret == false) { - debug_printf("Failed to translate shader in available space - trying again\n"); + if (virgl_debug & VIRGL_DEBUG_VERBOSE) + debug_printf("Failed to translate shader in available space - trying again\n"); old_size = str_total_size; str_total_size = 65536 * ++retry_size; str = REALLOC(str, old_size, str_total_size); diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c index c03ec4c9a97..a57c5b9df1f 100644 --- a/src/gallium/drivers/virgl/virgl_screen.c +++ b/src/gallium/drivers/virgl/virgl_screen.c @@ -36,6 +36,13 @@ #include "virgl_public.h" #include "virgl_context.h" +int virgl_debug = 0; +static const struct debug_named_value debug_options[] = { + { "verbose", VIRGL_DEBUG_VERBOSE, NULL }, + DEBUG_NAMED_VALUE_END +}; +DEBUG_GET_ONCE_FLAGS_OPTION(virgl_debug, "VIRGL_DEBUG", debug_options, 0) + static const char * virgl_get_vendor(struct pipe_screen *screen) { @@ -730,6 +737,8 @@ virgl_create_screen(struct virgl_winsys *vws) if (!screen) return NULL; + virgl_debug = debug_get_option_virgl_debug(); + screen->vws = vws; screen->base.get_name = virgl_get_name; screen->base.get_vendor = virgl_get_vendor; diff --git a/src/gallium/drivers/virgl/virgl_screen.h b/src/gallium/drivers/virgl/virgl_screen.h index dcf5816d603..8334d162424 100644 --- a/src/gallium/drivers/virgl/virgl_screen.h +++ b/src/gallium/drivers/virgl/virgl_screen.h @@ -27,6 +27,9 @@ #include "util/slab.h" #include "virgl_winsys.h" +#define VIRGL_DEBUG_VERBOSE 1 +extern int virgl_debug; + struct virgl_screen { struct pipe_screen base;