Advertisement
cheako

overlay_scale.patch

Jan 23rd, 2022
1,201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.75 KB | None | 0 0
  1. --- a/src/vulkan/overlay-layer/overlay.cpp      2022/01/23 15:01:00     1.1
  2. +++ b/src/vulkan/overlay-layer/overlay.cpp      2022/01/23 15:32:42
  3. @@ -1170,6 +1170,7 @@
  4.        return NULL;
  5.  
  6.     struct device_data *device_data = data->device;
  7. +   struct overlay_params *overlay_params = &data->device->instance->params;
  8.     struct overlay_draw *draw = get_overlay_draw(data);
  9.  
  10.     device_data->vtable.ResetCommandBuffer(draw->command_buffer, 0);
  11. @@ -1291,8 +1292,8 @@
  12.       * is typically (0,0) for single viewport apps.
  13.       */
  14.      float scale[2];
  15. -    scale[0] = 2.0f / draw_data->DisplaySize.x;
  16. -    scale[1] = 2.0f / draw_data->DisplaySize.y;
  17. +    scale[0] = overlay_params->scale * overlay_params->scale_x * 2.0f / draw_data->DisplaySize.x;
  18. +    scale[1] = overlay_params->scale * overlay_params->scale_y * 2.0f / draw_data->DisplaySize.y;
  19.      float translate[2];
  20.      translate[0] = -1.0f - draw_data->DisplayPos.x * scale[0];
  21.      translate[1] = -1.0f - draw_data->DisplayPos.y * scale[1];
  22. @@ -1318,8 +1319,8 @@
  23.              VkRect2D scissor;
  24.              scissor.offset.x = (int32_t)(pcmd->ClipRect.x - display_pos.x) > 0 ? (int32_t)(pcmd->ClipRect.x - display_pos.x) : 0;
  25.              scissor.offset.y = (int32_t)(pcmd->ClipRect.y - display_pos.y) > 0 ? (int32_t)(pcmd->ClipRect.y - display_pos.y) : 0;
  26. -            scissor.extent.width = (uint32_t)(pcmd->ClipRect.z - pcmd->ClipRect.x);
  27. -            scissor.extent.height = (uint32_t)(pcmd->ClipRect.w - pcmd->ClipRect.y + 1); // FIXME: Why +1 here?
  28. +            scissor.extent.width = (uint32_t)(overlay_params->scale * overlay_params->scale_x * pcmd->ClipRect.z - pcmd->ClipRect.x);
  29. +            scissor.extent.height = (uint32_t)(overlay_params->scale * overlay_params->scale_y * pcmd->ClipRect.w - pcmd->ClipRect.y + 1); // FIXME: Why +1 here?
  30.              device_data->vtable.CmdSetScissor(draw->command_buffer, 0, 1, &scissor);
  31.  
  32.              // Draw
  33. --- a/src/vulkan/overlay-layer/overlay_params.c 2022/01/23 15:06:59     1.1
  34. +++ b/src/vulkan/overlay-layer/overlay_params.c 2022/01/23 15:32:00
  35. @@ -87,6 +87,15 @@
  36.  #define parse_width(s) parse_unsigned(s)
  37.  #define parse_height(s) parse_unsigned(s)
  38.  
  39. +static float
  40. +parse_float(const char *str) {
  41. +   return strtof(str, NULL);
  42. +}
  43. +
  44. +#define parse_scale(s) parse_float(s)
  45. +#define parse_scale_x(s) parse_float(s)
  46. +#define parse_scale_y(s) parse_float(s)
  47. +
  48.  static bool
  49.  parse_help(const char *str)
  50.  {
  51. @@ -103,6 +111,9 @@
  52.     fprintf(stderr, "\toutput_file=/path/to/output.txt\n");
  53.     fprintf(stderr, "\twidth=width-in-pixels\n");
  54.     fprintf(stderr, "\theight=height-in-pixels\n");
  55. +   fprintf(stderr, "\tscale=scale\n");
  56. +   fprintf(stderr, "\tscale_x=scale\n");
  57. +   fprintf(stderr, "\tscale_y=scale\n");
  58.  
  59.     return true;
  60.  }
  61. @@ -170,6 +181,9 @@
  62.     params->fps_sampling_period = 500000; /* 500ms */
  63.     params->width = params->height = 300;
  64.     params->control = -1;
  65. +   params->scale = 1.0f;
  66. +   params->scale_x = 1.0f;
  67. +   params->scale_y = 1.0f;
  68.  
  69.     if (!env)
  70.        return;
  71. --- a/src/vulkan/overlay-layer/overlay_params.h 2022/01/23 15:06:59     1.1
  72. +++ b/src/vulkan/overlay-layer/overlay_params.h 2022/01/23 15:19:07
  73. @@ -72,6 +72,9 @@
  74.     OVERLAY_PARAM_CUSTOM(height)                      \
  75.     OVERLAY_PARAM_CUSTOM(no_display)                  \
  76.     OVERLAY_PARAM_CUSTOM(control)                     \
  77. +   OVERLAY_PARAM_CUSTOM(scale)                     \
  78. +   OVERLAY_PARAM_CUSTOM(scale_x)                     \
  79. +   OVERLAY_PARAM_CUSTOM(scale_y)                     \
  80.     OVERLAY_PARAM_CUSTOM(help)
  81.  
  82.  enum overlay_param_position {
  83. @@ -100,6 +103,9 @@
  84.     bool no_display;
  85.     unsigned width;
  86.     unsigned height;
  87. +   float scale;
  88. +   float scale_x;
  89. +   float scale_y;
  90.  };
  91.  
  92.  const extern char *overlay_param_names[];
  93.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement