mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
Merge pull request #11419 from OatmealDome/widescreen
VideoCommon: Allow widescreen heuristic's constants to be overridden by onion config
This commit is contained in:
commit
76a00551d1
@ -23,6 +23,12 @@ const Info<bool> GFX_WIDESCREEN_HACK{{System::GFX, "Settings", "wideScreenHack"}
|
||||
const Info<AspectMode> GFX_ASPECT_RATIO{{System::GFX, "Settings", "AspectRatio"}, AspectMode::Auto};
|
||||
const Info<AspectMode> GFX_SUGGESTED_ASPECT_RATIO{{System::GFX, "Settings", "SuggestedAspectRatio"},
|
||||
AspectMode::Auto};
|
||||
const Info<u32> GFX_WIDESCREEN_HEURISTIC_TRANSITION_THRESHOLD{
|
||||
{System::GFX, "Settings", "WidescreenHeuristicTransitionThreshold"}, 3};
|
||||
const Info<float> GFX_WIDESCREEN_HEURISTIC_ASPECT_RATIO_IDEAL{
|
||||
{System::GFX, "Settings", "WidescreenHeuristicAspectRatioIdeal"}, (16 / 9.f) / (4 / 3.f)};
|
||||
const Info<float> GFX_WIDESCREEN_HEURISTIC_ASPECT_RATIO_SLOP{
|
||||
{System::GFX, "Settings", "WidescreenHeuristicAspectRatioSlop"}, 0.11f};
|
||||
const Info<bool> GFX_CROP{{System::GFX, "Settings", "Crop"}, false};
|
||||
const Info<int> GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES{
|
||||
{System::GFX, "Settings", "SafeTextureCacheColorSamples"}, 128};
|
||||
|
@ -29,6 +29,9 @@ extern const Info<int> GFX_ADAPTER;
|
||||
extern const Info<bool> GFX_WIDESCREEN_HACK;
|
||||
extern const Info<AspectMode> GFX_ASPECT_RATIO;
|
||||
extern const Info<AspectMode> GFX_SUGGESTED_ASPECT_RATIO;
|
||||
extern const Info<u32> GFX_WIDESCREEN_HEURISTIC_TRANSITION_THRESHOLD;
|
||||
extern const Info<float> GFX_WIDESCREEN_HEURISTIC_ASPECT_RATIO_IDEAL;
|
||||
extern const Info<float> GFX_WIDESCREEN_HEURISTIC_ASPECT_RATIO_SLOP;
|
||||
extern const Info<bool> GFX_CROP;
|
||||
extern const Info<int> GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES;
|
||||
extern const Info<bool> GFX_SHOW_FPS;
|
||||
|
@ -76,26 +76,26 @@ constexpr Common::EnumMap<PrimitiveType, Primitive::GX_DRAW_POINTS> primitive_fr
|
||||
// by ~9% in opposite directions.
|
||||
// Just in case any game decides to take this into account, we do both these
|
||||
// tests with a large amount of slop.
|
||||
static constexpr float ASPECT_RATIO_SLOP = 0.11f;
|
||||
|
||||
static bool IsAnamorphicProjection(const Projection::Raw& projection, const Viewport& viewport)
|
||||
static bool IsAnamorphicProjection(const Projection::Raw& projection, const Viewport& viewport,
|
||||
const float ideal_ratio, const float slop)
|
||||
{
|
||||
// If ratio between our projection and viewport aspect ratios is similar to 16:9 / 4:3
|
||||
// we have an anamorphic projection.
|
||||
static constexpr float IDEAL_RATIO = (16 / 9.f) / (4 / 3.f);
|
||||
// (the "ideal ratio"), we have an anamorphic projection. This value can be overridden
|
||||
// by a GameINI.
|
||||
|
||||
const float projection_ar = projection[2] / projection[0];
|
||||
const float viewport_ar = viewport.wd / viewport.ht;
|
||||
|
||||
return std::abs(std::abs(projection_ar / viewport_ar) - IDEAL_RATIO) <
|
||||
IDEAL_RATIO * ASPECT_RATIO_SLOP;
|
||||
return std::abs(std::abs(projection_ar / viewport_ar) - ideal_ratio) < ideal_ratio * slop;
|
||||
}
|
||||
|
||||
static bool IsNormalProjection(const Projection::Raw& projection, const Viewport& viewport)
|
||||
static bool IsNormalProjection(const Projection::Raw& projection, const Viewport& viewport,
|
||||
const float slop)
|
||||
{
|
||||
const float projection_ar = projection[2] / projection[0];
|
||||
const float viewport_ar = viewport.wd / viewport.ht;
|
||||
return std::abs(std::abs(projection_ar / viewport_ar) - 1) < ASPECT_RATIO_SLOP;
|
||||
return std::abs(std::abs(projection_ar / viewport_ar) - 1) < slop;
|
||||
}
|
||||
|
||||
VertexManagerBase::VertexManagerBase()
|
||||
@ -507,12 +507,15 @@ void VertexManagerBase::Flush()
|
||||
auto& counts =
|
||||
is_perspective ? m_flush_statistics.perspective : m_flush_statistics.orthographic;
|
||||
|
||||
if (IsAnamorphicProjection(xfmem.projection.rawProjection, xfmem.viewport))
|
||||
const float ideal_ratio = g_ActiveConfig.widescreen_heuristic_aspect_ratio_ideal;
|
||||
const float slop = g_ActiveConfig.widescreen_heuristic_aspect_ratio_slop;
|
||||
|
||||
if (IsAnamorphicProjection(xfmem.projection.rawProjection, xfmem.viewport, ideal_ratio, slop))
|
||||
{
|
||||
++counts.anamorphic_flush_count;
|
||||
counts.anamorphic_vertex_count += m_index_generator.GetIndexLen();
|
||||
}
|
||||
else if (IsNormalProjection(xfmem.projection.rawProjection, xfmem.viewport))
|
||||
else if (IsNormalProjection(xfmem.projection.rawProjection, xfmem.viewport, slop))
|
||||
{
|
||||
++counts.normal_flush_count;
|
||||
counts.normal_vertex_count += m_index_generator.GetIndexLen();
|
||||
|
@ -86,6 +86,12 @@ void VideoConfig::Refresh()
|
||||
bWidescreenHack = Config::Get(Config::GFX_WIDESCREEN_HACK);
|
||||
aspect_mode = Config::Get(Config::GFX_ASPECT_RATIO);
|
||||
suggested_aspect_mode = Config::Get(Config::GFX_SUGGESTED_ASPECT_RATIO);
|
||||
widescreen_heuristic_transition_threshold =
|
||||
Config::Get(Config::GFX_WIDESCREEN_HEURISTIC_TRANSITION_THRESHOLD);
|
||||
widescreen_heuristic_aspect_ratio_ideal =
|
||||
Config::Get(Config::GFX_WIDESCREEN_HEURISTIC_ASPECT_RATIO_IDEAL);
|
||||
widescreen_heuristic_aspect_ratio_slop =
|
||||
Config::Get(Config::GFX_WIDESCREEN_HEURISTIC_ASPECT_RATIO_SLOP);
|
||||
bCrop = Config::Get(Config::GFX_CROP);
|
||||
iSafeTextureCache_ColorSamples = Config::Get(Config::GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES);
|
||||
bShowFPS = Config::Get(Config::GFX_SHOW_FPS);
|
||||
|
@ -106,6 +106,9 @@ struct VideoConfig final
|
||||
bool bWidescreenHack = false;
|
||||
AspectMode aspect_mode{};
|
||||
AspectMode suggested_aspect_mode{};
|
||||
u32 widescreen_heuristic_transition_threshold = 0;
|
||||
float widescreen_heuristic_aspect_ratio_ideal = 0.f;
|
||||
float widescreen_heuristic_aspect_ratio_slop = 0.f;
|
||||
bool bCrop = false; // Aspect ratio controls.
|
||||
bool bShaderCache = false;
|
||||
|
||||
|
@ -70,13 +70,13 @@ void WidescreenManager::UpdateWidescreenHeuristic()
|
||||
|
||||
// Modify the threshold based on which aspect ratio we're already using:
|
||||
// If the game's in 4:3, it probably won't switch to anamorphic, and vice-versa.
|
||||
static constexpr u32 TRANSITION_THRESHOLD = 3;
|
||||
const u32 transition_threshold = g_ActiveConfig.widescreen_heuristic_transition_threshold;
|
||||
|
||||
const auto looks_normal = [](auto& counts) {
|
||||
return counts.normal_vertex_count > counts.anamorphic_vertex_count * TRANSITION_THRESHOLD;
|
||||
const auto looks_normal = [transition_threshold](auto& counts) {
|
||||
return counts.normal_vertex_count > counts.anamorphic_vertex_count * transition_threshold;
|
||||
};
|
||||
const auto looks_anamorphic = [](auto& counts) {
|
||||
return counts.anamorphic_vertex_count > counts.normal_vertex_count * TRANSITION_THRESHOLD;
|
||||
const auto looks_anamorphic = [transition_threshold](auto& counts) {
|
||||
return counts.anamorphic_vertex_count > counts.normal_vertex_count * transition_threshold;
|
||||
};
|
||||
|
||||
const auto& persp = flush_statistics.perspective;
|
||||
|
Loading…
Reference in New Issue
Block a user