|
From: Sam S. <sam...@gm...> - 2006-04-07 21:59:00
|
Attached is a patch to twiddle textures loaded from image files,
which gives a huge increase in GL performance on the Dreamcast. I'm
using m_txrdata to point to the PVR memory (it seems to point to the
GL-formatted data on the PC side, which isn't touched from the
outside anyway), any objections to using that variable, or should I
add another one for the PVR pointer? I'll check it in if there's no
objections.
Thanks,
Sam
IIndex: texture.cpp
===================================================================
--- texture.cpp (revision 310)
+++ texture.cpp (working copy)
@@ -49,7 +49,11 @@
m_w = m_h = 0;
m_fmt = None;
if (!initial && m_txrdata && m_txrdata != oldptr)
+#if TIKI_PLAT != TIKI_DC
delete[] m_txrdata;
+#else
+ //glDeleteTexture frees the PVR memory for us, how
nice of it!
+#endif
m_txrdata = NULL;
if (!initial && m_gltxr)
glDeleteTextures(1, &m_gltxr);
@@ -178,10 +182,6 @@
memcpy(m_ptr, img->data, img->byteCount);
}
- /* We'll write the converted data into this buffer */
- if (!m_txrdata)
- m_txrdata = new uint8[img->w * img->h * 4];
-
m_w = img->w;
m_h = img->h;
m_fmt = (Fmt)(img->fmt);
@@ -204,6 +204,10 @@
glBindTexture(GL_TEXTURE_2D, m_gltxr);
#if TIKI_PLAT != TIKI_DC
+ /* We'll write the converted data into this buffer */
+ if (!m_txrdata)
+ m_txrdata = new uint8[img->w * img->h * 4];
+
convertToGl();
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
@@ -211,10 +215,13 @@
GLenum err = glGetError();
#else
+ m_txrdata = (uint8 *)pvr_mem_malloc(img->w * img->h * 2);
+ pvr_txr_load_ex(m_ptr, m_txrdata, img->w, img->h,
PVR_TXRLOAD_16BPP);
+
if(use_alpha) {
- glTexImage2D(GL_TEXTURE_2D, 0, GL_ARGB4444, m_w, m_h,
0, GL_ARGB4444, GL_UNSIGNED_BYTE, m_ptr);
+ glKosTex2D(GL_ARGB4444_TWID, m_w, m_h, m_txrdata);
} else {
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB565, m_w, m_h,
0, GL_RGB565, GL_UNSIGNED_BYTE, m_ptr);
+ glKosTex2D(GL_RGB565_TWID, m_w, m_h, m_txrdata);
}
glTexEnvi(GL_TEXTURE_2D,GL_TEXTURE_ENV_MODE,GL_MODULATEALPHA);
#endif
|