ilo: add ILO_DEBUG=draw
authorChia-I Wu <olvaffe@gmail.com>
Mon, 29 Jul 2013 05:51:56 +0000 (13:51 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Tue, 20 Aug 2013 05:54:38 +0000 (13:54 +0800)
It can print out pipe_draw_info and the dirty bits set, useful for debugging.

src/gallium/drivers/ilo/ilo_3d.c
src/gallium/drivers/ilo/ilo_common.h
src/gallium/drivers/ilo/ilo_screen.c
src/gallium/drivers/ilo/ilo_state.c
src/gallium/drivers/ilo/ilo_state.h

index 5b120e77d094bcf076e4d7872020b5cb9c456edc..3a810adf6f6558f2bc52c859ca1eeedf7ca6373f 100644 (file)
@@ -25,6 +25,7 @@
  *    Chia-I Wu <olv@lunarg.com>
  */
 
+#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;
 
index 1e1b4b56a4b5e050d8913f15b0458ed147a32610..dd87734517c6c7983a68b7b3ae14d131c7194d50 100644 (file)
 #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 {
index 9f3235ce4ce58d07fe473d52100273f8196eec3f..6d5b2ffbd97f5321492666ea1ac5ae9565a9f92a 100644 (file)
@@ -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
index c72d93a49df14011c39eb321b664edc8ae7bf180..a0c80aed3d02867524a433cda9ba3f2eaca2a883 100644 (file)
@@ -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");
+}
index 48abcb1b37325f1fc014321e2444e57515156b4d..0509fa042914f1deb87cc0591c522018a166f1f8 100644 (file)
@@ -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 */