[Mesa-dev] [PATCH v2 20/20] trace: add all compute related functions

Samuel Pitoiset samuel.pitoiset at gmail.com
Sat Feb 6 22:04:53 UTC 2016


Changes from v2:
 - remove use of MALLOC()

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu> (v1)
---
 src/gallium/drivers/trace/tr_context.c    | 75 +++++++++++++++++++++++++++++++
 src/gallium/drivers/trace/tr_dump_state.c | 51 +++++++++++++++++++++
 src/gallium/drivers/trace/tr_dump_state.h |  4 ++
 src/gallium/drivers/trace/tr_screen.c     | 25 +++++++++++
 4 files changed, 155 insertions(+)

diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c
index 4d03fe1..b04c88d 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -575,6 +575,51 @@ TRACE_SHADER_STATE(tes)
 
 
 static inline void *
+trace_context_create_compute_state(struct pipe_context *_pipe,
+                                   const struct pipe_compute_state *state)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+   void * result;
+
+   trace_dump_call_begin("pipe_context", "create_compute_state");
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(compute_state, state);
+   result = pipe->create_compute_state(pipe, state);
+   trace_dump_ret(ptr, result);
+   trace_dump_call_end();
+   return result;
+}
+
+static inline void
+trace_context_bind_compute_state(struct pipe_context *_pipe,
+                                 void *state)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+
+   trace_dump_call_begin("pipe_context", "bind_compute_state");
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(ptr, state);
+   pipe->bind_compute_state(pipe, state);
+   trace_dump_call_end();
+}
+
+static inline void
+trace_context_delete_compute_state(struct pipe_context *_pipe,
+                                   void *state)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+
+   trace_dump_call_begin("pipe_context", "delete_compute_state");
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(ptr, state);
+   pipe->delete_compute_state(pipe, state);
+   trace_dump_call_end();
+}
+
+static inline void *
 trace_context_create_vertex_elements_state(struct pipe_context *_pipe,
                                            unsigned num_elements,
                                            const struct  pipe_vertex_element *elements)
@@ -1616,6 +1661,32 @@ static void trace_context_set_shader_buffers(struct pipe_context *_context,
       FREE(_buffers);
 }
 
+static void trace_context_launch_grid(struct pipe_context *_pipe,
+                                      const struct pipe_grid_info *info)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+
+   trace_dump_call_begin("pipe_context", "launch_grid");
+
+   trace_dump_arg(ptr,  pipe);
+   trace_dump_arg(grid_info, info);
+
+   trace_dump_trace_flush();
+
+   if (info->indirect) {
+      struct pipe_grid_info _info;
+
+      memcpy(&_info, info, sizeof(_info));
+      _info.indirect = trace_resource_unwrap(tr_ctx, _info.indirect);
+      pipe->launch_grid(pipe, &_info);
+   } else {
+      pipe->launch_grid(pipe, info);
+   }
+
+   trace_dump_call_end();
+}
+
 
 static const struct debug_named_value rbug_blocker_flags[] = {
    {"before", 1, NULL},
@@ -1681,6 +1752,9 @@ trace_context_create(struct trace_screen *tr_scr,
    TR_CTX_INIT(create_tes_state);
    TR_CTX_INIT(bind_tes_state);
    TR_CTX_INIT(delete_tes_state);
+   TR_CTX_INIT(create_compute_state);
+   TR_CTX_INIT(bind_compute_state);
+   TR_CTX_INIT(delete_compute_state);
    TR_CTX_INIT(create_vertex_elements_state);
    TR_CTX_INIT(bind_vertex_elements_state);
    TR_CTX_INIT(delete_vertex_elements_state);
@@ -1715,6 +1789,7 @@ trace_context_create(struct trace_screen *tr_scr,
    TR_CTX_INIT(memory_barrier);
    TR_CTX_INIT(set_tess_state);
    TR_CTX_INIT(set_shader_buffers);
+   TR_CTX_INIT(launch_grid);
 
    TR_CTX_INIT(transfer_map);
    TR_CTX_INIT(transfer_unmap);
diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c
index cfbf53c..dc80469 100644
--- a/src/gallium/drivers/trace/tr_dump_state.c
+++ b/src/gallium/drivers/trace/tr_dump_state.c
@@ -305,6 +305,27 @@ void trace_dump_shader_state(const struct pipe_shader_state *state)
 }
 
 
+void trace_dump_compute_state(const struct pipe_compute_state *state)
+{
+   if (!trace_dumping_enabled_locked())
+      return;
+
+   if (!state) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_compute_state");
+
+   trace_dump_member(ptr, state, prog);
+   trace_dump_member(uint, state, req_local_mem);
+   trace_dump_member(uint, state, req_private_mem);
+   trace_dump_member(uint, state, req_input_mem);
+
+   trace_dump_struct_end();
+}
+
+
 void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state)
 {
    unsigned i;
@@ -864,3 +885,33 @@ trace_dump_query_result(unsigned query_type,
       break;
    }
 }
+
+void trace_dump_grid_info(const struct pipe_grid_info *state)
+{
+   if (!trace_dumping_enabled_locked())
+      return;
+
+   if (!state) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_grid_info");
+
+   trace_dump_member(uint, state, pc);
+   trace_dump_member(ptr, state, input);
+
+   trace_dump_member_begin("block");
+   trace_dump_array(uint, state->block, Elements(state->block));
+   trace_dump_member_end();
+
+   trace_dump_member_begin("grid");
+   trace_dump_array(uint, state->grid, Elements(state->grid));
+   trace_dump_member_end();
+
+   trace_dump_member(ptr, state, indirect);
+   trace_dump_member(uint, state, indirect_offset);
+
+   trace_dump_struct_end();
+}
+
diff --git a/src/gallium/drivers/trace/tr_dump_state.h b/src/gallium/drivers/trace/tr_dump_state.h
index 4f4ade1..ee0720d 100644
--- a/src/gallium/drivers/trace/tr_dump_state.h
+++ b/src/gallium/drivers/trace/tr_dump_state.h
@@ -50,6 +50,8 @@ void trace_dump_token(const struct tgsi_token *token);
 
 void trace_dump_shader_state(const struct pipe_shader_state *state);
 
+void trace_dump_compute_state(const struct pipe_compute_state *state);
+
 void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state);
 
 void trace_dump_blend_state(const struct pipe_blend_state *state);
@@ -87,4 +89,6 @@ void trace_dump_blit_info(const struct pipe_blit_info *);
 void trace_dump_query_result(unsigned query_type,
                              const union pipe_query_result *result);
 
+void trace_dump_grid_info(const struct pipe_grid_info *state);
+
 #endif /* TR_STATE_H */
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index ff057e2..0612109 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -173,6 +173,30 @@ trace_screen_get_paramf(struct pipe_screen *_screen,
 }
 
 
+static int
+trace_screen_get_compute_param(struct pipe_screen *_screen,
+                               enum pipe_compute_cap param, void *data)
+{
+   struct trace_screen *tr_scr = trace_screen(_screen);
+   struct pipe_screen *screen = tr_scr->screen;
+   int result;
+
+   trace_dump_call_begin("pipe_screen", "get_compute_param");
+
+   trace_dump_arg(ptr, screen);
+   trace_dump_arg(int, param);
+   trace_dump_arg(ptr, data);
+
+   result = screen->get_compute_param(screen, param, data);
+
+   trace_dump_ret(int, result);
+
+   trace_dump_call_end();
+
+   return result;
+}
+
+
 static boolean
 trace_screen_is_format_supported(struct pipe_screen *_screen,
                                  enum pipe_format format,
@@ -472,6 +496,7 @@ trace_screen_create(struct pipe_screen *screen)
    tr_scr->base.get_param = trace_screen_get_param;
    tr_scr->base.get_shader_param = trace_screen_get_shader_param;
    tr_scr->base.get_paramf = trace_screen_get_paramf;
+   tr_scr->base.get_compute_param = trace_screen_get_compute_param;
    tr_scr->base.is_format_supported = trace_screen_is_format_supported;
    assert(screen->context_create);
    tr_scr->base.context_create = trace_screen_context_create;
-- 
2.6.4



More information about the mesa-dev mailing list