diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index 28da5362a1..74b1cae7d5 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -593,14 +593,14 @@ SDL_Surface *RageDisplay::CreateSurfaceFromPixfmt( PixelFormat pixfmt, } RageDisplay::PixelFormat RageDisplay::FindPixelFormat( - int bpp, int Rmask, int Gmask, int Bmask, int Amask ) + int bpp, int Rmask, int Gmask, int Bmask, int Amask, bool realtime ) { PixelFormatDesc tmp = { bpp, Rmask, Gmask, Bmask, Amask }; for(int pixfmt = 0; pixfmt < NUM_PIX_FORMATS; ++pixfmt) { const PixelFormatDesc *pf = GetPixelFormatDesc(PixelFormat(pixfmt)); - if(!SupportsTextureFormat( PixelFormat(pixfmt) )) + if(!SupportsTextureFormat( PixelFormat(pixfmt), realtime )) continue; if(memcmp(pf, &tmp, sizeof(tmp))) diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index ee3c1b46dd..7905cc2972 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -139,7 +139,7 @@ public: virtual void SetBlendMode( BlendMode mode ) = 0; - virtual bool SupportsTextureFormat( PixelFormat pixfmt ) = 0; + virtual bool SupportsTextureFormat( PixelFormat pixfmt, bool realtime=false ) = 0; /* This really indicates whether 4-bit palettes will actually use less memory * than 8-bit ones. Note that 4-bit palettes are uploaded as 8-bit paletted @@ -254,7 +254,7 @@ public: void ChangeCentering( int trans_x, int trans_y, float scale_x, float scale_y ); SDL_Surface *CreateSurfaceFromPixfmt( PixelFormat pixfmt, void *pixels, int width, int height, int pitch ); - PixelFormat FindPixelFormat( int bpp, int Rmask, int Gmask, int Bmask, int Amask ); + PixelFormat FindPixelFormat( int bpp, int Rmask, int Gmask, int Bmask, int Amask, bool realtime=false ); protected: RageMatrix GetPerspectiveMatrix(float fovy, float aspect, float zNear, float zFar); diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index 5bffecaeaa..d7e3793b4d 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -639,7 +639,7 @@ void RageDisplay_D3D::EndFrame() ProcessStatsOnFlip(); } -bool RageDisplay_D3D::SupportsTextureFormat( PixelFormat pixfmt ) +bool RageDisplay_D3D::SupportsTextureFormat( PixelFormat pixfmt, bool realtime ) { #if defined _XBOX // Lazy... Xbox handles paletted textures completely differently diff --git a/stepmania/src/RageDisplay_D3D.h b/stepmania/src/RageDisplay_D3D.h index fb4f683dce..e248bad236 100644 --- a/stepmania/src/RageDisplay_D3D.h +++ b/stepmania/src/RageDisplay_D3D.h @@ -31,7 +31,7 @@ public: void EndFrame(); VideoModeParams GetVideoModeParams() const; void SetBlendMode( BlendMode mode ); - bool SupportsTextureFormat( PixelFormat pixfmt ); + bool SupportsTextureFormat( PixelFormat pixfmt, bool realtime=false ); unsigned CreateTexture( PixelFormat pixfmt, SDL_Surface* img ); void UpdateTexture( unsigned uTexHandle, diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index 57e6de05a6..9dfdc401e8 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -693,20 +693,6 @@ void RageDisplay_OGL::EndFrame() ProcessStatsOnFlip(); } -bool RageDisplay_OGL::SupportsTextureFormat( PixelFormat pixfmt ) -{ - switch( pixfmt ) - { - case FMT_PAL: - return GLExt::glColorTableEXT && GLExt::glGetColorTableParameterivEXT; - case FMT_BGR8: - case FMT_A1BGR5: - return g_bGL_EXT_bgra; - default: - return true; // No way to query this in OGL. You pass it a format and hope it doesn't have to convert. - } -} - bool RageDisplay_OGL::Supports4BitPalettes() { return g_b4BitPalettesWork; @@ -1386,3 +1372,23 @@ bool RageDisplay_OGL::SupportsSurfaceFormat( PixelFormat pixfmt ) } } + +bool RageDisplay_OGL::SupportsTextureFormat( PixelFormat pixfmt, bool realtime ) +{ + /* If we support a pixfmt for texture formats but not for surface formats, then + * we'll have to convert the texture to a supported surface format before uploading. + * This is too slow for dynamic textures. */ + if( realtime && !SupportsSurfaceFormat( pixfmt ) ) + return false; + + switch( GL_PIXFMT_INFO[pixfmt].format ) + { + case GL_COLOR_INDEX: + return GLExt::glColorTableEXT && GLExt::glGetColorTableParameterivEXT; + case GL_BGR: + case GL_BGRA: + return g_bGL_EXT_bgra; + default: + return true; + } +} diff --git a/stepmania/src/RageDisplay_OGL.h b/stepmania/src/RageDisplay_OGL.h index 2f66684d23..f3979b4fe9 100644 --- a/stepmania/src/RageDisplay_OGL.h +++ b/stepmania/src/RageDisplay_OGL.h @@ -16,7 +16,7 @@ public: void EndFrame(); VideoModeParams GetVideoModeParams() const; void SetBlendMode( BlendMode mode ); - bool SupportsTextureFormat( PixelFormat pixfmt ); + bool SupportsTextureFormat( PixelFormat pixfmt, bool realtime=false ); bool Supports4BitPalettes(); unsigned CreateTexture( PixelFormat pixfmt, SDL_Surface* img ); void UpdateTexture( diff --git a/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp b/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp index 5c906f1234..47da5eead0 100644 --- a/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp +++ b/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp @@ -117,7 +117,9 @@ static int FindCompatibleAVFormat( RageDisplay::PixelFormat &pixfmt, bool HighCo fmt.masks[0], fmt.masks[1], fmt.masks[2], - fmt.masks[3] ); + fmt.masks[3], + true /* realtime */ + ); if( pixfmt == RageDisplay::NUM_PIX_FORMATS ) continue;