lima: Rotate dump files after each finished pp frame
authorAndreas Baierl <ichgeh@imkreisrum.de>
Thu, 19 Dec 2019 21:17:45 +0000 (22:17 +0100)
committerAndreas Baierl <ichgeh@imkreisrum.de>
Thu, 19 Dec 2019 22:53:22 +0000 (23:53 +0100)
This rotates the dump files like the mali-syscall-tracker does.

After each finished pp frame a new file is generated. They are
numbered like lima.dump.0000, lima.dump.0001 ...
The filename and path can be given with the new environment
variable LIMA_DUMP_FILE.

Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Andreas Baierl <ichgeh@imkreisrum.de>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3175>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3175>

src/gallium/drivers/lima/lima_draw.c
src/gallium/drivers/lima/lima_screen.c
src/gallium/drivers/lima/lima_screen.h
src/gallium/drivers/lima/lima_util.c
src/gallium/drivers/lima/lima_util.h

index 2f35d9a3db3e7076c52e6d8c5100a7c45deb84f4..5b86cce4d0d2475cb0923545c29af7f123822ab3 100644 (file)
@@ -1710,6 +1710,8 @@ _lima_flush(struct lima_context *ctx, bool end_of_frame)
    }
 
    ctx->pp_max_stack_size = 0;
+
+   lima_dump_file_next();
 }
 
 void
index 768a6106c8d4f7e4280ab07ee337cdc92246b5ce..4dc1fc652b85b1f2f4c5b404a7657da5a8a8d822 100644 (file)
@@ -39,6 +39,7 @@
 #include "lima_bo.h"
 #include "lima_fence.h"
 #include "lima_format.h"
+#include "lima_util.h"
 #include "ir/lima_ir.h"
 
 #include "xf86drm.h"
@@ -50,10 +51,7 @@ lima_screen_destroy(struct pipe_screen *pscreen)
 {
    struct lima_screen *screen = lima_screen(pscreen);
 
-   if (lima_dump_command_stream) {
-      fclose(lima_dump_command_stream);
-      lima_dump_command_stream = NULL;
-   }
+   lima_dump_file_close();
 
    slab_destroy_parent(&screen->transfer_pool);
 
@@ -446,14 +444,8 @@ lima_screen_parse_env(void)
 {
    lima_debug = debug_get_option_lima_debug();
 
-   if (lima_debug & LIMA_DEBUG_DUMP) {
-      const char *dump_command = "lima.dump";
-      printf("lima: dump command stream to file %s\n", dump_command);
-      lima_dump_command_stream = fopen(dump_command, "w");
-      if (!lima_dump_command_stream)
-         fprintf(stderr, "lima: fail to open command stream log file %s\n",
-                 dump_command);
-   }
+   if (lima_debug & LIMA_DEBUG_DUMP)
+      lima_dump_file_open();
 
    lima_ctx_num_plb = debug_get_num_option("LIMA_CTX_NUM_PLB", LIMA_CTX_PLB_DEF_NUM);
    if (lima_ctx_num_plb > LIMA_CTX_PLB_MAX_NUM ||
index 144f5a2e1639ea37beb156ffed3e2fb33a895e4a..426f8e956c17709f35e9432236829d457bb5a9a5 100644 (file)
@@ -41,7 +41,6 @@
 #define LIMA_DEBUG_BO_CACHE       (1 << 5)
 
 extern uint32_t lima_debug;
-extern FILE *lima_dump_command_stream;
 extern int lima_ctx_num_plb;
 extern int lima_plb_max_blk;
 extern int lima_ppir_force_spilling;
index e162b4c556f8056ba519e981f180cb6ebc6d7322..65e3114ed5f3e8339adf5880babed975622308a9 100644 (file)
 
 #include <pipe/p_defines.h>
 
+#include "util/u_debug.h"
+
 #include "lima_util.h"
 #include "lima_parser.h"
 
 FILE *lima_dump_command_stream = NULL;
+int lima_dump_frame_count = 0;
 
 bool lima_get_absolute_timeout(uint64_t *timeout)
 {
@@ -98,6 +101,40 @@ lima_dump_texture_descriptor(void *data, int size, uint32_t start, uint32_t offs
       lima_parse_texture_descriptor(lima_dump_command_stream, (uint32_t *)data, size, start, offset);
 }
 
+void
+lima_dump_file_open(void)
+{
+   if (lima_dump_command_stream)
+      return;
+
+   char buffer[1024];
+   const char *dump_command = debug_get_option("LIMA_DUMP_FILE", "lima.dump");
+   snprintf(buffer, sizeof(buffer), "%s.%04d", dump_command, lima_dump_frame_count);
+
+   printf("lima: dump command stream to file %s\n", buffer);
+   lima_dump_command_stream = fopen(buffer, "w");
+   if (!lima_dump_command_stream)
+      fprintf(stderr, "lima: failed to open command stream log file %s\n",
+              buffer);
+}
+
+void
+lima_dump_file_close(void)
+{
+   if (lima_dump_command_stream) {
+      fclose(lima_dump_command_stream);
+      lima_dump_command_stream = NULL;
+   }
+}
+
+void
+lima_dump_file_next(void)
+{
+   lima_dump_file_close();
+   lima_dump_frame_count++;
+   lima_dump_file_open();
+}
+
 void
 lima_dump_command_stream_print(void *data, int size, bool is_float,
                                const char *fmt, ...)
index 36b6aaacabcf79e8b3c3a121f584e1868f1bf25b..9a050f8f0288b75223c476d39fac26c984de2694 100644 (file)
 
 #define LIMA_PAGE_SIZE 4096
 
+FILE *lima_dump_command_stream;
+
 bool lima_get_absolute_timeout(uint64_t *timeout);
+void lima_dump_file_open(void);
+void lima_dump_file_next(void);
+void lima_dump_file_close(void);
 void lima_dump_blob(FILE *fp, void *data, int size, bool is_float);
 void lima_dump_vs_command_stream_print(void *data, int size, uint32_t start);
 void lima_dump_plbu_command_stream_print(void *data, int size, uint32_t start);