Skip to content

Commit

Permalink
Change the arbitrary mipmap detection to use the square of the error
Browse files Browse the repository at this point in the history
Hopefully this better matches the user's view of a texture - as large changes in
colour should be weighted higher than lots of very small changes

Note: This likely invalidates the current heuristic threshold default
  • Loading branch information
JonnyH committed May 17, 2018
1 parent 8be5cdf commit 61a8179
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Source/Core/VideoCommon/TextureCacheBase.cpp
Expand Up @@ -608,10 +608,13 @@ class ArbitraryMipmapDetector
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]));
for (int channel = 0; channel < 4; channel++)
{
const float diff =
std::abs(static_cast<float>(row1[channel]) - static_cast<float>(row2[channel]));
const float diff_squared = diff * diff;
average_diff += diff_squared;
}
}
ptr1 += shape.row_length;
ptr2 += shape.row_length;
Expand Down

0 comments on commit 61a8179

Please sign in to comment.