From f2afd6bd769f3eab0b03352f5a3c94c91d7ec59e Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Sun, 3 Mar 2019 00:09:04 +0000 Subject: [PATCH] vulkan/overlay: make overlay size configurable Signed-off-by: Lionel Landwerlin --- src/vulkan/overlay-layer/overlay.cpp | 3 ++- src/vulkan/overlay-layer/overlay_params.c | 12 ++++++++++++ src/vulkan/overlay-layer/overlay_params.h | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/vulkan/overlay-layer/overlay.cpp b/src/vulkan/overlay-layer/overlay.cpp index c07409623bf..23b518ad0db 100644 --- a/src/vulkan/overlay-layer/overlay.cpp +++ b/src/vulkan/overlay-layer/overlay.cpp @@ -484,10 +484,11 @@ static void destroy_command_buffer_data(struct command_buffer_data *data) static struct swapchain_data *new_swapchain_data(VkSwapchainKHR swapchain, struct device_data *device_data) { + struct instance_data *instance_data = device_data->instance; struct swapchain_data *data = rzalloc(NULL, struct swapchain_data); data->device = device_data; data->swapchain = swapchain; - data->window_size = ImVec2(300, 300); + data->window_size = ImVec2(instance_data->params.width, instance_data->params.height); map_object((void *) data->swapchain, data); return data; } diff --git a/src/vulkan/overlay-layer/overlay_params.c b/src/vulkan/overlay-layer/overlay_params.c index 2028bccbdc0..2a09b6cf081 100644 --- a/src/vulkan/overlay-layer/overlay_params.c +++ b/src/vulkan/overlay-layer/overlay_params.c @@ -59,6 +59,15 @@ 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) { @@ -73,6 +82,8 @@ parse_help(const char *str) 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; } @@ -136,6 +147,7 @@ parse_overlay_env(struct overlay_params *params, 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; if (!env) return; diff --git a/src/vulkan/overlay-layer/overlay_params.h b/src/vulkan/overlay-layer/overlay_params.h index 6bbb2e4e657..4d3575bc2c2 100644 --- a/src/vulkan/overlay-layer/overlay_params.h +++ b/src/vulkan/overlay-layer/overlay_params.h @@ -65,6 +65,8 @@ extern "C" { OVERLAY_PARAM_CUSTOM(fps_sampling_period) \ OVERLAY_PARAM_CUSTOM(output_file) \ OVERLAY_PARAM_CUSTOM(position) \ + OVERLAY_PARAM_CUSTOM(width) \ + OVERLAY_PARAM_CUSTOM(height) \ OVERLAY_PARAM_CUSTOM(no_display) \ OVERLAY_PARAM_CUSTOM(help) @@ -91,6 +93,8 @@ struct overlay_params { uint32_t fps_sampling_period; /* us */ bool help; bool no_display; + unsigned width; + unsigned height; }; const extern char *overlay_param_names[]; -- 2.30.2