From 991def0edc823293d593fc23d2243556cbdc0ff4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 21 Jul 2020 15:11:56 -0700 Subject: [PATCH] softpipe: Convert to comma-separated SOFTPIPE_DEBUG for debug options. This makes us more like other drivers, and avoids having tons of different names (particularly when you want to dump vs and fs in debugging). In the process, having a debug flag for vertex shaders just falls out. Reviewed-by: Dave Airlie Part-of: --- docs/envvars.rst | 25 ++++++++++++------- src/gallium/drivers/softpipe/sp_clear.c | 3 ++- src/gallium/drivers/softpipe/sp_context.c | 7 ------ src/gallium/drivers/softpipe/sp_context.h | 5 ---- src/gallium/drivers/softpipe/sp_screen.c | 16 ++++++++++-- src/gallium/drivers/softpipe/sp_screen.h | 11 ++++++++ src/gallium/drivers/softpipe/sp_setup.c | 10 +++++--- .../drivers/softpipe/sp_state_shader.c | 10 ++++---- 8 files changed, 55 insertions(+), 32 deletions(-) diff --git a/docs/envvars.rst b/docs/envvars.rst index de6d4960b7a..76397eec041 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -414,15 +414,22 @@ Clover environment variables Softpipe driver environment variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -``SOFTPIPE_DUMP_FS`` - if set, the softpipe driver will print fragment shaders to stderr -``SOFTPIPE_DUMP_GS`` - if set, the softpipe driver will print geometry shaders to stderr -``SOFTPIPE_NO_RAST`` - if set, rasterization is no-op'd. For profiling purposes. -``SOFTPIPE_USE_LLVM`` - if set, the softpipe driver will try to use LLVM JIT for vertex - shading processing. +``SOFTPIPE_DEBUG`` + a comma-separated list of named flags, which do various things: + + ``vs`` + Dump vertex shader assembly to stderr + ``fs`` + Dump fragment shader assembly to stderr + ``gs`` + Dump geometry shader assembly to stderr + ``cs`` + Dump compute shader assembly to stderr + ``no_rast`` + rasterization is no-op'd. For profiling purposes. + ``use_llvm`` + the softpipe driver will try to use LLVM JIT for vertex + shading processing. LLVMpipe driver environment variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/gallium/drivers/softpipe/sp_clear.c b/src/gallium/drivers/softpipe/sp_clear.c index 300cbd077d9..7ad4b0946be 100644 --- a/src/gallium/drivers/softpipe/sp_clear.c +++ b/src/gallium/drivers/softpipe/sp_clear.c @@ -37,6 +37,7 @@ #include "util/u_surface.h" #include "sp_clear.h" #include "sp_context.h" +#include "sp_screen.h" #include "sp_query.h" #include "sp_tile_cache.h" @@ -57,7 +58,7 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers, uint64_t cv; uint i; - if (softpipe->no_rast) + if (unlikely(sp_debug & SP_DBG_NO_RAST)) return; if (!softpipe_check_render_cond(softpipe)) diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index ed0e67829d3..6a896b8a41d 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -214,10 +214,6 @@ softpipe_create_context(struct pipe_screen *screen, softpipe->tgsi.buffer[i] = sp_create_tgsi_buffer(); } - softpipe->dump_fs = debug_get_bool_option( "SOFTPIPE_DUMP_FS", false ); - softpipe->dump_gs = debug_get_bool_option( "SOFTPIPE_DUMP_GS", false ); - softpipe->dump_cs = debug_get_bool_option( "SOFTPIPE_DUMP_CS", false ); - softpipe->pipe.screen = screen; softpipe->pipe.destroy = softpipe_destroy; softpipe->pipe.priv = priv; @@ -316,9 +312,6 @@ softpipe_create_context(struct pipe_screen *screen, (struct tgsi_buffer *) softpipe->tgsi.buffer[PIPE_SHADER_GEOMETRY]); - if (debug_get_bool_option( "SOFTPIPE_NO_RAST", false )) - softpipe->no_rast = TRUE; - softpipe->vbuf_backend = sp_create_vbuf_backend(softpipe); if (!softpipe->vbuf_backend) goto fail; diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h index 21b867ad1b7..d4be1efc945 100644 --- a/src/gallium/drivers/softpipe/sp_context.h +++ b/src/gallium/drivers/softpipe/sp_context.h @@ -204,11 +204,6 @@ struct softpipe_context { * of sp_sampler_view? */ struct softpipe_tex_tile_cache *tex_cache[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS]; - - unsigned dump_fs : 1; - unsigned dump_gs : 1; - unsigned dump_cs : 1; - unsigned no_rast : 1; }; diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index 49d571ac185..7066e2f0b51 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -46,7 +46,17 @@ #include "sp_fence.h" #include "sp_public.h" -DEBUG_GET_ONCE_BOOL_OPTION(use_llvm, "SOFTPIPE_USE_LLVM", FALSE) +static const struct debug_named_value sp_debug_options[] = { + {"vs", SP_DBG_VS, "dump vertex shader assembly to stderr"}, + {"gs", SP_DBG_GS, "dump geometry shader assembly to stderr"}, + {"fs", SP_DBG_FS, "dump fragment shader assembly to stderr"}, + {"cs", SP_DBG_CS, "dump compute shader assembly to stderr"}, + {"no_rast", SP_DBG_NO_RAST, "no-ops rasterization, for profiling purposes"}, + {"use_llvm", SP_DBG_USE_LLVM, "Use LLVM if available for shaders"}, +}; + +int sp_debug; +DEBUG_GET_ONCE_FLAGS_OPTION(sp_debug, "SOFTPIPE_DEBUG", sp_debug_options, 0) static const char * softpipe_get_vendor(struct pipe_screen *screen) @@ -519,6 +529,8 @@ softpipe_create_screen(struct sw_winsys *winsys) if (!screen) return NULL; + sp_debug = debug_get_option_sp_debug(); + screen->winsys = winsys; screen->base.destroy = softpipe_destroy_screen; @@ -534,7 +546,7 @@ softpipe_create_screen(struct sw_winsys *winsys) screen->base.context_create = softpipe_create_context; screen->base.flush_frontbuffer = softpipe_flush_frontbuffer; screen->base.get_compute_param = softpipe_get_compute_param; - screen->use_llvm = debug_get_option_use_llvm(); + screen->use_llvm = sp_debug & SP_DBG_USE_LLVM; softpipe_init_screen_texture_funcs(&screen->base); softpipe_init_screen_fence_funcs(&screen->base); diff --git a/src/gallium/drivers/softpipe/sp_screen.h b/src/gallium/drivers/softpipe/sp_screen.h index f0e929111c2..969fa378ecf 100644 --- a/src/gallium/drivers/softpipe/sp_screen.h +++ b/src/gallium/drivers/softpipe/sp_screen.h @@ -55,6 +55,17 @@ softpipe_screen( struct pipe_screen *pipe ) return (struct softpipe_screen *)pipe; } +enum sp_debug_flag { + SP_DBG_VS = BITFIELD_BIT(0), + /* SP_DBG_TCS = BITFIELD_BIT(1), */ + /* SP_DBG_TES = BITFIELD_BIT(2), */ + SP_DBG_GS = BITFIELD_BIT(3), + SP_DBG_FS = BITFIELD_BIT(4), + SP_DBG_CS = BITFIELD_BIT(5), + SP_DBG_USE_LLVM = BITFIELD_BIT(6), + SP_DBG_NO_RAST = BITFIELD_BIT(7), +}; +extern int sp_debug; #endif /* SP_SCREEN_H */ diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c index a91e4f588c8..c64337dc5e9 100644 --- a/src/gallium/drivers/softpipe/sp_setup.c +++ b/src/gallium/drivers/softpipe/sp_setup.c @@ -33,6 +33,7 @@ */ #include "sp_context.h" +#include "sp_screen.h" #include "sp_quad.h" #include "sp_quad_pipe.h" #include "sp_setup.h" @@ -808,7 +809,8 @@ sp_setup_tri(struct setup_context *setup, print_vertex(setup, v2); #endif - if (setup->softpipe->no_rast || setup->softpipe->rasterizer->rasterizer_discard) + if (unlikely(sp_debug & SP_DBG_NO_RAST) || + setup->softpipe->rasterizer->rasterizer_discard) return; det = calc_det(v0, v1, v2); @@ -1093,7 +1095,8 @@ sp_setup_line(struct setup_context *setup, print_vertex(setup, v1); #endif - if (setup->softpipe->no_rast || setup->softpipe->rasterizer->rasterizer_discard) + if (unlikely(sp_debug & SP_DBG_NO_RAST) || + setup->softpipe->rasterizer->rasterizer_discard) return; if (dx == 0 && dy == 0) @@ -1240,7 +1243,8 @@ sp_setup_point(struct setup_context *setup, assert(sinfo->valid); - if (setup->softpipe->no_rast || setup->softpipe->rasterizer->rasterizer_discard) + if (unlikely(sp_debug & SP_DBG_NO_RAST) || + setup->softpipe->rasterizer->rasterizer_discard) return; assert(setup->softpipe->reduced_prim == PIPE_PRIM_POINTS); diff --git a/src/gallium/drivers/softpipe/sp_state_shader.c b/src/gallium/drivers/softpipe/sp_state_shader.c index fef187e7f11..b53d5540bdb 100644 --- a/src/gallium/drivers/softpipe/sp_state_shader.c +++ b/src/gallium/drivers/softpipe/sp_state_shader.c @@ -26,6 +26,7 @@ **************************************************************************/ #include "sp_context.h" +#include "sp_screen.h" #include "sp_state.h" #include "sp_fs.h" #include "sp_texture.h" @@ -137,7 +138,7 @@ softpipe_create_fs_state(struct pipe_context *pipe, struct softpipe_context *softpipe = softpipe_context(pipe); struct sp_fragment_shader *state = CALLOC_STRUCT(sp_fragment_shader); - softpipe_create_shader_state(&state->shader, templ, softpipe->dump_fs); + softpipe_create_shader_state(&state->shader, templ, sp_debug & SP_DBG_FS); /* draw's fs state */ state->draw_shader = draw_create_fragment_shader(softpipe->draw, @@ -221,7 +222,7 @@ softpipe_create_vs_state(struct pipe_context *pipe, if (!state) goto fail; - softpipe_create_shader_state(&state->shader, templ, false); + softpipe_create_shader_state(&state->shader, templ, sp_debug & SP_DBG_VS); if (!state->shader.tokens) goto fail; @@ -281,7 +282,7 @@ softpipe_create_gs_state(struct pipe_context *pipe, if (!state) goto fail; - softpipe_create_shader_state(&state->shader, templ, softpipe->dump_gs); + softpipe_create_shader_state(&state->shader, templ, sp_debug & SP_DBG_GS); if (templ->tokens) { state->draw_data = draw_create_geometry_shader(softpipe->draw, templ); @@ -380,7 +381,6 @@ static void * softpipe_create_compute_state(struct pipe_context *pipe, const struct pipe_compute_state *templ) { - struct softpipe_context *softpipe = softpipe_context(pipe); const struct tgsi_token *tokens; struct sp_compute_shader *state; if (templ->ir_type != PIPE_SHADER_IR_TGSI) @@ -388,7 +388,7 @@ softpipe_create_compute_state(struct pipe_context *pipe, tokens = templ->prog; /* debug */ - if (softpipe->dump_cs) + if (sp_debug & SP_DBG_CS) tgsi_dump(tokens, 0); state = CALLOC_STRUCT(sp_compute_shader); -- 2.30.2