Revert r3187 causes games to return lots of errors.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3189 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
b4ccf03967
commit
8e535bf2c0
|
@ -109,25 +109,6 @@ 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
|
//returns bytes
|
||||||
int TexDecoder_GetPaletteSize(int format)
|
int TexDecoder_GetPaletteSize(int format)
|
||||||
{
|
{
|
||||||
|
@ -237,6 +218,7 @@ 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 numpixels, int tlutaddr, int tlutfmt)
|
||||||
inline void decodebytesC14X2(u32 *dst, const u16 *src, int tlutaddr, int tlutfmt)
|
inline void decodebytesC14X2(u32 *dst, const u16 *src, int tlutaddr, int tlutfmt)
|
||||||
{
|
{
|
||||||
|
@ -487,6 +469,7 @@ PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int heigh
|
||||||
return PC_TEX_FMT_DXT1;
|
return PC_TEX_FMT_DXT1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// The "copy" texture formats, too?
|
// The "copy" texture formats, too?
|
||||||
return PC_TEX_FMT_NONE;
|
return PC_TEX_FMT_NONE;
|
||||||
}
|
}
|
||||||
|
@ -886,6 +869,7 @@ const unsigned char sfont_raw[][9*10] = {
|
||||||
0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x78, 0x78,
|
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, 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, 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,
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x78,
|
||||||
|
@ -1286,6 +1270,7 @@ 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,
|
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,
|
||||||
|
@ -1309,3 +1294,4 @@ 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,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,6 @@ enum TextureFormat
|
||||||
int TexDecoder_GetTexelSizeInNibbles(int format);
|
int TexDecoder_GetTexelSizeInNibbles(int format);
|
||||||
int TexDecoder_GetTextureSizeInBytes(int width, int height, int format);
|
int TexDecoder_GetTextureSizeInBytes(int width, int height, int format);
|
||||||
int TexDecoder_GetBlockWidthInTexels(int format);
|
int TexDecoder_GetBlockWidthInTexels(int format);
|
||||||
int TexDecoder_GetBlockHeightInTexels(int format);
|
|
||||||
int TexDecoder_GetPaletteSize(int fmt);
|
int TexDecoder_GetPaletteSize(int fmt);
|
||||||
|
|
||||||
enum PC_TexFormat
|
enum PC_TexFormat
|
||||||
|
@ -90,3 +89,4 @@ u32 TexDecoder_GetTlutHash(const u8* src, int len);
|
||||||
void TexDecoder_SetTexFmtOverlayOptions(bool enable, bool center);
|
void TexDecoder_SetTexFmtOverlayOptions(bool enable, bool center);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -218,6 +218,7 @@ void TextureMngr::ProgressiveCleanup()
|
||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::map<u32, DEPTHTARGET>::iterator itdepth = mapDepthTargets.begin();
|
std::map<u32, DEPTHTARGET>::iterator itdepth = mapDepthTargets.begin();
|
||||||
while (itdepth != mapDepthTargets.end())
|
while (itdepth != mapDepthTargets.end())
|
||||||
{
|
{
|
||||||
|
@ -274,18 +275,14 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||||
|
|
||||||
TexMode0 &tm0 = bpmem.tex[texstage > 3].texMode0[texstage & 3];
|
TexMode0 &tm0 = bpmem.tex[texstage > 3].texMode0[texstage & 3];
|
||||||
u8 *ptr = g_VideoInitialize.pGetMemoryPointer(address);
|
u8 *ptr = g_VideoInitialize.pGetMemoryPointer(address);
|
||||||
int bsw = TexDecoder_GetBlockWidthInTexels(tex_format) - 1;
|
int bs = TexDecoder_GetBlockWidthInTexels(tex_format) - 1;
|
||||||
int bsh = TexDecoder_GetBlockHeightInTexels(tex_format) - 1;
|
int expandedWidth = (width + bs) & (~bs);
|
||||||
int expandedWidth = (width + bsw) & (~bsw);
|
|
||||||
int expandedHeight = (height + bsh) & (~bsh);
|
|
||||||
|
|
||||||
u32 hash_value;
|
u32 hash_value;
|
||||||
u32 texID = address;
|
u32 texID = address;
|
||||||
u32 texHash;
|
if (g_Config.bSafeTextureCache)
|
||||||
|
|
||||||
if (g_Config.bSafeTextureCache || g_Config.bHiresTextures || g_Config.bDumpTextures)
|
|
||||||
{
|
{
|
||||||
hash_value = TexDecoder_GetSafeTextureHash(ptr, expandedWidth, expandedHeight, tex_format, 0); // remove last arg
|
hash_value = TexDecoder_GetSafeTextureHash(ptr, expandedWidth, height, tex_format, 0); // remove last arg
|
||||||
if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2))
|
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)
|
// WARNING! texID != address now => may break CopyRenderTargetToTexture (cf. TODO up)
|
||||||
|
@ -300,8 +297,6 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||||
texID ^= TexDecoder_GetTlutHash(&texMem[tlutaddr], (tex_format == GX_TF_C4) ? 32 : 128);
|
texID ^= TexDecoder_GetTlutHash(&texMem[tlutaddr], (tex_format == GX_TF_C4) ? 32 : 128);
|
||||||
//DebugLog("addr: %08x | texID: %08x | texHash: %08x", address, texID, hash_value);
|
//DebugLog("addr: %08x | texID: %08x | texHash: %08x", address, texID, hash_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
texHash = hash_value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool skip_texture_create = false;
|
bool skip_texture_create = false;
|
||||||
|
@ -345,32 +340,10 @@ 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
|
//Make an entry in the table
|
||||||
TCacheEntry& entry = textures[texID];
|
TCacheEntry& entry = textures[texID];
|
||||||
PC_TexFormat dfmt;
|
|
||||||
|
|
||||||
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.hashoffset = 0;
|
||||||
//entry.paletteHash = hashseed;
|
//entry.paletteHash = hashseed;
|
||||||
|
@ -398,11 +371,31 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||||
glBindTexture(target, entry.texture);
|
glBindTexture(target, entry.texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dfmt != PC_TEX_FMT_DXT1)
|
|
||||||
{
|
|
||||||
if (expandedWidth != width)
|
if (expandedWidth != width)
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, expandedWidth);
|
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_format;
|
||||||
int gl_iformat;
|
int gl_iformat;
|
||||||
int gl_type;
|
int gl_type;
|
||||||
|
@ -438,6 +431,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!entry.isNonPow2 && ((tm0.min_filter & 3) == 1 || (tm0.min_filter & 3) == 2))
|
if (!entry.isNonPow2 && ((tm0.min_filter & 3) == 1 || (tm0.min_filter & 3) == 2))
|
||||||
{
|
{
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
|
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
|
||||||
|
@ -448,16 +442,24 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
glTexImage2D(target, 0, gl_iformat, width, height, 0, gl_format, gl_type, temp);
|
glTexImage2D(target, 0, gl_iformat, width, height, 0, gl_format, gl_type, temp);
|
||||||
|
|
||||||
if (expandedWidth != width) // reset
|
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
|
||||||
}
|
}
|
||||||
else
|
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,
|
glCompressedTexImage2D(target, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
||||||
expandedWidth, expandedHeight, 0, expandedWidth*expandedHeight/2, temp);
|
nativeWidth, nativeHeight, 0, nativeWidth*nativeHeight/2, temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (expandedWidth != width) // reset
|
||||||
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
|
||||||
entry.frameCount = frameCount;
|
entry.frameCount = frameCount;
|
||||||
entry.w = width;
|
entry.w = width;
|
||||||
entry.h = height;
|
entry.h = height;
|
||||||
|
@ -471,7 +473,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);
|
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))
|
if (!File::Exists(szTemp))
|
||||||
{
|
{
|
||||||
SaveTexture(szTemp, target, entry.texture, expandedWidth, expandedHeight);
|
SaveTexture(szTemp, target, entry.texture, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,6 +644,7 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
|
||||||
colmat[0] = colmat[4] = colmat[8] = colmat[15] = 1;
|
colmat[0] = colmat[4] = colmat[8] = colmat[15] = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case 7: // A8
|
case 7: // A8
|
||||||
colmat[3] = colmat[7] = colmat[11] = colmat[15] = 1;
|
colmat[3] = colmat[7] = colmat[11] = colmat[15] = 1;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue