Implement new discovery of a larger CLUT than we thought, plus non-shared CLUTs for 8-bit indices.

Not sure yet what limitations apply, regarding using it for even more
16-bit colors, etc...
This commit is contained in:
Henrik Rydgård 2022-07-25 20:51:52 +02:00
parent f061eadc04
commit 2cb9e09ad3
3 changed files with 10 additions and 6 deletions

View File

@ -560,7 +560,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
}
} else {
if (texture3D) {
WRITE(p, " float bias = pow(u_mipBias, 1.0);\n");
WRITE(p, " float bias = u_mipBias * 1.0;\n");
if (doTextureProjection) {
WRITE(p, " vec4 t = %sProj(tex, vec4(%s.xy, bias, %s.z));\n", compat.texture, texcoord, texcoord);
} else {
@ -573,7 +573,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
WRITE(p, " vec4 t = %s(tex, %s.xy);\n", compat.texture, texcoord);
}
}
}
}
} else {
if (doTextureProjection) {
// We don't use textureProj because we need better control and it's probably not much of a savings anyway.

View File

@ -1678,10 +1678,13 @@ CheckAlphaResult TextureCacheCommon::ReadIndexedTex(u8 *out, int outPitch, int l
texptr = (u8 *)tmpTexBuf32_.data();
}
const bool mipmapShareClut = gstate.isClutSharedForMipmaps();
const int clutSharingOffset = mipmapShareClut ? 0 : (level & 1) * 256;
GEPaletteFormat palFormat = (GEPaletteFormat)gstate.getClutPaletteFormat();
const u16 *clut16 = (const u16 *)clutBuf_;
const u32 *clut32 = (const u32 *)clutBuf_;
const u16 *clut16 = (const u16 *)clutBuf_ + clutSharingOffset;
const u32 *clut32 = (const u32 *)clutBuf_ + clutSharingOffset;
if (expandTo32Bit && palFormat != GE_CMODE_32BIT_ABGR8888) {
ConvertFormatToRGBA8888(GEPaletteFormat(palFormat), expandClut_, clut16, 256);
@ -1721,6 +1724,7 @@ CheckAlphaResult TextureCacheCommon::ReadIndexedTex(u8 *out, int outPitch, int l
case GE_CMODE_32BIT_ABGR8888:
{
switch (bytesPerIndex) {
case 1:
for (int y = 0; y < h; ++y) {

View File

@ -300,8 +300,8 @@ 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 & 0x3F) * 32; }
int getClutLoadBlocks() const { return (loadclut & 0x3F); }
int getClutLoadBytes() const { return (loadclut & 0x7F) * 32; }
int getClutLoadBlocks() const { return (loadclut & 0x7F); }
GEPaletteFormat getClutPaletteFormat() const { return static_cast<GEPaletteFormat>(clutformat & 3); }
int getClutIndexShift() const { return (clutformat >> 2) & 0x1F; }
int getClutIndexMask() const { return (clutformat >> 8) & 0xFF; }