A fix by baby.lueshi that fixes the problems with rev 3187
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3190 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
8e535bf2c0
commit
be45b223bb
|
@ -260,8 +260,11 @@ void PixelShaderManager::SetTexDims(int texmapid, u32 width, u32 height, u32 wra
|
|||
|
||||
void PixelShaderManager::SetCustomTexScale(int texmapid, float x, float y)
|
||||
{
|
||||
if (lastCustomTexScale[texmapid][0] != x || lastCustomTexScale[texmapid][1] != y) {
|
||||
s_nTexDimsChanged |= 1 << texmapid;
|
||||
lastCustomTexScale[texmapid][0] = x;
|
||||
lastCustomTexScale[texmapid][1] = y;
|
||||
}
|
||||
}
|
||||
|
||||
void PixelShaderManager::SetZTextureBias(u32 bias)
|
||||
|
|
|
@ -109,6 +109,25 @@ int TexDecoder_GetBlockWidthInTexels(int format)
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME: Use reasonable values for block height
|
||||
int TexDecoder_GetBlockHeightInTexels(int format)
|
||||
{
|
||||
switch (format) {
|
||||
case GX_TF_I4: return 1;
|
||||
case GX_TF_I8: return 1;
|
||||
case GX_TF_IA4: return 1;
|
||||
case GX_TF_IA8: return 1;
|
||||
case GX_TF_RGB565: return 1;
|
||||
case GX_TF_RGB5A3: return 1;
|
||||
case GX_TF_RGBA8: return 1;
|
||||
case GX_TF_C4: return 1;
|
||||
case GX_TF_C8: return 1;
|
||||
case GX_TF_C14X2: return 1;
|
||||
case GX_TF_CMPR: return 8;
|
||||
default: return 1;
|
||||
}
|
||||
}
|
||||
|
||||
//returns bytes
|
||||
int TexDecoder_GetPaletteSize(int format)
|
||||
{
|
||||
|
@ -218,7 +237,6 @@ inline void decodebytesC8(u32 *dst, const u8 *src, int tlutaddr, int tlutfmt)
|
|||
}
|
||||
|
||||
|
||||
|
||||
//inline void decodebytesC14X2(u32 *dst, const u16 *src, int numpixels, int tlutaddr, int tlutfmt)
|
||||
inline void decodebytesC14X2(u32 *dst, const u16 *src, int tlutaddr, int tlutfmt)
|
||||
{
|
||||
|
@ -469,7 +487,6 @@ PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int heigh
|
|||
return PC_TEX_FMT_DXT1;
|
||||
}
|
||||
|
||||
|
||||
// The "copy" texture formats, too?
|
||||
return PC_TEX_FMT_NONE;
|
||||
}
|
||||
|
@ -869,7 +886,6 @@ const unsigned char sfont_raw[][9*10] = {
|
|||
0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x78, 0x78,
|
||||
0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x78, 0x78,
|
||||
0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x78, 0x78,
|
||||
|
||||
0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x78, 0x78,
|
||||
0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x78, 0x78,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x78,
|
||||
|
@ -1270,7 +1286,6 @@ const unsigned char sfont_raw[][9*10] = {
|
|||
0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78,
|
||||
},{
|
||||
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78,
|
||||
|
@ -1294,4 +1309,3 @@ const unsigned char sfont_raw[][9*10] = {
|
|||
0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ enum TextureFormat
|
|||
int TexDecoder_GetTexelSizeInNibbles(int format);
|
||||
int TexDecoder_GetTextureSizeInBytes(int width, int height, int format);
|
||||
int TexDecoder_GetBlockWidthInTexels(int format);
|
||||
int TexDecoder_GetBlockHeightInTexels(int format);
|
||||
int TexDecoder_GetPaletteSize(int fmt);
|
||||
|
||||
enum PC_TexFormat
|
||||
|
@ -89,4 +90,3 @@ u32 TexDecoder_GetTlutHash(const u8* src, int len);
|
|||
void TexDecoder_SetTexFmtOverlayOptions(bool enable, bool center);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -218,7 +218,6 @@ void TextureMngr::ProgressiveCleanup()
|
|||
iter++;
|
||||
}
|
||||
|
||||
|
||||
std::map<u32, DEPTHTARGET>::iterator itdepth = mapDepthTargets.begin();
|
||||
while (itdepth != mapDepthTargets.end())
|
||||
{
|
||||
|
@ -275,26 +274,33 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
|||
|
||||
TexMode0 &tm0 = bpmem.tex[texstage > 3].texMode0[texstage & 3];
|
||||
u8 *ptr = g_VideoInitialize.pGetMemoryPointer(address);
|
||||
int bs = TexDecoder_GetBlockWidthInTexels(tex_format) - 1;
|
||||
int expandedWidth = (width + bs) & (~bs);
|
||||
int bsw = TexDecoder_GetBlockWidthInTexels(tex_format) - 1;
|
||||
int bsh = TexDecoder_GetBlockHeightInTexels(tex_format) - 1;
|
||||
int expandedWidth = (width + bsw) & (~bsw);
|
||||
int expandedHeight = (height + bsh) & (~bsh);
|
||||
|
||||
u32 hash_value;
|
||||
u32 texID = address;
|
||||
if (g_Config.bSafeTextureCache)
|
||||
u32 texHash;
|
||||
|
||||
if (g_Config.bSafeTextureCache || g_Config.bHiresTextures || g_Config.bDumpTextures)
|
||||
{
|
||||
hash_value = TexDecoder_GetSafeTextureHash(ptr, expandedWidth, height, tex_format, 0); // remove last arg
|
||||
texHash = TexDecoder_GetSafeTextureHash(ptr, expandedWidth, expandedHeight, tex_format, 0); // remove last arg
|
||||
if (g_Config.bSafeTextureCache)
|
||||
hash_value = texHash;
|
||||
if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2))
|
||||
{
|
||||
// WARNING! texID != address now => may break CopyRenderTargetToTexture (cf. TODO up)
|
||||
// tlut size can be up to 32768B (GX_TF_C14X2) but Safer == Slower.
|
||||
//texID ^= TexDecoder_GetTlutHash(&texMem[tlutaddr], TexDecoder_GetPaletteSize(tex_format));
|
||||
|
||||
// This trick (to change the texID depending on the TLUT addr) is a trick to get around
|
||||
// an issue with metroid prime's fonts, where it has multiple sets of fonts on top of
|
||||
// each other stored in a single texture, and uses the palette to make different characters
|
||||
// visible or invisible. Thus, unless we want to recreate the textures for every drawn character,
|
||||
// we must make sure that texture with different tluts get different IDs.
|
||||
texID ^= TexDecoder_GetTlutHash(&texMem[tlutaddr], (tex_format == GX_TF_C4) ? 32 : 128);
|
||||
u32 tlutHash = TexDecoder_GetTlutHash(&texMem[tlutaddr], (tex_format == GX_TF_C4) ? 32 : 128);
|
||||
texHash ^= tlutHash;
|
||||
if (g_Config.bSafeTextureCache)
|
||||
texID ^= tlutHash;
|
||||
//DebugLog("addr: %08x | texID: %08x | texHash: %08x", address, texID, hash_value);
|
||||
}
|
||||
}
|
||||
|
@ -340,10 +346,32 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
|||
}
|
||||
}
|
||||
|
||||
PC_TexFormat dfmt = TexDecoder_Decode(temp, ptr, expandedWidth, height, tex_format, tlutaddr, tlutfmt);
|
||||
|
||||
//Make an entry in the table
|
||||
TCacheEntry& entry = textures[texID];
|
||||
PC_TexFormat dfmt = PC_TEX_FMT_NONE;
|
||||
|
||||
if (g_Config.bHiresTextures)
|
||||
{
|
||||
//Load Custom textures
|
||||
char texPathTemp[MAX_PATH];
|
||||
int oldWidth = width;
|
||||
int oldHeight = height;
|
||||
sprintf(texPathTemp, "%s_%08x_%i", ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.GetUniqueID().c_str(), texHash, tex_format);
|
||||
dfmt = HiresTextures::GetHiresTex(texPathTemp, &width, &height, temp);
|
||||
|
||||
if (dfmt != PC_TEX_FMT_NONE)
|
||||
{
|
||||
expandedWidth = width;
|
||||
expandedHeight = height;
|
||||
entry.size_in_bytes = sizeof(temp);
|
||||
entry.scaleX = (float) width / oldWidth;
|
||||
entry.scaleY = (float) height / oldHeight;
|
||||
INFO_LOG(VIDEO, "loading custom texture from %s", texPathTemp);
|
||||
}
|
||||
}
|
||||
|
||||
if (dfmt == PC_TEX_FMT_NONE)
|
||||
dfmt = TexDecoder_Decode(temp, ptr, expandedWidth, expandedHeight, tex_format, tlutaddr, tlutfmt);
|
||||
|
||||
entry.hashoffset = 0;
|
||||
//entry.paletteHash = hashseed;
|
||||
|
@ -371,31 +399,11 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
|||
glBindTexture(target, entry.texture);
|
||||
}
|
||||
|
||||
if (dfmt != PC_TEX_FMT_DXT1)
|
||||
{
|
||||
if (expandedWidth != width)
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, expandedWidth);
|
||||
|
||||
u32 texHash = HashFNV(temp, entry.size_in_bytes);
|
||||
if (g_Config.bHiresTextures)
|
||||
{
|
||||
//Load Custom textures
|
||||
char texPathTemp[MAX_PATH];
|
||||
int oldWidth = width;
|
||||
int oldHeight = height;
|
||||
sprintf(texPathTemp, "%s_%08x_%i", ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.GetUniqueID().c_str(), texHash, tex_format);
|
||||
PC_TexFormat customTex = HiresTextures::GetHiresTex(texPathTemp, &width, &height, temp);
|
||||
|
||||
if (customTex != PC_TEX_FMT_NONE)
|
||||
{
|
||||
entry.size_in_bytes = sizeof(temp);
|
||||
entry.scaleX = (float) width / oldWidth;
|
||||
entry.scaleY = (float) height / oldHeight;
|
||||
INFO_LOG(VIDEO, "loading custom texture from %s", texPathTemp);
|
||||
dfmt = customTex;
|
||||
}
|
||||
}
|
||||
|
||||
if (dfmt != PC_TEX_FMT_DXT1)
|
||||
{
|
||||
int gl_format;
|
||||
int gl_iformat;
|
||||
int gl_type;
|
||||
|
@ -431,7 +439,6 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
if (!entry.isNonPow2 && ((tm0.min_filter & 3) == 1 || (tm0.min_filter & 3) == 2))
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
|
||||
|
@ -442,23 +449,15 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
|||
}
|
||||
else
|
||||
glTexImage2D(target, 0, gl_iformat, width, height, 0, gl_format, gl_type, temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Round dimensions up to the next multiple of 4; this is an OpenGL
|
||||
// requirement.
|
||||
// FIXME: Why does the GameCube have compressed textures that aren't
|
||||
// multiples of 4, and what is the best way to handle them?
|
||||
// An example is in SSB Melee's Adventure Mode on the Paratroopas'
|
||||
// wings.
|
||||
int nativeWidth = (width + 3) & ~3;
|
||||
int nativeHeight = (height + 3) & ~3;
|
||||
glCompressedTexImage2D(target, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
||||
nativeWidth, nativeHeight, 0, nativeWidth*nativeHeight/2, temp);
|
||||
}
|
||||
|
||||
if (expandedWidth != width) // reset
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
glCompressedTexImage2D(target, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
||||
expandedWidth, expandedHeight, 0, expandedWidth*expandedHeight/2, temp);
|
||||
}
|
||||
|
||||
entry.frameCount = frameCount;
|
||||
entry.w = width;
|
||||
|
@ -473,7 +472,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
|||
sprintf(szTemp, "%s/%s_%08x_%i.tga", FULL_DUMP_TEXTURES_DIR, ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.GetUniqueID().c_str(), texHash, tex_format);
|
||||
if (!File::Exists(szTemp))
|
||||
{
|
||||
SaveTexture(szTemp, target, entry.texture, width, height);
|
||||
SaveTexture(szTemp, target, entry.texture, expandedWidth, expandedHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -644,7 +643,6 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
|
|||
colmat[0] = colmat[4] = colmat[8] = colmat[15] = 1;
|
||||
break;
|
||||
|
||||
|
||||
case 7: // A8
|
||||
colmat[3] = colmat[7] = colmat[11] = colmat[15] = 1;
|
||||
break;
|
||||
|
|
|
@ -237,7 +237,7 @@ void Flush()
|
|||
PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, 0, 0);
|
||||
}
|
||||
// texture is hires - pass the scaling size
|
||||
if (tentry->scaleX != 1.0f && tentry->scaleY != 1.0f)
|
||||
if (tentry->scaleX != 1.0f || tentry->scaleY != 1.0f)
|
||||
PixelShaderManager::SetCustomTexScale(i, tentry->scaleX, tentry->scaleY);
|
||||
if (g_Config.iLog & CONF_SAVETEXTURES)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue