From 216a576e111b85662eabd8d4c398149818adbf39 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 29 Jul 2013 13:51:56 +0800 Subject: [PATCH] ilo: add ILO_DEBUG=draw It can print out pipe_draw_info and the dirty bits set, useful for debugging. --- src/gallium/drivers/ilo/ilo_3d.c | 16 +++++++++ src/gallium/drivers/ilo/ilo_common.h | 13 +++++-- src/gallium/drivers/ilo/ilo_screen.c | 1 + src/gallium/drivers/ilo/ilo_state.c | 52 ++++++++++++++++++++++++++++ src/gallium/drivers/ilo/ilo_state.h | 3 ++ 5 files changed, 83 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_3d.c b/src/gallium/drivers/ilo/ilo_3d.c index 5b120e77d09..3a810adf6f6 100644 --- a/src/gallium/drivers/ilo/ilo_3d.c +++ b/src/gallium/drivers/ilo/ilo_3d.c @@ -25,6 +25,7 @@ * Chia-I Wu */ +#include "util/u_prim.h" #include "intel_winsys.h" #include "ilo_3d_pipeline.h" @@ -701,6 +702,21 @@ ilo_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) struct ilo_3d *hw3d = ilo->hw3d; int prim_generated, prim_emitted; + if (ilo_debug & ILO_DEBUG_DRAW) { + if (info->indexed) { + ilo_printf("indexed draw %s: " + "index start %d, count %d, vertex range [%d, %d]\n", + u_prim_name(info->mode), info->start, info->count, + info->min_index, info->max_index); + } + else { + ilo_printf("draw %s: vertex start %d, count %d\n", + u_prim_name(info->mode), info->start, info->count); + } + + ilo_dump_dirty_flags(ilo->dirty); + } + if (!ilo_3d_pass_render_condition(ilo)) return; diff --git a/src/gallium/drivers/ilo/ilo_common.h b/src/gallium/drivers/ilo/ilo_common.h index 1e1b4b56a4b..dd87734517c 100644 --- a/src/gallium/drivers/ilo/ilo_common.h +++ b/src/gallium/drivers/ilo/ilo_common.h @@ -43,15 +43,24 @@ #define ILO_GEN(gen) ((int) (gen * 100)) #define ILO_GEN_GET_MAJOR(gen) (gen / 100) +/* enable debug flags affecting hot pathes only with debug builds */ +#ifdef DEBUG +#define ILO_DEBUG_HOT 1 +#else +#define ILO_DEBUG_HOT 0 +#endif + enum ilo_debug { ILO_DEBUG_3D = 1 << 0, ILO_DEBUG_VS = 1 << 1, ILO_DEBUG_GS = 1 << 2, ILO_DEBUG_FS = 1 << 3, ILO_DEBUG_CS = 1 << 4, + ILO_DEBUG_DRAW = ILO_DEBUG_HOT << 5, - ILO_DEBUG_NOHW = 1 << 8, - ILO_DEBUG_NOCACHE = 1 << 9, + /* flags that affect the behaviors of the driver */ + ILO_DEBUG_NOHW = 1 << 20, + ILO_DEBUG_NOCACHE = 1 << 21, }; struct ilo_dev_info { diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c index 9f3235ce4ce..6d5b2ffbd97 100644 --- a/src/gallium/drivers/ilo/ilo_screen.c +++ b/src/gallium/drivers/ilo/ilo_screen.c @@ -46,6 +46,7 @@ static const struct debug_named_value ilo_debug_flags[] = { { "gs", ILO_DEBUG_GS, "Dump geometry shaders" }, { "fs", ILO_DEBUG_FS, "Dump fragment shaders" }, { "cs", ILO_DEBUG_CS, "Dump compute shaders" }, + { "draw", ILO_DEBUG_DRAW, "Show draw information" }, { "nohw", ILO_DEBUG_NOHW, "Do not send commands to HW" }, { "nocache", ILO_DEBUG_NOCACHE, "Always invalidate HW caches" }, DEBUG_NAMED_VALUE_END diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c index c72d93a49df..a0c80aed3d0 100644 --- a/src/gallium/drivers/ilo/ilo_state.c +++ b/src/gallium/drivers/ilo/ilo_state.c @@ -1452,3 +1452,55 @@ ilo_mark_states_with_resource_dirty(struct ilo_context *ilo, ilo->dirty |= states; } + +void +ilo_dump_dirty_flags(uint32_t dirty) +{ + static const char *state_names[ILO_STATE_COUNT] = { + [ILO_STATE_VB] = "VB", + [ILO_STATE_VE] = "VE", + [ILO_STATE_IB] = "IB", + [ILO_STATE_VS] = "VS", + [ILO_STATE_GS] = "GS", + [ILO_STATE_SO] = "SO", + [ILO_STATE_CLIP] = "CLIP", + [ILO_STATE_VIEWPORT] = "VIEWPORT", + [ILO_STATE_SCISSOR] = "SCISSOR", + [ILO_STATE_RASTERIZER] = "RASTERIZER", + [ILO_STATE_POLY_STIPPLE] = "POLY_STIPPLE", + [ILO_STATE_SAMPLE_MASK] = "SAMPLE_MASK", + [ILO_STATE_FS] = "FS", + [ILO_STATE_DSA] = "DSA", + [ILO_STATE_STENCIL_REF] = "STENCIL_REF", + [ILO_STATE_BLEND] = "BLEND", + [ILO_STATE_BLEND_COLOR] = "BLEND_COLOR", + [ILO_STATE_FB] = "FB", + [ILO_STATE_SAMPLER_VS] = "SAMPLER_VS", + [ILO_STATE_SAMPLER_GS] = "SAMPLER_GS", + [ILO_STATE_SAMPLER_FS] = "SAMPLER_FS", + [ILO_STATE_SAMPLER_CS] = "SAMPLER_CS", + [ILO_STATE_VIEW_VS] = "VIEW_VS", + [ILO_STATE_VIEW_GS] = "VIEW_GS", + [ILO_STATE_VIEW_FS] = "VIEW_FS", + [ILO_STATE_VIEW_CS] = "VIEW_CS", + [ILO_STATE_CBUF] = "CBUF", + [ILO_STATE_RESOURCE] = "RESOURCE", + [ILO_STATE_CS] = "CS", + [ILO_STATE_CS_RESOURCE] = "CS_RESOURCE", + [ILO_STATE_GLOBAL_BINDING] = "GLOBAL_BINDING", + }; + + if (!dirty) { + ilo_printf("no state is dirty\n"); + return; + } + + dirty &= (1U << ILO_STATE_COUNT) - 1; + + ilo_printf("%2d states are dirty:", util_bitcount(dirty)); + while (dirty) { + const enum ilo_state state = u_bit_scan(&dirty); + ilo_printf(" %s", state_names[state]); + } + ilo_printf("\n"); +} diff --git a/src/gallium/drivers/ilo/ilo_state.h b/src/gallium/drivers/ilo/ilo_state.h index 48abcb1b373..0509fa04291 100644 --- a/src/gallium/drivers/ilo/ilo_state.h +++ b/src/gallium/drivers/ilo/ilo_state.h @@ -136,4 +136,7 @@ void ilo_mark_states_with_resource_dirty(struct ilo_context *ilo, const struct pipe_resource *res); +void +ilo_dump_dirty_flags(uint32_t dirty); + #endif /* ILO_STATE_H */ -- 2.30.2