Created
June 5, 2022 00:14
-
-
Save Pokechu22/58ecabbb17526f7c6b5ccd8fba14b708 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp | |
index dc08fd90bc..11b89f31bb 100644 | |
--- a/Source/Core/VideoCommon/TextureCacheBase.cpp | |
+++ b/Source/Core/VideoCommon/TextureCacheBase.cpp | |
@@ -939,7 +939,7 @@ TextureCacheBase::DoPartialTextureUpdates(TCacheEntry* entry_to_update, const u8 | |
} | |
void TextureCacheBase::DumpTexture(TCacheEntry* entry, std::string basename, unsigned int level, | |
- bool is_arbitrary) | |
+ bool is_arbitrary, float arb_amount) | |
{ | |
std::string szDir = File::GetUserPath(D_DUMPTEXTURES_IDX) + SConfig::GetInstance().GetGameID(); | |
@@ -951,6 +951,7 @@ void TextureCacheBase::DumpTexture(TCacheEntry* entry, std::string basename, uns | |
{ | |
basename += "_arb"; | |
} | |
+ basename += fmt::format("_{}", arb_amount); | |
if (level > 0) | |
{ | |
@@ -1071,10 +1072,10 @@ public: | |
void AddLevel(u32 width, u32 height, u32 row_length, const u8* buffer) | |
{ | |
- levels.push_back({{width, height, row_length}, buffer}); | |
+ levels.push_back({{width, height, row_length}, buffer, 0}); | |
} | |
- bool HasArbitraryMipmaps(u8* downsample_buffer) const | |
+ bool HasArbitraryMipmaps(u8* downsample_buffer) | |
{ | |
if (levels.size() < 2) | |
return false; | |
@@ -1095,8 +1096,8 @@ public: | |
for (std::size_t i = 0; i < levels.size() - 1; ++i) | |
{ | |
- const auto& level = levels[i]; | |
- const auto& mip = levels[i + 1]; | |
+ auto& level = levels[i]; | |
+ auto& mip = levels[i + 1]; | |
u64 level_pixel_count = level.shape.width; | |
level_pixel_count *= level.shape.height; | |
@@ -1112,16 +1113,18 @@ public: | |
// Find the average difference between pixels in this level but downsampled | |
// and the next level | |
auto diff = mip.AverageDiff(dst); | |
+ mip.final_diff = diff; | |
total_diff += diff; | |
std::swap(src, dst); | |
} | |
auto all_levels = total_diff / (levels.size() - 1); | |
+ levels[0].final_diff = all_levels; | |
return all_levels > threshold; | |
} | |
-private: | |
+ // private: | |
struct Shape | |
{ | |
u32 width; | |
@@ -1133,6 +1136,7 @@ private: | |
{ | |
Shape shape; | |
const u8* pixels; | |
+ float final_diff = 0; | |
static PixelRGBAu8 SampleLinear(const u8* src, const Shape& src_shape, u32 x, u32 y) | |
{ | |
@@ -1678,7 +1682,8 @@ TextureCacheBase::GetTexture(const int textureCacheSafetyColorSampleSize, Textur | |
{ | |
for (u32 level = 0; level < texLevels; ++level) | |
{ | |
- DumpTexture(entry, basename, level, entry->has_arbitrary_mips); | |
+ DumpTexture(entry, basename, level, entry->has_arbitrary_mips, | |
+ arbitrary_mip_detector.levels[level].final_diff); | |
} | |
} | |
diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h | |
index daf7e292d1..6e9cf216d6 100644 | |
--- a/Source/Core/VideoCommon/TextureCacheBase.h | |
+++ b/Source/Core/VideoCommon/TextureCacheBase.h | |
@@ -310,7 +310,8 @@ private: | |
TLUTFormat tlutfmt); | |
void StitchXFBCopy(TCacheEntry* entry_to_update); | |
- void DumpTexture(TCacheEntry* entry, std::string basename, unsigned int level, bool is_arbitrary); | |
+ void DumpTexture(TCacheEntry* entry, std::string basename, unsigned int level, bool is_arbitrary, | |
+ float arb_amount = 0); | |
void CheckTempSize(size_t required_size); | |
TCacheEntry* AllocateCacheEntry(const TextureConfig& config); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment