GPU: Restrict mip CLUT enhancement a bit.

Can't replicate this behavior on a real PSP.

In case a game sets the separate CLUT flag by accident, ignore except
in a safe case that occurs in Misshitsu no Sacrifice.  See #15727.
This commit is contained in:
Unknown W. Brackets 2022-08-20 17:32:45 -07:00
parent 5046cbd015
commit e374ea6b21
2 changed files with 11 additions and 3 deletions

View File

@ -1666,7 +1666,9 @@ CheckAlphaResult TextureCacheCommon::ReadIndexedTex(u8 *out, int outPitch, int l
texptr = (u8 *)tmpTexBuf32_.data();
}
const bool mipmapShareClut = gstate.isClutSharedForMipmaps();
// Misshitsu no Sacrifice has separate CLUT data, this is a hack to allow it.
// Normally separate CLUTs are not allowed for 8-bit or higher indices.
const bool mipmapShareClut = gstate.isClutSharedForMipmaps() && gstate.getClutLoadBlocks() == 0x40;
const int clutSharingOffset = mipmapShareClut ? 0 : (level & 1) * 256;
GEPaletteFormat palFormat = (GEPaletteFormat)gstate.getClutPaletteFormat();

View File

@ -300,8 +300,14 @@ struct GPUgstate {
bool isTextureFormatIndexed() const { return (texformat & 4) != 0; } // GE_TFMT_CLUT4 - GE_TFMT_CLUT32 are 0b1xx.
int getTextureEnvColRGB() const { return texenvcolor & 0x00FFFFFF; }
u32 getClutAddress() const { return (clutaddr & 0x00FFFFF0) | ((clutaddrupper << 8) & 0x0F000000); }
int getClutLoadBytes() const { return (loadclut & 0x7F) * 32; }
int getClutLoadBlocks() const { return (loadclut & 0x7F); }
int getClutLoadBytes() const { return getClutLoadBlocks() * 32; }
int getClutLoadBlocks() const {
// The PSP only supports 0x3F, but Misshitsu no Sacrifice has extra color data (see #15727.)
// 0x40 would be 0, which would be a no-op, so we allow it.
if ((loadclut & 0x7F) == 0x40)
return 0x40;
return loadclut & 0x3F;
}
GEPaletteFormat getClutPaletteFormat() const { return static_cast<GEPaletteFormat>(clutformat & 3); }
int getClutIndexShift() const { return (clutformat >> 2) & 0x1F; }
int getClutIndexMask() const { return (clutformat >> 8) & 0xFF; }