trace: add all compute related functions
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Sun, 24 Jan 2016 15:10:14 +0000 (16:10 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Sat, 13 Feb 2016 15:01:02 +0000 (16:01 +0100)
Changes from v3:
 - dump the TGSI compute program

Changes from v2:
 - remove use of MALLOC()

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/drivers/trace/tr_context.c
src/gallium/drivers/trace/tr_dump_state.c
src/gallium/drivers/trace/tr_dump_state.h
src/gallium/drivers/trace/tr_screen.c

index 2ce2b3aef758ff4092287d828bdeac88bcfac568..46936c1b6b7851b1e78fe24b5cd70db74d8d1e03 100644 (file)
@@ -569,6 +569,51 @@ TRACE_SHADER_STATE(tes)
 #undef TRACE_SHADER_STATE
 
 
+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,
@@ -1638,6 +1683,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},
@@ -1703,6 +1774,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);
@@ -1738,6 +1812,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);
index cfbf53cf767ab809cfa19254fec6565784f40aec..0627e5ab5d7555c7cd8a9a3cbc101f8416e70404 100644 (file)
@@ -305,6 +305,36 @@ 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_begin("prog");
+   if (state->prog) {
+      static char str[64 * 1024];
+      tgsi_dump_str(state->prog, 0, str, sizeof(str));
+      trace_dump_string(str);
+   } else {
+      trace_dump_null();
+   }
+   trace_dump_member_end();
+
+   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 +894,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();
+}
+
index 4f4ade155bcc6d883a4bcf78b55cb78a64ed1102..ee0720d8ac898cca0f623e197d7e5c2e5b71e5d3 100644 (file)
@@ -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 */
index ff057e2a4a40a3cf2384f24b22d676459cf6ae99..0612109c8009fd72a40dff3a81e5674f3d3eb18e 100644 (file)
@@ -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;