From c1a544733749cd388b9f51d087c695b2ce0ec729 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 12 Mar 2007 09:35:44 -0600 Subject: take GL_UNPACK_ALIGNMENT into account in _mesa_image_row_stride() for GL_BITMAP type (bug 10261) --- src/mesa/main/image.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index eb91ebb611..58dd771484 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -667,7 +667,7 @@ _mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, ASSERT(packing); if (type == GL_BITMAP) { /* BITMAP data */ - GLint bytes; + GLint bytes, remainder; if (packing->RowLength == 0) { bytes = (width + 7) / 8; } @@ -678,6 +678,11 @@ _mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, /* negate the bytes per row (negative row stride) */ bytes = -bytes; } + + remainder = bytes % packing->Alignment; + if (remainder > 0) + bytes += (packing->Alignment - remainder); + return bytes; } else { -- cgit v1.2.3 From 17fb7821d7cdc0ed211eaef013ee7798619a61d3 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 12 Mar 2007 09:49:44 -0600 Subject: clean-up, simplify _mesa_image_row_stride() --- src/mesa/main/image.c | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 58dd771484..7c0b63b173 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -651,44 +651,34 @@ _mesa_image_address3d( const struct gl_pixelstore_attrib *packing, /** - * Compute the stride between image rows. + * Compute the stride (in bytes) between image rows. * * \param packing the pixelstore attributes * \param width image width. * \param format pixel format. * \param type pixel data type. * - * \return the stride in bytes for the given parameters. + * \return the stride in bytes for the given parameters, or -1 if error */ GLint _mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, GLint width, GLenum format, GLenum type ) { + GLint bytesPerRow, remainder; + ASSERT(packing); + if (type == GL_BITMAP) { - /* BITMAP data */ - GLint bytes, remainder; if (packing->RowLength == 0) { - bytes = (width + 7) / 8; + bytesPerRow = (width + 7) / 8; } else { - bytes = (packing->RowLength + 7) / 8; - } - if (packing->Invert) { - /* negate the bytes per row (negative row stride) */ - bytes = -bytes; + bytesPerRow = (packing->RowLength + 7) / 8; } - - remainder = bytes % packing->Alignment; - if (remainder > 0) - bytes += (packing->Alignment - remainder); - - return bytes; } else { /* Non-BITMAP data */ const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); - GLint bytesPerRow, remainder; if (bytesPerPixel <= 0) return -1; /* error */ if (packing->RowLength == 0) { @@ -697,13 +687,19 @@ _mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, else { bytesPerRow = bytesPerPixel * packing->RowLength; } - remainder = bytesPerRow % packing->Alignment; - if (remainder > 0) - bytesPerRow += (packing->Alignment - remainder); - if (packing->Invert) - bytesPerRow = -bytesPerRow; - return bytesPerRow; } + + remainder = bytesPerRow % packing->Alignment; + if (remainder > 0) { + bytesPerRow += (packing->Alignment - remainder); + } + + if (packing->Invert) { + /* negate the bytes per row (negative row stride) */ + bytesPerRow = -bytesPerRow; + } + + return bytesPerRow; } -- cgit v1.2.3 From 53f83b435ce9a94092503712e3d4e16d4c942752 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Tue, 13 Mar 2007 13:39:34 +0800 Subject: mesa: _mesa_unpack_image 1. take packed pixel data as a component 2. fix for GL_BITMAP when compiling glTexImage, etc into a display list: a. flip byte if lsbFirst is true since DefaultPacking->lsbFirst is false. b. handle SkipPixels --- src/mesa/main/image.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 3 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 7c0b63b173..a60f4d3f4d 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -59,6 +59,34 @@ #define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 ) +/** + * \return GL_TRUE if type is packed pixel type, GL_FALSE otherwise. + */ +static GLboolean +_mesa_type_is_packed(GLenum type) + { + switch (type) { + case GL_UNSIGNED_BYTE_3_3_2: + case GL_UNSIGNED_BYTE_2_3_3_REV: + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_5_6_5_REV: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + case GL_UNSIGNED_INT_10_10_10_2: + case GL_UNSIGNED_INT_2_10_10_10_REV: + case GL_UNSIGNED_SHORT_8_8_MESA: + case GL_UNSIGNED_SHORT_8_8_REV_MESA: + case GL_UNSIGNED_INT_24_8_EXT: + return GL_TRUE; + } + + return GL_FALSE; +} + /** * Flip the 8 bits in each byte of the given array. * @@ -4187,14 +4215,18 @@ _mesa_unpack_image( GLuint dimensions, if (type == GL_BITMAP) { bytesPerRow = (width + 7) >> 3; - flipBytes = !unpack->LsbFirst; + flipBytes = unpack->LsbFirst; swap2 = swap4 = GL_FALSE; compsPerRow = 0; } else { const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); - const GLint components = _mesa_components_in_format(format); + GLint components = _mesa_components_in_format(format); GLint bytesPerComp; + + if (_mesa_type_is_packed(type)) + components = 1; + if (bytesPerPixel <= 0 || components <= 0) return NULL; /* bad format or type. generate error later */ bytesPerRow = bytesPerPixel * width; @@ -4219,7 +4251,61 @@ _mesa_unpack_image( GLuint dimensions, for (row = 0; row < height; row++) { const GLvoid *src = _mesa_image_address(dimensions, unpack, pixels, width, height, format, type, img, row, 0); - _mesa_memcpy(dst, src, bytesPerRow); + + if ((type == GL_BITMAP) && (unpack->SkipPixels & 0x7)) { + GLint i; + flipBytes = GL_FALSE; + if (unpack->LsbFirst) { + GLubyte srcMask = 1 << (unpack->SkipPixels & 0x7); + GLubyte dstMask = 128; + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 128) { + srcMask = 1; + s++; + } else { + srcMask = srcMask << 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } else { + dstMask = dstMask >> 1; + } + } + } else { + GLubyte srcMask = 128 >> (unpack->SkipPixels & 0x7); + GLubyte dstMask = 128; + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 1) { + srcMask = 128; + s++; + } else { + srcMask = srcMask >> 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } else { + dstMask = dstMask >> 1; + } + } + } + } else + _mesa_memcpy(dst, src, bytesPerRow); /* byte flipping/swapping */ if (flipBytes) { flip_bytes((GLubyte *) dst, bytesPerRow); -- cgit v1.2.3 From b6adf336f41d2f0ed0ea33eaf53faee9635a2405 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 14 Mar 2007 14:33:46 -0600 Subject: Re-org of gl_pixel_attrib struct. Reorder fields according to the order in which the pixel transfer operations take place. Improve comments. Move the pixel maps out of gl_pixel_attrib since they're not supposed to be pushed/popped by glPush/PopAttrib. New gl_pixelmap and gl_pixelmaps structs to contain the pixelmaps. --- src/mesa/main/get.c | 60 ++++++------- src/mesa/main/get_gen.py | 20 ++--- src/mesa/main/image.c | 12 +-- src/mesa/main/mtypes.h | 121 ++++++++++++++++---------- src/mesa/main/pixel.c | 218 +++++++++++++++++++++++------------------------ 5 files changed, 228 insertions(+), 203 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 9b2a42f7c1..7601f32069 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -677,34 +677,34 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) params[0] = ENUM_TO_BOOLEAN(ctx->Hint.PerspectiveCorrection); break; case GL_PIXEL_MAP_A_TO_A_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapAtoAsize); + params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.AtoA.Size); break; case GL_PIXEL_MAP_B_TO_B_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapBtoBsize); + params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.BtoB.Size); break; case GL_PIXEL_MAP_G_TO_G_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapGtoGsize); + params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.GtoG.Size); break; case GL_PIXEL_MAP_I_TO_A_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapItoAsize); + params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.ItoA.Size); break; case GL_PIXEL_MAP_I_TO_B_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapItoBsize); + params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.ItoB.Size); break; case GL_PIXEL_MAP_I_TO_G_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapItoGsize); + params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.ItoG.Size); break; case GL_PIXEL_MAP_I_TO_I_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapItoIsize); + params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.ItoI.Size); break; case GL_PIXEL_MAP_I_TO_R_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapItoRsize); + params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.ItoR.Size); break; case GL_PIXEL_MAP_R_TO_R_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapRtoRsize); + params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.RtoR.Size); break; case GL_PIXEL_MAP_S_TO_S_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapStoSsize); + params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.StoS.Size); break; case GL_POINT_SIZE: params[0] = FLOAT_TO_BOOLEAN(ctx->Point.Size); @@ -2504,34 +2504,34 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) params[0] = ENUM_TO_FLOAT(ctx->Hint.PerspectiveCorrection); break; case GL_PIXEL_MAP_A_TO_A_SIZE: - params[0] = (GLfloat)(ctx->Pixel.MapAtoAsize); + params[0] = (GLfloat)(ctx->PixelMaps.AtoA.Size); break; case GL_PIXEL_MAP_B_TO_B_SIZE: - params[0] = (GLfloat)(ctx->Pixel.MapBtoBsize); + params[0] = (GLfloat)(ctx->PixelMaps.BtoB.Size); break; case GL_PIXEL_MAP_G_TO_G_SIZE: - params[0] = (GLfloat)(ctx->Pixel.MapGtoGsize); + params[0] = (GLfloat)(ctx->PixelMaps.GtoG.Size); break; case GL_PIXEL_MAP_I_TO_A_SIZE: - params[0] = (GLfloat)(ctx->Pixel.MapItoAsize); + params[0] = (GLfloat)(ctx->PixelMaps.ItoA.Size); break; case GL_PIXEL_MAP_I_TO_B_SIZE: - params[0] = (GLfloat)(ctx->Pixel.MapItoBsize); + params[0] = (GLfloat)(ctx->PixelMaps.ItoB.Size); break; case GL_PIXEL_MAP_I_TO_G_SIZE: - params[0] = (GLfloat)(ctx->Pixel.MapItoGsize); + params[0] = (GLfloat)(ctx->PixelMaps.ItoG.Size); break; case GL_PIXEL_MAP_I_TO_I_SIZE: - params[0] = (GLfloat)(ctx->Pixel.MapItoIsize); + params[0] = (GLfloat)(ctx->PixelMaps.ItoI.Size); break; case GL_PIXEL_MAP_I_TO_R_SIZE: - params[0] = (GLfloat)(ctx->Pixel.MapItoRsize); + params[0] = (GLfloat)(ctx->PixelMaps.ItoR.Size); break; case GL_PIXEL_MAP_R_TO_R_SIZE: - params[0] = (GLfloat)(ctx->Pixel.MapRtoRsize); + params[0] = (GLfloat)(ctx->PixelMaps.RtoR.Size); break; case GL_PIXEL_MAP_S_TO_S_SIZE: - params[0] = (GLfloat)(ctx->Pixel.MapStoSsize); + params[0] = (GLfloat)(ctx->PixelMaps.StoS.Size); break; case GL_POINT_SIZE: params[0] = ctx->Point.Size; @@ -4331,34 +4331,34 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) params[0] = ENUM_TO_INT(ctx->Hint.PerspectiveCorrection); break; case GL_PIXEL_MAP_A_TO_A_SIZE: - params[0] = ctx->Pixel.MapAtoAsize; + params[0] = ctx->PixelMaps.AtoA.Size; break; case GL_PIXEL_MAP_B_TO_B_SIZE: - params[0] = ctx->Pixel.MapBtoBsize; + params[0] = ctx->PixelMaps.BtoB.Size; break; case GL_PIXEL_MAP_G_TO_G_SIZE: - params[0] = ctx->Pixel.MapGtoGsize; + params[0] = ctx->PixelMaps.GtoG.Size; break; case GL_PIXEL_MAP_I_TO_A_SIZE: - params[0] = ctx->Pixel.MapItoAsize; + params[0] = ctx->PixelMaps.ItoA.Size; break; case GL_PIXEL_MAP_I_TO_B_SIZE: - params[0] = ctx->Pixel.MapItoBsize; + params[0] = ctx->PixelMaps.ItoB.Size; break; case GL_PIXEL_MAP_I_TO_G_SIZE: - params[0] = ctx->Pixel.MapItoGsize; + params[0] = ctx->PixelMaps.ItoG.Size; break; case GL_PIXEL_MAP_I_TO_I_SIZE: - params[0] = ctx->Pixel.MapItoIsize; + params[0] = ctx->PixelMaps.ItoI.Size; break; case GL_PIXEL_MAP_I_TO_R_SIZE: - params[0] = ctx->Pixel.MapItoRsize; + params[0] = ctx->PixelMaps.ItoR.Size; break; case GL_PIXEL_MAP_R_TO_R_SIZE: - params[0] = ctx->Pixel.MapRtoRsize; + params[0] = ctx->PixelMaps.RtoR.Size; break; case GL_PIXEL_MAP_S_TO_S_SIZE: - params[0] = ctx->Pixel.MapStoSsize; + params[0] = ctx->PixelMaps.StoS.Size; break; case GL_POINT_SIZE: params[0] = IROUND(ctx->Point.Size); diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index c18216d4a8..76417d2899 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -337,16 +337,16 @@ StateVars = [ ( "GL_PACK_INVERT_MESA", GLboolean, ["ctx->Pack.Invert"], "", None ), ( "GL_PERSPECTIVE_CORRECTION_HINT", GLenum, ["ctx->Hint.PerspectiveCorrection"], "", None ), - ( "GL_PIXEL_MAP_A_TO_A_SIZE", GLint, ["ctx->Pixel.MapAtoAsize"], "", None ), - ( "GL_PIXEL_MAP_B_TO_B_SIZE", GLint, ["ctx->Pixel.MapBtoBsize"], "", None ), - ( "GL_PIXEL_MAP_G_TO_G_SIZE", GLint, ["ctx->Pixel.MapGtoGsize"], "", None ), - ( "GL_PIXEL_MAP_I_TO_A_SIZE", GLint, ["ctx->Pixel.MapItoAsize"], "", None ), - ( "GL_PIXEL_MAP_I_TO_B_SIZE", GLint, ["ctx->Pixel.MapItoBsize"], "", None ), - ( "GL_PIXEL_MAP_I_TO_G_SIZE", GLint, ["ctx->Pixel.MapItoGsize"], "", None ), - ( "GL_PIXEL_MAP_I_TO_I_SIZE", GLint, ["ctx->Pixel.MapItoIsize"], "", None ), - ( "GL_PIXEL_MAP_I_TO_R_SIZE", GLint, ["ctx->Pixel.MapItoRsize"], "", None ), - ( "GL_PIXEL_MAP_R_TO_R_SIZE", GLint, ["ctx->Pixel.MapRtoRsize"], "", None ), - ( "GL_PIXEL_MAP_S_TO_S_SIZE", GLint, ["ctx->Pixel.MapStoSsize"], "", None ), + ( "GL_PIXEL_MAP_A_TO_A_SIZE", GLint, ["ctx->PixelMaps.AtoA.Size"], "", None ), + ( "GL_PIXEL_MAP_B_TO_B_SIZE", GLint, ["ctx->PixelMaps.BtoB.Size"], "", None ), + ( "GL_PIXEL_MAP_G_TO_G_SIZE", GLint, ["ctx->PixelMaps.GtoG.Size"], "", None ), + ( "GL_PIXEL_MAP_I_TO_A_SIZE", GLint, ["ctx->PixelMaps.ItoA.Size"], "", None ), + ( "GL_PIXEL_MAP_I_TO_B_SIZE", GLint, ["ctx->PixelMaps.ItoB.Size"], "", None ), + ( "GL_PIXEL_MAP_I_TO_G_SIZE", GLint, ["ctx->PixelMaps.ItoG.Size"], "", None ), + ( "GL_PIXEL_MAP_I_TO_I_SIZE", GLint, ["ctx->PixelMaps.ItoI.Size"], "", None ), + ( "GL_PIXEL_MAP_I_TO_R_SIZE", GLint, ["ctx->PixelMaps.ItoR.Size"], "", None ), + ( "GL_PIXEL_MAP_R_TO_R_SIZE", GLint, ["ctx->PixelMaps.RtoR.Size"], "", None ), + ( "GL_PIXEL_MAP_S_TO_S_SIZE", GLint, ["ctx->PixelMaps.StoS.Size"], "", None ), ( "GL_POINT_SIZE", GLfloat, ["ctx->Point.Size"], "", None ), ( "GL_POINT_SIZE_GRANULARITY", GLfloat, ["ctx->Const.PointSizeGranularity"], "", None ), diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index a60f4d3f4d..cdcf49886a 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1129,11 +1129,11 @@ _mesa_apply_ci_transfer_ops(const GLcontext *ctx, GLbitfield transferOps, shift_and_offset_ci(ctx, n, indexes); } if (transferOps & IMAGE_MAP_COLOR_BIT) { - const GLuint mask = ctx->Pixel.MapItoIsize - 1; + const GLuint mask = ctx->PixelMaps.ItoI.Size - 1; GLuint i; for (i = 0; i < n; i++) { const GLuint j = indexes[i] & mask; - indexes[i] = IROUND(ctx->Pixel.MapItoI[j]); + indexes[i] = IROUND(ctx->PixelMaps.ItoI.Map[j]); } } } @@ -1169,10 +1169,10 @@ _mesa_apply_stencil_transfer_ops(const GLcontext *ctx, GLuint n, } } if (ctx->Pixel.MapStencilFlag) { - GLuint mask = ctx->Pixel.MapStoSsize - 1; + GLuint mask = ctx->PixelMaps.StoS.Size - 1; GLuint i; for (i = 0; i < n; i++) { - stencil[i] = ctx->Pixel.MapStoS[ stencil[i] & mask ]; + stencil[i] = ctx->PixelMaps.StoS.Map[ stencil[i] & mask ]; } } } @@ -3691,10 +3691,10 @@ _mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n, if (ctx->Pixel.MapStencilFlag) { /* Apply stencil lookup table */ - GLuint mask = ctx->Pixel.MapStoSsize - 1; + GLuint mask = ctx->PixelMaps.StoS.Size - 1; GLuint i; for (i=0;iPixel.MapStoS[ indexes[i] & mask ]; + indexes[i] = ctx->PixelMaps.StoS.Map[ indexes[i] & mask ]; } } } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 7caa1f8d7f..bced1a64d9 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -964,75 +964,105 @@ struct gl_multisample_attrib }; +/** + * A pixelmap (see glPixelMap) + */ +struct gl_pixelmap +{ + GLint Size; + GLfloat Map[MAX_PIXEL_MAP_TABLE]; + GLubyte Map8[MAX_PIXEL_MAP_TABLE]; /**< converted to 8-bit color */ +}; + + +/** + * Collection of all pixelmaps + */ +struct gl_pixelmaps +{ + struct gl_pixelmap RtoR; /**< i.e. GL_PIXEL_MAP_R_TO_R */ + struct gl_pixelmap GtoG; + struct gl_pixelmap BtoB; + struct gl_pixelmap AtoA; + struct gl_pixelmap ItoR; + struct gl_pixelmap ItoG; + struct gl_pixelmap ItoB; + struct gl_pixelmap ItoA; + struct gl_pixelmap ItoI; + struct gl_pixelmap StoS; +}; + + /** * Pixel attribute group (GL_PIXEL_MODE_BIT). */ struct gl_pixel_attrib { GLenum ReadBuffer; /**< source buffer for glRead/CopyPixels() */ + + /*--- Begin Pixel Transfer State ---*/ + /* Fields are in the order in which they're applied... */ + + /* Scale & Bias (index shift, offset) */ GLfloat RedBias, RedScale; GLfloat GreenBias, GreenScale; GLfloat BlueBias, BlueScale; GLfloat AlphaBias, AlphaScale; GLfloat DepthBias, DepthScale; GLint IndexShift, IndexOffset; + + /* Pixel Maps */ + /* Note: actual pixel maps are not part of this attrib group */ GLboolean MapColorFlag; GLboolean MapStencilFlag; - GLfloat ZoomX, ZoomY; - /* XXX move these out of gl_pixel_attrib */ - GLint MapStoSsize; /**< Size of each pixel map */ - GLint MapItoIsize; - GLint MapItoRsize; - GLint MapItoGsize; - GLint MapItoBsize; - GLint MapItoAsize; - GLint MapRtoRsize; - GLint MapGtoGsize; - GLint MapBtoBsize; - GLint MapAtoAsize; - GLint MapStoS[MAX_PIXEL_MAP_TABLE]; /**< Pixel map tables */ - GLfloat MapItoI[MAX_PIXEL_MAP_TABLE]; - GLfloat MapItoR[MAX_PIXEL_MAP_TABLE]; - GLfloat MapItoG[MAX_PIXEL_MAP_TABLE]; - GLfloat MapItoB[MAX_PIXEL_MAP_TABLE]; - GLfloat MapItoA[MAX_PIXEL_MAP_TABLE]; - GLubyte MapItoR8[MAX_PIXEL_MAP_TABLE]; /**< converted to 8-bit color */ - GLubyte MapItoG8[MAX_PIXEL_MAP_TABLE]; - GLubyte MapItoB8[MAX_PIXEL_MAP_TABLE]; - GLubyte MapItoA8[MAX_PIXEL_MAP_TABLE]; - GLfloat MapRtoR[MAX_PIXEL_MAP_TABLE]; - GLfloat MapGtoG[MAX_PIXEL_MAP_TABLE]; - GLfloat MapBtoB[MAX_PIXEL_MAP_TABLE]; - GLfloat MapAtoA[MAX_PIXEL_MAP_TABLE]; - /** GL_EXT_histogram */ - GLboolean HistogramEnabled; - GLboolean MinMaxEnabled; - /** GL_SGI_color_matrix */ - GLfloat PostColorMatrixScale[4]; /**< RGBA */ - GLfloat PostColorMatrixBias[4]; /**< RGBA */ - /** GL_SGI_color_table */ + + /* Color table lookup (GL_SGI_color_table) */ + /* Note: actual table is not part of this attrib group */ GLfloat ColorTableScale[4]; GLfloat ColorTableBias[4]; GLboolean ColorTableEnabled; - GLfloat PCCTscale[4]; - GLfloat PCCTbias[4]; - GLboolean PostConvolutionColorTableEnabled; - GLfloat PCMCTscale[4]; - GLfloat PCMCTbias[4]; - GLboolean PostColorMatrixColorTableEnabled; - /** GL_SGI_texture_color_table */ - GLfloat TextureColorTableScale[4]; - GLfloat TextureColorTableBias[4]; - /** Convolution */ + + /* Convolution (GL_EXT_convolution) */ GLboolean Convolution1DEnabled; GLboolean Convolution2DEnabled; GLboolean Separable2DEnabled; GLfloat ConvolutionBorderColor[3][4]; GLenum ConvolutionBorderMode[3]; - GLfloat ConvolutionFilterScale[3][4]; - GLfloat ConvolutionFilterBias[3][4]; + GLfloat ConvolutionFilterScale[3][4]; /**< RGBA */ + GLfloat ConvolutionFilterBias[3][4]; /**< RGBA */ GLfloat PostConvolutionScale[4]; /**< RGBA */ GLfloat PostConvolutionBias[4]; /**< RGBA */ + + /* Post-convolution color table */ + /* Note: actual table is not part of this attrib group */ + GLboolean PostConvolutionColorTableEnabled; + GLfloat PCCTscale[4]; /** Post Convolution Color Table scale */ + GLfloat PCCTbias[4]; /** Post Convolution Color Table bias */ + + /* Color matrix (GL_SGI_color_matrix) */ + /* Note: the color matrix is not part of this attrib group */ + GLfloat PostColorMatrixScale[4]; /**< RGBA */ + GLfloat PostColorMatrixBias[4]; /**< RGBA */ + + /* Post color matrix color table */ + /* Note: actual table is not part of this attrib group */ + GLboolean PostColorMatrixColorTableEnabled; + GLfloat PCMCTscale[4]; /** Post Color Matrix Color Table scale */ + GLfloat PCMCTbias[4]; /** Post Color Matrix Color Table bias */ + + /* Histogram & minmax (GL_EXT_histogram) */ + /* Note: histogram and minmax data are not part of this attrib group */ + GLboolean HistogramEnabled; + GLboolean MinMaxEnabled; + + /*--- End Pixel Transfer State ---*/ + + /* Pixel Zoom */ + GLfloat ZoomX, ZoomY; + + /** GL_SGI_texture_color_table */ + GLfloat TextureColorTableScale[4]; + GLfloat TextureColorTableBias[4]; }; @@ -2893,6 +2923,7 @@ struct __GLcontextRec /** \name Other assorted state (not pushed/popped on attribute stack) */ /*@{*/ + struct gl_pixelmaps PixelMaps; struct gl_histogram_attrib Histogram; struct gl_minmax_attrib MinMax; struct gl_convolution_attrib Convolution1D; diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index 4e47cdba89..a6a0ffdfa3 100644 --- a/src/mesa/main/pixel.c +++ b/src/mesa/main/pixel.c @@ -262,71 +262,71 @@ pixelmap(GLcontext *ctx, GLenum map, GLsizei mapsize, const GLfloat *values) GLint i; switch (map) { case GL_PIXEL_MAP_S_TO_S: - ctx->Pixel.MapStoSsize = mapsize; + ctx->PixelMaps.StoS.Size = mapsize; for (i = 0; i < mapsize; i++) { - ctx->Pixel.MapStoS[i] = IROUND(values[i]); + ctx->PixelMaps.StoS.Map[i] = IROUND(values[i]); } break; case GL_PIXEL_MAP_I_TO_I: - ctx->Pixel.MapItoIsize = mapsize; + ctx->PixelMaps.ItoI.Size = mapsize; for (i = 0; i < mapsize; i++) { - ctx->Pixel.MapItoI[i] = values[i]; + ctx->PixelMaps.ItoI.Map[i] = values[i]; } break; case GL_PIXEL_MAP_I_TO_R: - ctx->Pixel.MapItoRsize = mapsize; + ctx->PixelMaps.ItoR.Size = mapsize; for (i = 0; i < mapsize; i++) { GLfloat val = CLAMP( values[i], 0.0F, 1.0F ); - ctx->Pixel.MapItoR[i] = val; - ctx->Pixel.MapItoR8[i] = (GLint) (val * 255.0F); + ctx->PixelMaps.ItoR.Map[i] = val; + ctx->PixelMaps.ItoR.Map8[i] = (GLint) (val * 255.0F); } break; case GL_PIXEL_MAP_I_TO_G: - ctx->Pixel.MapItoGsize = mapsize; + ctx->PixelMaps.ItoG.Size = mapsize; for (i = 0; i < mapsize; i++) { GLfloat val = CLAMP( values[i], 0.0F, 1.0F ); - ctx->Pixel.MapItoG[i] = val; - ctx->Pixel.MapItoG8[i] = (GLint) (val * 255.0F); + ctx->PixelMaps.ItoG.Map[i] = val; + ctx->PixelMaps.ItoG.Map8[i] = (GLint) (val * 255.0F); } break; case GL_PIXEL_MAP_I_TO_B: - ctx->Pixel.MapItoBsize = mapsize; + ctx->PixelMaps.ItoB.Size = mapsize; for (i = 0; i < mapsize; i++) { GLfloat val = CLAMP( values[i], 0.0F, 1.0F ); - ctx->Pixel.MapItoB[i] = val; - ctx->Pixel.MapItoB8[i] = (GLint) (val * 255.0F); + ctx->PixelMaps.ItoB.Map[i] = val; + ctx->PixelMaps.ItoB.Map8[i] = (GLint) (val * 255.0F); } break; case GL_PIXEL_MAP_I_TO_A: - ctx->Pixel.MapItoAsize = mapsize; + ctx->PixelMaps.ItoA.Size = mapsize; for (i = 0; i < mapsize; i++) { GLfloat val = CLAMP( values[i], 0.0F, 1.0F ); - ctx->Pixel.MapItoA[i] = val; - ctx->Pixel.MapItoA8[i] = (GLint) (val * 255.0F); + ctx->PixelMaps.ItoA.Map[i] = val; + ctx->PixelMaps.ItoA.Map8[i] = (GLint) (val * 255.0F); } break; case GL_PIXEL_MAP_R_TO_R: - ctx->Pixel.MapRtoRsize = mapsize; + ctx->PixelMaps.RtoR.Size = mapsize; for (i = 0; i < mapsize; i++) { - ctx->Pixel.MapRtoR[i] = CLAMP( values[i], 0.0F, 1.0F ); + ctx->PixelMaps.RtoR.Map[i] = CLAMP( values[i], 0.0F, 1.0F ); } break; case GL_PIXEL_MAP_G_TO_G: - ctx->Pixel.MapGtoGsize = mapsize; + ctx->PixelMaps.GtoG.Size = mapsize; for (i = 0; i < mapsize; i++) { - ctx->Pixel.MapGtoG[i] = CLAMP( values[i], 0.0F, 1.0F ); + ctx->PixelMaps.GtoG.Map[i] = CLAMP( values[i], 0.0F, 1.0F ); } break; case GL_PIXEL_MAP_B_TO_B: - ctx->Pixel.MapBtoBsize = mapsize; + ctx->PixelMaps.BtoB.Size = mapsize; for (i = 0; i < mapsize; i++) { - ctx->Pixel.MapBtoB[i] = CLAMP( values[i], 0.0F, 1.0F ); + ctx->PixelMaps.BtoB.Map[i] = CLAMP( values[i], 0.0F, 1.0F ); } break; case GL_PIXEL_MAP_A_TO_A: - ctx->Pixel.MapAtoAsize = mapsize; + ctx->PixelMaps.AtoA.Size = mapsize; for (i = 0; i < mapsize; i++) { - ctx->Pixel.MapAtoA[i] = CLAMP( values[i], 0.0F, 1.0F ); + ctx->PixelMaps.AtoA.Map[i] = CLAMP( values[i], 0.0F, 1.0F ); } break; default: @@ -551,25 +551,25 @@ get_map_size(GLcontext *ctx, GLenum map) { switch (map) { case GL_PIXEL_MAP_I_TO_I: - return ctx->Pixel.MapItoIsize; + return ctx->PixelMaps.ItoI.Size; case GL_PIXEL_MAP_S_TO_S: - return ctx->Pixel.MapStoSsize; + return ctx->PixelMaps.StoS.Size; case GL_PIXEL_MAP_I_TO_R: - return ctx->Pixel.MapItoRsize; + return ctx->PixelMaps.ItoR.Size; case GL_PIXEL_MAP_I_TO_G: - return ctx->Pixel.MapItoGsize; + return ctx->PixelMaps.ItoG.Size; case GL_PIXEL_MAP_I_TO_B: - return ctx->Pixel.MapItoBsize; + return ctx->PixelMaps.ItoB.Size; case GL_PIXEL_MAP_I_TO_A: - return ctx->Pixel.MapItoAsize; + return ctx->PixelMaps.ItoA.Size; case GL_PIXEL_MAP_R_TO_R: - return ctx->Pixel.MapRtoRsize; + return ctx->PixelMaps.RtoR.Size; case GL_PIXEL_MAP_G_TO_G: - return ctx->Pixel.MapGtoGsize; + return ctx->PixelMaps.GtoG.Size; case GL_PIXEL_MAP_B_TO_B: - return ctx->Pixel.MapBtoBsize; + return ctx->PixelMaps.BtoB.Size; case GL_PIXEL_MAP_A_TO_A: - return ctx->Pixel.MapAtoAsize; + return ctx->PixelMaps.AtoA.Size; default: return 0; } @@ -615,36 +615,36 @@ _mesa_GetPixelMapfv( GLenum map, GLfloat *values ) switch (map) { case GL_PIXEL_MAP_I_TO_I: - MEMCPY(values, ctx->Pixel.MapItoI, mapsize * sizeof(GLfloat)); + MEMCPY(values, ctx->PixelMaps.ItoI.Map, mapsize * sizeof(GLfloat)); break; case GL_PIXEL_MAP_S_TO_S: for (i = 0; i < mapsize; i++) { - values[i] = (GLfloat) ctx->Pixel.MapStoS[i]; + values[i] = (GLfloat) ctx->PixelMaps.StoS.Map[i]; } break; case GL_PIXEL_MAP_I_TO_R: - MEMCPY(values, ctx->Pixel.MapItoR, mapsize * sizeof(GLfloat)); + MEMCPY(values, ctx->PixelMaps.ItoR.Map, mapsize * sizeof(GLfloat)); break; case GL_PIXEL_MAP_I_TO_G: - MEMCPY(values, ctx->Pixel.MapItoG, mapsize * sizeof(GLfloat)); + MEMCPY(values, ctx->PixelMaps.ItoG.Map, mapsize * sizeof(GLfloat)); break; case GL_PIXEL_MAP_I_TO_B: - MEMCPY(values, ctx->Pixel.MapItoB, mapsize * sizeof(GLfloat)); + MEMCPY(values, ctx->PixelMaps.ItoB.Map, mapsize * sizeof(GLfloat)); break; case GL_PIXEL_MAP_I_TO_A: - MEMCPY(values, ctx->Pixel.MapItoA, mapsize * sizeof(GLfloat)); + MEMCPY(values, ctx->PixelMaps.ItoA.Map, mapsize * sizeof(GLfloat)); break; case GL_PIXEL_MAP_R_TO_R: - MEMCPY(values, ctx->Pixel.MapRtoR, mapsize * sizeof(GLfloat)); + MEMCPY(values, ctx->PixelMaps.RtoR.Map, mapsize * sizeof(GLfloat)); break; case GL_PIXEL_MAP_G_TO_G: - MEMCPY(values, ctx->Pixel.MapGtoG, mapsize * sizeof(GLfloat)); + MEMCPY(values, ctx->PixelMaps.GtoG.Map, mapsize * sizeof(GLfloat)); break; case GL_PIXEL_MAP_B_TO_B: - MEMCPY(values, ctx->Pixel.MapBtoB, mapsize * sizeof(GLfloat)); + MEMCPY(values, ctx->PixelMaps.BtoB.Map, mapsize * sizeof(GLfloat)); break; case GL_PIXEL_MAP_A_TO_A: - MEMCPY(values, ctx->Pixel.MapAtoA, mapsize * sizeof(GLfloat)); + MEMCPY(values, ctx->PixelMaps.AtoA.Map, mapsize * sizeof(GLfloat)); break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glGetPixelMapfv" ); @@ -697,50 +697,50 @@ _mesa_GetPixelMapuiv( GLenum map, GLuint *values ) switch (map) { case GL_PIXEL_MAP_I_TO_I: for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoI[i] ); + values[i] = FLOAT_TO_UINT( ctx->PixelMaps.ItoI.Map[i] ); } break; case GL_PIXEL_MAP_S_TO_S: - MEMCPY(values, ctx->Pixel.MapStoS, mapsize * sizeof(GLint)); + MEMCPY(values, ctx->PixelMaps.StoS.Map, mapsize * sizeof(GLint)); break; case GL_PIXEL_MAP_I_TO_R: for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoR[i] ); + values[i] = FLOAT_TO_UINT( ctx->PixelMaps.ItoR.Map[i] ); } break; case GL_PIXEL_MAP_I_TO_G: for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoG[i] ); + values[i] = FLOAT_TO_UINT( ctx->PixelMaps.ItoG.Map[i] ); } break; case GL_PIXEL_MAP_I_TO_B: for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoB[i] ); + values[i] = FLOAT_TO_UINT( ctx->PixelMaps.ItoB.Map[i] ); } break; case GL_PIXEL_MAP_I_TO_A: for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoA[i] ); + values[i] = FLOAT_TO_UINT( ctx->PixelMaps.ItoA.Map[i] ); } break; case GL_PIXEL_MAP_R_TO_R: for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( ctx->Pixel.MapRtoR[i] ); + values[i] = FLOAT_TO_UINT( ctx->PixelMaps.RtoR.Map[i] ); } break; case GL_PIXEL_MAP_G_TO_G: for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( ctx->Pixel.MapGtoG[i] ); + values[i] = FLOAT_TO_UINT( ctx->PixelMaps.GtoG.Map[i] ); } break; case GL_PIXEL_MAP_B_TO_B: for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( ctx->Pixel.MapBtoB[i] ); + values[i] = FLOAT_TO_UINT( ctx->PixelMaps.BtoB.Map[i] ); } break; case GL_PIXEL_MAP_A_TO_A: for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( ctx->Pixel.MapAtoA[i] ); + values[i] = FLOAT_TO_UINT( ctx->PixelMaps.AtoA.Map[i] ); } break; default: @@ -795,52 +795,52 @@ _mesa_GetPixelMapusv( GLenum map, GLushort *values ) switch (map) { case GL_PIXEL_MAP_I_TO_I: for (i = 0; i < mapsize; i++) { - values[i] = (GLushort) CLAMP(ctx->Pixel.MapItoI[i], 0.0, 65535.0); + values[i] = (GLushort) CLAMP(ctx->PixelMaps.ItoI.Map[i], 0.0, 65535.0); } break; case GL_PIXEL_MAP_S_TO_S: for (i = 0; i < mapsize; i++) { - values[i] = (GLushort) CLAMP(ctx->Pixel.MapStoS[i], 0.0, 65535.0); + values[i] = (GLushort) CLAMP(ctx->PixelMaps.StoS.Map[i], 0.0, 65535.0); } break; case GL_PIXEL_MAP_I_TO_R: for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapItoR[i] ); + CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->PixelMaps.ItoR.Map[i] ); } break; case GL_PIXEL_MAP_I_TO_G: for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapItoG[i] ); + CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->PixelMaps.ItoG.Map[i] ); } break; case GL_PIXEL_MAP_I_TO_B: for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapItoB[i] ); + CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->PixelMaps.ItoB.Map[i] ); } break; case GL_PIXEL_MAP_I_TO_A: for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapItoA[i] ); + CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->PixelMaps.ItoA.Map[i] ); } break; case GL_PIXEL_MAP_R_TO_R: for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapRtoR[i] ); + CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->PixelMaps.RtoR.Map[i] ); } break; case GL_PIXEL_MAP_G_TO_G: for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapGtoG[i] ); + CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->PixelMaps.GtoG.Map[i] ); } break; case GL_PIXEL_MAP_B_TO_B: for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapBtoB[i] ); + CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->PixelMaps.BtoB.Map[i] ); } break; case GL_PIXEL_MAP_A_TO_A: for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapAtoA[i] ); + CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->PixelMaps.AtoA.Map[i] ); } break; default: @@ -1113,14 +1113,14 @@ _mesa_scale_and_bias_rgba(GLuint n, GLfloat rgba[][4], void _mesa_map_rgba( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] ) { - const GLfloat rscale = (GLfloat) (ctx->Pixel.MapRtoRsize - 1); - const GLfloat gscale = (GLfloat) (ctx->Pixel.MapGtoGsize - 1); - const GLfloat bscale = (GLfloat) (ctx->Pixel.MapBtoBsize - 1); - const GLfloat ascale = (GLfloat) (ctx->Pixel.MapAtoAsize - 1); - const GLfloat *rMap = ctx->Pixel.MapRtoR; - const GLfloat *gMap = ctx->Pixel.MapGtoG; - const GLfloat *bMap = ctx->Pixel.MapBtoB; - const GLfloat *aMap = ctx->Pixel.MapAtoA; + const GLfloat rscale = (GLfloat) (ctx->PixelMaps.RtoR.Size - 1); + const GLfloat gscale = (GLfloat) (ctx->PixelMaps.GtoG.Size - 1); + const GLfloat bscale = (GLfloat) (ctx->PixelMaps.BtoB.Size - 1); + const GLfloat ascale = (GLfloat) (ctx->PixelMaps.AtoA.Size - 1); + const GLfloat *rMap = ctx->PixelMaps.RtoR.Map; + const GLfloat *gMap = ctx->PixelMaps.GtoG.Map; + const GLfloat *bMap = ctx->PixelMaps.BtoB.Map; + const GLfloat *aMap = ctx->PixelMaps.AtoA.Map; GLuint i; for (i=0;iPixel.MapItoRsize - 1; - GLuint gmask = ctx->Pixel.MapItoGsize - 1; - GLuint bmask = ctx->Pixel.MapItoBsize - 1; - GLuint amask = ctx->Pixel.MapItoAsize - 1; - const GLfloat *rMap = ctx->Pixel.MapItoR; - const GLfloat *gMap = ctx->Pixel.MapItoG; - const GLfloat *bMap = ctx->Pixel.MapItoB; - const GLfloat *aMap = ctx->Pixel.MapItoA; + GLuint rmask = ctx->PixelMaps.ItoR.Size - 1; + GLuint gmask = ctx->PixelMaps.ItoG.Size - 1; + GLuint bmask = ctx->PixelMaps.ItoB.Size - 1; + GLuint amask = ctx->PixelMaps.ItoA.Size - 1; + const GLfloat *rMap = ctx->PixelMaps.ItoR.Map; + const GLfloat *gMap = ctx->PixelMaps.ItoG.Map; + const GLfloat *bMap = ctx->PixelMaps.ItoB.Map; + const GLfloat *aMap = ctx->PixelMaps.ItoA.Map; GLuint i; for (i=0;iPixel.MapItoRsize - 1; - GLuint gmask = ctx->Pixel.MapItoGsize - 1; - GLuint bmask = ctx->Pixel.MapItoBsize - 1; - GLuint amask = ctx->Pixel.MapItoAsize - 1; - const GLubyte *rMap = ctx->Pixel.MapItoR8; - const GLubyte *gMap = ctx->Pixel.MapItoG8; - const GLubyte *bMap = ctx->Pixel.MapItoB8; - const GLubyte *aMap = ctx->Pixel.MapItoA8; + GLuint rmask = ctx->PixelMaps.ItoR.Size - 1; + GLuint gmask = ctx->PixelMaps.ItoG.Size - 1; + GLuint bmask = ctx->PixelMaps.ItoB.Size - 1; + GLuint amask = ctx->PixelMaps.ItoA.Size - 1; + const GLubyte *rMap = ctx->PixelMaps.ItoR.Map8; + const GLubyte *gMap = ctx->PixelMaps.ItoG.Map8; + const GLubyte *bMap = ctx->PixelMaps.ItoB.Map8; + const GLubyte *aMap = ctx->PixelMaps.ItoA.Map8; GLuint i; for (i=0;iSize = 1; + map->Map[0] = 0.0; + map->Map8[0] = 0; +} + /** * Initialize the context's PIXEL attribute group. @@ -1584,30 +1592,16 @@ _mesa_init_pixel( GLcontext *ctx ) ctx->Pixel.ZoomY = 1.0; ctx->Pixel.MapColorFlag = GL_FALSE; ctx->Pixel.MapStencilFlag = GL_FALSE; - ctx->Pixel.MapStoSsize = 1; - ctx->Pixel.MapItoIsize = 1; - ctx->Pixel.MapItoRsize = 1; - ctx->Pixel.MapItoGsize = 1; - ctx->Pixel.MapItoBsize = 1; - ctx->Pixel.MapItoAsize = 1; - ctx->Pixel.MapRtoRsize = 1; - ctx->Pixel.MapGtoGsize = 1; - ctx->Pixel.MapBtoBsize = 1; - ctx->Pixel.MapAtoAsize = 1; - ctx->Pixel.MapStoS[0] = 0; - ctx->Pixel.MapItoI[0] = 0.0; - ctx->Pixel.MapItoR[0] = 0.0; - ctx->Pixel.MapItoG[0] = 0.0; - ctx->Pixel.MapItoB[0] = 0.0; - ctx->Pixel.MapItoA[0] = 0.0; - ctx->Pixel.MapItoR8[0] = 0; - ctx->Pixel.MapItoG8[0] = 0; - ctx->Pixel.MapItoB8[0] = 0; - ctx->Pixel.MapItoA8[0] = 0; - ctx->Pixel.MapRtoR[0] = 0.0; - ctx->Pixel.MapGtoG[0] = 0.0; - ctx->Pixel.MapBtoB[0] = 0.0; - ctx->Pixel.MapAtoA[0] = 0.0; + init_pixelmap(&ctx->PixelMaps.StoS); + init_pixelmap(&ctx->PixelMaps.ItoI); + init_pixelmap(&ctx->PixelMaps.ItoR); + init_pixelmap(&ctx->PixelMaps.ItoG); + init_pixelmap(&ctx->PixelMaps.ItoB); + init_pixelmap(&ctx->PixelMaps.ItoA); + init_pixelmap(&ctx->PixelMaps.RtoR); + init_pixelmap(&ctx->PixelMaps.GtoG); + init_pixelmap(&ctx->PixelMaps.BtoB); + init_pixelmap(&ctx->PixelMaps.AtoA); ctx->Pixel.HistogramEnabled = GL_FALSE; ctx->Pixel.MinMaxEnabled = GL_FALSE; ASSIGN_4V(ctx->Pixel.PostColorMatrixScale, 1.0, 1.0, 1.0, 1.0); -- cgit v1.2.3 From 32d196820f5669a03bfd1adde1352b857ffda3b6 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 14 Mar 2007 14:56:39 -0600 Subject: pixelmap code simplification --- src/mesa/main/pixel.c | 377 +++++++++++++++++--------------------------------- 1 file changed, 124 insertions(+), 253 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index a6a0ffdfa3..ae014a23c4 100644 --- a/src/mesa/main/pixel.c +++ b/src/mesa/main/pixel.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.2 + * Version: 6.5.3 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -252,85 +252,76 @@ _mesa_PixelStoref( GLenum pname, GLfloat param ) /***** glPixelMap *****/ /**********************************************************************/ +/** + * Return pointer to a pixelmap by name. + */ +static struct gl_pixelmap * +get_pixelmap(GLcontext *ctx, GLenum map) +{ + switch (map) { + case GL_PIXEL_MAP_I_TO_I: + return &ctx->PixelMaps.ItoI; + case GL_PIXEL_MAP_S_TO_S: + return &ctx->PixelMaps.StoS; + case GL_PIXEL_MAP_I_TO_R: + return &ctx->PixelMaps.ItoR; + case GL_PIXEL_MAP_I_TO_G: + return &ctx->PixelMaps.ItoG; + case GL_PIXEL_MAP_I_TO_B: + return &ctx->PixelMaps.ItoB; + case GL_PIXEL_MAP_I_TO_A: + return &ctx->PixelMaps.ItoA; + case GL_PIXEL_MAP_R_TO_R: + return &ctx->PixelMaps.RtoR; + case GL_PIXEL_MAP_G_TO_G: + return &ctx->PixelMaps.GtoG; + case GL_PIXEL_MAP_B_TO_B: + return &ctx->PixelMaps.BtoB; + case GL_PIXEL_MAP_A_TO_A: + return &ctx->PixelMaps.AtoA; + default: + return NULL; + } +} + /** * Helper routine used by the other _mesa_PixelMap() functions. */ static void -pixelmap(GLcontext *ctx, GLenum map, GLsizei mapsize, const GLfloat *values) +store_pixelmap(GLcontext *ctx, GLenum map, GLsizei mapsize, + const GLfloat *values) { GLint i; + struct gl_pixelmap *pm = get_pixelmap(ctx, map); + if (!pm) { + _mesa_error(ctx, GL_INVALID_ENUM, "glPixelMap(map)"); + return; + } + switch (map) { - case GL_PIXEL_MAP_S_TO_S: - ctx->PixelMaps.StoS.Size = mapsize; - for (i = 0; i < mapsize; i++) { - ctx->PixelMaps.StoS.Map[i] = IROUND(values[i]); - } - break; - case GL_PIXEL_MAP_I_TO_I: - ctx->PixelMaps.ItoI.Size = mapsize; - for (i = 0; i < mapsize; i++) { - ctx->PixelMaps.ItoI.Map[i] = values[i]; - } - break; - case GL_PIXEL_MAP_I_TO_R: - ctx->PixelMaps.ItoR.Size = mapsize; - for (i = 0; i < mapsize; i++) { - GLfloat val = CLAMP( values[i], 0.0F, 1.0F ); - ctx->PixelMaps.ItoR.Map[i] = val; - ctx->PixelMaps.ItoR.Map8[i] = (GLint) (val * 255.0F); - } - break; - case GL_PIXEL_MAP_I_TO_G: - ctx->PixelMaps.ItoG.Size = mapsize; - for (i = 0; i < mapsize; i++) { - GLfloat val = CLAMP( values[i], 0.0F, 1.0F ); - ctx->PixelMaps.ItoG.Map[i] = val; - ctx->PixelMaps.ItoG.Map8[i] = (GLint) (val * 255.0F); - } - break; - case GL_PIXEL_MAP_I_TO_B: - ctx->PixelMaps.ItoB.Size = mapsize; - for (i = 0; i < mapsize; i++) { - GLfloat val = CLAMP( values[i], 0.0F, 1.0F ); - ctx->PixelMaps.ItoB.Map[i] = val; - ctx->PixelMaps.ItoB.Map8[i] = (GLint) (val * 255.0F); - } - break; - case GL_PIXEL_MAP_I_TO_A: - ctx->PixelMaps.ItoA.Size = mapsize; - for (i = 0; i < mapsize; i++) { - GLfloat val = CLAMP( values[i], 0.0F, 1.0F ); - ctx->PixelMaps.ItoA.Map[i] = val; - ctx->PixelMaps.ItoA.Map8[i] = (GLint) (val * 255.0F); - } - break; - case GL_PIXEL_MAP_R_TO_R: - ctx->PixelMaps.RtoR.Size = mapsize; - for (i = 0; i < mapsize; i++) { - ctx->PixelMaps.RtoR.Map[i] = CLAMP( values[i], 0.0F, 1.0F ); - } - break; - case GL_PIXEL_MAP_G_TO_G: - ctx->PixelMaps.GtoG.Size = mapsize; - for (i = 0; i < mapsize; i++) { - ctx->PixelMaps.GtoG.Map[i] = CLAMP( values[i], 0.0F, 1.0F ); - } - break; - case GL_PIXEL_MAP_B_TO_B: - ctx->PixelMaps.BtoB.Size = mapsize; - for (i = 0; i < mapsize; i++) { - ctx->PixelMaps.BtoB.Map[i] = CLAMP( values[i], 0.0F, 1.0F ); - } - break; - case GL_PIXEL_MAP_A_TO_A: - ctx->PixelMaps.AtoA.Size = mapsize; - for (i = 0; i < mapsize; i++) { - ctx->PixelMaps.AtoA.Map[i] = CLAMP( values[i], 0.0F, 1.0F ); - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glPixelMap(map)" ); + case GL_PIXEL_MAP_S_TO_S: + /* special case */ + ctx->PixelMaps.StoS.Size = mapsize; + for (i = 0; i < mapsize; i++) { + ctx->PixelMaps.StoS.Map[i] = IROUND(values[i]); + } + break; + case GL_PIXEL_MAP_I_TO_I: + /* special case */ + ctx->PixelMaps.ItoI.Size = mapsize; + for (i = 0; i < mapsize; i++) { + ctx->PixelMaps.ItoI.Map[i] = values[i]; + } + break; + default: + /* general case */ + pm->Size = mapsize; + for (i = 0; i < mapsize; i++) { + GLfloat val = CLAMP(values[i], 0.0F, 1.0F); + pm->Map[i] = val; + pm->Map8[i] = (GLint) (val * 255.0F); + } } } @@ -385,7 +376,7 @@ _mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values ) return; } - pixelmap(ctx, map, mapsize, values); + store_pixelmap(ctx, map, mapsize, values); if (ctx->Unpack.BufferObj->Name) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, @@ -394,7 +385,6 @@ _mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values ) } - void GLAPIENTRY _mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values ) { @@ -464,11 +454,10 @@ _mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values ) ctx->Unpack.BufferObj); } - pixelmap(ctx, map, mapsize, fvalues); + store_pixelmap(ctx, map, mapsize, fvalues); } - void GLAPIENTRY _mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values ) { @@ -520,7 +509,7 @@ _mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values ) return; } - /* convert to floats */ + /* convert to floats */ if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { GLint i; for (i = 0; i < mapsize; i++) { @@ -539,40 +528,7 @@ _mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values ) ctx->Unpack.BufferObj); } - pixelmap(ctx, map, mapsize, fvalues); -} - - -/** - * Return size of the named map. - */ -static GLuint -get_map_size(GLcontext *ctx, GLenum map) -{ - switch (map) { - case GL_PIXEL_MAP_I_TO_I: - return ctx->PixelMaps.ItoI.Size; - case GL_PIXEL_MAP_S_TO_S: - return ctx->PixelMaps.StoS.Size; - case GL_PIXEL_MAP_I_TO_R: - return ctx->PixelMaps.ItoR.Size; - case GL_PIXEL_MAP_I_TO_G: - return ctx->PixelMaps.ItoG.Size; - case GL_PIXEL_MAP_I_TO_B: - return ctx->PixelMaps.ItoB.Size; - case GL_PIXEL_MAP_I_TO_A: - return ctx->PixelMaps.ItoA.Size; - case GL_PIXEL_MAP_R_TO_R: - return ctx->PixelMaps.RtoR.Size; - case GL_PIXEL_MAP_G_TO_G: - return ctx->PixelMaps.GtoG.Size; - case GL_PIXEL_MAP_B_TO_B: - return ctx->PixelMaps.BtoB.Size; - case GL_PIXEL_MAP_A_TO_A: - return ctx->PixelMaps.AtoA.Size; - default: - return 0; - } + store_pixelmap(ctx, map, mapsize, fvalues); } @@ -581,9 +537,17 @@ _mesa_GetPixelMapfv( GLenum map, GLfloat *values ) { GET_CURRENT_CONTEXT(ctx); GLuint mapsize, i; + const struct gl_pixelmap *pm; + ASSERT_OUTSIDE_BEGIN_END(ctx); - mapsize = get_map_size(ctx, map); + pm = get_pixelmap(ctx, map); + if (!pm) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapfv(map)"); + return; + } + + mapsize = pm->Size; if (ctx->Pack.BufferObj->Name) { /* pack pixelmap into PBO */ @@ -613,41 +577,14 @@ _mesa_GetPixelMapfv( GLenum map, GLfloat *values ) return; } - switch (map) { - case GL_PIXEL_MAP_I_TO_I: - MEMCPY(values, ctx->PixelMaps.ItoI.Map, mapsize * sizeof(GLfloat)); - break; - case GL_PIXEL_MAP_S_TO_S: - for (i = 0; i < mapsize; i++) { - values[i] = (GLfloat) ctx->PixelMaps.StoS.Map[i]; - } - break; - case GL_PIXEL_MAP_I_TO_R: - MEMCPY(values, ctx->PixelMaps.ItoR.Map, mapsize * sizeof(GLfloat)); - break; - case GL_PIXEL_MAP_I_TO_G: - MEMCPY(values, ctx->PixelMaps.ItoG.Map, mapsize * sizeof(GLfloat)); - break; - case GL_PIXEL_MAP_I_TO_B: - MEMCPY(values, ctx->PixelMaps.ItoB.Map, mapsize * sizeof(GLfloat)); - break; - case GL_PIXEL_MAP_I_TO_A: - MEMCPY(values, ctx->PixelMaps.ItoA.Map, mapsize * sizeof(GLfloat)); - break; - case GL_PIXEL_MAP_R_TO_R: - MEMCPY(values, ctx->PixelMaps.RtoR.Map, mapsize * sizeof(GLfloat)); - break; - case GL_PIXEL_MAP_G_TO_G: - MEMCPY(values, ctx->PixelMaps.GtoG.Map, mapsize * sizeof(GLfloat)); - break; - case GL_PIXEL_MAP_B_TO_B: - MEMCPY(values, ctx->PixelMaps.BtoB.Map, mapsize * sizeof(GLfloat)); - break; - case GL_PIXEL_MAP_A_TO_A: - MEMCPY(values, ctx->PixelMaps.AtoA.Map, mapsize * sizeof(GLfloat)); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetPixelMapfv" ); + if (map == GL_PIXEL_MAP_S_TO_S) { + /* special case */ + for (i = 0; i < mapsize; i++) { + values[i] = (GLfloat) ctx->PixelMaps.StoS.Map[i]; + } + } + else { + MEMCPY(values, pm->Map, mapsize * sizeof(GLfloat)); } if (ctx->Pack.BufferObj->Name) { @@ -662,9 +599,16 @@ _mesa_GetPixelMapuiv( GLenum map, GLuint *values ) { GET_CURRENT_CONTEXT(ctx); GLint mapsize, i; + const struct gl_pixelmap *pm; + ASSERT_OUTSIDE_BEGIN_END(ctx); - mapsize = get_map_size(ctx, map); + pm = get_pixelmap(ctx, map); + if (!pm) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapuiv(map)"); + return; + } + mapsize = pm->Size; if (ctx->Pack.BufferObj->Name) { /* pack pixelmap into PBO */ @@ -694,57 +638,14 @@ _mesa_GetPixelMapuiv( GLenum map, GLuint *values ) return; } - switch (map) { - case GL_PIXEL_MAP_I_TO_I: - for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( ctx->PixelMaps.ItoI.Map[i] ); - } - break; - case GL_PIXEL_MAP_S_TO_S: - MEMCPY(values, ctx->PixelMaps.StoS.Map, mapsize * sizeof(GLint)); - break; - case GL_PIXEL_MAP_I_TO_R: - for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( ctx->PixelMaps.ItoR.Map[i] ); - } - break; - case GL_PIXEL_MAP_I_TO_G: - for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( ctx->PixelMaps.ItoG.Map[i] ); - } - break; - case GL_PIXEL_MAP_I_TO_B: - for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( ctx->PixelMaps.ItoB.Map[i] ); - } - break; - case GL_PIXEL_MAP_I_TO_A: - for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( ctx->PixelMaps.ItoA.Map[i] ); - } - break; - case GL_PIXEL_MAP_R_TO_R: - for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( ctx->PixelMaps.RtoR.Map[i] ); - } - break; - case GL_PIXEL_MAP_G_TO_G: - for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( ctx->PixelMaps.GtoG.Map[i] ); - } - break; - case GL_PIXEL_MAP_B_TO_B: - for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( ctx->PixelMaps.BtoB.Map[i] ); - } - break; - case GL_PIXEL_MAP_A_TO_A: - for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( ctx->PixelMaps.AtoA.Map[i] ); - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetPixelMapfv" ); + if (map == GL_PIXEL_MAP_S_TO_S) { + /* special case */ + MEMCPY(values, ctx->PixelMaps.StoS.Map, mapsize * sizeof(GLint)); + } + else { + for (i = 0; i < mapsize; i++) { + values[i] = FLOAT_TO_UINT( pm->Map[i] ); + } } if (ctx->Pack.BufferObj->Name) { @@ -759,9 +660,16 @@ _mesa_GetPixelMapusv( GLenum map, GLushort *values ) { GET_CURRENT_CONTEXT(ctx); GLint mapsize, i; + const struct gl_pixelmap *pm; + ASSERT_OUTSIDE_BEGIN_END(ctx); - mapsize = get_map_size(ctx, map); + pm = get_pixelmap(ctx, map); + if (!pm) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapusv(map)"); + return; + } + mapsize = pm ? pm->Size : 0; if (ctx->Pack.BufferObj->Name) { /* pack pixelmap into PBO */ @@ -793,58 +701,21 @@ _mesa_GetPixelMapusv( GLenum map, GLushort *values ) } switch (map) { - case GL_PIXEL_MAP_I_TO_I: - for (i = 0; i < mapsize; i++) { - values[i] = (GLushort) CLAMP(ctx->PixelMaps.ItoI.Map[i], 0.0, 65535.0); - } - break; - case GL_PIXEL_MAP_S_TO_S: - for (i = 0; i < mapsize; i++) { - values[i] = (GLushort) CLAMP(ctx->PixelMaps.StoS.Map[i], 0.0, 65535.0); - } - break; - case GL_PIXEL_MAP_I_TO_R: - for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->PixelMaps.ItoR.Map[i] ); - } - break; - case GL_PIXEL_MAP_I_TO_G: - for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->PixelMaps.ItoG.Map[i] ); - } - break; - case GL_PIXEL_MAP_I_TO_B: - for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->PixelMaps.ItoB.Map[i] ); - } - break; - case GL_PIXEL_MAP_I_TO_A: - for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->PixelMaps.ItoA.Map[i] ); - } - break; - case GL_PIXEL_MAP_R_TO_R: - for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->PixelMaps.RtoR.Map[i] ); - } - break; - case GL_PIXEL_MAP_G_TO_G: - for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->PixelMaps.GtoG.Map[i] ); - } - break; - case GL_PIXEL_MAP_B_TO_B: - for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->PixelMaps.BtoB.Map[i] ); - } - break; - case GL_PIXEL_MAP_A_TO_A: - for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->PixelMaps.AtoA.Map[i] ); - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetPixelMapfv" ); + /* special cases */ + case GL_PIXEL_MAP_I_TO_I: + for (i = 0; i < mapsize; i++) { + values[i] = (GLushort) CLAMP(ctx->PixelMaps.ItoI.Map[i], 0.0, 65535.); + } + break; + case GL_PIXEL_MAP_S_TO_S: + for (i = 0; i < mapsize; i++) { + values[i] = (GLushort) CLAMP(ctx->PixelMaps.StoS.Map[i], 0.0, 65535.); + } + break; + default: + for (i = 0; i < mapsize; i++) { + CLAMPED_FLOAT_TO_USHORT(values[i], pm->Map[i] ); + } } if (ctx->Pack.BufferObj->Name) { -- cgit v1.2.3 From 0cfdf432e4efe6662c6cea013a6870a4f82cb478 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 15 Mar 2007 09:02:14 -0600 Subject: implement byteswapping for all multi-byte types in _mesa_pack_rgba_span_float(), bug 10298 --- src/mesa/main/image.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index cdcf49886a..f53730cbcf 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.2 + * Version: 6.5.3 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -1454,9 +1454,6 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4], default: _mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n"); } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n * comps); - } } break; case GL_SHORT: @@ -1530,9 +1527,6 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4], default: _mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n"); } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n * comps ); - } } break; case GL_UNSIGNED_INT: @@ -1606,9 +1600,6 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4], default: _mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n"); } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n * comps ); - } } break; case GL_INT: @@ -1682,9 +1673,6 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4], default: _mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n"); } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n * comps ); - } } break; case GL_FLOAT: @@ -1758,9 +1746,6 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4], default: _mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n"); } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n * comps ); - } } break; case GL_HALF_FLOAT_ARB: @@ -1834,9 +1819,6 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4], default: _mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n"); } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n * comps ); - } } break; case GL_UNSIGNED_BYTE_3_3_2: @@ -2113,6 +2095,21 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4], break; default: _mesa_problem(ctx, "bad type in _mesa_pack_rgba_span_float"); + return; + } + + if (dstPacking->SwapBytes) { + GLint swapSize = _mesa_sizeof_packed_type(dstType); + if (swapSize == 2) { + if (dstPacking->SwapBytes) { + _mesa_swap2((GLushort *) dstAddr, n * comps); + } + } + else if (swapSize == 4) { + if (dstPacking->SwapBytes) { + _mesa_swap4((GLuint *) dstAddr, n * comps); + } + } } } -- cgit v1.2.3 From 4d2eb637a20e4fdf5d5f6c0ea4d4627894594661 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 15 Mar 2007 11:16:41 -0600 Subject: no-op clear if buffer width or height is zero (bug 7205) --- src/mesa/main/buffers.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/mesa/main') diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 0e3ed15584..11bd173e35 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -140,6 +140,9 @@ _mesa_Clear( GLbitfield mask ) return; } + if (ctx->DrawBuffer->Width == 0 || ctx->DrawBuffer->Height == 0) + return; + if (ctx->RenderMode == GL_RENDER) { GLbitfield bufferMask; -- cgit v1.2.3 From d7049431a09a71a51768fc8cea292653557fc261 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 16 Mar 2007 08:36:22 -0600 Subject: added a renderbuffer comment --- src/mesa/main/mtypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index bced1a64d9..321adfe615 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2169,7 +2169,7 @@ struct gl_renderbuffer GLubyte IndexBits; GLubyte DepthBits; GLubyte StencilBits; - GLvoid *Data; + GLvoid *Data; /**< This may not be used by some kinds of RBs */ /* Used to wrap one renderbuffer around another: */ struct gl_renderbuffer *Wrapped; -- cgit v1.2.3 From 7573b58db659b32f3589fc955959710d44353239 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 16 Mar 2007 09:36:12 -0600 Subject: Colortable re-org. The pixel transfer path has three color table lookups. Use an array [3] to store that info, rather than separate variables. --- src/mesa/main/attrib.c | 19 +-- src/mesa/main/colortab.c | 313 +++++++++++++++++------------------------------ src/mesa/main/enable.c | 18 +-- src/mesa/main/get.c | 18 +-- src/mesa/main/get_gen.py | 6 +- src/mesa/main/image.c | 6 +- src/mesa/main/mtypes.h | 38 +++--- src/mesa/main/pixel.c | 20 ++- 8 files changed, 170 insertions(+), 268 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 2b1a35f3de..0df8d23050 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -138,9 +138,9 @@ _mesa_PushAttrib(GLbitfield mask) attr->Blend = ctx->Color.BlendEnabled; attr->ClipPlanes = ctx->Transform.ClipPlanesEnabled; attr->ColorMaterial = ctx->Light.ColorMaterialEnabled; - attr->ColorTable = ctx->Pixel.ColorTableEnabled; - attr->PostColorMatrixColorTable = ctx->Pixel.PostColorMatrixColorTableEnabled; - attr->PostConvolutionColorTable = ctx->Pixel.PostConvolutionColorTableEnabled; + for (i = 0; i < COLORTABLE_MAX; i++) { + attr->ColorTable[i] = ctx->Pixel.ColorTableEnabled[i]; + } attr->Convolution1D = ctx->Pixel.Convolution1DEnabled; attr->Convolution2D = ctx->Pixel.Convolution2DEnabled; attr->Separable2D = ctx->Pixel.Separable2DEnabled; @@ -432,14 +432,15 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable) TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, enable->ColorMaterial, GL_COLOR_MATERIAL); - TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled, enable->ColorTable, + TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION], + enable->ColorTable[COLORTABLE_PRECONVOLUTION], GL_COLOR_TABLE); - TEST_AND_UPDATE(ctx->Pixel.PostColorMatrixColorTableEnabled, - enable->PostColorMatrixColorTable, - GL_POST_COLOR_MATRIX_COLOR_TABLE); - TEST_AND_UPDATE(ctx->Pixel.PostConvolutionColorTableEnabled, - enable->PostConvolutionColorTable, + TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION], + enable->ColorTable[COLORTABLE_POSTCONVOLUTION], GL_POST_CONVOLUTION_COLOR_TABLE); + TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX], + enable->ColorTable[COLORTABLE_POSTCOLORMATRIX], + GL_POST_COLOR_MATRIX_COLOR_TABLE); TEST_AND_UPDATE(ctx->Polygon.CullFlag, enable->CullFace, GL_CULL_FACE); TEST_AND_UPDATE(ctx->Depth.Test, enable->DepthTest, GL_DEPTH_TEST); TEST_AND_UPDATE(ctx->Color.DitherFlag, enable->Dither, GL_DITHER); diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c index 9fb0baf4a7..d8c4136f49 100644 --- a/src/mesa/main/colortab.c +++ b/src/mesa/main/colortab.c @@ -291,15 +291,17 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *data ) { + static const GLfloat one[4] = { 1.0, 1.0, 1.0, 1.0 }; + static const GLfloat zero[4] = { 0.0, 0.0, 0.0, 0.0 }; GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; struct gl_texture_object *texObj = NULL; struct gl_color_table *table = NULL; GLboolean proxy = GL_FALSE; GLint baseFormat; - GLfloat rScale = 1.0, gScale = 1.0, bScale = 1.0, aScale = 1.0; - GLfloat rBias = 0.0, gBias = 0.0, bBias = 0.0, aBias = 0.0; + const GLfloat *scale = one, *bias = zero; GLint comps; + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex */ switch (target) { @@ -350,18 +352,12 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat, table = &ctx->Texture.Palette; break; case GL_COLOR_TABLE: - table = &ctx->ColorTable; - rScale = ctx->Pixel.ColorTableScale[0]; - gScale = ctx->Pixel.ColorTableScale[1]; - bScale = ctx->Pixel.ColorTableScale[2]; - aScale = ctx->Pixel.ColorTableScale[3]; - rBias = ctx->Pixel.ColorTableBias[0]; - gBias = ctx->Pixel.ColorTableBias[1]; - bBias = ctx->Pixel.ColorTableBias[2]; - aBias = ctx->Pixel.ColorTableBias[3]; + table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; + scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]; + bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]; break; case GL_PROXY_COLOR_TABLE: - table = &ctx->ProxyColorTable; + table = &ctx->ProxyColorTable[COLORTABLE_PRECONVOLUTION]; proxy = GL_TRUE; break; case GL_TEXTURE_COLOR_TABLE_SGI: @@ -370,14 +366,8 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat, return; } table = &(texUnit->ColorTable); - rScale = ctx->Pixel.TextureColorTableScale[0]; - gScale = ctx->Pixel.TextureColorTableScale[1]; - bScale = ctx->Pixel.TextureColorTableScale[2]; - aScale = ctx->Pixel.TextureColorTableScale[3]; - rBias = ctx->Pixel.TextureColorTableBias[0]; - gBias = ctx->Pixel.TextureColorTableBias[1]; - bBias = ctx->Pixel.TextureColorTableBias[2]; - aBias = ctx->Pixel.TextureColorTableBias[3]; + scale = ctx->Pixel.TextureColorTableScale; + bias = ctx->Pixel.TextureColorTableBias; break; case GL_PROXY_TEXTURE_COLOR_TABLE_SGI: if (!ctx->Extensions.SGI_texture_color_table) { @@ -388,33 +378,21 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat, proxy = GL_TRUE; break; case GL_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->PostConvolutionColorTable; - rScale = ctx->Pixel.PCCTscale[0]; - gScale = ctx->Pixel.PCCTscale[1]; - bScale = ctx->Pixel.PCCTscale[2]; - aScale = ctx->Pixel.PCCTscale[3]; - rBias = ctx->Pixel.PCCTbias[0]; - gBias = ctx->Pixel.PCCTbias[1]; - bBias = ctx->Pixel.PCCTbias[2]; - aBias = ctx->Pixel.PCCTbias[3]; + table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; + scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]; + bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]; break; case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->ProxyPostConvolutionColorTable; + table = &ctx->ProxyColorTable[COLORTABLE_POSTCONVOLUTION]; proxy = GL_TRUE; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->PostColorMatrixColorTable; - rScale = ctx->Pixel.PCMCTscale[0]; - gScale = ctx->Pixel.PCMCTscale[1]; - bScale = ctx->Pixel.PCMCTscale[2]; - aScale = ctx->Pixel.PCMCTscale[3]; - rBias = ctx->Pixel.PCMCTbias[0]; - gBias = ctx->Pixel.PCMCTbias[1]; - bBias = ctx->Pixel.PCMCTbias[2]; - aBias = ctx->Pixel.PCMCTbias[3]; + table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; + scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; + bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX]; break; case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->ProxyPostColorMatrixColorTable; + table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX]; proxy = GL_TRUE; break; default: @@ -483,10 +461,10 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat, store_colortable_entries(ctx, table, 0, width, /* start, count */ format, type, data, - rScale, rBias, - gScale, gBias, - bScale, bBias, - aScale, aBias); + scale[0], bias[0], + scale[1], bias[1], + scale[2], bias[2], + scale[3], bias[3]); } } /* proxy */ @@ -510,12 +488,14 @@ _mesa_ColorSubTable( GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data ) { + static const GLfloat one[4] = { 1.0, 1.0, 1.0, 1.0 }; + static const GLfloat zero[4] = { 0.0, 0.0, 0.0, 0.0 }; GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; struct gl_texture_object *texObj = NULL; struct gl_color_table *table = NULL; - GLfloat rScale = 1.0, gScale = 1.0, bScale = 1.0, aScale = 1.0; - GLfloat rBias = 0.0, gBias = 0.0, bBias = 0.0, aBias = 0.0; + const GLfloat *scale = one, *bias = zero; + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); switch (target) { @@ -543,15 +523,9 @@ _mesa_ColorSubTable( GLenum target, GLsizei start, table = &ctx->Texture.Palette; break; case GL_COLOR_TABLE: - table = &ctx->ColorTable; - rScale = ctx->Pixel.ColorTableScale[0]; - gScale = ctx->Pixel.ColorTableScale[1]; - bScale = ctx->Pixel.ColorTableScale[2]; - aScale = ctx->Pixel.ColorTableScale[3]; - rBias = ctx->Pixel.ColorTableBias[0]; - gBias = ctx->Pixel.ColorTableBias[1]; - bBias = ctx->Pixel.ColorTableBias[2]; - aBias = ctx->Pixel.ColorTableBias[3]; + table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; + scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]; + bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]; break; case GL_TEXTURE_COLOR_TABLE_SGI: if (!ctx->Extensions.SGI_texture_color_table) { @@ -559,36 +533,18 @@ _mesa_ColorSubTable( GLenum target, GLsizei start, return; } table = &(texUnit->ColorTable); - rScale = ctx->Pixel.TextureColorTableScale[0]; - gScale = ctx->Pixel.TextureColorTableScale[1]; - bScale = ctx->Pixel.TextureColorTableScale[2]; - aScale = ctx->Pixel.TextureColorTableScale[3]; - rBias = ctx->Pixel.TextureColorTableBias[0]; - gBias = ctx->Pixel.TextureColorTableBias[1]; - bBias = ctx->Pixel.TextureColorTableBias[2]; - aBias = ctx->Pixel.TextureColorTableBias[3]; + scale = ctx->Pixel.TextureColorTableScale; + bias = ctx->Pixel.TextureColorTableBias; break; case GL_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->PostConvolutionColorTable; - rScale = ctx->Pixel.PCCTscale[0]; - gScale = ctx->Pixel.PCCTscale[1]; - bScale = ctx->Pixel.PCCTscale[2]; - aScale = ctx->Pixel.PCCTscale[3]; - rBias = ctx->Pixel.PCCTbias[0]; - gBias = ctx->Pixel.PCCTbias[1]; - bBias = ctx->Pixel.PCCTbias[2]; - aBias = ctx->Pixel.PCCTbias[3]; + table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; + scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]; + bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->PostColorMatrixColorTable; - rScale = ctx->Pixel.PCMCTscale[0]; - gScale = ctx->Pixel.PCMCTscale[1]; - bScale = ctx->Pixel.PCMCTscale[2]; - aScale = ctx->Pixel.PCMCTscale[3]; - rBias = ctx->Pixel.PCMCTbias[0]; - gBias = ctx->Pixel.PCMCTbias[1]; - bBias = ctx->Pixel.PCMCTbias[2]; - aBias = ctx->Pixel.PCMCTbias[3]; + table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; + scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; + bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX]; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)"); @@ -623,10 +579,10 @@ _mesa_ColorSubTable( GLenum target, GLsizei start, store_colortable_entries(ctx, table, start, count, format, type, data, - rScale, rBias, - gScale, gBias, - bScale, bBias, - aScale, aBias); + scale[0], bias[0], + scale[1], bias[1], + scale[2], bias[2], + scale[3], bias[3]); if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) { /* per-texture object palette */ @@ -700,7 +656,7 @@ _mesa_GetColorTable( GLenum target, GLenum format, table = &ctx->Texture.Palette; break; case GL_COLOR_TABLE: - table = &ctx->ColorTable; + table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; break; case GL_TEXTURE_COLOR_TABLE_SGI: if (!ctx->Extensions.SGI_texture_color_table) { @@ -710,10 +666,10 @@ _mesa_GetColorTable( GLenum target, GLenum format, table = &(texUnit->ColorTable); break; case GL_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->PostConvolutionColorTable; + table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->PostColorMatrixColorTable; + table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)"); @@ -827,16 +783,10 @@ _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) switch (target) { case GL_COLOR_TABLE_SGI: if (pname == GL_COLOR_TABLE_SCALE_SGI) { - ctx->Pixel.ColorTableScale[0] = params[0]; - ctx->Pixel.ColorTableScale[1] = params[1]; - ctx->Pixel.ColorTableScale[2] = params[2]; - ctx->Pixel.ColorTableScale[3] = params[3]; + COPY_4V(ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION], params); } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - ctx->Pixel.ColorTableBias[0] = params[0]; - ctx->Pixel.ColorTableBias[1] = params[1]; - ctx->Pixel.ColorTableBias[2] = params[2]; - ctx->Pixel.ColorTableBias[3] = params[3]; + COPY_4V(ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION], params); } else { _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); @@ -849,16 +799,10 @@ _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) return; } if (pname == GL_COLOR_TABLE_SCALE_SGI) { - ctx->Pixel.TextureColorTableScale[0] = params[0]; - ctx->Pixel.TextureColorTableScale[1] = params[1]; - ctx->Pixel.TextureColorTableScale[2] = params[2]; - ctx->Pixel.TextureColorTableScale[3] = params[3]; + COPY_4V(ctx->Pixel.TextureColorTableScale, params); } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - ctx->Pixel.TextureColorTableBias[0] = params[0]; - ctx->Pixel.TextureColorTableBias[1] = params[1]; - ctx->Pixel.TextureColorTableBias[2] = params[2]; - ctx->Pixel.TextureColorTableBias[3] = params[3]; + COPY_4V(ctx->Pixel.TextureColorTableBias, params); } else { _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); @@ -867,16 +811,10 @@ _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) break; case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: if (pname == GL_COLOR_TABLE_SCALE_SGI) { - ctx->Pixel.PCCTscale[0] = params[0]; - ctx->Pixel.PCCTscale[1] = params[1]; - ctx->Pixel.PCCTscale[2] = params[2]; - ctx->Pixel.PCCTscale[3] = params[3]; + COPY_4V(ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION], params); } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - ctx->Pixel.PCCTbias[0] = params[0]; - ctx->Pixel.PCCTbias[1] = params[1]; - ctx->Pixel.PCCTbias[2] = params[2]; - ctx->Pixel.PCCTbias[3] = params[3]; + COPY_4V(ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION], params); } else { _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); @@ -885,16 +823,10 @@ _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) break; case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: if (pname == GL_COLOR_TABLE_SCALE_SGI) { - ctx->Pixel.PCMCTscale[0] = params[0]; - ctx->Pixel.PCMCTscale[1] = params[1]; - ctx->Pixel.PCMCTscale[2] = params[2]; - ctx->Pixel.PCMCTscale[3] = params[3]; + COPY_4V(ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX], params); } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - ctx->Pixel.PCMCTbias[0] = params[0]; - ctx->Pixel.PCMCTbias[1] = params[1]; - ctx->Pixel.PCMCTbias[2] = params[2]; - ctx->Pixel.PCMCTbias[3] = params[3]; + COPY_4V(ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX], params); } else { _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); @@ -981,24 +913,18 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) table = &ctx->Texture.Palette; break; case GL_COLOR_TABLE: - table = &ctx->ColorTable; + table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; if (pname == GL_COLOR_TABLE_SCALE_SGI) { - params[0] = ctx->Pixel.ColorTableScale[0]; - params[1] = ctx->Pixel.ColorTableScale[1]; - params[2] = ctx->Pixel.ColorTableScale[2]; - params[3] = ctx->Pixel.ColorTableScale[3]; + COPY_4V(params, ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]); return; } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - params[0] = ctx->Pixel.ColorTableBias[0]; - params[1] = ctx->Pixel.ColorTableBias[1]; - params[2] = ctx->Pixel.ColorTableBias[2]; - params[3] = ctx->Pixel.ColorTableBias[3]; + COPY_4V(params, ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]); return; } break; case GL_PROXY_COLOR_TABLE: - table = &ctx->ProxyColorTable; + table = &ctx->ProxyColorTable[COLORTABLE_PRECONVOLUTION]; break; case GL_TEXTURE_COLOR_TABLE_SGI: if (!ctx->Extensions.SGI_texture_color_table) { @@ -1007,17 +933,11 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) } table = &(texUnit->ColorTable); if (pname == GL_COLOR_TABLE_SCALE_SGI) { - params[0] = ctx->Pixel.TextureColorTableScale[0]; - params[1] = ctx->Pixel.TextureColorTableScale[1]; - params[2] = ctx->Pixel.TextureColorTableScale[2]; - params[3] = ctx->Pixel.TextureColorTableScale[3]; + COPY_4V(params, ctx->Pixel.TextureColorTableScale); return; } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - params[0] = ctx->Pixel.TextureColorTableBias[0]; - params[1] = ctx->Pixel.TextureColorTableBias[1]; - params[2] = ctx->Pixel.TextureColorTableBias[2]; - params[3] = ctx->Pixel.TextureColorTableBias[3]; + COPY_4V(params, ctx->Pixel.TextureColorTableBias); return; } break; @@ -1029,44 +949,32 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) table = &(texUnit->ProxyColorTable); break; case GL_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->PostConvolutionColorTable; + table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; if (pname == GL_COLOR_TABLE_SCALE_SGI) { - params[0] = ctx->Pixel.PCCTscale[0]; - params[1] = ctx->Pixel.PCCTscale[1]; - params[2] = ctx->Pixel.PCCTscale[2]; - params[3] = ctx->Pixel.PCCTscale[3]; + COPY_4V(params, ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]); return; } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - params[0] = ctx->Pixel.PCCTbias[0]; - params[1] = ctx->Pixel.PCCTbias[1]; - params[2] = ctx->Pixel.PCCTbias[2]; - params[3] = ctx->Pixel.PCCTbias[3]; + COPY_4V(params, ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]); return; } break; case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->ProxyPostConvolutionColorTable; + table = &ctx->ProxyColorTable[COLORTABLE_POSTCONVOLUTION]; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->PostColorMatrixColorTable; + table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; if (pname == GL_COLOR_TABLE_SCALE_SGI) { - params[0] = ctx->Pixel.PCMCTscale[0]; - params[1] = ctx->Pixel.PCMCTscale[1]; - params[2] = ctx->Pixel.PCMCTscale[2]; - params[3] = ctx->Pixel.PCMCTscale[3]; + COPY_4V(params, ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]); return; } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - params[0] = ctx->Pixel.PCMCTbias[0]; - params[1] = ctx->Pixel.PCMCTbias[1]; - params[2] = ctx->Pixel.PCMCTbias[2]; - params[3] = ctx->Pixel.PCMCTbias[3]; + COPY_4V(params, ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX]); return; } break; case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->ProxyPostColorMatrixColorTable; + table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX]; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(target)"); @@ -1155,24 +1063,26 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) table = &ctx->Texture.Palette; break; case GL_COLOR_TABLE: - table = &ctx->ColorTable; + table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; if (pname == GL_COLOR_TABLE_SCALE_SGI) { - params[0] = (GLint) ctx->Pixel.ColorTableScale[0]; - params[1] = (GLint) ctx->Pixel.ColorTableScale[1]; - params[2] = (GLint) ctx->Pixel.ColorTableScale[2]; - params[3] = (GLint) ctx->Pixel.ColorTableScale[3]; + GLfloat *scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]; + params[0] = (GLint) scale[0]; + params[1] = (GLint) scale[1]; + params[2] = (GLint) scale[2]; + params[3] = (GLint) scale[3]; return; } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - params[0] = (GLint) ctx->Pixel.ColorTableBias[0]; - params[1] = (GLint) ctx->Pixel.ColorTableBias[1]; - params[2] = (GLint) ctx->Pixel.ColorTableBias[2]; - params[3] = (GLint) ctx->Pixel.ColorTableBias[3]; + GLfloat *bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]; + params[0] = (GLint) bias[0]; + params[1] = (GLint) bias[1]; + params[2] = (GLint) bias[2]; + params[3] = (GLint) bias[3]; return; } break; case GL_PROXY_COLOR_TABLE: - table = &ctx->ProxyColorTable; + table = &ctx->ProxyColorTable[COLORTABLE_PRECONVOLUTION]; break; case GL_TEXTURE_COLOR_TABLE_SGI: if (!ctx->Extensions.SGI_texture_color_table) { @@ -1203,44 +1113,48 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) table = &(texUnit->ProxyColorTable); break; case GL_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->PostConvolutionColorTable; + table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; if (pname == GL_COLOR_TABLE_SCALE_SGI) { - params[0] = (GLint) ctx->Pixel.PCCTscale[0]; - params[1] = (GLint) ctx->Pixel.PCCTscale[1]; - params[2] = (GLint) ctx->Pixel.PCCTscale[2]; - params[3] = (GLint) ctx->Pixel.PCCTscale[3]; + GLfloat *scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]; + params[0] = (GLint) scale[0]; + params[1] = (GLint) scale[1]; + params[2] = (GLint) scale[2]; + params[3] = (GLint) scale[3]; return; } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - params[0] = (GLint) ctx->Pixel.PCCTbias[0]; - params[1] = (GLint) ctx->Pixel.PCCTbias[1]; - params[2] = (GLint) ctx->Pixel.PCCTbias[2]; - params[3] = (GLint) ctx->Pixel.PCCTbias[3]; + GLfloat *bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]; + params[0] = (GLint) bias[0]; + params[1] = (GLint) bias[1]; + params[2] = (GLint) bias[2]; + params[3] = (GLint) bias[3]; return; } break; case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->ProxyPostConvolutionColorTable; + table = &ctx->ProxyColorTable[COLORTABLE_POSTCONVOLUTION]; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->PostColorMatrixColorTable; + table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; if (pname == GL_COLOR_TABLE_SCALE_SGI) { - params[0] = (GLint) ctx->Pixel.PCMCTscale[0]; - params[1] = (GLint) ctx->Pixel.PCMCTscale[1]; - params[2] = (GLint) ctx->Pixel.PCMCTscale[2]; - params[3] = (GLint) ctx->Pixel.PCMCTscale[3]; + GLfloat *scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; + params[0] = (GLint) scale[0]; + params[0] = (GLint) scale[1]; + params[0] = (GLint) scale[2]; + params[0] = (GLint) scale[3]; return; } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - params[0] = (GLint) ctx->Pixel.PCMCTbias[0]; - params[1] = (GLint) ctx->Pixel.PCMCTbias[1]; - params[2] = (GLint) ctx->Pixel.PCMCTbias[2]; - params[3] = (GLint) ctx->Pixel.PCMCTbias[3]; + GLfloat *bias = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; + params[0] = (GLint) bias[0]; + params[1] = (GLint) bias[1]; + params[2] = (GLint) bias[2]; + params[3] = (GLint) bias[3]; return; } break; case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->ProxyPostColorMatrixColorTable; + table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX]; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(target)"); @@ -1316,13 +1230,11 @@ _mesa_free_colortable_data( struct gl_color_table *p ) void _mesa_init_colortables( GLcontext * ctx ) { - /* Color tables */ - _mesa_init_colortable(&ctx->ColorTable); - _mesa_init_colortable(&ctx->ProxyColorTable); - _mesa_init_colortable(&ctx->PostConvolutionColorTable); - _mesa_init_colortable(&ctx->ProxyPostConvolutionColorTable); - _mesa_init_colortable(&ctx->PostColorMatrixColorTable); - _mesa_init_colortable(&ctx->ProxyPostColorMatrixColorTable); + GLuint i; + for (i = 0; i < COLORTABLE_MAX; i++) { + _mesa_init_colortable(&ctx->ColorTable[i]); + _mesa_init_colortable(&ctx->ProxyColorTable[i]); + } } @@ -1332,10 +1244,9 @@ _mesa_init_colortables( GLcontext * ctx ) void _mesa_free_colortables_data( GLcontext *ctx ) { - _mesa_free_colortable_data(&ctx->ColorTable); - _mesa_free_colortable_data(&ctx->ProxyColorTable); - _mesa_free_colortable_data(&ctx->PostConvolutionColorTable); - _mesa_free_colortable_data(&ctx->ProxyPostConvolutionColorTable); - _mesa_free_colortable_data(&ctx->PostColorMatrixColorTable); - _mesa_free_colortable_data(&ctx->ProxyPostColorMatrixColorTable); + GLuint i; + for (i = 0; i < COLORTABLE_MAX; i++) { + _mesa_free_colortable_data(&ctx->ColorTable[i]); + _mesa_free_colortable_data(&ctx->ProxyColorTable[i]); + } } diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 0d54c29949..11b4ad6400 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -663,24 +663,24 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state) /* GL_SGI_color_table */ case GL_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_color_table, cap); - if (ctx->Pixel.ColorTableEnabled == state) + if (ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.ColorTableEnabled = state; + ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] = state; break; case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_color_table, cap); - if (ctx->Pixel.PostConvolutionColorTableEnabled == state) + if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostConvolutionColorTableEnabled = state; + ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] = state; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_color_table, cap); - if (ctx->Pixel.PostColorMatrixColorTableEnabled == state) + if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostColorMatrixColorTableEnabled = state; + ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] = state; break; case GL_TEXTURE_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_texture_color_table, cap); @@ -1192,13 +1192,13 @@ _mesa_IsEnabled( GLenum cap ) /* GL_SGI_color_table */ case GL_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_color_table); - return ctx->Pixel.ColorTableEnabled; + return ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]; case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_color_table); - return ctx->Pixel.PostConvolutionColorTableEnabled; + return ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]; case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_color_table); - return ctx->Pixel.PostColorMatrixColorTableEnabled; + return ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]; /* GL_SGI_texture_color_table */ case GL_TEXTURE_COLOR_TABLE_SGI: diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 7601f32069..4eda349134 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1283,15 +1283,15 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) break; case GL_COLOR_TABLE_SGI: CHECK_EXT1(SGI_color_table, "GetBooleanv"); - params[0] = ctx->Pixel.ColorTableEnabled; + params[0] = ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]; break; case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: CHECK_EXT1(SGI_color_table, "GetBooleanv"); - params[0] = ctx->Pixel.PostConvolutionColorTableEnabled; + params[0] = ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: CHECK_EXT1(SGI_color_table, "GetBooleanv"); - params[0] = ctx->Pixel.PostColorMatrixColorTableEnabled; + params[0] = ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]; break; case GL_TEXTURE_COLOR_TABLE_SGI: CHECK_EXT1(SGI_texture_color_table, "GetBooleanv"); @@ -3110,15 +3110,15 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) break; case GL_COLOR_TABLE_SGI: CHECK_EXT1(SGI_color_table, "GetFloatv"); - params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.ColorTableEnabled); + params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]); break; case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: CHECK_EXT1(SGI_color_table, "GetFloatv"); - params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.PostConvolutionColorTableEnabled); + params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]); break; case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: CHECK_EXT1(SGI_color_table, "GetFloatv"); - params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.PostColorMatrixColorTableEnabled); + params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]); break; case GL_TEXTURE_COLOR_TABLE_SGI: CHECK_EXT1(SGI_texture_color_table, "GetFloatv"); @@ -4937,15 +4937,15 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) break; case GL_COLOR_TABLE_SGI: CHECK_EXT1(SGI_color_table, "GetIntegerv"); - params[0] = BOOLEAN_TO_INT(ctx->Pixel.ColorTableEnabled); + params[0] = BOOLEAN_TO_INT(ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]); break; case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: CHECK_EXT1(SGI_color_table, "GetIntegerv"); - params[0] = BOOLEAN_TO_INT(ctx->Pixel.PostConvolutionColorTableEnabled); + params[0] = BOOLEAN_TO_INT(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]); break; case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: CHECK_EXT1(SGI_color_table, "GetIntegerv"); - params[0] = BOOLEAN_TO_INT(ctx->Pixel.PostColorMatrixColorTableEnabled); + params[0] = BOOLEAN_TO_INT(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]); break; case GL_TEXTURE_COLOR_TABLE_SGI: CHECK_EXT1(SGI_texture_color_table, "GetIntegerv"); diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index 76417d2899..0b6cd3e5c5 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -624,11 +624,11 @@ StateVars = [ # GL_SGI_color_table / GL_ARB_imaging ( "GL_COLOR_TABLE_SGI", GLboolean, - ["ctx->Pixel.ColorTableEnabled"], "", ["SGI_color_table"] ), + ["ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]"], "", ["SGI_color_table"] ), ( "GL_POST_CONVOLUTION_COLOR_TABLE_SGI", GLboolean, - ["ctx->Pixel.PostConvolutionColorTableEnabled"], "", ["SGI_color_table"] ), + ["ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]"], "", ["SGI_color_table"] ), ( "GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI", GLboolean, - ["ctx->Pixel.PostColorMatrixColorTableEnabled"], "", ["SGI_color_table"] ), + ["ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]"], "", ["SGI_color_table"] ), # GL_SGI_texture_color_table ( "GL_TEXTURE_COLOR_TABLE_SGI", GLboolean, diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index f53730cbcf..cad9736b30 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1036,7 +1036,7 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps, } /* GL_COLOR_TABLE lookup */ if (transferOps & IMAGE_COLOR_TABLE_BIT) { - _mesa_lookup_rgba_float(&ctx->ColorTable, n, rgba); + _mesa_lookup_rgba_float(&ctx->ColorTable[COLORTABLE_PRECONVOLUTION], n, rgba); } /* convolution */ if (transferOps & IMAGE_CONVOLUTION_BIT) { @@ -1057,7 +1057,7 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps, } /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */ if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) { - _mesa_lookup_rgba_float(&ctx->PostConvolutionColorTable, n, rgba); + _mesa_lookup_rgba_float(&ctx->ColorTable[COLORTABLE_POSTCONVOLUTION], n, rgba); } /* color matrix transform */ if (transferOps & IMAGE_COLOR_MATRIX_BIT) { @@ -1065,7 +1065,7 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps, } /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */ if (transferOps & IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT) { - _mesa_lookup_rgba_float(&ctx->PostColorMatrixColorTable, n, rgba); + _mesa_lookup_rgba_float(&ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX], n, rgba); } /* update histogram count */ if (transferOps & IMAGE_HISTOGRAM_BIT) { diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 321adfe615..65246eb116 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -383,6 +383,13 @@ enum { BUFFER_BIT_COLOR7) +/** The pixel transfer path has three color tables: */ +/*@{*/ +#define COLORTABLE_PRECONVOLUTION 0 +#define COLORTABLE_POSTCONVOLUTION 1 +#define COLORTABLE_POSTCOLORMATRIX 2 +#define COLORTABLE_MAX 3 +/*@}*/ /** @@ -663,9 +670,7 @@ struct gl_enable_attrib GLboolean Blend; GLbitfield ClipPlanes; GLboolean ColorMaterial; - GLboolean ColorTable; /* SGI_color_table */ - GLboolean PostColorMatrixColorTable; /* SGI_color_table */ - GLboolean PostConvolutionColorTable; /* SGI_color_table */ + GLboolean ColorTable[COLORTABLE_MAX]; GLboolean Convolution1D; GLboolean Convolution2D; GLboolean Separable2D; @@ -1016,11 +1021,10 @@ struct gl_pixel_attrib GLboolean MapColorFlag; GLboolean MapStencilFlag; - /* Color table lookup (GL_SGI_color_table) */ - /* Note: actual table is not part of this attrib group */ - GLfloat ColorTableScale[4]; - GLfloat ColorTableBias[4]; - GLboolean ColorTableEnabled; + /* There are multiple color table stages: */ + GLboolean ColorTableEnabled[COLORTABLE_MAX]; + GLfloat ColorTableScale[COLORTABLE_MAX][4]; /**< RGBA */ + GLfloat ColorTableBias[COLORTABLE_MAX][4]; /**< RGBA */ /* Convolution (GL_EXT_convolution) */ GLboolean Convolution1DEnabled; @@ -1033,23 +1037,11 @@ struct gl_pixel_attrib GLfloat PostConvolutionScale[4]; /**< RGBA */ GLfloat PostConvolutionBias[4]; /**< RGBA */ - /* Post-convolution color table */ - /* Note: actual table is not part of this attrib group */ - GLboolean PostConvolutionColorTableEnabled; - GLfloat PCCTscale[4]; /** Post Convolution Color Table scale */ - GLfloat PCCTbias[4]; /** Post Convolution Color Table bias */ - /* Color matrix (GL_SGI_color_matrix) */ /* Note: the color matrix is not part of this attrib group */ GLfloat PostColorMatrixScale[4]; /**< RGBA */ GLfloat PostColorMatrixBias[4]; /**< RGBA */ - /* Post color matrix color table */ - /* Note: actual table is not part of this attrib group */ - GLboolean PostColorMatrixColorTableEnabled; - GLfloat PCMCTscale[4]; /** Post Color Matrix Color Table scale */ - GLfloat PCMCTbias[4]; /** Post Color Matrix Color Table bias */ - /* Histogram & minmax (GL_EXT_histogram) */ /* Note: histogram and minmax data are not part of this attrib group */ GLboolean HistogramEnabled; @@ -2934,12 +2926,14 @@ struct __GLcontextRec struct gl_feedback Feedback; /**< Feedback */ struct gl_selection Select; /**< Selection */ - struct gl_color_table ColorTable; /**< Pre-convolution */ - struct gl_color_table ProxyColorTable; /**< Pre-convolution */ + struct gl_color_table ColorTable[COLORTABLE_MAX]; + struct gl_color_table ProxyColorTable[COLORTABLE_MAX]; +#if 0 struct gl_color_table PostConvolutionColorTable; struct gl_color_table ProxyPostConvolutionColorTable; struct gl_color_table PostColorMatrixColorTable; struct gl_color_table ProxyPostColorMatrixColorTable; +#endif struct gl_program_state Program; /**< for vertex or fragment progs */ struct gl_vertex_program_state VertexProgram; /**< GL_ARB/NV_vertex_program */ diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index ae014a23c4..b9e23d80b6 100644 --- a/src/mesa/main/pixel.c +++ b/src/mesa/main/pixel.c @@ -1367,7 +1367,7 @@ update_image_transfer_state(GLcontext *ctx) if (ctx->Pixel.MapColorFlag) mask |= IMAGE_MAP_COLOR_BIT; - if (ctx->Pixel.ColorTableEnabled) + if (ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]) mask |= IMAGE_COLOR_TABLE_BIT; if (ctx->Pixel.Convolution1DEnabled || @@ -1386,7 +1386,7 @@ update_image_transfer_state(GLcontext *ctx) } } - if (ctx->Pixel.PostConvolutionColorTableEnabled) + if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]) mask |= IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT; if (ctx->ColorMatrixStack.Top->type != MATRIX_IDENTITY || @@ -1400,7 +1400,7 @@ update_image_transfer_state(GLcontext *ctx) ctx->Pixel.PostColorMatrixBias[3] != 0.0F) mask |= IMAGE_COLOR_MATRIX_BIT; - if (ctx->Pixel.PostColorMatrixColorTableEnabled) + if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]) mask |= IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT; if (ctx->Pixel.HistogramEnabled) @@ -1477,15 +1477,11 @@ _mesa_init_pixel( GLcontext *ctx ) ctx->Pixel.MinMaxEnabled = GL_FALSE; ASSIGN_4V(ctx->Pixel.PostColorMatrixScale, 1.0, 1.0, 1.0, 1.0); ASSIGN_4V(ctx->Pixel.PostColorMatrixBias, 0.0, 0.0, 0.0, 0.0); - ASSIGN_4V(ctx->Pixel.ColorTableScale, 1.0, 1.0, 1.0, 1.0); - ASSIGN_4V(ctx->Pixel.ColorTableBias, 0.0, 0.0, 0.0, 0.0); - ASSIGN_4V(ctx->Pixel.PCCTscale, 1.0, 1.0, 1.0, 1.0); - ASSIGN_4V(ctx->Pixel.PCCTbias, 0.0, 0.0, 0.0, 0.0); - ASSIGN_4V(ctx->Pixel.PCMCTscale, 1.0, 1.0, 1.0, 1.0); - ASSIGN_4V(ctx->Pixel.PCMCTbias, 0.0, 0.0, 0.0, 0.0); - ctx->Pixel.ColorTableEnabled = GL_FALSE; - ctx->Pixel.PostConvolutionColorTableEnabled = GL_FALSE; - ctx->Pixel.PostColorMatrixColorTableEnabled = GL_FALSE; + for (i = 0; i < COLORTABLE_MAX; i++) { + ASSIGN_4V(ctx->Pixel.ColorTableScale[i], 1.0, 1.0, 1.0, 1.0); + ASSIGN_4V(ctx->Pixel.ColorTableBias[i], 0.0, 0.0, 0.0, 0.0); + ctx->Pixel.ColorTableEnabled[i] = GL_FALSE; + } ctx->Pixel.Convolution1DEnabled = GL_FALSE; ctx->Pixel.Convolution2DEnabled = GL_FALSE; ctx->Pixel.Separable2DEnabled = GL_FALSE; -- cgit v1.2.3 From e5070bc3ca75dee31034cc543f3d2ee04e5dc032 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 16 Mar 2007 11:00:07 -0600 Subject: Assorted fixes for dealing with zero-size frame/renderbuffers. In xmesa_check_and_update_buffer_size() handle xmctx==NULL correctly: still call _mesa_resize_framebufer(). If we don't we can wind up in a situation where the framebuffer size is non-zero but an attached renderbuffer size is still initialized to zero. This inconsistancy can later cause problems. Check for zero-size renderbuffers in update_color_draw_buffers() and update_color_read_buffer(). See bug 7205. --- src/mesa/drivers/x11/xm_api.c | 14 ++++++++------ src/mesa/drivers/x11/xm_buffer.c | 39 +++++++++++++++++++++++---------------- src/mesa/main/framebuffer.c | 7 +++++-- src/mesa/main/renderbuffer.c | 26 +++++++++++++++----------- 4 files changed, 51 insertions(+), 35 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index ba020fc3d6..b513dc8d40 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1842,16 +1842,18 @@ XMesaDestroyBuffer(XMesaBuffer b) * 1. the first time a buffer is bound to a context. * 2. from glViewport to poll for window size changes * 3. from the XMesaResizeBuffers() API function. + * Note: it's possible (and legal) for xmctx to be NULL. That can happen + * when resizing a buffer when no rendering context is bound. */ void xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer) { GLuint width, height; - xmesa_get_window_size(xmctx->display, drawBuffer, &width, &height); + xmesa_get_window_size(drawBuffer->display, drawBuffer, &width, &height); if (drawBuffer->mesa_buffer.Width != width || drawBuffer->mesa_buffer.Height != height) { - _mesa_resize_framebuffer(&(xmctx->mesa), - &(drawBuffer->mesa_buffer), width, height); + GLcontext *ctx = xmctx ? &xmctx->mesa : NULL; + _mesa_resize_framebuffer(ctx, &(drawBuffer->mesa_buffer), width, height); } drawBuffer->mesa_buffer.Initialized = GL_TRUE; /* XXX TEMPORARY? */ } @@ -2175,7 +2177,7 @@ void XMesaSwapBuffers( XMesaBuffer b ) } #endif if (b->backxrb->ximage) { - /* Copy Ximage from host's memory to server's window */ + /* Copy Ximage (back buf) from client memory to server window */ #if defined(USE_XSHM) && !defined(XFree86Server) if (b->shm) { /*_glthread_LOCK_MUTEX(_xmesa_lock);*/ @@ -2197,8 +2199,8 @@ void XMesaSwapBuffers( XMesaBuffer b ) /*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/ } } - else { - /* Copy pixmap to window on server */ + else if (b->backxrb->pixmap) { + /* Copy pixmap (back buf) to window (front buf) on server */ /*_glthread_LOCK_MUTEX(_xmesa_lock);*/ XMesaCopyArea( b->xm_visual->display, b->backxrb->pixmap, /* source drawable */ diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c index 73c46b1fe6..c1fa23328f 100644 --- a/src/mesa/drivers/x11/xm_buffer.c +++ b/src/mesa/drivers/x11/xm_buffer.c @@ -168,9 +168,6 @@ alloc_back_shm_ximage(XMesaBuffer b, GLuint width, GLuint height) static void alloc_back_buffer(XMesaBuffer b, GLuint width, GLuint height) { - if (width == 0 || height == 0) - return; - if (b->db_mode == BACK_XIMAGE) { /* Deallocate the old backxrb->ximage, if any */ if (b->backxrb->ximage) { @@ -186,6 +183,9 @@ alloc_back_buffer(XMesaBuffer b, GLuint width, GLuint height) b->backxrb->ximage = NULL; } + if (width == 0 || height == 0) + return; + /* Allocate new back buffer */ #ifdef XFree86Server /* Allocate a regular XImage for the back buffer. */ @@ -218,20 +218,20 @@ alloc_back_buffer(XMesaBuffer b, GLuint width, GLuint height) b->backxrb->pixmap = None; } else if (b->db_mode == BACK_PIXMAP) { - if (!width) - width = 1; - if (!height) - height = 1; - /* Free the old back pixmap */ if (b->backxrb->pixmap) { - XMesaFreePixmap(b->xm_visual->display, b->backxrb->pixmap); + XMesaFreePixmap(b->xm_visual->display, b->backxrb->pixmap); + b->backxrb->pixmap = 0; } - /* Allocate new back pixmap */ - b->backxrb->pixmap = XMesaCreatePixmap(b->xm_visual->display, - b->frontxrb->drawable, - width, height, - GET_VISUAL_DEPTH(b->xm_visual)); + + if (width > 0 && height > 0) { + /* Allocate new back pixmap */ + b->backxrb->pixmap = XMesaCreatePixmap(b->xm_visual->display, + b->frontxrb->drawable, + width, height, + GET_VISUAL_DEPTH(b->xm_visual)); + } + b->backxrb->ximage = NULL; } } @@ -250,6 +250,7 @@ xmesa_delete_renderbuffer(struct gl_renderbuffer *rb) /** * Reallocate renderbuffer storage for front color buffer. + * Called via gl_renderbuffer::AllocStorage() */ static GLboolean xmesa_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, @@ -260,6 +261,7 @@ xmesa_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, /* just clear these to be sure we don't accidentally use them */ xrb->origin1 = NULL; xrb->origin2 = NULL; + xrb->origin3 = NULL; xrb->origin4 = NULL; /* for the FLIP macro: */ @@ -275,6 +277,7 @@ xmesa_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, /** * Reallocate renderbuffer storage for back color buffer. + * Called via gl_renderbuffer::AllocStorage() */ static GLboolean xmesa_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb, @@ -309,8 +312,12 @@ xmesa_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb, xrb->origin4 = (GLuint *) xrb->ximage->data + xrb->width4 * (height - 1); } else { - /* this assertion will fail if we happend to run out of memory */ - /*assert(xrb->pixmap);*/ + /* out of memory or buffer size is 0 x 0 */ + xrb->width1 = xrb->width2 = xrb->width3 = xrb->width4 = 0; + xrb->origin1 = NULL; + xrb->origin2 = NULL; + xrb->origin3 = NULL; + xrb->origin4 = NULL; } return GL_TRUE; diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 3136a950e0..cd4f594aa2 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -647,7 +647,7 @@ update_color_draw_buffers(GLcontext *ctx, struct gl_framebuffer *fb) const GLuint bufferBit = 1 << i; if (bufferBit & bufferMask) { struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; - if (rb) { + if (rb && rb->Width > 0 && rb->Height > 0) { fb->_ColorDrawBuffers[output][count] = rb; count++; } @@ -673,7 +673,10 @@ static void update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb) { (void) ctx; - if (fb->_ColorReadBufferIndex == -1 || fb->DeletePending) { + if (fb->_ColorReadBufferIndex == -1 || + fb->DeletePending || + fb->Width == 0 || + fb->Height == 0) { fb->_ColorReadBuffer = NULL; /* legal! */ } else { diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index 1cc95a7d3b..e387c42c34 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -1192,18 +1192,22 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, ASSERT(rb->PutMonoValues); /* free old buffer storage */ - if (rb->Data) + if (rb->Data) { _mesa_free(rb->Data); - - /* allocate new buffer storage */ - rb->Data = _mesa_malloc(width * height * pixelSize); - if (rb->Data == NULL) { - rb->Width = 0; - rb->Height = 0; - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "software renderbuffer allocation (%d x %d x %d)", - width, height, pixelSize); - return GL_FALSE; + rb->Data = NULL; + } + + if (width > 0 && height > 0) { + /* allocate new buffer storage */ + rb->Data = _mesa_malloc(width * height * pixelSize); + if (rb->Data == NULL) { + rb->Width = 0; + rb->Height = 0; + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "software renderbuffer allocation (%d x %d x %d)", + width, height, pixelSize); + return GL_FALSE; + } } rb->Width = width; -- cgit v1.2.3 From ee5b7f0574c6c5bce9ab75a2825f1fe089a57fa5 Mon Sep 17 00:00:00 2001 From: Haihao Xiang Date: Sat, 17 Mar 2007 09:42:36 -0600 Subject: fix some format conversion bugs in glGetTexImage(), bug 10288 --- src/mesa/main/texstore.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/mesa/main') diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 994fb16730..2098bdddbf 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -3608,6 +3608,25 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level, GLint col; for (col = 0; col < width; col++) { (*texImage->FetchTexelf)(texImage, col, row, img, rgba[col]); + if (texImage->TexFormat->BaseFormat == GL_ALPHA) { + rgba[col][RCOMP] = 0.0; + rgba[col][GCOMP] = 0.0; + rgba[col][BCOMP] = 0.0; + } + else if (texImage->TexFormat->BaseFormat == GL_LUMINANCE) { + rgba[col][GCOMP] = 0.0; + rgba[col][BCOMP] = 0.0; + rgba[col][ACOMP] = 1.0; + } + else if (texImage->TexFormat->BaseFormat == GL_LUMINANCE_ALPHA) { + rgba[col][GCOMP] = 0.0; + rgba[col][BCOMP] = 0.0; + } + else if (texImage->TexFormat->BaseFormat == GL_INTENSITY) { + rgba[col][GCOMP] = 0.0; + rgba[col][BCOMP] = 0.0; + rgba[col][ACOMP] = 1.0; + } } _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, format, type, dest, -- cgit v1.2.3 From b6fe1bdd4da806895f90f3f5be4fb364d6f1f64a Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Sun, 18 Mar 2007 18:34:21 +0800 Subject: mesa: enhance fxt1_quantize_ALPHA1 If possible, let minCol != maxCol --- src/mesa/main/texcompress_fxt1.c | 77 +++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 33 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c index d3011cedce..411d51cfcc 100644 --- a/src/mesa/main/texcompress_fxt1.c +++ b/src/mesa/main/texcompress_fxt1.c @@ -752,44 +752,55 @@ fxt1_quantize_ALPHA1 (GLuint *cc, GLint minColL = 0, maxColL = 0; GLint minColR = 0, maxColR = 0; GLint sumL = 0, sumR = 0; - + GLint nn_comp; /* Our solution here is to find the darkest and brightest colors in * the 4x4 tile and use those as the two representative colors. * There are probably better algorithms to use (histogram-based). */ - minSum = 2000; /* big enough */ - maxSum = -1; /* small enough */ - for (k = 0; k < N_TEXELS / 2; k++) { - GLint sum = 0; - for (i = 0; i < n_comp; i++) { - sum += input[k][i]; - } - if (minSum > sum) { - minSum = sum; - minColL = k; - } - if (maxSum < sum) { - maxSum = sum; - maxColL = k; - } - sumL += sum; + nn_comp = n_comp; + while ((minColL == maxColL) && nn_comp) { + minSum = 2000; /* big enough */ + maxSum = -1; /* small enough */ + for (k = 0; k < N_TEXELS / 2; k++) { + GLint sum = 0; + for (i = 0; i < nn_comp; i++) { + sum += input[k][i]; + } + if (minSum > sum) { + minSum = sum; + minColL = k; + } + if (maxSum < sum) { + maxSum = sum; + maxColL = k; + } + sumL += sum; + } + + nn_comp--; } - minSum = 2000; /* big enough */ - maxSum = -1; /* small enough */ - for (; k < N_TEXELS; k++) { - GLint sum = 0; - for (i = 0; i < n_comp; i++) { - sum += input[k][i]; - } - if (minSum > sum) { - minSum = sum; - minColR = k; - } - if (maxSum < sum) { - maxSum = sum; - maxColR = k; - } - sumR += sum; + + nn_comp = n_comp; + while ((minColR == maxColR) && nn_comp) { + minSum = 2000; /* big enough */ + maxSum = -1; /* small enough */ + for (k = N_TEXELS / 2; k < N_TEXELS; k++) { + GLint sum = 0; + for (i = 0; i < nn_comp; i++) { + sum += input[k][i]; + } + if (minSum > sum) { + minSum = sum; + minColR = k; + } + if (maxSum < sum) { + maxSum = sum; + maxColR = k; + } + sumR += sum; + } + + nn_comp--; } /* choose the common vector (yuck!) */ -- cgit v1.2.3 From bb02092d749ff9d58a13fd99f66154504b4f3dd1 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Sun, 18 Mar 2007 18:44:51 +0800 Subject: mesa: SWAP_BUFF support when calling DrawPixels(DEPTH_COMPONENT) or TexImage(DEPTH_COMPONENT) --- src/mesa/main/image.c | 98 +++++++++++++++++++++------------------------ src/mesa/swrast/s_drawpix.c | 6 ++- 2 files changed, 49 insertions(+), 55 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index cad9736b30..44729b7419 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -3877,6 +3877,22 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n, } } +#define DEPTH_VALUES(GLTYPE, GLTYPE2FLOAT) \ + do { \ + GLuint i; \ + const GLTYPE *src = (const GLTYPE *)source; \ + for (i = 0; i < n; i++) { \ + GLTYPE value = src[i]; \ + if (srcPacking->SwapBytes) { \ + if (sizeof(GLTYPE) == 2) { \ + SWAP2BYTE(value); \ + } else if (sizeof(GLTYPE) == 4) { \ + SWAP4BYTE(value); \ + } \ + } \ + depthValues[i] = CLAMP(GLTYPE2FLOAT(value), 0.0F, 1.0F); \ + } \ + } while (0) void _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, @@ -3898,59 +3914,23 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, switch (srcType) { case GL_BYTE: - { - GLuint i; - const GLubyte *src = (const GLubyte *) source; - for (i = 0; i < n; i++) { - depthValues[i] = BYTE_TO_FLOAT(src[i]); - } - } - break; + DEPTH_VALUES(GLbyte, BYTE_TO_FLOAT); + break; case GL_UNSIGNED_BYTE: - { - GLuint i; - const GLubyte *src = (const GLubyte *) source; - for (i = 0; i < n; i++) { - depthValues[i] = UBYTE_TO_FLOAT(src[i]); - } - } - break; + DEPTH_VALUES(GLubyte, UBYTE_TO_FLOAT); + break; case GL_SHORT: - { - GLuint i; - const GLshort *src = (const GLshort *) source; - for (i = 0; i < n; i++) { - depthValues[i] = SHORT_TO_FLOAT(src[i]); - } - } - break; + DEPTH_VALUES(GLshort, SHORT_TO_FLOAT); + break; case GL_UNSIGNED_SHORT: - { - GLuint i; - const GLushort *src = (const GLushort *) source; - for (i = 0; i < n; i++) { - depthValues[i] = USHORT_TO_FLOAT(src[i]); - } - } - break; + DEPTH_VALUES(GLushort, USHORT_TO_FLOAT); + break; case GL_INT: - { - GLuint i; - const GLint *src = (const GLint *) source; - for (i = 0; i < n; i++) { - depthValues[i] = INT_TO_FLOAT(src[i]); - } - } - break; + DEPTH_VALUES(GLint, INT_TO_FLOAT); + break; case GL_UNSIGNED_INT: - { - GLuint i; - const GLuint *src = (const GLuint *) source; - for (i = 0; i < n; i++) { - depthValues[i] = UINT_TO_FLOAT(src[i]); - } - } - break; + DEPTH_VALUES(GLuint, UINT_TO_FLOAT); + break; case GL_UNSIGNED_INT_24_8_EXT: /* GL_EXT_packed_depth_stencil */ if (dstType == GL_UNSIGNED_INT && depthScale == (GLfloat) 0xffffff && @@ -3960,7 +3940,11 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLuint *zValues = (GLuint *) dest; GLuint i; for (i = 0; i < n; i++) { - zValues[i] = src[i] & 0xffffff00; + GLuint value = src[i]; + if (srcPacking->SwapBytes) { + SWAP4BYTE(value); + } + zValues[i] = value & 0xffffff00; } return; } @@ -3969,19 +3953,27 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, const GLfloat scale = 1.0f / 0xffffff; GLuint i; for (i = 0; i < n; i++) { - depthValues[i] = (src[i] >> 8) * scale; + GLuint value = src[i]; + if (srcPacking->SwapBytes) { + SWAP4BYTE(value); + } + depthValues[i] = (value >> 8) * scale; } } break; case GL_FLOAT: - _mesa_memcpy(depthValues, source, n * sizeof(GLfloat)); - break; + DEPTH_VALUES(GLfloat, 1*); + break; case GL_HALF_FLOAT_ARB: { GLuint i; const GLhalfARB *src = (const GLhalfARB *) source; for (i = 0; i < n; i++) { - depthValues[i] = _mesa_half_to_float(src[i]); + GLhalfARB value = src[i]; + if (srcPacking->SwapBytes) { + SWAP2BYTE(value); + } + depthValues[i] = _mesa_half_to_float(value); } } break; diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index d945a871ae..d97d53e83b 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -452,7 +452,8 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, && !scaleOrBias && !zoom && ctx->Visual.rgbMode - && width <= MAX_WIDTH) { + && width <= MAX_WIDTH + && !unpack->SwapBytes) { /* Special case: directly write 16-bit depth values */ GLint row; for (row = 0; row < height; row++) { @@ -472,7 +473,8 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, && !scaleOrBias && !zoom && ctx->Visual.rgbMode - && width <= MAX_WIDTH) { + && width <= MAX_WIDTH + && !unpack->SwapBytes) { /* Special case: shift 32-bit values down to Visual.depthBits */ const GLint shift = 32 - ctx->DrawBuffer->Visual.depthBits; GLint row; -- cgit v1.2.3 From 704cd61120443501530279937a144a5dd4b6399e Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Wed, 21 Mar 2007 10:50:19 +0800 Subject: mesa: revert f9f79c8d770e696249bd98c68b563f887562c974 to fix #10232 Table6.1(in gl2.1) has been applied for glGetTexImage before calling into _mesa_pack_rgba_span_float. --- src/mesa/main/image.c | 19 +++++-------------- src/mesa/main/mtypes.h | 1 - src/mesa/main/texstore.c | 2 +- 3 files changed, 6 insertions(+), 16 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 44729b7419..394a7c65cd 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1211,24 +1211,15 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4], if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) { /* compute luminance values */ - if (transferOps & IMAGE_RED_TO_LUMINANCE) { - /* Luminance = Red (glGetTexImage) */ + if (dstType != GL_FLOAT || ctx->Color.ClampReadColor == GL_TRUE) { for (i = 0; i < n; i++) { - luminance[i] = rgba[i][RCOMP]; + GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; + luminance[i] = CLAMP(sum, 0.0F, 1.0F); } } else { - /* Luminance = Red + Green + Blue (glReadPixels) */ - if (dstType != GL_FLOAT || ctx->Color.ClampReadColor == GL_TRUE) { - for (i = 0; i < n; i++) { - GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; - luminance[i] = CLAMP(sum, 0.0F, 1.0F); - } - } - else { - for (i = 0; i < n; i++) { - luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; - } + for (i = 0; i < n; i++) { + luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; } } } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 65246eb116..df77c6cbf9 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2562,7 +2562,6 @@ struct matrix_stack #define IMAGE_HISTOGRAM_BIT 0x200 #define IMAGE_MIN_MAX_BIT 0x400 #define IMAGE_CLAMP_BIT 0x800 /* extra */ -#define IMAGE_RED_TO_LUMINANCE 0x1000 /** Pixel Transfer ops up to convolution */ diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 2098bdddbf..a570525155 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -3630,7 +3630,7 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level, } _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, format, type, dest, - &ctx->Pack, IMAGE_RED_TO_LUMINANCE); + &ctx->Pack, 0x0 /*image xfer ops*/); } /* format */ } /* row */ } /* img */ -- cgit v1.2.3