GL: Don't create a new texture every time the contents of one is updated. Probably not a noticable speed boost, but still .. it's good to be nice to GL :P
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1531 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
b5b43f9408
commit
f3eda7d85a
|
@ -142,7 +142,7 @@ void EncodeToRam(GLuint srcTexture, const TRectangle& sourceRc,
|
||||||
TextureMngr::DisableStage(i);
|
TextureMngr::DisableStage(i);
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
glViewport(0, 0, dstFmtWidth, dstHeight);
|
glViewport(0, 0, (GLsizei)dstFmtWidth, (GLsizei)dstHeight);
|
||||||
|
|
||||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||||
glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, s_rgbToYuyvProgram.glprogid);
|
glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, s_rgbToYuyvProgram.glprogid);
|
||||||
|
|
|
@ -237,6 +237,8 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||||
int bs = TexDecoder_GetBlockWidthInTexels(format) - 1;
|
int bs = TexDecoder_GetBlockWidthInTexels(format) - 1;
|
||||||
int expandedWidth = (width + bs) & (~bs);
|
int expandedWidth = (width + bs) & (~bs);
|
||||||
|
|
||||||
|
bool skip_texture_create = false;
|
||||||
|
|
||||||
if (iter != textures.end()) {
|
if (iter != textures.end()) {
|
||||||
TCacheEntry &entry = iter->second;
|
TCacheEntry &entry = iter->second;
|
||||||
|
|
||||||
|
@ -256,24 +258,21 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// can potentially do some caching
|
// Let's reload the new texture data into the same texture,
|
||||||
|
// instead of destroying it and having to create a new one.
|
||||||
//TCacheEntry &entry = entry;
|
// Might speed up movie playback very, very slightly.
|
||||||
/*if (width == entry.w && height==entry.h && format==entry.fmt)
|
if (width == entry.w && height == entry.h && format == entry.fmt)
|
||||||
{
|
{
|
||||||
LPDIRECT3DTEXTURE9 tex = entry.texture;
|
glBindTexture(entry.isNonPow2 ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D, entry.texture);
|
||||||
int bs = TexDecoder_GetBlockWidthInTexels(format)-1;
|
if (entry.mode.hex != tm0.hex)
|
||||||
int expandedWidth = (width+bs) & (~bs);
|
entry.SetTextureParameters(tm0);
|
||||||
D3DFORMAT dfmt = TexDecoder_Decode(temp,ptr,expandedWidth,height,format, tlutaddr, tlutfmt);
|
skip_texture_create = true;
|
||||||
ReplaceTexture2D(tex,temp,width,height,expandedWidth,dfmt);
|
|
||||||
dev->SetTexture(texstage, stage,tex);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{*/
|
{
|
||||||
entry.Destroy();
|
entry.Destroy();
|
||||||
textures.erase(iter);
|
textures.erase(iter);
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,12 +293,13 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||||
|
|
||||||
entry.addr = address;
|
entry.addr = address;
|
||||||
entry.isRenderTarget = false;
|
entry.isRenderTarget = false;
|
||||||
|
|
||||||
entry.isNonPow2 = ((width & (width - 1)) || (height & (height - 1)));
|
entry.isNonPow2 = ((width & (width - 1)) || (height & (height - 1)));
|
||||||
|
|
||||||
glGenTextures(1, (GLuint *)&entry.texture);
|
GLenum target = entry.isNonPow2 ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D;
|
||||||
GLenum target = entry.isNonPow2 ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D;
|
if (!skip_texture_create) {
|
||||||
glBindTexture(target, entry.texture);
|
glGenTextures(1, (GLuint *)&entry.texture);
|
||||||
|
glBindTexture(target, entry.texture);
|
||||||
|
}
|
||||||
|
|
||||||
if (expandedWidth != width)
|
if (expandedWidth != width)
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, expandedWidth);
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, expandedWidth);
|
||||||
|
|
Loading…
Reference in New Issue