diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2008-09-20 17:48:01 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2008-09-20 17:48:01 +0000 |
commit | 0e99017da985eff9bf9b996ae1268794e6dfa770 (patch) | |
tree | 71259826b0349aae4ee31b6fd5670bee28f45c7a /libvo/gl_common.c | |
parent | 2d4476731cfcc01df399835bd0c96864550ac009 (diff) | |
download | mpv-0e99017da985eff9bf9b996ae1268794e6dfa770.tar.bz2 mpv-0e99017da985eff9bf9b996ae1268794e6dfa770.tar.xz |
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.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27653 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo/gl_common.c')
-rw-r--r-- | libvo/gl_common.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/libvo/gl_common.c b/libvo/gl_common.c index a52a605234..e191f7e6ad 100644 --- a/libvo/gl_common.c +++ b/libvo/gl_common.c @@ -349,22 +349,26 @@ static void getFunctions(void *(*getProcAddress)(const GLubyte *), * \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 fmt, GLint filter, 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 fmt, GLint filter, 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_conversion_params_t *params, int *texu, char 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); |