From 114152e068ec919feb0a57a1259c2ada970b9f02 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 12 Mar 2009 15:01:16 +0100 Subject: mesa: add support for ATI_envmap_bumpmap add new entrypoints, new texture format, etc translate in texenvprogram.c for drivers using the mesa-generated tex env fragment program also handled in swrast, but not tested (cannot work due to negative texel results not handled correctly) --- src/mesa/main/image.c | 153 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 150 insertions(+), 3 deletions(-) (limited to 'src/mesa/main/image.c') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 4d86c54777..ed0811660d 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -293,6 +293,8 @@ _mesa_components_in_format( GLenum format ) return 2; case GL_DEPTH_STENCIL_EXT: return 2; + case GL_DUDV_ATI: + return 2; default: return -1; } @@ -503,6 +505,20 @@ _mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type ) return GL_TRUE; else return GL_FALSE; + case GL_DUDV_ATI: + case GL_DU8DV8_ATI: + switch (type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + return GL_TRUE; + default: + return GL_FALSE; + } default: ; /* fall-through */ } @@ -1674,8 +1690,19 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4], GLfloat luminance[MAX_WIDTH]; const GLint comps = _mesa_components_in_format(dstFormat); GLuint i; - - if (dstType != GL_FLOAT || ctx->Color.ClampReadColor == GL_TRUE) { + /* clamping only applies to colors, not the dudv values, but still need + it if converting to unsigned values (which doesn't make much sense) */ + if (dstFormat == GL_DUDV_ATI || dstFormat == GL_DU8DV8_ATI) { + switch (dstType) { + case GL_UNSIGNED_BYTE: + case GL_UNSIGNED_SHORT: + case GL_UNSIGNED_INT: + transferOps |= IMAGE_CLAMP_BIT; + break; + /* actually might want clamp to [-1,1] otherwise but shouldn't matter? */ + } + } + else if (dstType != GL_FLOAT || ctx->Color.ClampReadColor == GL_TRUE) { /* need to clamp to [0, 1] */ transferOps |= IMAGE_CLAMP_BIT; } @@ -1774,6 +1801,13 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4], dst[i*4+3] = FLOAT_TO_UBYTE(rgba[i][RCOMP]); } break; + case GL_DUDV_ATI: + case GL_DU8DV8_ATI: + for (i=0;i 0); + + /* + * Extract image data and convert to RGBA floats + */ + assert(n <= MAX_WIDTH); + extract_float_rgba(n, rgba, srcFormat, srcType, source, + srcPacking->SwapBytes); + + + /* Now determine which color channels we need to produce. + * And determine the dest index (offset) within each color tuple. + */ + + /* Now pack results in the requested dstFormat */ + GLbyte *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + /* not sure - need clamp[-1,1] here? */ + dst[0] = FLOAT_TO_BYTE(rgba[i][RCOMP]); + dst[1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); + dst += dstComponents; + } + } +} /* * Unpack a row of color index data from a client buffer according to -- cgit v1.2.3 From 47053782b8e82f447d7d2fb590da9cced2926021 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 12 Mar 2009 16:13:44 -0600 Subject: mesa: move declarations before code --- src/mesa/main/image.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa/main/image.c') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index ed0811660d..5c5f9f6028 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -3996,6 +3996,8 @@ _mesa_unpack_dudv_span_byte( GLcontext *ctx, { GLint dstComponents; GLfloat rgba[MAX_WIDTH][4]; + GLbyte *dst = dest; + GLuint i; dstComponents = _mesa_components_in_format( dstFormat ); /* source & dest image formats should have been error checked by now */ @@ -4014,8 +4016,6 @@ _mesa_unpack_dudv_span_byte( GLcontext *ctx, */ /* Now pack results in the requested dstFormat */ - GLbyte *dst = dest; - GLuint i; for (i = 0; i < n; i++) { /* not sure - need clamp[-1,1] here? */ dst[0] = FLOAT_TO_BYTE(rgba[i][RCOMP]); -- cgit v1.2.3 From f786e46cf4fbf50a1cacfb81e22ee155ffe6edd3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 12 Mar 2009 19:42:14 -0600 Subject: mesa: added GL_DU8DV8_ATI case in _mesa_components_in_format() This gets hit when glTexSubImage2D() is called with format==GL_DU8DV8_ATI. --- src/mesa/main/image.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/mesa/main/image.c') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 5c5f9f6028..804e840820 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -294,6 +294,7 @@ _mesa_components_in_format( GLenum format ) case GL_DEPTH_STENCIL_EXT: return 2; case GL_DUDV_ATI: + case GL_DU8DV8_ATI: return 2; default: return -1; -- cgit v1.2.3 From a577471c546732419908893b481948feac5b7241 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 18 Mar 2009 15:39:11 -0600 Subject: mesa: use the IROUND() macro in pixel packing code It turns out some tests are sensitive to rounding vs. truncating when converting float color values to integers in glReadPixels(). In particular, this matters when the destination format is 5/6/5 or 4/4/4/4, etc. --- src/mesa/main/image.c | 216 +++++++++++++++++++++++++------------------------- 1 file changed, 108 insertions(+), 108 deletions(-) (limited to 'src/mesa/main/image.c') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 804e840820..fa3149d56d 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -2378,9 +2378,9 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4], if (dstFormat == GL_RGB) { GLubyte *dst = (GLubyte *) dstAddr; for (i=0;i