Merge pull request #6590 from lioncash/hires

HiresTexture: Correct texture hashes
This commit is contained in:
Mat M 2018-04-03 19:00:28 -04:00 committed by GitHub
commit 88853551e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,7 +12,6 @@
#include <mutex> #include <mutex>
#include <string> #include <string>
#include <thread> #include <thread>
#include <tuple>
#include <unordered_map> #include <unordered_map>
#include <utility> #include <utility>
#include <vector> #include <vector>
@ -232,21 +231,29 @@ std::string HiresTexture::GenBaseName(const u8* texture, size_t texture_size, co
{ {
const u32 low_nibble = texture[i] & 0xf; const u32 low_nibble = texture[i] & 0xf;
const u32 high_nibble = texture[i] >> 4; const u32 high_nibble = texture[i] >> 4;
std::tie(min, max) = std::minmax({min, max, low_nibble, high_nibble});
min = std::min({min, low_nibble, high_nibble});
max = std::max({max, low_nibble, high_nibble});
} }
break; break;
case 256 * 2: case 256 * 2:
{ {
const auto minmax = std::minmax_element(texture, texture + texture_size); for (size_t i = 0; i < texture_size; i++)
min = *minmax.first; {
max = *minmax.second; const u32 texture_byte = texture[i];
min = std::min(min, texture_byte);
max = std::max(max, texture_byte);
}
break; break;
} }
case 16384 * 2: case 16384 * 2:
for (size_t i = 0; i < texture_size; i += sizeof(u16)) for (size_t i = 0; i < texture_size; i += sizeof(u16))
{ {
const u32 texture_halfword = Common::swap16(texture[i]) & 0x3fff; const u32 texture_halfword = Common::swap16(texture[i]) & 0x3fff;
std::tie(min, max) = std::minmax({min, max, texture_halfword});
min = std::min(min, texture_halfword);
max = std::max(max, texture_halfword);
} }
break; break;
} }