VideoCommon: Use XFB for internal resolution stats

fb4ff3e added a statistics option to show the internal resolution, but
it just showed the total size of the EFB (which is always 640x528) times
the IR scale, so it didn't convey any useful information.

This commit instead makes the option use the size of the last XFB copy
(not multiplied by the IR scale), which changes based on the game's
rendering resolution.
This commit is contained in:
JosJuice
2026-06-19 12:27:38 +02:00
parent 5f372d6b1d
commit c958dbc46c
5 changed files with 25 additions and 20 deletions
+3
View File
@@ -863,6 +863,9 @@ void Callback_FramePresented(const PresentInfo& present_info)
present_info.actual_present_time - present_info.intended_present_time;
perf_metrics.SetLatestFramePresentationOffset(presentation_offset);
perf_metrics.SetLatestFrameBufferSize(present_info.frame_buffer_width,
present_info.frame_buffer_height);
if (present_info.reason == PresentInfo::PresentReason::VideoInterfaceDuplicate)
return;
+7 -18
View File
@@ -11,7 +11,6 @@
#include "Common/HookableEvent.h"
#include "Core/Config/GraphicsSettings.h"
#include "Core/Core.h"
#include "VideoCommon/FramebufferManager.h"
#include "VideoCommon/VideoConfig.h"
PerformanceMetrics::PerformanceMetrics()
@@ -89,20 +88,6 @@ double PerformanceMetrics::GetFPS() const
return m_fps_counter.GetHzAvg();
}
u32 PerformanceMetrics::GetEFBWidth() const
{
if (g_framebuffer_manager)
return g_framebuffer_manager->GetEFBWidth();
return 0;
}
u32 PerformanceMetrics::GetEFBHeight() const
{
if (g_framebuffer_manager)
return g_framebuffer_manager->GetEFBHeight();
return 0;
}
double PerformanceMetrics::GetVPS() const
{
return m_vps_counter.GetHzAvg();
@@ -123,6 +108,11 @@ void PerformanceMetrics::SetLatestFramePresentationOffset(DT offset)
m_frame_presentation_offset.store(offset, std::memory_order_relaxed);
}
void PerformanceMetrics::SetLatestFrameBufferSize(u32 width, u32 height)
{
m_frame_buffer_size.store(FrameBufferSize{width, height}, std::memory_order_relaxed);
}
void PerformanceMetrics::DrawImGuiStats(const float backbuffer_scale)
{
m_vps_counter.UpdateStats();
@@ -139,8 +129,6 @@ void PerformanceMetrics::DrawImGuiStats(const float backbuffer_scale)
const double fps = GetFPS();
const double vps = GetVPS();
const double speed = GetSpeed();
const u32 width = GetEFBWidth();
const u32 height = GetEFBHeight();
static ImVec2 last_display_size(-1.0f, -1.0f);
@@ -350,7 +338,8 @@ void PerformanceMetrics::DrawImGuiStats(const float backbuffer_scale)
clamp_window_position();
ImGui::TextColored(ImVec4(r, g, b, 1.0f), "Res: %ux%u", width, height);
const FrameBufferSize size = m_frame_buffer_size.load(std::memory_order_relaxed);
ImGui::TextColored(ImVec4(r, g, b, 1.0f), "XFB res: %ux%u", size.width, size.height);
}
ImGui::End();
}
+8 -2
View File
@@ -41,15 +41,20 @@ public:
double GetVPS() const;
double GetSpeed() const;
double GetMaxSpeed() const;
u32 GetEFBWidth() const;
u32 GetEFBHeight() const;
// Call from any thread.
void SetLatestFramePresentationOffset(DT offset);
void SetLatestFrameBufferSize(u32 width, u32 height);
// ImGui Functions
void DrawImGuiStats(const float backbuffer_scale);
private:
struct FrameBufferSize
{
u32 width = 0;
u32 height = 0;
};
PerformanceTracker m_fps_counter{"render_times.txt"};
PerformanceTracker m_vps_counter{"vblank_times.txt"};
@@ -59,6 +64,7 @@ private:
std::atomic<double> m_max_speed{};
std::atomic<DT> m_frame_presentation_offset{};
std::atomic<FrameBufferSize> m_frame_buffer_size{};
struct PerfSample
{
+4
View File
@@ -174,6 +174,8 @@ void Presenter::ViSwap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height,
.present_count = m_present_count++,
.emulated_timestamp = ticks,
.intended_present_time = presentation_time,
.frame_buffer_width = fb_width,
.frame_buffer_height = fb_height,
};
if (is_duplicate)
@@ -237,6 +239,8 @@ void Presenter::ImmediateSwap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_
.emulated_timestamp = ticks,
.intended_present_time = m_next_swap_estimated_time,
.reason = PresentInfo::PresentReason::Immediate,
.frame_buffer_width = fb_width,
.frame_buffer_height = fb_height,
};
auto& video_events = GetVideoEvents();
+3
View File
@@ -61,6 +61,9 @@ struct PresentInfo
// Where the presentation of the frame was triggered from
PresentReason reason = PresentReason::Immediate;
u32 frame_buffer_width;
u32 frame_buffer_height;
std::vector<std::string_view> xfb_copy_hashes;
};