Merge pull request #6875 from JonnyH/WIP/mipmap-heuristic-tweaks

Make arbitrary mipmap detection a config option
This commit is contained in:
Markus Wick 2018-06-21 10:19:47 +02:00 committed by GitHub
commit 0459a1a9e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 6 deletions

View File

@ -107,6 +107,10 @@ const ConfigInfo<bool> GFX_ENHANCE_FORCE_TRUE_COLOR{{System::GFX, "Enhancements"
true};
const ConfigInfo<bool> GFX_ENHANCE_DISABLE_COPY_FILTER{
{System::GFX, "Enhancements", "DisableCopyFilter"}, true};
const ConfigInfo<bool> GFX_ENHANCE_ARBITRARY_MIPMAP_DETECTION{
{System::GFX, "Enhancements", "ArbitraryMipmapDetection"}, true};
const ConfigInfo<float> GFX_ENHANCE_ARBITRARY_MIPMAP_DETECTION_THRESHOLD{
{System::GFX, "Enhancements", "ArbitraryMipmapDetectionThreshold"}, 4.5f};
// Graphics.Stereoscopy

View File

@ -85,6 +85,8 @@ extern const ConfigInfo<int> GFX_ENHANCE_MAX_ANISOTROPY; // NOTE - this is x in
extern const ConfigInfo<std::string> GFX_ENHANCE_POST_SHADER;
extern const ConfigInfo<bool> GFX_ENHANCE_FORCE_TRUE_COLOR;
extern const ConfigInfo<bool> GFX_ENHANCE_DISABLE_COPY_FILTER;
extern const ConfigInfo<bool> GFX_ENHANCE_ARBITRARY_MIPMAP_DETECTION;
extern const ConfigInfo<float> GFX_ENHANCE_ARBITRARY_MIPMAP_DETECTION_THRESHOLD;
// Graphics.Stereoscopy

View File

@ -500,11 +500,14 @@ public:
if (levels.size() < 2)
return false;
if (!g_ActiveConfig.bArbitraryMipmapDetection)
return false;
// This is the average per-pixel, per-channel difference in percent between what we
// expect a normal blurred mipmap to look like and what we actually received
// 4.5% was chosen because it's just below the lowest clearly-arbitrary texture
// I found in my tests, the background clouds in Mario Galaxy's Observatory lobby.
constexpr auto THRESHOLD_PERCENT = 4.5f;
const auto threshold = g_ActiveConfig.fArbitraryMipmapDetectionThreshold;
auto* src = downsample_buffer;
auto* dst = downsample_buffer + levels[1].shape.row_length * levels[1].shape.height * 4;
@ -530,7 +533,7 @@ public:
}
auto all_levels = total_diff / (levels.size() - 1);
return all_levels > THRESHOLD_PERCENT;
return all_levels > threshold;
}
private:
@ -605,10 +608,14 @@ private:
const auto* row2 = ptr2;
for (u32 j = 0; j < shape.width; ++j, row1 += 4, row2 += 4)
{
average_diff += std::abs(static_cast<float>(row1[0]) - static_cast<float>(row2[0]));
average_diff += std::abs(static_cast<float>(row1[1]) - static_cast<float>(row2[1]));
average_diff += std::abs(static_cast<float>(row1[2]) - static_cast<float>(row2[2]));
average_diff += std::abs(static_cast<float>(row1[3]) - static_cast<float>(row2[3]));
int pixel_diff = 0;
for (int channel = 0; channel < 4; channel++)
{
const int diff = static_cast<int>(row1[channel]) - static_cast<int>(row2[channel]);
const int diff_squared = diff * diff;
pixel_diff += diff_squared;
}
average_diff += pixel_diff;
}
ptr1 += shape.row_length;
ptr2 += shape.row_length;

View File

@ -120,6 +120,9 @@ void VideoConfig::Refresh()
sPostProcessingShader = Config::Get(Config::GFX_ENHANCE_POST_SHADER);
bForceTrueColor = Config::Get(Config::GFX_ENHANCE_FORCE_TRUE_COLOR);
bDisableCopyFilter = Config::Get(Config::GFX_ENHANCE_DISABLE_COPY_FILTER);
bArbitraryMipmapDetection = Config::Get(Config::GFX_ENHANCE_ARBITRARY_MIPMAP_DETECTION);
fArbitraryMipmapDetectionThreshold =
Config::Get(Config::GFX_ENHANCE_ARBITRARY_MIPMAP_DETECTION_THRESHOLD);
stereo_mode = Config::Get(Config::GFX_STEREO_MODE);
iStereoDepth = Config::Get(Config::GFX_STEREO_DEPTH);

View File

@ -74,6 +74,8 @@ struct VideoConfig final
std::string sPostProcessingShader;
bool bForceTrueColor;
bool bDisableCopyFilter;
bool bArbitraryMipmapDetection;
float fArbitraryMipmapDetectionThreshold;
// Information
bool bShowFPS;