More work and optimization. Still not quite there.

This commit is contained in:
Henrik Rydgard committed 2012-12-21 21:49:09 +01:00
1 parent 3b114eb24a
commit d663e28bde
12 files changed
+250 -56

No files matched your search

+18 -20
View File
@@ -597,17 +597,16 @@ void convertColors(u8 *finalBuf, GLuint dstFmt, int numPixels)
void PSPSetTexture()
{
static int lastBoundTexture = -1;
u32 texaddr = (gstate.texaddr[0] & 0xFFFFF0) | ((gstate.texbufwidth[0]<<8) & 0xFF000000);
texaddr &= 0xFFFFFFF;
if (!texaddr) return;
u8 level = 0;
u32 format = gstate.texformat & 0xF;
u32 clutformat = gstate.clutformat & 3;
u32 clutaddr = GetClutAddr(clutformat == GE_CMODE_32BIT_ABGR8888 ? 4 : 2);
DEBUG_LOG(G3D,"Texture at %08x",texaddr);
u8 *texptr = Memory::GetPointer(texaddr);
u32 texhash = texptr ? *(u32*)texptr : 0;
@@ -636,8 +635,11 @@ void PSPSetTexture()
if (match) {
//got one!
entry.frameCounter = gpuStats.numFrames;
glBindTexture(GL_TEXTURE_2D, entry.texture);
UpdateSamplingParams();
if (entry.texture != lastBoundTexture) {
glBindTexture(GL_TEXTURE_2D, entry.texture);
UpdateSamplingParams();
lastBoundTexture = entry.texture;
}
DEBUG_LOG(G3D, "Texture at %08x Found in Cache, applying", texaddr);
return; //Done!
} else {
@@ -653,7 +655,7 @@ void PSPSetTexture()
//we have to decode it
TexCacheEntry entry;
TexCacheEntry entry = {0};
entry.addr = texaddr;
entry.hash = texhash;
@@ -671,9 +673,6 @@ void PSPSetTexture()
entry.clutaddr = 0;
}
glGenTextures(1, &entry.texture);
glBindTexture(GL_TEXTURE_2D, entry.texture);
int bufw = gstate.texbufwidth[0] & 0x3ff;
entry.dim = gstate.texsize[0] & 0xF0F;
@@ -681,8 +680,6 @@ void PSPSetTexture()
int w = 1 << (gstate.texsize[0] & 0xf);
int h = 1 << ((gstate.texsize[0]>>8) & 0xf);
INFO_LOG(G3D, "Creating texture %i from %08x: %i x %i (stride: %i). fmt: %i", entry.texture, entry.addr, w, h, bufw, entry.format);
gstate_c.curTextureWidth=w;
gstate_c.curTextureHeight=h;
GLenum dstFmt = 0;
@@ -932,26 +929,27 @@ void PSPSetTexture()
}
}
gpuStats.numTexturesDecoded++;
// Can restore these and remove the above fixup on some platforms.
//glPixelStorei(GL_UNPACK_ROW_LENGTH, bufw);
glPixelStorei(GL_UNPACK_ALIGNMENT, texByteAlign);
//glPixelStorei(GL_UNPACK_ALIGNMENT, texByteAlign);
//glPixelStorei(GL_PACK_ROW_LENGTH, bufw);
glPixelStorei(GL_PACK_ALIGNMENT, texByteAlign);
//glPixelStorei(GL_PACK_ALIGNMENT, texByteAlign);
INFO_LOG(G3D, "Creating texture %i from %08x: %i x %i (stride: %i). fmt: %i", entry.texture, entry.addr, w, h, bufw, entry.format);
glGenTextures(1, &entry.texture);
glBindTexture(GL_TEXTURE_2D, entry.texture);
lastBoundTexture = entry.texture;
GLuint components = dstFmt == GL_UNSIGNED_SHORT_5_6_5 ? GL_RGB : GL_RGBA;
glTexImage2D(GL_TEXTURE_2D, 0, components, w, h, 0, components, dstFmt, finalBuf);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// glGenerateMipmap(GL_TEXTURE_2D);
UpdateSamplingParams();
//glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
//glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
//glPixelStorei(GL_PACK_ROW_LENGTH, 0);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
//glPixelStorei(GL_PACK_ALIGNMENT, 1);
cache[cachekey] = entry;
}