From 123cd35e17a456bbce21858ea0f78c2608ef83a6 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 11 Mar 2003 18:27:10 +0000 Subject: [PATCH] Small movie texture optimization: honor the texture color depth. Another biggie is that we're copying every frame an extra time in MovieTexture_DShow::NewData(). This is rather hard to fix without bringing back the stability problems we had before; I need to think about how to do this. (Commenting out this memcpy boosts my test video to about 22fps, so this isn't minor.) --- .../arch/MovieTexture/MovieTexture_DShow.cpp | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/stepmania/src/arch/MovieTexture/MovieTexture_DShow.cpp b/stepmania/src/arch/MovieTexture/MovieTexture_DShow.cpp index 2f170eee52..e3de4240b3 100644 --- a/stepmania/src/arch/MovieTexture/MovieTexture_DShow.cpp +++ b/stepmania/src/arch/MovieTexture/MovieTexture_DShow.cpp @@ -23,6 +23,9 @@ #include "MovieTexture_DShowHelper.h" #include "MovieTexture_DShow.h" +/* for TEXTUREMAN->GetTextureColorDepth() */ +#include "RageTextureManager.h" + #include "RageUtil.h" #include "RageLog.h" #include "RageException.h" @@ -233,7 +236,23 @@ void MovieTexture_DShow::CreateTexture() /* Initialize the texture and set it to black. */ string buf(m_iTextureWidth*m_iTextureHeight*3, 0); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, + + /* My test clip (a high-res, MPEG1 video) goes from 12 fps to 14 fps + * if I use a 16-bit internalformat instead of a 32-bit one; that's a + * 16% jump, which is significant. (Simply decoding this video is probably + * taking 30-40% CPU.) It means much less bus traffic (sending textures to + * the card is slow). + * + * So, it *might* make sense to make this separately configurable. However, + * that's getting pretty detailed; well beyond what most users will tweak. + * Some way to figure this out dynamically would be nice, but it's probably + * impossible. (For example, 24-bit textures may even be cheaper on pure + * AGP cards; 16-bit requires a conversion.) */ + int internalformat = GL_RGB8; + if(TEXTUREMAN->GetTextureColorDepth() == 16) + internalformat = GL_RGB5; + + glTexImage2D(GL_TEXTURE_2D, 0, internalformat, m_iTextureWidth, m_iTextureHeight, 0, GL_BGR, GL_UNSIGNED_BYTE, buf.data()); }