Skip to content

Commit

Permalink
Add comment about swizzling to the texture replacer hash
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Dec 7, 2023
1 parent 443a882 commit 877324c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion GPU/Common/TextureCacheCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ class TextureCacheCommon {

static inline u32 QuickTexHash(TextureReplacer &replacer, u32 addr, int bufw, int w, int h, bool swizzled, GETextureFormat format, const TexCacheEntry *entry) {
if (replacer.Enabled()) {
return replacer.ComputeHash(addr, bufw, w, h, format, entry->maxSeenV);
return replacer.ComputeHash(addr, bufw, w, h, swizzled, format, entry->maxSeenV);
}

if (h == 512 && entry->maxSeenV < 512 && entry->maxSeenV != 0) {
Expand Down
5 changes: 4 additions & 1 deletion GPU/Common/TextureReplacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,12 @@ void TextureReplacer::ParseReduceHashRange(const std::string& key, const std::st
reducehashranges_[reducerangeKey] = rhashvalue;
}

u32 TextureReplacer::ComputeHash(u32 addr, int bufw, int w, int h, GETextureFormat fmt, u16 maxSeenV) {
u32 TextureReplacer::ComputeHash(u32 addr, int bufw, int w, int h, bool swizzled, GETextureFormat fmt, u16 maxSeenV) {
_dbg_assert_msg_(enabled_, "Replacement not enabled");

// TODO: Take swizzled into account, like in QuickTexHash().
// Note: Currently, only the MLB games are known to need this.

if (!LookupHashRange(addr, w, h, &w, &h)) {
// There wasn't any hash range, let's fall back to maxSeenV logic.
if (h == 512 && maxSeenV < 512 && maxSeenV != 0) {
Expand Down
2 changes: 1 addition & 1 deletion GPU/Common/TextureReplacer.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class TextureReplacer {
bool Enabled() const { return enabled_; }
bool AllowVideo() const { return allowVideo_; }

u32 ComputeHash(u32 addr, int bufw, int w, int h, GETextureFormat fmt, u16 maxSeenV);
u32 ComputeHash(u32 addr, int bufw, int w, int h, bool swizzled, GETextureFormat fmt, u16 maxSeenV);

// Returns nullptr if not found.
ReplacedTexture *FindReplacement(u64 cachekey, u32 hash, int w, int h);
Expand Down

0 comments on commit 877324c

Please sign in to comment.