From cb3ff7e0a5f1d77a5b32c10c389fdef1e6bfee07 Mon Sep 17 00:00:00 2001 From: BehroozRezvani Date: Wed, 25 Mar 2026 01:11:39 +0000 Subject: [PATCH] overlays: addresses comments and fixes overlay sizing issue --- rpcs3/Emu/RSX/GL/GLOverlays.cpp | 5 ++++- rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.cpp | 16 +++++++++++++--- rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.h | 2 +- rpcs3/Emu/RSX/Overlays/overlays.h | 6 +++--- rpcs3/Emu/RSX/VK/VKOverlays.cpp | 5 ++++- rpcs3/Emu/system_config.h | 4 ++-- rpcs3/rpcs3qt/tooltips.h | 6 +++--- 7 files changed, 30 insertions(+), 14 deletions(-) diff --git a/rpcs3/Emu/RSX/GL/GLOverlays.cpp b/rpcs3/Emu/RSX/GL/GLOverlays.cpp index 34327aeaee..a758804e4f 100644 --- a/rpcs3/Emu/RSX/GL/GLOverlays.cpp +++ b/rpcs3/Emu/RSX/GL/GLOverlays.cpp @@ -399,7 +399,10 @@ namespace gl void ui_overlay_renderer::run(gl::command_context& cmd_, const areau& viewport, GLuint target, rsx::overlays::overlay& ui, bool flip_vertically) { - ui.set_render_viewport(viewport.width(), viewport.height()); + ui.set_render_viewport( + static_cast(std::min(viewport.width(), std::numeric_limits::max())), + static_cast(std::min(viewport.height(), std::numeric_limits::max())) + ); const auto ui_scale = color4f(static_cast(ui.virtual_width), static_cast(ui.virtual_height), 1.f, 1.f); const auto ui_viewport = color4f(static_cast(viewport.width()), static_cast(viewport.height()), static_cast(viewport.x1), static_cast(viewport.y1)); diff --git a/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.cpp b/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.cpp index e8eefaecfa..e62097c71c 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.cpp @@ -115,6 +115,7 @@ namespace rsx { graph_height += m_padding; } + const u16 overlay_width = std::max(m_body.w, graph_width); const u16 overlay_height = static_cast(m_body.h + graph_height); const auto percent_to_margin_px = [](f32 margin_percent, u16 virtual_size, u16 overlay_size) -> u32 @@ -450,15 +451,24 @@ namespace rsx m_force_update = true; } - void perf_metrics_overlay::set_render_viewport(u32 width, u32 height) + void perf_metrics_overlay::set_render_viewport(u16 width, u16 height) { u16 new_virtual_width = virtual_width; u16 new_virtual_height = virtual_height; if (use_window_space && width > 0 && height > 0) { - new_virtual_width = static_cast(std::min(width, std::numeric_limits::max())); - new_virtual_height = static_cast(std::min(height, std::numeric_limits::max())); + const double scale_x = static_cast(width) / virtual_width; + const double scale_y = static_cast(height) / virtual_height; + const double scale = std::min(scale_x, scale_y); + + new_virtual_width = static_cast(std::min( + static_cast(std::lround(width / scale)), + std::numeric_limits::max())); + + new_virtual_height = static_cast(std::min( + static_cast(std::lround(height / scale)), + std::numeric_limits::max())); } if (m_virtual_width == new_virtual_width && m_virtual_height == new_virtual_height) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.h b/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.h index 64b1cd2a03..2b676e591b 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.h @@ -103,7 +103,7 @@ namespace rsx void set_body_colors(std::string color, std::string background); void set_title_colors(std::string color, std::string background); void force_next_update(); - void set_render_viewport(u32 width, u32 height) override; + void set_render_viewport(u16 width, u16 height) override; u16 get_virtual_width() const override { return m_virtual_width; } u16 get_virtual_height() const override { return m_virtual_height; } diff --git a/rpcs3/Emu/RSX/Overlays/overlays.h b/rpcs3/Emu/RSX/Overlays/overlays.h index e8d71564f5..d9f3986aee 100644 --- a/rpcs3/Emu/RSX/Overlays/overlays.h +++ b/rpcs3/Emu/RSX/Overlays/overlays.h @@ -58,9 +58,9 @@ namespace rsx virtual compiled_resource get_compiled() = 0; void refresh() const; - virtual u16 get_virtual_width() const { return virtual_width;} - virtual u16 get_virtual_height() const { return virtual_height;} - virtual void set_render_viewport(u32 /*width*/, u32 /*height*/) {} + virtual u16 get_virtual_width() const { return virtual_width; } + virtual u16 get_virtual_height() const { return virtual_height; } + virtual void set_render_viewport(u16 /*width*/, u16 /*height*/) {} }; // Interactable UI element diff --git a/rpcs3/Emu/RSX/VK/VKOverlays.cpp b/rpcs3/Emu/RSX/VK/VKOverlays.cpp index fcf19498f4..684cf8fedb 100644 --- a/rpcs3/Emu/RSX/VK/VKOverlays.cpp +++ b/rpcs3/Emu/RSX/VK/VKOverlays.cpp @@ -628,7 +628,10 @@ namespace vk void ui_overlay_renderer::run(vk::command_buffer& cmd, const areau& viewport, vk::framebuffer* target, VkRenderPass render_pass, vk::data_heap& upload_heap, rsx::overlays::overlay& ui) { - ui.set_render_viewport(viewport.width(), viewport.height()); + ui.set_render_viewport( + static_cast(std::min(viewport.width(), std::numeric_limits::max())), + static_cast(std::min(viewport.height(), std::numeric_limits::max())) + ); m_scale_offset = color4f(ui.get_virtual_width(), ui.get_virtual_height(), 1.f, 1.f); m_viewport = { { static_cast(viewport.x1), static_cast(viewport.y1) }, { static_cast(viewport.width()), static_cast(viewport.height()) } }; diff --git a/rpcs3/Emu/system_config.h b/rpcs3/Emu/system_config.h index f62b25ae89..75d824938f 100644 --- a/rpcs3/Emu/system_config.h +++ b/rpcs3/Emu/system_config.h @@ -209,8 +209,8 @@ struct cfg_root : cfg::node cfg::uint<4, 36> font_size{ this, "Font size (px)", 10, true }; cfg::_enum position{ this, "Position", screen_quadrant::top_left, true }; cfg::string font{ this, "Font", "n023055ms.ttf", true }; - cfg::_float<0, 100> margin_x{ this, "Horizontal Margin (%)", 1.5, true }; // horizontal distance to the window border relative to the screen_quadrant in percent of the window width - cfg::_float<0, 100> margin_y{ this, "Vertical Margin (%)", 4.5, true }; // vertical distance to the window border relative to the screen_quadrant in percent of the window height + cfg::_float<0, 100> margin_x{ this, "Horizontal Margin (%)", 4, true }; // horizontal distance to the window border relative to the screen_quadrant in percent of the window width + cfg::_float<0, 100> margin_y{ this, "Vertical Margin (%)", 7, true }; // vertical distance to the window border relative to the screen_quadrant in percent of the window height cfg::_bool center_x{ this, "Center Horizontally", false, true }; cfg::_bool center_y{ this, "Center Vertically", false, true }; cfg::uint<0, 100> opacity{ this, "Opacity (%)", 70, true }; diff --git a/rpcs3/rpcs3qt/tooltips.h b/rpcs3/rpcs3qt/tooltips.h index 98d09a6c22..0276ac0f82 100644 --- a/rpcs3/rpcs3qt/tooltips.h +++ b/rpcs3/rpcs3qt/tooltips.h @@ -169,11 +169,11 @@ public: const QString perf_overlay_update_interval = tr("Sets the time interval in which the performance overlay is being updated (measured in milliseconds).\nSetting this to 16 milliseconds will refresh the performance overlay at roughly 60Hz.\nThe performance overlay refresh rate does not affect the frame graph statistics and can only be as fast as the current game allows."); const QString perf_overlay_font_size = tr("Sets the font size of the performance overlay (measured in pixels)."); const QString perf_overlay_opacity = tr("Sets the opacity of the performance overlay (measured in %)."); - const QString perf_overlay_margin_x = tr("Sets the horizontal distance to the screen border relative to the screen quadrant (measured as a percentage of the window width)."); - const QString perf_overlay_margin_y = tr("Sets the vertical distance to the screen border relative to the screen quadrant (measured as a percentage of the window height)."); + const QString perf_overlay_margin_x = tr("Sets the horizontal distance to the screen border relative to the screen quadrant (measured in %)."); + const QString perf_overlay_margin_y = tr("Sets the vertical distance to the screen border relative to the screen quadrant (measured in %)."); const QString perf_overlay_center_x = tr("Centers the performance overlay horizontally and overrides the horizontal margin."); const QString perf_overlay_center_y = tr("Centers the performance overlay vertically and overrides the vertical margin."); - const QString perf_overlay_use_window_space = tr("Position overlay relative to the full window surface, enabling placement outside game's framebuffer area."); + const QString perf_overlay_use_window_space = tr("Position overlay relative to the full window surface, enabling placement outside game's render area."); const QString shader_load_bg_enabled = tr("Shows a background image during the native shader loading dialog/loading screen.\nBy default the used image will be /PS3_GAME/PIC1.PNG."); const QString shader_load_bg_darkening = tr("Changes the background image darkening effect strength of the native shader loading dialog.\nThis may be used to improve readability and/or aesthetics.");