Mercurial > mplayer.hg
changeset 34972:445009e9ee8d
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.
author | reimar |
---|---|
date | Wed, 08 Aug 2012 19:18:02 +0000 |
parents | 7e818f6eadd8 |
children | 7a51bcd28fd1 |
files | libvo/gl_common.c libvo/gl_common.h |
diffstat | 2 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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));
--- 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