[Mesa-dev] [PATCH v2 22/26] ddebug: generalize print_named_xxx via a PRINT_NAMED macro

Nicolai Hähnle nhaehnle at gmail.com
Mon Nov 6 10:23:53 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
---
 src/gallium/drivers/ddebug/dd_draw.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/src/gallium/drivers/ddebug/dd_draw.c b/src/gallium/drivers/ddebug/dd_draw.c
index 99c9c929b2e..a856d0142a1 100644
--- a/src/gallium/drivers/ddebug/dd_draw.c
+++ b/src/gallium/drivers/ddebug/dd_draw.c
@@ -127,31 +127,26 @@ dd_num_active_viewports(struct dd_draw_state *dstate)
    util_dump_##name(f, (var)->member); \
    fprintf(f, "\n"); \
 } while(0)
 
 #define DUMP_M_ADDR(name, var, member) do { \
    fprintf(f, "  " #member ": "); \
    util_dump_##name(f, &(var)->member); \
    fprintf(f, "\n"); \
 } while(0)
 
-static void
-print_named_value(FILE *f, const char *name, int value)
-{
-   fprintf(f, COLOR_STATE "%s" COLOR_RESET " = %i\n", name, value);
-}
-
-static void
-print_named_xvalue(FILE *f, const char *name, int value)
-{
-   fprintf(f, COLOR_STATE "%s" COLOR_RESET " = 0x%08x\n", name, value);
-}
+#define PRINT_NAMED(type, name, value) \
+do { \
+   fprintf(f, COLOR_STATE "%s" COLOR_RESET " = ", name); \
+   util_dump_##type(f, value); \
+   fprintf(f, "\n"); \
+} while (0)
 
 static void
 util_dump_uint(FILE *f, unsigned i)
 {
    fprintf(f, "%u", i);
 }
 
 static void
 util_dump_int(FILE *f, int i)
 {
@@ -305,29 +300,29 @@ dd_dump_draw_vbo(struct dd_draw_state *dstate, struct pipe_draw_info *info, FILE
    dd_dump_render_condition(dstate, f);
 
    for (i = 0; i < PIPE_MAX_ATTRIBS; i++)
       if (dstate->vertex_buffers[i].buffer.resource) {
          DUMP_I(vertex_buffer, &dstate->vertex_buffers[i], i);
          if (!dstate->vertex_buffers[i].is_user_buffer)
             DUMP_M(resource, &dstate->vertex_buffers[i], buffer.resource);
       }
 
    if (dstate->velems) {
-      print_named_value(f, "num vertex elements",
+      PRINT_NAMED(uint, "num vertex elements",
                         dstate->velems->state.velems.count);
       for (i = 0; i < dstate->velems->state.velems.count; i++) {
          fprintf(f, "  ");
          DUMP_I(vertex_element, &dstate->velems->state.velems.velems[i], i);
       }
    }
 
-   print_named_value(f, "num stream output targets", dstate->num_so_targets);
+   PRINT_NAMED(uint, "num stream output targets", dstate->num_so_targets);
    for (i = 0; i < dstate->num_so_targets; i++)
       if (dstate->so_targets[i]) {
          DUMP_I(stream_output_target, dstate->so_targets[i], i);
          DUMP_M(resource, dstate->so_targets[i], buffer);
          fprintf(f, "  offset = %i\n", dstate->so_offsets[i]);
       }
 
    fprintf(f, "\n");
    for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) {
       if (sh == PIPE_SHADER_COMPUTE)
@@ -337,22 +332,22 @@ dd_dump_draw_vbo(struct dd_draw_state *dstate, struct pipe_draw_info *info, FILE
    }
 
    if (dstate->dsa)
       DUMP(depth_stencil_alpha_state, &dstate->dsa->state.dsa);
    DUMP(stencil_ref, &dstate->stencil_ref);
 
    if (dstate->blend)
       DUMP(blend_state, &dstate->blend->state.blend);
    DUMP(blend_color, &dstate->blend_color);
 
-   print_named_value(f, "min_samples", dstate->min_samples);
-   print_named_xvalue(f, "sample_mask", dstate->sample_mask);
+   PRINT_NAMED(uint, "min_samples", dstate->min_samples);
+   PRINT_NAMED(hex, "sample_mask", dstate->sample_mask);
    fprintf(f, "\n");
 
    DUMP(framebuffer_state, &dstate->framebuffer_state);
    for (i = 0; i < dstate->framebuffer_state.nr_cbufs; i++)
       if (dstate->framebuffer_state.cbufs[i]) {
          fprintf(f, "  " COLOR_STATE "cbufs[%i]:" COLOR_RESET "\n    ", i);
          DUMP(surface, dstate->framebuffer_state.cbufs[i]);
          fprintf(f, "    ");
          DUMP(resource, dstate->framebuffer_state.cbufs[i]->texture);
       }
-- 
2.11.0



More information about the mesa-dev mailing list