[MPlayer-cvslog] r27653 - in trunk/libvo: gl_common.c gl_common.h vo_gl.c vo_gl2.c

reimar subversion at mplayerhq.hu
Sat Sep 20 19:48:01 CEST 2008


Author: reimar
Date: Sat Sep 20 19:48:01 2008
New Revision: 27653

Log:
Change glCreateClearTex to use the same host data format as later uploads.
This fixes at least some of the massive performance problems the ATI drivers have.


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

Modified: trunk/libvo/gl_common.c
==============================================================================
--- trunk/libvo/gl_common.c	(original)
+++ trunk/libvo/gl_common.c	Sat Sep 20 19:48:01 2008
@@ -349,22 +349,26 @@ static void getFunctions(void *(*getProc
  * \brief create a texture and set some defaults
  * \param target texture taget, usually GL_TEXTURE_2D
  * \param fmt internal texture format
+ * \param format texture host data format
+ * \param type texture host data type
  * \param filter filter used for scaling, e.g. GL_LINEAR
  * \param w texture width
  * \param h texture height
  * \param val luminance value to fill texture with
  * \ingroup gltexture
  */
-void glCreateClearTex(GLenum target, GLenum fmt, GLint filter,
+void glCreateClearTex(GLenum target, GLenum fmt, GLenum format, GLenum type, GLint filter,
                       int w, int h, unsigned char val) {
   GLfloat fval = (GLfloat)val / 255.0;
   GLfloat border[4] = {fval, fval, fval, fval};
-  GLenum clrfmt = (fmt == GL_ALPHA) ? GL_ALPHA : GL_LUMINANCE;
-  char *init = malloc(w * h);
-  memset(init, val, w * h);
+  int stride = w * glFmt2bpp(format, type);
+  char *init;
+  if (!stride) return;
+  init = malloc(stride * h);
+  memset(init, val, stride * h);
   glAdjustAlignment(w);
   glPixelStorei(GL_UNPACK_ROW_LENGTH, w);
-  glTexImage2D(target, 0, fmt, w, h, 0, clrfmt, GL_UNSIGNED_BYTE, init);
+  glTexImage2D(target, 0, fmt, w, h, 0, format, type, init);
   glTexParameterf(target, GL_TEXTURE_PRIORITY, 1.0);
   glTexParameteri(target, GL_TEXTURE_MIN_FILTER, filter);
   glTexParameteri(target, GL_TEXTURE_MAG_FILTER, filter);
@@ -411,6 +415,7 @@ int glCreatePPMTex(GLenum target, GLenum
                    FILE *f, int *width, int *height, int *maxval) {
   unsigned w, h, m, val, bpp;
   char *data;
+  GLenum type;
   ppm_skip(f);
   if (fgetc(f) != 'P' || fgetc(f) != '6')
     return 0;
@@ -437,8 +442,9 @@ int glCreatePPMTex(GLenum target, GLenum
     if (fmt == GL_FLOAT_RGB32_NV && target != GL_TEXTURE_RECTANGLE)
       fmt = GL_RGB16;
   }
-  glCreateClearTex(target, fmt, filter, w, h, 0);
-  glUploadTex(target, GL_RGB, (m > 255) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE,
+  type = m > 255 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE;
+  glCreateClearTex(target, fmt, GL_RGB, type, filter, w, h, 0);
+  glUploadTex(target, GL_RGB, type,
               data, w * bpp, 0, 0, w, h, 0);
   free(data);
   if (width) *width = w;
@@ -980,7 +986,7 @@ static void create_conv_textures(gl_conv
       gen_gamma_map(lookup_data, LOOKUP_RES, params->rgamma);
       gen_gamma_map(&lookup_data[LOOKUP_RES], LOOKUP_RES, params->ggamma);
       gen_gamma_map(&lookup_data[2 * LOOKUP_RES], LOOKUP_RES, params->bgamma);
-      glCreateClearTex(GL_TEXTURE_2D, GL_LUMINANCE8, GL_LINEAR,
+      glCreateClearTex(GL_TEXTURE_2D, GL_LUMINANCE8, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_LINEAR,
                        LOOKUP_RES, 4, 0);
       glUploadTex(GL_TEXTURE_2D, GL_LUMINANCE, GL_UNSIGNED_BYTE, lookup_data,
                   LOOKUP_RES, 0, 0, LOOKUP_RES, 4, 0);

Modified: trunk/libvo/gl_common.h
==============================================================================
--- trunk/libvo/gl_common.h	(original)
+++ trunk/libvo/gl_common.h	Sat Sep 20 19:48:01 2008
@@ -210,7 +210,7 @@ const char *glValName(GLint value);
 int glFindFormat(uint32_t format, int *bpp, GLint *gl_texfmt,
                   GLenum *gl_format, GLenum *gl_type);
 int glFmt2bpp(GLenum format, GLenum type);
-void glCreateClearTex(GLenum target, GLenum fmt, GLint filter,
+void glCreateClearTex(GLenum target, GLenum fmt, GLenum format, GLenum type, GLint filter,
                       int w, int h, unsigned char val);
 int glCreatePPMTex(GLenum target, GLenum fmt, GLint filter,
                    FILE *f, int *width, int *height, int *maxval);

Modified: trunk/libvo/vo_gl.c
==============================================================================
--- trunk/libvo/vo_gl.c	(original)
+++ trunk/libvo/vo_gl.c	Sat Sep 20 19:48:01 2008
@@ -281,9 +281,9 @@ static void genEOSD(mp_eosd_images_t *im
   if (!largeeosdtex[0]) {
     glGenTextures(2, largeeosdtex);
     BindTexture(gl_target, largeeosdtex[0]);
-    glCreateClearTex(gl_target, GL_ALPHA, scale_type, 512, 512, 0);
+    glCreateClearTex(gl_target, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, scale_type, 512, 512, 0);
     BindTexture(gl_target, largeeosdtex[1]);
-    glCreateClearTex(gl_target, GL_ALPHA, scale_type, 512, 512, 0);
+    glCreateClearTex(gl_target, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, scale_type, 512, 512, 0);
   }
   for (i = img; i; i = i->next)
   {
@@ -322,7 +322,7 @@ static void genEOSD(mp_eosd_images_t *im
     } else {
       texSize(i->w, i->h, &sx, &sy);
       BindTexture(gl_target, *curtex++);
-      glCreateClearTex(gl_target, GL_ALPHA, scale_type, sx, sy, 0);
+      glCreateClearTex(gl_target, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, scale_type, sx, sy, 0);
     }
     glUploadTex(gl_target, GL_ALPHA, GL_UNSIGNED_BYTE, i->bitmap, i->stride,
                 x, y, i->w, i->h, 0);
@@ -412,10 +412,10 @@ static int initGl(uint32_t d_width, uint
       BindTexture(GL_TEXTURE_3D, default_texs[i + 14]);
     }
     ActiveTexture(GL_TEXTURE1);
-    glCreateClearTex(gl_target, gl_texfmt, GL_LINEAR,
+    glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, GL_LINEAR,
                      texture_width / 2, texture_height / 2, 128);
     ActiveTexture(GL_TEXTURE2);
-    glCreateClearTex(gl_target, gl_texfmt, GL_LINEAR,
+    glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, GL_LINEAR,
                      texture_width / 2, texture_height / 2, 128);
     switch (use_yuv) {
       case YUV_CONVERSION_FRAGMENT_LOOKUP:
@@ -433,7 +433,7 @@ static int initGl(uint32_t d_width, uint
     BindTexture(gl_target, 0);
     update_yuvconv();
   }
-  glCreateClearTex(gl_target, gl_texfmt, GL_LINEAR,
+  glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, GL_LINEAR,
                    texture_width, texture_height, 0);
 
   resize(d_width, d_height);
@@ -537,14 +537,14 @@ static void create_osd_texture(int x0, i
   // create Textures for OSD part
   glGenTextures(1, &osdtex[osdtexCnt]);
   BindTexture(gl_target, osdtex[osdtexCnt]);
-  glCreateClearTex(gl_target, GL_LUMINANCE, scale_type, sx, sy, 0);
+  glCreateClearTex(gl_target, GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, scale_type, sx, sy, 0);
   glUploadTex(gl_target, GL_LUMINANCE, GL_UNSIGNED_BYTE, src, stride,
               0, 0, w, h, 0);
 
 #ifndef FAST_OSD
   glGenTextures(1, &osdatex[osdtexCnt]);
   BindTexture(gl_target, osdatex[osdtexCnt]);
-  glCreateClearTex(gl_target, GL_ALPHA, scale_type, sx, sy, 255);
+  glCreateClearTex(gl_target, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, scale_type, sx, sy, 255);
   {
   int i;
   char *tmp = malloc(stride * h);

Modified: trunk/libvo/vo_gl2.c
==============================================================================
--- trunk/libvo/vo_gl2.c	(original)
+++ trunk/libvo/vo_gl2.c	Sat Sep 20 19:48:01 2008
@@ -256,16 +256,16 @@ static int initTextures(void)
         ActiveTexture(GL_TEXTURE0);
       }
 
-      glCreateClearTex(GL_TEXTURE_2D, gl_internal_format, GL_LINEAR,
+      glCreateClearTex(GL_TEXTURE_2D, gl_internal_format, gl_bitmap_format,  gl_bitmap_type, GL_LINEAR,
                        texture_width, texture_height, 0);
 
       glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
       if (image_format == IMGFMT_YV12) {
         ActiveTexture(GL_TEXTURE1);
-        glCreateClearTex(GL_TEXTURE_2D, gl_internal_format, GL_LINEAR,
+        glCreateClearTex(GL_TEXTURE_2D, gl_internal_format, gl_bitmap_format,  gl_bitmap_type, GL_LINEAR,
                          texture_width / 2, texture_height / 2, 128);
         ActiveTexture(GL_TEXTURE2);
-        glCreateClearTex(GL_TEXTURE_2D, gl_internal_format, GL_LINEAR,
+        glCreateClearTex(GL_TEXTURE_2D, gl_internal_format, gl_bitmap_format,  gl_bitmap_type, GL_LINEAR,
                          texture_width / 2, texture_height / 2, 128);
         ActiveTexture(GL_TEXTURE0);
       }



More information about the MPlayer-cvslog mailing list