summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/TextureCacheBase.cpp
diff options
context:
space:
mode:
authorMarkus Wick <degasus@users.noreply.github.com>2018-06-21 10:19:47 +0200
committerGitHub <noreply@github.com>2018-06-21 10:19:47 +0200
commit0459a1a9e60172b3667ff2f9c3279714225d29ba (patch)
tree97caf3c5fd8caffae513c0811bab5bfe313a86fe /Source/Core/VideoCommon/TextureCacheBase.cpp
parentbf50348d9fac2b403e79b5bde396f134152ec704 (diff)
parentb30d56ccc0a03c41c758afcd47f5d19fa34b0a98 (diff)
Merge pull request #6875 from JonnyH/WIP/mipmap-heuristic-tweaks
Make arbitrary mipmap detection a config option
Diffstat (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp')
-rw-r--r--Source/Core/VideoCommon/TextureCacheBase.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp
index c1e112e69a..2ea772890a 100644
--- a/Source/Core/VideoCommon/TextureCacheBase.cpp
+++ b/Source/Core/VideoCommon/TextureCacheBase.cpp
@@ -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;