1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-10 22:31:40 +02:00

Merge pull request #5387 from IvanSavenko/xbrz_autoselect

Enable xbrz2 by default on mobile systems
This commit is contained in:
Ivan Savenko
2025-02-09 19:16:42 +02:00
committed by GitHub

View File

@@ -357,34 +357,23 @@ EUpscalingFilter ScreenHandler::loadUpscalingFilter() const
return filter; return filter;
// else - autoselect // else - autoselect
#ifdef VCMI_MOBILE
// to help with performance - only if player explicitly enabled xbrz
return EUpscalingFilter::NONE;
#else
Point outputResolution = getRenderResolution(); Point outputResolution = getRenderResolution();
Point logicalResolution = getPreferredLogicalResolution(); Point logicalResolution = getPreferredLogicalResolution();
float scaleX = static_cast<float>(outputResolution.x) / logicalResolution.x; float scaleX = static_cast<float>(outputResolution.x) / logicalResolution.x;
float scaleY = static_cast<float>(outputResolution.x) / logicalResolution.x; float scaleY = static_cast<float>(outputResolution.x) / logicalResolution.x;
float scaling = std::min(scaleX, scaleY); float scaling = std::min(scaleX, scaleY);
int systemMemoryMb = SDL_GetSystemRAM();
if (scaling <= 1.001f) if (scaling <= 1.001f)
return EUpscalingFilter::NONE; // running at original resolution or even lower than that - no need for xbrz return EUpscalingFilter::NONE; // running at original resolution or even lower than that - no need for xbrz
else
if (systemMemoryMb < 2048)
return EUpscalingFilter::NONE; // xbrz2 may use ~1.0 - 1.5 Gb of RAM and has notable CPU cost - avoid on low-spec hardware
// Only using xbrz2 for autoselection.
// Higher options may have high system requirements and should be only selected explicitly by player
return EUpscalingFilter::XBRZ_2; return EUpscalingFilter::XBRZ_2;
#endif
#if 0
// Old version, most optimal, but rather performance-heavy
if (scaling <= 1.001f)
return EUpscalingFilter::NONE; // running at original resolution or even lower than that - no need for xbrz
if (scaling <= 2.001f)
return EUpscalingFilter::XBRZ_2; // resolutions below 1200p (including 1080p / FullHD)
if (scaling <= 3.001f)
return EUpscalingFilter::XBRZ_3; // resolutions below 2400p (including 1440p and 2160p / 4K)
return EUpscalingFilter::XBRZ_4; // Only for massive displays, e.g. 8K
#endif
} }
void ScreenHandler::selectUpscalingFilter() void ScreenHandler::selectUpscalingFilter()