Avoid calling FindReplacement unnecessarily.

This commit is contained in:
Henrik Rydgård 2023-03-18 12:03:32 +01:00
parent 97c9b9e4f7
commit 9a228b1f23
2 changed files with 5 additions and 4 deletions

View File

@ -531,11 +531,11 @@ TexCacheEntry *TextureCacheCommon::SetTexture() {
int w0 = gstate.getTextureWidth(0);
int h0 = gstate.getTextureHeight(0);
int d0 = 1;
ReplacedTexture *replaced = FindReplacement(entry, &w0, &h0, &d0);
if (replaced) {
if (entry->replacedTexture) {
PollReplacement(entry, &w0, &h0, &d0);
// This texture is pending a replacement load.
// So check the replacer if it's reached a conclusion.
switch (replaced->State()) {
switch (entry->replacedTexture->State()) {
case ReplacementState::NOT_FOUND:
// Didn't find a replacement, so stop looking.
// DEBUG_LOG(G3D, "No replacement for texture %dx%d", w0, h0);

View File

@ -389,7 +389,8 @@ protected:
CheckAlphaResult DecodeTextureLevel(u8 *out, int outPitch, GETextureFormat format, GEPaletteFormat clutformat, uint32_t texaddr, int level, int bufw, TexDecodeFlags flags);
void UnswizzleFromMem(u32 *dest, u32 destPitch, const u8 *texptr, u32 bufw, u32 height, u32 bytesPerPixel);
CheckAlphaResult ReadIndexedTex(u8 *out, int outPitch, int level, const u8 *texptr, int bytesPerIndex, int bufw, bool reverseColors, bool expandTo32Bit);
ReplacedTexture *FindReplacement(TexCacheEntry *entry, int &w, int &h, int &d);
ReplacedTexture *FindReplacement(TexCacheEntry *entry, int *w, int *h, int *d);
void PollReplacement(TexCacheEntry *entry, int *w, int *h, int *d);
// Return value is mapData normally, but could be another buffer allocated with AllocateAlignedMemory.
void LoadTextureLevel(TexCacheEntry &entry, uint8_t *mapData, size_t dataSize, int mapRowPitch, BuildTexturePlan &plan, int srcLevel, Draw::DataFormat dstFmt, TexDecodeFlags texDecFlags);