VideoCommon: Show the average projection to viewport ratio in statistics

window.
This commit is contained in:
Jordan Woyak 2023-09-05 15:34:43 -05:00
parent 1805f6e381
commit 1e27183dff
5 changed files with 21 additions and 2 deletions

View File

@ -147,6 +147,9 @@ void Statistics::DisplayProj() const
ImGui::Text("Projection 13: %f (%f)", gproj[13], g2proj[13]); ImGui::Text("Projection 13: %f (%f)", gproj[13], g2proj[13]);
ImGui::Text("Projection 14: %f (%f)", gproj[14], g2proj[14]); ImGui::Text("Projection 14: %f (%f)", gproj[14], g2proj[14]);
ImGui::Text("Projection 15: %f (%f)", gproj[15], g2proj[15]); ImGui::Text("Projection 15: %f (%f)", gproj[15], g2proj[15]);
ImGui::NewLine();
ImGui::Text("Avg Projection Viewport Ratio Persp(3D): %f", avg_persp_proj_viewport_ratio);
ImGui::Text("Avg Projection Viewport Ratio Ortho(2D): %f", avg_ortho_proj_viewport_ratio);
ImGui::End(); ImGui::End();
} }

View File

@ -25,6 +25,10 @@ struct Statistics
std::array<float, 16> gproj{}; std::array<float, 16> gproj{};
std::array<float, 16> g2proj{}; std::array<float, 16> g2proj{};
// For widescreen heuristic.
float avg_persp_proj_viewport_ratio = 0;
float avg_ortho_proj_viewport_ratio = 0;
std::vector<BPFunctions::ScissorResult> scissors{}; std::vector<BPFunctions::ScissorResult> scissors{};
size_t current_scissor = 0; // 0 => all, otherwise index + 1 size_t current_scissor = 0; // 0 => all, otherwise index + 1
int scissor_scale = 10; int scissor_scale = 10;

View File

@ -520,15 +520,21 @@ void VertexManagerBase::Flush()
auto& counts = auto& counts =
is_perspective ? m_flush_statistics.perspective : m_flush_statistics.orthographic; is_perspective ? m_flush_statistics.perspective : m_flush_statistics.orthographic;
const auto& projection = xfmem.projection.rawProjection;
// TODO: Potentially the viewport size could be used as weight for the flush count average. // TODO: Potentially the viewport size could be used as weight for the flush count average.
// This way a small minimap would have less effect than a fullscreen projection. // This way a small minimap would have less effect than a fullscreen projection.
const auto& viewport = xfmem.viewport;
if (IsAnamorphicProjection(xfmem.projection.rawProjection, xfmem.viewport, g_ActiveConfig)) // FYI: This average is based on flushes.
// It doesn't look at vertex counts like the heuristic does.
counts.average_ratio.Push(CalculateProjectionViewportRatio(projection, viewport));
if (IsAnamorphicProjection(projection, viewport, g_ActiveConfig))
{ {
++counts.anamorphic_flush_count; ++counts.anamorphic_flush_count;
counts.anamorphic_vertex_count += m_index_generator.GetIndexLen(); counts.anamorphic_vertex_count += m_index_generator.GetIndexLen();
} }
else if (IsNormalProjection(xfmem.projection.rawProjection, xfmem.viewport, g_ActiveConfig)) else if (IsNormalProjection(projection, viewport, g_ActiveConfig))
{ {
++counts.normal_flush_count; ++counts.normal_flush_count;
counts.normal_vertex_count += m_index_generator.GetIndexLen(); counts.normal_vertex_count += m_index_generator.GetIndexLen();

View File

@ -79,6 +79,8 @@ private:
{ {
return normal_vertex_count + anamorphic_vertex_count + other_vertex_count; return normal_vertex_count + anamorphic_vertex_count + other_vertex_count;
} }
MathUtil::RunningMean<float> average_ratio;
}; };
ProjectionCounts perspective; ProjectionCounts perspective;

View File

@ -8,6 +8,7 @@
#include "Core/Config/SYSCONFSettings.h" #include "Core/Config/SYSCONFSettings.h"
#include "Core/System.h" #include "Core/System.h"
#include "VideoCommon/Statistics.h"
#include "VideoCommon/VertexManagerBase.h" #include "VideoCommon/VertexManagerBase.h"
std::unique_ptr<WidescreenManager> g_widescreen; std::unique_ptr<WidescreenManager> g_widescreen;
@ -117,6 +118,9 @@ void WidescreenManager::UpdateWidescreenHeuristic()
const auto& persp = flush_statistics.perspective; const auto& persp = flush_statistics.perspective;
const auto& ortho = flush_statistics.orthographic; const auto& ortho = flush_statistics.orthographic;
g_stats.avg_persp_proj_viewport_ratio = persp.average_ratio.Mean();
g_stats.avg_ortho_proj_viewport_ratio = ortho.average_ratio.Mean();
const auto ortho_looks_anamorphic = looks_anamorphic(ortho); const auto ortho_looks_anamorphic = looks_anamorphic(ortho);
const auto persp_looks_normal = looks_normal(persp); const auto persp_looks_normal = looks_normal(persp);