# HG changeset patch # User reimar # Date 1344453482 0 # Node ID 445009e9ee8d0515157cace7ac9b942bc89d8398 # Parent 7e818f6eadd84ace91fc1104203937a78b1f78bf When the LUMINANCE16 format is less than 14 bit try to use a depth texture instead. On Intel 945 this is vastly faster (after re-enabling the Z16 support in the driver again for newer versions) due to no need for any software conversion. It also has slightly higher precision, good enough for the 14 and possibly 12 bit formats. 10 and 9 bit formats still look horrible, no idea what causes this, there is very little information on the internal precision of the hardware. It is still useful for those since swscale is faster converting 10 bit formats to 16 bit than to 8 bit. diff -r 7e818f6eadd8 -r 445009e9ee8d libvo/gl_common.c --- a/libvo/gl_common.c Wed Aug 08 05:55:05 2012 +0000 +++ b/libvo/gl_common.c Wed Aug 08 19:18:02 2012 +0000 @@ -157,6 +157,7 @@ //! \defgroup glconversion OpenGL conversion helper functions static GLint hqtexfmt; +static int use_depth_l16; /** * \brief adjusts the GL_UNPACK_ALIGNMENT to fit the stride. @@ -570,6 +571,17 @@ glAdjustAlignment(stride); mpglPixelStorei(GL_UNPACK_ROW_LENGTH, w); mpglTexImage2D(target, 0, fmt, w, h, 0, format, type, init); + if (format == GL_LUMINANCE && type == GL_UNSIGNED_SHORT) { + // ensure we get enough bits + GLint rs = 16; + glGetTexLevelParameteriv(target, 0, GL_TEXTURE_RED_SIZE, &rs); + use_depth_l16 = rs < 14; + if (use_depth_l16) { + fmt = GL_DEPTH_COMPONENT16; + format = GL_DEPTH_COMPONENT; + mpglTexImage2D(target, 0, fmt, w, h, 0, format, type, init); + } + } mpglTexParameterf(target, GL_TEXTURE_PRIORITY, 1.0); mpglTexParameteri(target, GL_TEXTURE_MIN_FILTER, filter); mpglTexParameteri(target, GL_TEXTURE_MAG_FILTER, filter); @@ -692,6 +704,8 @@ data += (h - 1) * stride; stride = -stride; } + if (use_depth_l16 && format == GL_LUMINANCE && type == GL_UNSIGNED_SHORT) + format = GL_DEPTH_COMPONENT; // this is not always correct, but should work for MPlayer glAdjustAlignment(stride); mpglPixelStorei(GL_UNPACK_ROW_LENGTH, stride / glFmt2bpp(format, type)); diff -r 7e818f6eadd8 -r 445009e9ee8d libvo/gl_common.h --- a/libvo/gl_common.h Wed Aug 08 05:55:05 2012 +0000 +++ b/libvo/gl_common.h Wed Aug 08 19:18:02 2012 +0000 @@ -272,6 +272,12 @@ #ifndef GL_DEPTH_COMPONENT #define GL_DEPTH_COMPONENT 0x1902 #endif +#ifndef GL_DEPTH_COMPONENT16 +#define GL_DEPTH_COMPONENT16 0x81A5 +#endif +#ifndef GL_TEXTURE_RED_SIZE +#define GL_TEXTURE_RED_SIZE 0x805C +#endif #ifndef GL_DEPTH_TEXTURE_MODE #define GL_DEPTH_TEXTURE_MODE 0x884B #endif