[MPlayer-cvslog] r35066 - in trunk/libvo: gl_common.c gl_common.h

reimar subversion at mplayerhq.hu
Wed Aug 8 21:18:02 CEST 2012


Author: reimar
Date: Wed Aug  8 21:18:02 2012
New Revision: 35066

Log:
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.

Modified:
   trunk/libvo/gl_common.c
   trunk/libvo/gl_common.h

Modified: trunk/libvo/gl_common.c
==============================================================================
--- trunk/libvo/gl_common.c	Wed Aug  8 07:55:05 2012	(r35065)
+++ trunk/libvo/gl_common.c	Wed Aug  8 21:18:02 2012	(r35066)
@@ -157,6 +157,7 @@ void (GLAPIENTRY *mpglDrawArrays)(GLenum
 //! \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 @@ void glCreateClearTex(GLenum target, GLe
   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 @@ void glUploadTex(GLenum target, GLenum f
     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));

Modified: trunk/libvo/gl_common.h
==============================================================================
--- trunk/libvo/gl_common.h	Wed Aug  8 07:55:05 2012	(r35065)
+++ trunk/libvo/gl_common.h	Wed Aug  8 21:18:02 2012	(r35066)
@@ -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


More information about the MPlayer-cvslog mailing list