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 <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6018>
This commit is contained in:
Eric Anholt 2020-07-21 15:11:56 -07:00 committed by Marge Bot
parent 86cfb62b87
commit 991def0edc
8 changed files with 55 additions and 32 deletions

View 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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View 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))

View 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;

View 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;
};

View File

@ -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);

View 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 */

View 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);

View 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);