softpipe: Convert to comma-separated SOFTPIPE_DEBUG for debug options.
authorEric Anholt <eric@anholt.net>
Tue, 21 Jul 2020 22:11:56 +0000 (15:11 -0700)
committerMarge Bot <eric+marge@anholt.net>
Thu, 23 Jul 2020 00:24:26 +0000 (00:24 +0000)
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 <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6018>

docs/envvars.rst
src/gallium/drivers/softpipe/sp_clear.c
src/gallium/drivers/softpipe/sp_context.c
src/gallium/drivers/softpipe/sp_context.h
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/softpipe/sp_screen.h
src/gallium/drivers/softpipe/sp_setup.c
src/gallium/drivers/softpipe/sp_state_shader.c

index de6d4960b7a3e420c2207ba3c685b3c8b7cef54f..76397eec0416bc3246e182b3fd7a82367782d82b 100644 (file)
@@ -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
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index 300cbd077d9638a039a2a3af59f4ffaf479dc193..7ad4b0946be62777ccd82cfad12b3d2d533bc2c0 100644 (file)
@@ -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))
index ed0e67829d3e9653bbe2107d93337ec7728f43b3..6a896b8a41d70ac09266ec6d47dfbf0f66841103 100644 (file)
@@ -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;
index 21b867ad1b7a9783327aefbfa2a80ea9325fbc98..d4be1efc945a9db16e65a1202cd5f3a1f7767158 100644 (file)
@@ -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;
 };
 
 
index 49d571ac185cd62de75677ae26365de335da6c22..7066e2f0b51b083162d98b468665baff2f041cba 100644 (file)
 #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);
index f0e929111c25d87f4c56a299905c17d5625f858d..969fa378ecfc20b9b0ffac19b4a0018b1c035a1f 100644 (file)
@@ -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 */
index a91e4f588c8e5f83e5c016293f58d22ed1ecedfa..c64337dc5e9e2e3983a3f82b4c258e333bbdaf28 100644 (file)
@@ -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);
index fef187e7f114c62acc46174b88e759e716a149f4..b53d5540bdb2b1fb8cc25369d40ccbe01865d365 100644 (file)
@@ -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);