vulkan/overlay: record all select metrics into output file
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Sat, 2 Mar 2019 17:49:21 +0000 (17:49 +0000)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Thu, 2 May 2019 16:02:34 +0000 (17:02 +0100)
The output looks something like this (csv style) :

fps, frame, frame_timing(us), submit, draw_indexed, pipeline_graphics, acquire_timing(us), vert_invocations, frag_invocations, gpu_timing(ns)
480.55, 242, 501512, 247, 1444, 1204, 714, 5827272, 113043296121424174
467.80, 234, 500214, 234, 1412, 1176, 648, 5635680, 109436188117743760
424.37, 213, 501923, 213, 2130, 1704, 623, 5132448, 99657292105474683
472.15, 237, 501962, 237, 2370, 1896, 667, 5710752, 110924644122226004
411.32, 206, 500826, 206, 2060, 1648, 709, 4963776, 9649176495333273
458.87, 230, 501228, 230, 2300, 1840, 634, 5542080, 107758204123112090
475.01, 238, 501044, 238, 2380, 1904, 631, 5734848, 111477480122087426
471.08, 236, 500972, 236, 2360, 1888, 655, 5686656, 110498496114816162

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/vulkan/overlay-layer/overlay.cpp
src/vulkan/overlay-layer/overlay_params.c

index 28a63fb..8c5489f 100644 (file)
@@ -49,6 +49,8 @@ struct instance_data {
 
    struct overlay_params params;
    bool pipeline_statistics_enabled;
+
+   bool first_line_printed;
 };
 
 struct frame_stat {
@@ -496,6 +498,19 @@ static void destroy_swapchain_data(struct swapchain_data *data)
    ralloc_free(data);
 }
 
+static const char *param_unit(enum overlay_param_enabled param)
+{
+   switch (param) {
+   case OVERLAY_PARAM_ENABLED_frame_timing:
+   case OVERLAY_PARAM_ENABLED_acquire_timing:
+      return "(us)";
+   case OVERLAY_PARAM_ENABLED_gpu_timing:
+      return "(ns)";
+   default:
+      return "";
+   }
+}
+
 static void snapshot_swapchain_frame(struct swapchain_data *data)
 {
    struct device_data *device_data = data->device;
@@ -519,7 +534,38 @@ static void snapshot_swapchain_frame(struct swapchain_data *data)
       if (elapsed >= instance_data->params.fps_sampling_period) {
          data->fps = 1000000.0f * data->n_frames_since_update / elapsed;
          if (instance_data->params.output_file) {
-            fprintf(instance_data->params.output_file, "%.2f\n", data->fps);
+            if (!instance_data->first_line_printed) {
+               bool first_column = true;
+
+               instance_data->first_line_printed = true;
+
+#define OVERLAY_PARAM_BOOL(name) \
+               if (instance_data->params.enabled[OVERLAY_PARAM_ENABLED_##name]) { \
+                  fprintf(instance_data->params.output_file, \
+                          "%s%s%s", first_column ? "" : ", ", #name, \
+                          param_unit(OVERLAY_PARAM_ENABLED_##name)); \
+                  first_column = false; \
+               }
+#define OVERLAY_PARAM_CUSTOM(name)
+               OVERLAY_PARAMS
+#undef OVERLAY_PARAM_BOOL
+#undef OVERLAY_PARAM_CUSTOM
+               fprintf(instance_data->params.output_file, "\n");
+            }
+
+            for (int s = 0; s < OVERLAY_PARAM_ENABLED_MAX; s++) {
+               if (!instance_data->params.enabled[s])
+                  continue;
+               if (s == OVERLAY_PARAM_ENABLED_fps) {
+                  fprintf(instance_data->params.output_file,
+                          "%s%.2f", s == 0 ? "" : ", ", data->fps);
+               } else {
+                  fprintf(instance_data->params.output_file,
+                          "%s%" PRIu64, s == 0 ? "" : ", ",
+                          data->accumulated_stats.stats[s]);
+               }
+            }
+            fprintf(instance_data->params.output_file, "\n");
             fflush(instance_data->params.output_file);
          }
 
index 16cf5b8..2028bcc 100644 (file)
@@ -72,6 +72,7 @@ parse_help(const char *str)
    fprintf(stderr, "\tposition=top-left|top-right|bottom-left|bottom-right\n");
    fprintf(stderr, "\tfps_sampling_period=number-of-milliseconds\n");
    fprintf(stderr, "\tno_display=0|1\n");
+   fprintf(stderr, "\toutput_file=/path/to/output.txt\n");
 
    return true;
 }