overlays: add settings for overlay graphs

This commit is contained in:
Megamouse 2019-11-14 20:10:43 +01:00
parent dd1707bd46
commit fb96047d2f
8 changed files with 134 additions and 40 deletions

View File

@ -94,7 +94,7 @@ namespace rsx
void perf_metrics_overlay::reset_transforms()
{
const u16 per_overlay_padding = m_font_size / 2;
const u16 perf_overlay_padding = m_font_size / 2;
const u16 graphs_padding = m_font_size * 2;
const u16 fps_graph_h = 60;
@ -102,31 +102,59 @@ namespace rsx
u16 bottom_margin{};
if (m_graphs_enabled)
if (m_framerate_graph_enabled || m_frametime_graph_enabled)
{
// Adjust body size to account for the graphs
// TODO: Bit hacky, could do this with margins if overlay_element had bottom margin (or negative top at least)
bottom_margin = per_overlay_padding + fps_graph_h + graphs_padding + frametime_graph_h;
bottom_margin = perf_overlay_padding;
if (m_framerate_graph_enabled)
{
bottom_margin += fps_graph_h;
if (m_frametime_graph_enabled)
{
bottom_margin += graphs_padding;
}
}
if (m_frametime_graph_enabled)
{
bottom_margin += frametime_graph_h;
}
}
// Set body/titles transform
reset_transform(m_body, bottom_margin);
reset_transform(m_titles, bottom_margin);
if (m_graphs_enabled)
if (m_framerate_graph_enabled || m_frametime_graph_enabled)
{
// Position the graphs within the body
const u16 graphs_width = m_body.w;
const u16 body_left = m_body.x;
const u16 body_bottom = m_body.y + m_body.h + per_overlay_padding;
const u16 body_bottom = m_body.y + m_body.h + perf_overlay_padding;
if (m_framerate_graph_enabled)
{
m_fps_graph.set_pos(body_left, body_bottom);
m_fps_graph.set_size(graphs_width, fps_graph_h);
}
m_frametime_graph.set_pos(body_left, body_bottom + m_fps_graph.h + graphs_padding);
if (m_frametime_graph_enabled)
{
u16 padding = 0;
if (m_framerate_graph_enabled)
{
padding = m_fps_graph.h + graphs_padding;
}
m_frametime_graph.set_pos(body_left, body_bottom + padding);
m_frametime_graph.set_size(graphs_width, frametime_graph_h);
}
}
}
void perf_metrics_overlay::reset_body()
{
@ -165,18 +193,6 @@ namespace rsx
reset_text();
force_next_update();
m_fps_graph.set_title("Framerate");
m_fps_graph.set_font_size(m_font_size * 0.8);
m_fps_graph.set_count(50);
m_fps_graph.set_color(convert_color_code(g_cfg.video.perf_overlay.color_body));
m_fps_graph.set_guide_interval(10);
m_frametime_graph.set_title("Frametime");
m_frametime_graph.set_font_size(m_font_size * 0.8);
m_frametime_graph.set_count(170);
m_frametime_graph.set_color(convert_color_code(g_cfg.video.perf_overlay.color_body));
m_frametime_graph.set_guide_interval(8);
m_update_timer.Start();
m_frametime_timer.Start();
@ -185,12 +201,48 @@ namespace rsx
m_is_initialised = true;
}
void perf_metrics_overlay::set_framerate_graph_enabled(bool enabled)
{
m_framerate_graph_enabled = enabled;
if (enabled)
{
m_fps_graph.set_title("Framerate");
m_fps_graph.set_font_size(m_font_size * 0.8);
m_fps_graph.set_count(50);
m_fps_graph.set_color(convert_color_code(g_cfg.video.perf_overlay.color_body));
m_fps_graph.set_guide_interval(10);
}
if (m_is_initialised)
{
reset_transforms();
}
}
void perf_metrics_overlay::set_frametime_graph_enabled(bool enabled)
{
m_frametime_graph_enabled = enabled;
if (enabled)
{
m_frametime_graph.set_title("Frametime");
m_frametime_graph.set_font_size(m_font_size * 0.8);
m_frametime_graph.set_count(170);
m_frametime_graph.set_color(convert_color_code(g_cfg.video.perf_overlay.color_body));
m_frametime_graph.set_guide_interval(8);
}
if (m_is_initialised)
{
reset_transforms();
}
}
void perf_metrics_overlay::set_detail_level(detail_level level)
{
m_detail = level;
m_graphs_enabled = (level == detail_level::high);
if (m_is_initialised)
{
reset_titles();
@ -263,7 +315,7 @@ namespace rsx
{
const auto elapsed_update = m_update_timer.GetElapsedTimeInMilliSec();
if (m_is_initialised && m_graphs_enabled)
if (m_is_initialised && m_frametime_graph_enabled)
{
const auto elapsed_frame = m_frametime_timer.GetElapsedTimeInMilliSec();
m_frametime_graph.record_datapoint(elapsed_frame);
@ -276,7 +328,7 @@ namespace rsx
if (elapsed_update >= m_update_interval || m_force_update)
{
if (!m_force_update && m_graphs_enabled)
if (!m_force_update)
{
m_update_timer.Start();
}
@ -350,7 +402,7 @@ namespace rsx
case detail_level::minimal:
{
fps = m_force_update ? 0 : std::max(0.0, static_cast<f32>(m_frames) / (elapsed_update / 1000));
if (m_is_initialised && m_graphs_enabled)
if (m_is_initialised && m_framerate_graph_enabled)
m_fps_graph.record_datapoint(fps);
}
}
@ -416,11 +468,14 @@ namespace rsx
}
}
if (m_graphs_enabled)
if (m_framerate_graph_enabled)
{
m_fps_graph.update();
m_frametime_graph.update();
}
if (m_frametime_graph_enabled)
{
m_frametime_graph.update();
m_frametime_timer.Start();
}
}
@ -431,9 +486,13 @@ namespace rsx
compiled_resources.add(m_titles.get_compiled());
if (m_graphs_enabled)
if (m_framerate_graph_enabled)
{
compiled_resources.add(m_fps_graph.get_compiled());
}
if (m_frametime_graph_enabled)
{
compiled_resources.add(m_frametime_graph.get_compiled());
}

View File

@ -21,7 +21,8 @@ namespace rsx
label m_body{};
label m_titles{};
bool m_graphs_enabled{};
bool m_framerate_graph_enabled{};
bool m_frametime_graph_enabled{};
graph m_fps_graph;
graph m_frametime_graph;
@ -52,6 +53,8 @@ namespace rsx
public:
void init();
void set_framerate_graph_enabled(bool enabled);
void set_frametime_graph_enabled(bool enabled);
void set_detail_level(detail_level level);
void set_position(screen_quadrant quadrant);
void set_update_interval(u32 update_interval);

View File

@ -438,6 +438,8 @@ namespace rsx
perf_overlay->set_font_size(perf_settings.font_size);
perf_overlay->set_margins(perf_settings.margin_x, perf_settings.margin_y);
perf_overlay->set_opacity(perf_settings.opacity / 100.f);
perf_overlay->set_framerate_graph_enabled(perf_settings.framerate_graph_enabled.get());
perf_overlay->set_frametime_graph_enabled(perf_settings.frametime_graph_enabled.get());
perf_overlay->init();
}
}

View File

@ -515,6 +515,8 @@ struct cfg_root : cfg::node
node_perf_overlay(cfg::node* _this) : cfg::node(_this, "Performance Overlay") {}
cfg::_bool perf_overlay_enabled{this, "Enabled", false};
cfg::_bool framerate_graph_enabled{ this, "Enable Framerate Graph", false };
cfg::_bool frametime_graph_enabled{ this, "Enable Frametime Graph", false };
cfg::_enum<detail_level> level{this, "Detail level", detail_level::medium};
cfg::_int<30, 5000> update_interval{ this, "Metrics update interval (ms)", 350 };
cfg::_int<4, 36> font_size{ this, "Font size (px)", 10 };

View File

@ -91,6 +91,8 @@
},
"overlay": {
"perfOverlayEnabled": "Enables or disables the performance overlay.",
"perfOverlayFramerateGraphEnabled": "Enables or disables the framerate graph.",
"perfOverlayFrametimeGraphEnabled": "Enables or disables the frametime graph.",
"perfOverlayPosition": "Sets the on-screen position (quadrant) of the performance overlay.",
"perfOverlayDetailLevel": "Controls the amount of information displayed on the performance overlay.",
"perfOverlayUpdateInterval": "Sets the time interval in which the performance overlay is being updated (measured in milliseconds).",

View File

@ -86,6 +86,8 @@ public:
// Performance Overlay
PerfOverlayEnabled,
PerfOverlayFramerateGraphEnabled,
PerfOverlayFrametimeGraphEnabled,
PerfOverlayDetailLevel,
PerfOverlayPosition,
PerfOverlayUpdateInterval,
@ -313,6 +315,8 @@ private:
// Performance Overlay
{ PerfOverlayEnabled, { "Video", "Performance Overlay", "Enabled" } },
{ PerfOverlayFramerateGraphEnabled, { "Video", "Performance Overlay", "Enable Framerate Graph" } },
{ PerfOverlayFrametimeGraphEnabled, { "Video", "Performance Overlay", "Enable Frametime Graph" } },
{ PerfOverlayDetailLevel, { "Video", "Performance Overlay", "Detail level" } },
{ PerfOverlayPosition, { "Video", "Performance Overlay", "Position" } },
{ PerfOverlayUpdateInterval, { "Video", "Performance Overlay", "Metrics update interval (ms)" } },

View File

@ -1170,6 +1170,12 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
});
ui->perfOverlayMarginY->setEnabled(!ui->perfOverlayCenterY->isChecked());
xemu_settings->EnhanceCheckBox(ui->perfOverlayFramerateGraphEnabled, emu_settings::PerfOverlayFramerateGraphEnabled);
SubscribeTooltip(ui->perfOverlayFramerateGraphEnabled, json_emu_overlay["perfOverlayFramerateGraphEnabled"].toString());
xemu_settings->EnhanceCheckBox(ui->perfOverlayFrametimeGraphEnabled, emu_settings::PerfOverlayFrametimeGraphEnabled);
SubscribeTooltip(ui->perfOverlayFrametimeGraphEnabled, json_emu_overlay["perfOverlayFrametimeGraphEnabled"].toString());
xemu_settings->EnhanceCheckBox(ui->perfOverlayEnabled, emu_settings::PerfOverlayEnabled);
SubscribeTooltip(ui->perfOverlayEnabled, json_emu_overlay["perfOverlayEnabled"].toString());
auto EnablePerfOverlayOptions = [this](bool enabled)
@ -1190,6 +1196,8 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
ui->perfOverlayMarginY->setEnabled(enabled && !ui->perfOverlayCenterY->isChecked());
ui->perfOverlayCenterX->setEnabled(enabled);
ui->perfOverlayCenterY->setEnabled(enabled);
ui->perfOverlayFramerateGraphEnabled->setEnabled(enabled);
ui->perfOverlayFrametimeGraphEnabled->setEnabled(enabled);
};
EnablePerfOverlayOptions(ui->perfOverlayEnabled->isChecked());
connect(ui->perfOverlayEnabled, &QCheckBox::clicked, EnablePerfOverlayOptions);

View File

@ -2138,6 +2138,20 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="perfOverlayFramerateGraphEnabled">
<property name="text">
<string>Show framerate graph</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="perfOverlayFrametimeGraphEnabled">
<property name="text">
<string>Show frametime graph</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_detail_level">
<property name="text">