[Mesa-dev] [PATCH 2/2] ddebug: dump shader buffers and images

Marek Olšák maraeo at gmail.com
Mon Sep 12 21:18:40 UTC 2016


From: Marek Olšák <marek.olsak at amd.com>

this was unimplemented
---
 src/gallium/auxiliary/util/u_dump.h       |  3 +++
 src/gallium/auxiliary/util/u_dump_state.c | 19 +++++++++++++++++++
 src/gallium/drivers/ddebug/dd_draw.c      | 30 +++++++++++++++++++++++++++---
 3 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_dump.h b/src/gallium/auxiliary/util/u_dump.h
index 2598851..bce8517 100644
--- a/src/gallium/auxiliary/util/u_dump.h
+++ b/src/gallium/auxiliary/util/u_dump.h
@@ -152,20 +152,23 @@ util_dump_sampler_state(FILE *stream,
                         const struct pipe_sampler_state *state);
 
 void
 util_dump_surface(FILE *stream,
                   const struct pipe_surface *state);
 
 void
 util_dump_image_view(FILE *stream, const struct pipe_image_view *state);
 
 void
+util_dump_shader_buffer(FILE *stream, const struct pipe_shader_buffer *state);
+
+void
 util_dump_sampler_view(FILE *stream, const struct pipe_sampler_view *state);
 
 void
 util_dump_transfer(FILE *stream,
                    const struct pipe_transfer *state);
 
 void
 util_dump_constant_buffer(FILE *stream,
                           const struct pipe_constant_buffer *state);
 
diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c
index 6aecee1..06d5e78 100644
--- a/src/gallium/auxiliary/util/u_dump_state.c
+++ b/src/gallium/auxiliary/util/u_dump_state.c
@@ -729,20 +729,39 @@ util_dump_image_view(FILE *stream, const struct pipe_image_view *state)
       util_dump_member(stream, uint, state, u.tex.first_layer);
       util_dump_member(stream, uint, state, u.tex.last_layer);
       util_dump_member(stream, uint, state, u.tex.level);
    }
 
    util_dump_struct_end(stream);
 }
 
 
 void
+util_dump_shader_buffer(FILE *stream, const struct pipe_shader_buffer *state)
+{
+   if (!state) {
+      util_dump_null(stream);
+      return;
+   }
+
+   util_dump_struct_begin(stream, "pipe_shader_buffer");
+
+   util_dump_member(stream, ptr, state, buffer);
+   util_dump_member(stream, uint, state, buffer_offset);
+   util_dump_member(stream, uint, state, buffer_size);
+
+   util_dump_struct_end(stream);
+
+}
+
+
+void
 util_dump_sampler_view(FILE *stream, const struct pipe_sampler_view *state)
 {
    if (!state) {
       util_dump_null(stream);
       return;
    }
 
    util_dump_struct_begin(stream, "pipe_sampler_view");
 
    util_dump_member(stream, enum_tex_target, state, target);
diff --git a/src/gallium/drivers/ddebug/dd_draw.c b/src/gallium/drivers/ddebug/dd_draw.c
index 3124d05..511daf4 100644
--- a/src/gallium/drivers/ddebug/dd_draw.c
+++ b/src/gallium/drivers/ddebug/dd_draw.c
@@ -306,22 +306,33 @@ dd_dump_draw_vbo(struct dd_draw_state *dstate, struct pipe_draw_info *info, FILE
       for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
          if (dstate->sampler_states[sh][i])
             DUMP_I(sampler_state, &dstate->sampler_states[sh][i]->state.sampler, i);
 
       for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
          if (dstate->sampler_views[sh][i]) {
             DUMP_I(sampler_view, dstate->sampler_views[sh][i], i);
             DUMP_M(resource, dstate->sampler_views[sh][i], texture);
          }
 
-      /* TODO: print shader images */
-      /* TODO: print shader buffers */
+      for (i = 0; i < PIPE_MAX_SHADER_IMAGES; i++)
+         if (dstate->shader_images[sh][i].resource) {
+            DUMP_I(image_view, &dstate->shader_images[sh][i], i);
+            if (dstate->shader_images[sh][i].resource)
+               DUMP_M(resource, &dstate->shader_images[sh][i], resource);
+         }
+
+      for (i = 0; i < PIPE_MAX_SHADER_BUFFERS; i++)
+         if (dstate->shader_buffers[sh][i].buffer) {
+            DUMP_I(shader_buffer, &dstate->shader_buffers[sh][i], i);
+            if (dstate->shader_buffers[sh][i].buffer)
+               DUMP_M(resource, &dstate->shader_buffers[sh][i], buffer);
+         }
 
       fprintf(f, COLOR_SHADER "end shader: %s" COLOR_RESET "\n\n", shader_str[sh]);
    }
 
    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);
@@ -797,21 +808,34 @@ dd_copy_draw_state(struct dd_draw_state *dst, struct dd_draw_state *src)
 
       for (j = 0; j < PIPE_MAX_SAMPLERS; j++) {
          pipe_sampler_view_reference(&dst->sampler_views[i][j],
                                      src->sampler_views[i][j]);
          if (src->sampler_states[i][j])
             dst->sampler_states[i][j]->state.sampler =
                src->sampler_states[i][j]->state.sampler;
          else
             dst->sampler_states[i][j] = NULL;
       }
-      /* TODO: shader buffers & images */
+
+      for (j = 0; j < PIPE_MAX_SHADER_IMAGES; j++) {
+         pipe_resource_reference(&dst->shader_images[i][j].resource,
+                                 src->shader_images[i][j].resource);
+         memcpy(&dst->shader_images[i][j], &src->shader_images[i][j],
+                sizeof(src->shader_images[i][j]));
+      }
+
+      for (j = 0; j < PIPE_MAX_SHADER_BUFFERS; j++) {
+         pipe_resource_reference(&dst->shader_buffers[i][j].buffer,
+                                 src->shader_buffers[i][j].buffer);
+         memcpy(&dst->shader_buffers[i][j], &src->shader_buffers[i][j],
+                sizeof(src->shader_buffers[i][j]));
+      }
    }
 
    if (src->velems)
       dst->velems->state.velems = src->velems->state.velems;
    else
       dst->velems = NULL;
 
    if (src->rs)
       dst->rs->state.rs = src->rs->state.rs;
    else
-- 
2.7.4



More information about the mesa-dev mailing list