Added few more stubs so that control reaches to DestroyDevice().
[mesa.git] / src / vulkan / overlay-layer / overlay_params.c
index d28799ccf06d3dd9e04a0fc5e6c737a2241f8172..afc17ec07a92451b4a9d23eff9741ce51815d180 100644 (file)
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <string.h>
+#include <errno.h>
 
 #include "overlay_params.h"
 
+#include "util/os_socket.h"
+
 static enum overlay_param_position
 parse_position(const char *str)
 {
@@ -41,21 +45,64 @@ parse_position(const char *str)
    return LAYER_POSITION_TOP_LEFT;
 }
 
+static FILE *
+parse_output_file(const char *str)
+{
+   return fopen(str, "w+");
+}
+
+static int
+parse_control(const char *str)
+{
+   int ret = os_socket_listen_abstract(str, 1);
+   if (ret < 0) {
+      fprintf(stderr, "ERROR: Couldn't create socket pipe at '%s'\n", str);
+      fprintf(stderr, "ERROR: '%s'\n", strerror(errno));
+      return ret;
+   }
+
+   os_socket_block(ret, false);
+
+   return ret;
+}
+
+static uint32_t
+parse_fps_sampling_period(const char *str)
+{
+   return strtol(str, NULL, 0) * 1000;
+}
+
+static bool
+parse_no_display(const char *str)
+{
+   return strtol(str, NULL, 0) != 0;
+}
+
+static unsigned
+parse_unsigned(const char *str)
+{
+   return strtol(str, NULL, 0);
+}
+
+#define parse_width(s) parse_unsigned(s)
+#define parse_height(s) parse_unsigned(s)
+
 static bool
 parse_help(const char *str)
 {
    fprintf(stderr, "Layer params using VK_LAYER_MESA_OVERLAY_CONFIG=\n");
 #define OVERLAY_PARAM_BOOL(name)                \
-   fprintf(stderr, "\t%s=0/1\n", #name);
+   fprintf(stderr, "\t%s=0|1\n", #name);
 #define OVERLAY_PARAM_CUSTOM(name)
    OVERLAY_PARAMS
 #undef OVERLAY_PARAM_BOOL
 #undef OVERLAY_PARAM_CUSTOM
-   fprintf(stderr, "\tposition=\n"
-           "\t\ttop-left\n"
-           "\t\ttop-right\n"
-           "\t\tbottom-left\n"
-           "\t\tbottom-right\n");
+   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");
+   fprintf(stderr, "\twidth=width-in-pixels\n");
+   fprintf(stderr, "\theight=height-in-pixels\n");
 
    return true;
 }
@@ -80,7 +127,8 @@ parse_string(const char *s, char *out_param, char *out_value)
       i++;
       for (; !is_delimiter(*s); s++, out_value++, i++)
          *out_value = *s;
-   }
+   } else
+      *(out_value++) = '1';
    *out_value = 0;
 
    if (*s && is_delimiter(*s)) {
@@ -117,6 +165,9 @@ parse_overlay_env(struct overlay_params *params,
    /* Visible by default */
    params->enabled[OVERLAY_PARAM_ENABLED_fps] = true;
    params->enabled[OVERLAY_PARAM_ENABLED_frame_timing] = true;
+   params->fps_sampling_period = 500000; /* 500ms */
+   params->width = params->height = 300;
+   params->control = -1;
 
    if (!env)
       return;
@@ -126,11 +177,12 @@ parse_overlay_env(struct overlay_params *params,
 
 #define OVERLAY_PARAM_BOOL(name)                                        \
       if (!strcmp(#name, key)) {                                        \
-         params->enabled[OVERLAY_PARAM_ENABLED_##name] = strtol(value, NULL, 0); \
+         params->enabled[OVERLAY_PARAM_ENABLED_##name] =                \
+            strtol(value, NULL, 0);                                     \
          continue;                                                      \
       }
-#define OVERLAY_PARAM_CUSTOM(name)              \
-      if (!strcmp(#name, key)) {                \
+#define OVERLAY_PARAM_CUSTOM(name)               \
+      if (!strcmp(#name, key)) {                 \
          params->name = parse_##name(value);     \
          continue;                               \
       }