diff options
author | Eric Anholt <eric@anholt.net> | 2010-09-09 19:37:15 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2010-09-23 13:25:45 -0700 |
commit | a62efdf82c20747feb11dfd7756f0579aa914b57 (patch) | |
tree | bec6c2cfa1e9bb626fb90ecadb2b288dc5daa2a1 /src/mesa | |
parent | 73578ba9c4938db3a23198c3a2ddf843cfc4f700 (diff) |
mesa: Remove EXT_convolution.
More optional code.
Diffstat (limited to 'src/mesa')
27 files changed, 63 insertions, 2210 deletions
diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c index f92cdc5a777..aee73b53bb3 100644 --- a/src/mesa/drivers/common/driverfuncs.c +++ b/src/mesa/drivers/common/driverfuncs.c @@ -122,8 +122,6 @@ _mesa_init_driver_functions(struct dd_function_table *driver) /* imaging */ driver->CopyColorTable = _mesa_meta_CopyColorTable; driver->CopyColorSubTable = _mesa_meta_CopyColorSubTable; - driver->CopyConvolutionFilter1D = _mesa_meta_CopyConvolutionFilter1D; - driver->CopyConvolutionFilter2D = _mesa_meta_CopyConvolutionFilter2D; /* Vertex/fragment programs */ driver->BindProgram = NULL; diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 87d116ad9f1..16ca42f7b5e 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -40,7 +40,6 @@ #include "main/bufferobj.h" #include "main/buffers.h" #include "main/colortab.h" -#include "main/convolve.h" #include "main/depth.h" #include "main/enable.h" #include "main/fbobject.h" @@ -128,9 +127,6 @@ struct save_state GLfloat AlphaBias, AlphaScale; GLfloat DepthBias, DepthScale; GLboolean MapColorFlag; - GLboolean Convolution1DEnabled; - GLboolean Convolution2DEnabled; - GLboolean Separable2DEnabled; /** META_RASTERIZATION */ GLenum FrontPolygonMode, BackPolygonMode; @@ -389,9 +385,6 @@ _mesa_meta_begin(GLcontext *ctx, GLbitfield state) save->AlphaScale = ctx->Pixel.AlphaScale; save->AlphaBias = ctx->Pixel.AlphaBias; save->MapColorFlag = ctx->Pixel.MapColorFlag; - save->Convolution1DEnabled = ctx->Pixel.Convolution1DEnabled; - save->Convolution2DEnabled = ctx->Pixel.Convolution2DEnabled; - save->Separable2DEnabled = ctx->Pixel.Separable2DEnabled; ctx->Pixel.RedScale = 1.0F; ctx->Pixel.RedBias = 0.0F; ctx->Pixel.GreenScale = 1.0F; @@ -401,9 +394,6 @@ _mesa_meta_begin(GLcontext *ctx, GLbitfield state) ctx->Pixel.AlphaScale = 1.0F; ctx->Pixel.AlphaBias = 0.0F; ctx->Pixel.MapColorFlag = GL_FALSE; - ctx->Pixel.Convolution1DEnabled = GL_FALSE; - ctx->Pixel.Convolution2DEnabled = GL_FALSE; - ctx->Pixel.Separable2DEnabled = GL_FALSE; /* XXX more state */ ctx->NewState |=_NEW_PIXEL; } @@ -638,9 +628,6 @@ _mesa_meta_end(GLcontext *ctx) ctx->Pixel.AlphaScale = save->AlphaScale; ctx->Pixel.AlphaBias = save->AlphaBias; ctx->Pixel.MapColorFlag = save->MapColorFlag; - ctx->Pixel.Convolution1DEnabled = save->Convolution1DEnabled; - ctx->Pixel.Convolution2DEnabled = save->Convolution2DEnabled; - ctx->Pixel.Separable2DEnabled = save->Separable2DEnabled; /* XXX more state */ ctx->NewState |=_NEW_PIXEL; } @@ -2579,14 +2566,6 @@ copy_tex_image(GLcontext *ctx, GLuint dims, GLenum target, GLint level, format, type, &ctx->Pack, buf); _mesa_meta_end(ctx); - /* - * Prepare for new texture image size/data - */ - if (_mesa_is_color_format(internalFormat)) { - _mesa_adjust_image_for_convolution(ctx, 2, - &postConvWidth, &postConvHeight); - } - if (texImage->Data) { ctx->Driver.FreeTexImageData(ctx, texImage); } @@ -2804,64 +2783,3 @@ _mesa_meta_CopyColorSubTable(GLcontext *ctx,GLenum target, GLsizei start, free(buf); } - - -void -_mesa_meta_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target, - GLenum internalFormat, - GLint x, GLint y, GLsizei width) -{ - GLfloat *buf; - - buf = (GLfloat *) malloc(width * 4 * sizeof(GLfloat)); - if (!buf) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyConvolutionFilter2D"); - return; - } - - /* - * Read image from framebuffer (disable pixel transfer ops) - */ - _mesa_meta_begin(ctx, META_PIXEL_STORE | META_PIXEL_TRANSFER); - _mesa_update_state(ctx); - ctx->Driver.ReadPixels(ctx, x, y, width, 1, - GL_RGBA, GL_FLOAT, &ctx->Pack, buf); - - _mesa_ConvolutionFilter1D(target, internalFormat, width, - GL_RGBA, GL_FLOAT, buf); - - _mesa_meta_end(ctx); - - free(buf); -} - - -void -_mesa_meta_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target, - GLenum internalFormat, GLint x, GLint y, - GLsizei width, GLsizei height) -{ - GLfloat *buf; - - buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - if (!buf) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyConvolutionFilter2D"); - return; - } - - /* - * Read image from framebuffer (disable pixel transfer ops) - */ - _mesa_meta_begin(ctx, META_PIXEL_STORE | META_PIXEL_TRANSFER); - _mesa_update_state(ctx); - - ctx->Driver.ReadPixels(ctx, x, y, width, height, - GL_RGBA, GL_FLOAT, &ctx->Pack, buf); - - _mesa_ConvolutionFilter2D(target, internalFormat, width, height, - GL_RGBA, GL_FLOAT, buf); - - _mesa_meta_end(ctx); - - free(buf); -} diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c b/src/mesa/drivers/dri/intel/intel_extensions.c index 4b6229ffe6f..2edd6d21b48 100644 --- a/src/mesa/drivers/dri/intel/intel_extensions.c +++ b/src/mesa/drivers/dri/intel/intel_extensions.c @@ -208,8 +208,6 @@ intelInitExtensions(GLcontext *ctx) { struct intel_context *intel = intel_context(ctx); - /* Disable imaging extension until convolution is working in teximage paths. - */ driInitExtensions(ctx, card_extensions, GL_FALSE); _mesa_map_function_array(GL_VERSION_2_1_functions); diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index b1ed7ee5e73..f8cb50797e1 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -4,7 +4,6 @@ #include "main/mtypes.h" #include "main/enums.h" #include "main/bufferobj.h" -#include "main/convolve.h" #include "main/context.h" #include "main/formats.h" #include "main/texcompress.h" @@ -320,8 +319,6 @@ intelTexImage(GLcontext * ctx, struct intel_context *intel = intel_context(ctx); struct intel_texture_object *intelObj = intel_texture_object(texObj); struct intel_texture_image *intelImage = intel_texture_image(texImage); - GLint postConvWidth = width; - GLint postConvHeight = height; GLint texelBytes, sizeInBytes; GLuint dstRowStride = 0, srcRowStride = texImage->RowStride; @@ -331,11 +328,6 @@ intelTexImage(GLcontext * ctx, intelImage->face = target_to_face(target); intelImage->level = level; - if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) { - _mesa_adjust_image_for_convolution(ctx, dims, &postConvWidth, - &postConvHeight); - } - if (_mesa_is_format_compressed(texImage->TexFormat)) { texelBytes = 0; } @@ -343,13 +335,13 @@ intelTexImage(GLcontext * ctx, texelBytes = _mesa_get_format_bytes(texImage->TexFormat); /* Minimum pitch of 32 bytes */ - if (postConvWidth * texelBytes < 32) { - postConvWidth = 32 / texelBytes; - texImage->RowStride = postConvWidth; + if (width * texelBytes < 32) { + width = 32 / texelBytes; + texImage->RowStride = width; } if (!intelImage->mt) { - assert(texImage->RowStride == postConvWidth); + assert(texImage->RowStride == width); } } @@ -502,8 +494,8 @@ intelTexImage(GLcontext * ctx, assert(dims != 3); } else { - dstRowStride = postConvWidth * texelBytes; - sizeInBytes = depth * dstRowStride * postConvHeight; + dstRowStride = width * texelBytes; + sizeInBytes = depth * dstRowStride * height; } texImage->Data = _mesa_alloc_texmemory(sizeInBytes); diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c index 8c6a50d2f0d..bf30e0cab8b 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texture.c +++ b/src/mesa/drivers/dri/radeon/radeon_texture.c @@ -32,7 +32,6 @@ #include "main/glheader.h" #include "main/imports.h" #include "main/context.h" -#include "main/convolve.h" #include "main/enums.h" #include "main/mipmap.h" #include "main/texcompress.h" @@ -773,8 +772,6 @@ static void radeon_teximage( radeonContextPtr rmesa = RADEON_CONTEXT(ctx); radeonTexObj* t = radeon_tex_obj(texObj); radeon_texture_image* image = get_radeon_texture_image(texImage); - GLint postConvWidth = width; - GLint postConvHeight = height; GLuint face = _mesa_tex_target_to_face(target); radeon_print(RADEON_TEXTURE, RADEON_NORMAL, @@ -795,20 +792,15 @@ static void radeon_teximage( t->validated = GL_FALSE; - if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) { - _mesa_adjust_image_for_convolution(ctx, dims, &postConvWidth, - &postConvHeight); - } - if (!_mesa_is_format_compressed(texImage->TexFormat)) { GLuint texelBytes = _mesa_get_format_bytes(texImage->TexFormat); /* Minimum pitch of 32 bytes */ - if (postConvWidth * texelBytes < 32) { - postConvWidth = 32 / texelBytes; - texImage->RowStride = postConvWidth; + if (width * texelBytes < 32) { + width = 32 / texelBytes; + texImage->RowStride = width; } if (!image->mt) { - assert(texImage->RowStride == postConvWidth); + assert(texImage->RowStride == width); } } diff --git a/src/mesa/drivers/dri/savage/savagetex.c b/src/mesa/drivers/dri/savage/savagetex.c index 1523af4065f..89090da5c63 100644 --- a/src/mesa/drivers/dri/savage/savagetex.c +++ b/src/mesa/drivers/dri/savage/savagetex.c @@ -28,7 +28,6 @@ #include "main/macros.h" #include "main/texstore.h" #include "main/texobj.h" -#include "main/convolve.h" #include "main/colormac.h" #include "main/simple_list.h" #include "main/enums.h" @@ -586,7 +585,6 @@ _savage_texstore_a1114444(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLuint texelBytes = _mesa_get_format_bytes(dstFormat); GLubyte *dstRow = (GLubyte *) dstAddr @@ -626,7 +624,6 @@ _savage_texstore_a1118888(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLuint texelBytes = _mesa_get_format_bytes(dstFormat); GLubyte *dstRow = (GLubyte *) dstAddr diff --git a/src/mesa/drivers/dri/unichrome/via_tex.c b/src/mesa/drivers/dri/unichrome/via_tex.c index a64f093326f..01cb3ebbc88 100644 --- a/src/mesa/drivers/dri/unichrome/via_tex.c +++ b/src/mesa/drivers/dri/unichrome/via_tex.c @@ -32,7 +32,6 @@ #include "main/enums.h" #include "main/formats.h" #include "main/colortab.h" -#include "main/convolve.h" #include "main/context.h" #include "main/mipmap.h" #include "main/mm.h" @@ -664,8 +663,6 @@ static void viaTexImage(GLcontext *ctx, struct gl_texture_image *texImage) { struct via_context *vmesa = VIA_CONTEXT(ctx); - GLint postConvWidth = width; - GLint postConvHeight = height; GLint texelBytes, sizeInBytes; struct via_texture_object *viaObj = (struct via_texture_object *)texObj; struct via_texture_image *viaImage = (struct via_texture_image *)texImage; @@ -676,11 +673,6 @@ static void viaTexImage(GLcontext *ctx, via_release_pending_textures(vmesa); } - if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) { - _mesa_adjust_image_for_convolution(ctx, dims, &postConvWidth, - &postConvHeight); - } - /* choose the texture format */ texImage->TexFormat = viaChooseTexFormat(ctx, internalFormat, format, type); @@ -690,13 +682,13 @@ static void viaTexImage(GLcontext *ctx, texelBytes = _mesa_get_format_bytes(texImage->TexFormat); /* Minimum pitch of 32 bytes */ - if (postConvWidth * texelBytes < 32) { - postConvWidth = 32 / texelBytes; - texImage->RowStride = postConvWidth; + if (width * texelBytes < 32) { + width = 32 / texelBytes; + texImage->RowStride = width; } - assert(texImage->RowStride == postConvWidth); - viaImage->pitchLog2 = logbase2(postConvWidth * texelBytes); + assert(texImage->RowStride == width); + viaImage->pitchLog2 = logbase2(width * texelBytes); /* allocate memory */ if (_mesa_is_format_compressed(texImage->TexFormat)) @@ -705,7 +697,7 @@ static void viaTexImage(GLcontext *ctx, texImage->Height, texImage->Depth); else - sizeInBytes = postConvWidth * postConvHeight * texelBytes; + sizeInBytes = width * height * texelBytes; /* Attempt to allocate texture memory directly, otherwise use main @@ -786,7 +778,7 @@ static void viaTexImage(GLcontext *ctx, dstRowStride = _mesa_format_row_stride(texImage->TexFormat, width); } else { - dstRowStride = postConvWidth * _mesa_get_format_bytes(texImage->TexFormat); + dstRowStride = width * _mesa_get_format_bytes(texImage->TexFormat); } success = _mesa_texstore(ctx, dims, texImage->_BaseFormat, diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 73c2375f9d3..0299525f46b 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -69,9 +69,6 @@ struct gl_enable_attrib GLboolean Blend; GLbitfield ClipPlanes; GLboolean ColorMaterial; - GLboolean Convolution1D; - GLboolean Convolution2D; - GLboolean Separable2D; GLboolean CullFace; GLboolean DepthClamp; GLboolean DepthTest; @@ -259,9 +256,6 @@ _mesa_PushAttrib(GLbitfield mask) attr->Blend = ctx->Color.BlendEnabled; attr->ClipPlanes = ctx->Transform.ClipPlanesEnabled; attr->ColorMaterial = ctx->Light.ColorMaterialEnabled; - attr->Convolution1D = ctx->Pixel.Convolution1DEnabled; - attr->Convolution2D = ctx->Pixel.Convolution2DEnabled; - attr->Separable2D = ctx->Pixel.Separable2DEnabled; attr->CullFace = ctx->Polygon.CullFlag; attr->DepthClamp = ctx->Transform.DepthClamp; attr->DepthTest = ctx->Depth.Test; @@ -516,12 +510,6 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable) GL_DEPTH_CLAMP); TEST_AND_UPDATE(ctx->Depth.Test, enable->DepthTest, GL_DEPTH_TEST); TEST_AND_UPDATE(ctx->Color.DitherFlag, enable->Dither, GL_DITHER); - TEST_AND_UPDATE(ctx->Pixel.Convolution1DEnabled, enable->Convolution1D, - GL_CONVOLUTION_1D); - TEST_AND_UPDATE(ctx->Pixel.Convolution2DEnabled, enable->Convolution2D, - GL_CONVOLUTION_2D); - TEST_AND_UPDATE(ctx->Pixel.Separable2DEnabled, enable->Separable2D, - GL_SEPARABLE_2D); TEST_AND_UPDATE(ctx->Fog.Enabled, enable->Fog, GL_FOG); TEST_AND_UPDATE(ctx->Light.Enabled, enable->Lighting, GL_LIGHTING); TEST_AND_UPDATE(ctx->Line.SmoothFlag, enable->LineSmooth, GL_LINE_SMOOTH); diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 87285683f80..7d6bfaa62d1 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -557,8 +557,6 @@ _mesa_init_constants(GLcontext *ctx) ctx->Const.MaxLineWidthAA = MAX_LINE_WIDTH; ctx->Const.LineWidthGranularity = (GLfloat) LINE_WIDTH_GRANULARITY; ctx->Const.MaxColorTableSize = MAX_COLOR_TABLE_SIZE; - ctx->Const.MaxConvolutionWidth = MAX_CONVOLUTION_WIDTH; - ctx->Const.MaxConvolutionHeight = MAX_CONVOLUTION_HEIGHT; ctx->Const.MaxClipPlanes = MAX_CLIP_PLANES; ctx->Const.MaxLights = MAX_LIGHTS; ctx->Const.MaxShininess = 128.0; diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c index f63bddc44d5..301569e5f67 100644 --- a/src/mesa/main/convolve.c +++ b/src/mesa/main/convolve.c @@ -45,218 +45,20 @@ #if FEATURE_convolve - -/* - * Given an internalFormat token passed to glConvolutionFilter - * or glSeparableFilter, return the corresponding base format. - * Return -1 if invalid token. - */ -static GLint -base_filter_format( GLenum format ) -{ - switch (format) { - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - return GL_ALPHA; - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - return GL_LUMINANCE; - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - return GL_LUMINANCE_ALPHA; - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - return GL_INTENSITY; - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return GL_RGB; - case 4: - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - return GL_RGBA; - default: - return -1; /* error */ - } -} - - -void GLAPIENTRY +static void GLAPIENTRY _mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *image) { - GLint baseFormat; GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (target != GL_CONVOLUTION_1D) { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter1D(target)"); - return; - } - - baseFormat = base_filter_format(internalFormat); - if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter1D(internalFormat)"); - return; - } - if (width < 0 || width > MAX_CONVOLUTION_WIDTH) { - _mesa_error(ctx, GL_INVALID_VALUE, "glConvolutionFilter1D(width)"); - return; - } - - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glConvolutionFilter1D(format or type)"); - return; - } - - if (format == GL_COLOR_INDEX || - format == GL_STENCIL_INDEX || - format == GL_DEPTH_COMPONENT || - format == GL_INTENSITY || - type == GL_BITMAP) { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter1D(format or type)"); - return; - } - - ctx->Convolution1D.Format = format; - ctx->Convolution1D.InternalFormat = internalFormat; - ctx->Convolution1D.Width = width; - ctx->Convolution1D.Height = 1; - - image = _mesa_map_validate_pbo_source(ctx, - 1, &ctx->Unpack, width, 1, 1, - format, type, image, - "glConvolutionFilter1D"); - if (!image) - return; - - _mesa_unpack_color_span_float(ctx, width, GL_RGBA, - ctx->Convolution1D.Filter, - format, type, image, &ctx->Unpack, - 0); /* transferOps */ - - _mesa_unmap_pbo_source(ctx, &ctx->Unpack); - - _mesa_scale_and_bias_rgba(width, - (GLfloat (*)[4]) ctx->Convolution1D.Filter, - ctx->Pixel.ConvolutionFilterScale[0][0], - ctx->Pixel.ConvolutionFilterScale[0][1], - ctx->Pixel.ConvolutionFilterScale[0][2], - ctx->Pixel.ConvolutionFilterScale[0][3], - ctx->Pixel.ConvolutionFilterBias[0][0], - ctx->Pixel.ConvolutionFilterBias[0][1], - ctx->Pixel.ConvolutionFilterBias[0][2], - ctx->Pixel.ConvolutionFilterBias[0][3]); - - ctx->NewState |= _NEW_PIXEL; + _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter1D"); } - -void GLAPIENTRY +static void GLAPIENTRY _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image) { - GLint baseFormat; - GLint i; GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (target != GL_CONVOLUTION_2D) { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter2D(target)"); - return; - } - - baseFormat = base_filter_format(internalFormat); - if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter2D(internalFormat)"); - return; - } - - if (width < 0 || width > MAX_CONVOLUTION_WIDTH) { - _mesa_error(ctx, GL_INVALID_VALUE, "glConvolutionFilter2D(width)"); - return; - } - if (height < 0 || height > MAX_CONVOLUTION_HEIGHT) { - _mesa_error(ctx, GL_INVALID_VALUE, "glConvolutionFilter2D(height)"); - return; - } - - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glConvolutionFilter2D(format or type)"); - return; - } - if (format == GL_COLOR_INDEX || - format == GL_STENCIL_INDEX || - format == GL_DEPTH_COMPONENT || - format == GL_INTENSITY || - type == GL_BITMAP) { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter2D(format or type)"); - return; - } - - /* this should have been caught earlier */ - assert(_mesa_components_in_format(format)); - - ctx->Convolution2D.Format = format; - ctx->Convolution2D.InternalFormat = internalFormat; - ctx->Convolution2D.Width = width; - ctx->Convolution2D.Height = height; - - image = _mesa_map_validate_pbo_source(ctx, - 2, &ctx->Unpack, width, height, 1, - format, type, image, - "glConvolutionFilter2D"); - if (!image) - return; - - /* Unpack filter image. We always store filters in RGBA format. */ - for (i = 0; i < height; i++) { - const GLvoid *src = _mesa_image_address2d(&ctx->Unpack, image, width, - height, format, type, i, 0); - GLfloat *dst = ctx->Convolution2D.Filter + i * width * 4; - _mesa_unpack_color_span_float(ctx, width, GL_RGBA, dst, - format, type, src, &ctx->Unpack, - 0); /* transferOps */ - } - - _mesa_unmap_pbo_source(ctx, &ctx->Unpack); - _mesa_scale_and_bias_rgba(width * height, - (GLfloat (*)[4]) ctx->Convolution2D.Filter, - ctx->Pixel.ConvolutionFilterScale[1][0], - ctx->Pixel.ConvolutionFilterScale[1][1], - ctx->Pixel.ConvolutionFilterScale[1][2], - ctx->Pixel.ConvolutionFilterScale[1][3], - ctx->Pixel.ConvolutionFilterBias[1][0], - ctx->Pixel.ConvolutionFilterBias[1][1], - ctx->Pixel.ConvolutionFilterBias[1][2], - ctx->Pixel.ConvolutionFilterBias[1][3]); - - ctx->NewState |= _NEW_PIXEL; + _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter2D"); } @@ -264,42 +66,8 @@ static void GLAPIENTRY _mesa_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param) { GET_CURRENT_CONTEXT(ctx); - GLuint c; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - switch (target) { - case GL_CONVOLUTION_1D: - c = 0; - break; - case GL_CONVOLUTION_2D: - c = 1; - break; - case GL_SEPARABLE_2D: - c = 2; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterf(target)"); - return; - } - - switch (pname) { - case GL_CONVOLUTION_BORDER_MODE: - if (param == (GLfloat) GL_REDUCE || - param == (GLfloat) GL_CONSTANT_BORDER || - param == (GLfloat) GL_REPLICATE_BORDER) { - ctx->Pixel.ConvolutionBorderMode[c] = (GLenum) param; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterf(params)"); - return; - } - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterf(pname)"); - return; - } - ctx->NewState |= _NEW_PIXEL; + _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterf"); } @@ -307,51 +75,8 @@ static void GLAPIENTRY _mesa_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params) { GET_CURRENT_CONTEXT(ctx); - GLuint c; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - switch (target) { - case GL_CONVOLUTION_1D: - c = 0; - break; - case GL_CONVOLUTION_2D: - c = 1; - break; - case GL_SEPARABLE_2D: - c = 2; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv(target)"); - return; - } - - switch (pname) { - case GL_CONVOLUTION_BORDER_COLOR: - COPY_4V(ctx->Pixel.ConvolutionBorderColor[c], params); - break; - case GL_CONVOLUTION_BORDER_MODE: - if (params[0] == (GLfloat) GL_REDUCE || - params[0] == (GLfloat) GL_CONSTANT_BORDER || - params[0] == (GLfloat) GL_REPLICATE_BORDER) { - ctx->Pixel.ConvolutionBorderMode[c] = (GLenum) params[0]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv(params)"); - return; - } - break; - case GL_CONVOLUTION_FILTER_SCALE: - COPY_4V(ctx->Pixel.ConvolutionFilterScale[c], params); - break; - case GL_CONVOLUTION_FILTER_BIAS: - COPY_4V(ctx->Pixel.ConvolutionFilterBias[c], params); - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv(pname)"); - return; - } - ctx->NewState |= _NEW_PIXEL; + _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv"); } @@ -359,42 +84,8 @@ static void GLAPIENTRY _mesa_ConvolutionParameteri(GLenum target, GLenum pname, GLint param) { GET_CURRENT_CONTEXT(ctx); - GLuint c; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - switch (target) { - case GL_CONVOLUTION_1D: - c = 0; - break; - case GL_CONVOLUTION_2D: - c = 1; - break; - case GL_SEPARABLE_2D: - c = 2; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteri(target)"); - return; - } - - switch (pname) { - case GL_CONVOLUTION_BORDER_MODE: - if (param == (GLint) GL_REDUCE || - param == (GLint) GL_CONSTANT_BORDER || - param == (GLint) GL_REPLICATE_BORDER) { - ctx->Pixel.ConvolutionBorderMode[c] = (GLenum) param; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteri(params)"); - return; - } - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteri(pname)"); - return; - } - - ctx->NewState |= _NEW_PIXEL; + _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteri"); } @@ -402,132 +93,26 @@ static void GLAPIENTRY _mesa_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params) { GET_CURRENT_CONTEXT(ctx); - GLuint c; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - switch (target) { - case GL_CONVOLUTION_1D: - c = 0; - break; - case GL_CONVOLUTION_2D: - c = 1; - break; - case GL_SEPARABLE_2D: - c = 2; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteriv(target)"); - return; - } - - switch (pname) { - case GL_CONVOLUTION_BORDER_COLOR: - ctx->Pixel.ConvolutionBorderColor[c][0] = INT_TO_FLOAT(params[0]); - ctx->Pixel.ConvolutionBorderColor[c][1] = INT_TO_FLOAT(params[1]); - ctx->Pixel.ConvolutionBorderColor[c][2] = INT_TO_FLOAT(params[2]); - ctx->Pixel.ConvolutionBorderColor[c][3] = INT_TO_FLOAT(params[3]); - break; - case GL_CONVOLUTION_BORDER_MODE: - if (params[0] == (GLint) GL_REDUCE || - params[0] == (GLint) GL_CONSTANT_BORDER || - params[0] == (GLint) GL_REPLICATE_BORDER) { - ctx->Pixel.ConvolutionBorderMode[c] = (GLenum) params[0]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteriv(params)"); - return; - } - break; - case GL_CONVOLUTION_FILTER_SCALE: - /* COPY_4V(ctx->Pixel.ConvolutionFilterScale[c], params); */ - /* need cast to prevent compiler warnings */ - ctx->Pixel.ConvolutionFilterScale[c][0] = (GLfloat) params[0]; - ctx->Pixel.ConvolutionFilterScale[c][1] = (GLfloat) params[1]; - ctx->Pixel.ConvolutionFilterScale[c][2] = (GLfloat) params[2]; - ctx->Pixel.ConvolutionFilterScale[c][3] = (GLfloat) params[3]; - break; - case GL_CONVOLUTION_FILTER_BIAS: - /* COPY_4V(ctx->Pixel.ConvolutionFilterBias[c], params); */ - /* need cast to prevent compiler warnings */ - ctx->Pixel.ConvolutionFilterBias[c][0] = (GLfloat) params[0]; - ctx->Pixel.ConvolutionFilterBias[c][1] = (GLfloat) params[1]; - ctx->Pixel.ConvolutionFilterBias[c][2] = (GLfloat) params[2]; - ctx->Pixel.ConvolutionFilterBias[c][3] = (GLfloat) params[3]; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteriv(pname)"); - return; - } - ctx->NewState |= _NEW_PIXEL; + _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteriv"); } static void GLAPIENTRY _mesa_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width) { - GLint baseFormat; GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (target != GL_CONVOLUTION_1D) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter1D(target)"); - return; - } - - baseFormat = base_filter_format(internalFormat); - if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter1D(internalFormat)"); - return; - } - - if (width < 0 || width > MAX_CONVOLUTION_WIDTH) { - _mesa_error(ctx, GL_INVALID_VALUE, "glCopyConvolutionFilter1D(width)"); - return; - } - - if (!ctx->ReadBuffer->_ColorReadBuffer) { - return; /* no readbuffer - OK */ - } - - ctx->Driver.CopyConvolutionFilter1D( ctx, target, - internalFormat, x, y, width); + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter1D"); } static void GLAPIENTRY _mesa_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height) { - GLint baseFormat; GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (target != GL_CONVOLUTION_2D) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter2D(target)"); - return; - } - baseFormat = base_filter_format(internalFormat); - if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter2D(internalFormat)"); - return; - } - - if (width < 0 || width > MAX_CONVOLUTION_WIDTH) { - _mesa_error(ctx, GL_INVALID_VALUE, "glCopyConvolutionFilter2D(width)"); - return; - } - if (height < 0 || height > MAX_CONVOLUTION_HEIGHT) { - _mesa_error(ctx, GL_INVALID_VALUE, "glCopyConvolutionFilter2D(height)"); - return; - } - - if (!ctx->ReadBuffer->_ColorReadBuffer) { - return; /* no readbuffer - OK */ - } - - ctx->Driver.CopyConvolutionFilter2D( ctx, target, internalFormat, x, y, - width, height ); + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter2D"); } @@ -535,58 +120,9 @@ static void GLAPIENTRY _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid *image) { - struct gl_convolution_attrib *filter; - GLuint row; GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->NewState) { - _mesa_update_state(ctx); - } - - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetConvolutionFilter(format or type)"); - return; - } - if (format == GL_COLOR_INDEX || - format == GL_STENCIL_INDEX || - format == GL_DEPTH_COMPONENT || - format == GL_INTENSITY || - type == GL_BITMAP) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionFilter(format or type)"); - return; - } - - switch (target) { - case GL_CONVOLUTION_1D: - filter = &(ctx->Convolution1D); - break; - case GL_CONVOLUTION_2D: - filter = &(ctx->Convolution2D); - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionFilter(target)"); - return; - } - - image = _mesa_map_validate_pbo_dest(ctx, 2, &ctx->Pack, - filter->Width, filter->Height, 1, - format, type, image, - "glGetConvolutionFilter"); - if (!image) - return; - - for (row = 0; row < filter->Height; row++) { - GLvoid *dst = _mesa_image_address2d(&ctx->Pack, image, filter->Width, - filter->Height, format, type, - row, 0); - GLfloat (*src)[4] = (GLfloat (*)[4]) (filter->Filter + row * filter->Width * 4); - _mesa_pack_rgba_span_float(ctx, filter->Width, src, - format, type, dst, &ctx->Pack, 0x0); - } - - _mesa_unmap_pbo_dest(ctx, &ctx->Pack); + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetConvolutionFilter"); } @@ -594,60 +130,8 @@ static void GLAPIENTRY _mesa_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params) { GET_CURRENT_CONTEXT(ctx); - const struct gl_convolution_attrib *conv; - GLuint c; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (target) { - case GL_CONVOLUTION_1D: - c = 0; - conv = &ctx->Convolution1D; - break; - case GL_CONVOLUTION_2D: - c = 1; - conv = &ctx->Convolution2D; - break; - case GL_SEPARABLE_2D: - c = 2; - conv = &ctx->Separable2D; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameterfv(target)"); - return; - } - switch (pname) { - case GL_CONVOLUTION_BORDER_COLOR: - COPY_4V(params, ctx->Pixel.ConvolutionBorderColor[c]); - break; - case GL_CONVOLUTION_BORDER_MODE: - *params = (GLfloat) ctx->Pixel.ConvolutionBorderMode[c]; - break; - case GL_CONVOLUTION_FILTER_SCALE: - COPY_4V(params, ctx->Pixel.ConvolutionFilterScale[c]); - break; - case GL_CONVOLUTION_FILTER_BIAS: - COPY_4V(params, ctx->Pixel.ConvolutionFilterBias[c]); - break; - case GL_CONVOLUTION_FORMAT: - *params = (GLfloat) conv->Format; - break; - case GL_CONVOLUTION_WIDTH: - *params = (GLfloat) conv->Width; - break; - case GL_CONVOLUTION_HEIGHT: - *params = (GLfloat) conv->Height; - break; - case GL_MAX_CONVOLUTION_WIDTH: - *params = (GLfloat) ctx->Const.MaxConvolutionWidth; - break; - case GL_MAX_CONVOLUTION_HEIGHT: - *params = (GLfloat) ctx->Const.MaxConvolutionHeight; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameterfv(pname)"); - return; - } + _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameterfv"); } @@ -655,69 +139,8 @@ static void GLAPIENTRY _mesa_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params) { GET_CURRENT_CONTEXT(ctx); - const struct gl_convolution_attrib *conv; - GLuint c; - ASSERT_OUTSIDE_BEGIN_END(ctx); - switch (target) { - case GL_CONVOLUTION_1D: - c = 0; - conv = &ctx->Convolution1D; - break; - case GL_CONVOLUTION_2D: - c = 1; - conv = &ctx->Convolution2D; - break; - case GL_SEPARABLE_2D: - c = 2; - conv = &ctx->Separable2D; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameteriv(target)"); - return; - } - - switch (pname) { - case GL_CONVOLUTION_BORDER_COLOR: - params[0] = FLOAT_TO_INT(ctx->Pixel.ConvolutionBorderColor[c][0]); - params[1] = FLOAT_TO_INT(ctx->Pixel.ConvolutionBorderColor[c][1]); - params[2] = FLOAT_TO_INT(ctx->Pixel.ConvolutionBorderColor[c][2]); - params[3] = FLOAT_TO_INT(ctx->Pixel.ConvolutionBorderColor[c][3]); - break; - case GL_CONVOLUTION_BORDER_MODE: - *params = (GLint) ctx->Pixel.ConvolutionBorderMode[c]; - break; - case GL_CONVOLUTION_FILTER_SCALE: - params[0] = (GLint) ctx->Pixel.ConvolutionFilterScale[c][0]; - params[1] = (GLint) ctx->Pixel.ConvolutionFilterScale[c][1]; - params[2] = (GLint) ctx->Pixel.ConvolutionFilterScale[c][2]; - params[3] = (GLint) ctx->Pixel.ConvolutionFilterScale[c][3]; - break; - case GL_CONVOLUTION_FILTER_BIAS: - params[0] = (GLint) ctx->Pixel.ConvolutionFilterBias[c][0]; - params[1] = (GLint) ctx->Pixel.ConvolutionFilterBias[c][1]; - params[2] = (GLint) ctx->Pixel.ConvolutionFilterBias[c][2]; - params[3] = (GLint) ctx->Pixel.ConvolutionFilterBias[c][3]; - break; - case GL_CONVOLUTION_FORMAT: - *params = (GLint) conv->Format; - break; - case GL_CONVOLUTION_WIDTH: - *params = (GLint) conv->Width; - break; - case GL_CONVOLUTION_HEIGHT: - *params = (GLint) conv->Height; - break; - case GL_MAX_CONVOLUTION_WIDTH: - *params = (GLint) ctx->Const.MaxConvolutionWidth; - break; - case GL_MAX_CONVOLUTION_HEIGHT: - *params = (GLint) ctx->Const.MaxConvolutionHeight; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameteriv(pname)"); - return; - } + _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameteriv"); } @@ -725,720 +148,20 @@ static void GLAPIENTRY _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span) { - const GLint colStart = MAX_CONVOLUTION_WIDTH * 4; - struct gl_convolution_attrib *filter; GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->NewState) { - _mesa_update_state(ctx); - } - - if (target != GL_SEPARABLE_2D) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetSeparableFilter(target)"); - return; - } - - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetConvolutionFilter(format or type)"); - return; - } - if (format == GL_COLOR_INDEX || - format == GL_STENCIL_INDEX || - format == GL_DEPTH_COMPONENT || - format == GL_INTENSITY || - type == GL_BITMAP) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionFilter(format or type)"); - return; - } - - filter = &ctx->Separable2D; - - /* Get row filter */ - row = _mesa_map_validate_pbo_dest(ctx, 1, &ctx->Pack, - filter->Width, 1, 1, - format, type, row, - "glGetConvolutionFilter"); - if (row) { - GLvoid *dst = _mesa_image_address1d(&ctx->Pack, row, filter->Width, - format, type, 0); - _mesa_pack_rgba_span_float(ctx, filter->Width, - (GLfloat (*)[4]) filter->Filter, - format, type, dst, &ctx->Pack, 0x0); - _mesa_unmap_pbo_dest(ctx, &ctx->Pack); - } - - /* get column filter */ - column = _mesa_map_validate_pbo_dest(ctx, 1, &ctx->Pack, - filter->Height, 1, 1, - format, type, column, - "glGetConvolutionFilter"); - if (column) { - GLvoid *dst = _mesa_image_address1d(&ctx->Pack, column, filter->Height, - format, type, 0); - GLfloat (*src)[4] = (GLfloat (*)[4]) (filter->Filter + colStart); - _mesa_pack_rgba_span_float(ctx, filter->Height, src, - format, type, dst, &ctx->Pack, 0x0); - _mesa_unmap_pbo_dest(ctx, &ctx->Pack); - } - - (void) span; /* unused at this time */ + _mesa_error(ctx, GL_INVALID_ENUM, "glGetSeparableFilter"); } static void GLAPIENTRY _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column) { - const GLint colStart = MAX_CONVOLUTION_WIDTH * 4; - GLint baseFormat; GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (target != GL_SEPARABLE_2D) { - _mesa_error(ctx, GL_INVALID_ENUM, "glSeparableFilter2D(target)"); - return; - } - - baseFormat = base_filter_format(internalFormat); - if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) { - _mesa_error(ctx, GL_INVALID_ENUM, "glSeparableFilter2D(internalFormat)"); - return; - } - - if (width < 0 || width > MAX_CONVOLUTION_WIDTH) { - _mesa_error(ctx, GL_INVALID_VALUE, "glSeparableFilter2D(width)"); - return; - } - if (height < 0 || height > MAX_CONVOLUTION_HEIGHT) { - _mesa_error(ctx, GL_INVALID_VALUE, "glSeparableFilter2D(height)"); - return; - } - - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glSeparableFilter2D(format or type)"); - return; - } - - if (format == GL_COLOR_INDEX || - format == GL_STENCIL_INDEX || - format == GL_DEPTH_COMPONENT || - format == GL_INTENSITY || - type == GL_BITMAP) { - _mesa_error(ctx, GL_INVALID_ENUM, "glSeparableFilter2D(format or type)"); - return; - } - - ctx->Separable2D.Format = format; - ctx->Separable2D.InternalFormat = internalFormat; - ctx->Separable2D.Width = width; - ctx->Separable2D.Height = height; - - /* unpack row filter */ - row = _mesa_map_validate_pbo_source(ctx, 1, &ctx->Unpack, - width, 1, 1, - format, type, row, - "glSeparableFilter2D"); - if (row) { - _mesa_unpack_color_span_float(ctx, width, GL_RGBA, - ctx->Separable2D.Filter, - format, type, row, &ctx->Unpack, - 0x0); /* transferOps */ - _mesa_scale_and_bias_rgba(width, - (GLfloat (*)[4]) ctx->Separable2D.Filter, - ctx->Pixel.ConvolutionFilterScale[2][0], - ctx->Pixel.ConvolutionFilterScale[2][1], - ctx->Pixel.ConvolutionFilterScale[2][2], - ctx->Pixel.ConvolutionFilterScale[2][3], - ctx->Pixel.ConvolutionFilterBias[2][0], - ctx->Pixel.ConvolutionFilterBias[2][1], - ctx->Pixel.ConvolutionFilterBias[2][2], - ctx->Pixel.ConvolutionFilterBias[2][3]); - _mesa_unmap_pbo_source(ctx, &ctx->Unpack); - } - - /* unpack column filter */ - column = _mesa_map_validate_pbo_source(ctx, 1, &ctx->Unpack, - height, 1, 1, - format, type, column, - "glSeparableFilter2D"); - if (column) { - _mesa_unpack_color_span_float(ctx, height, GL_RGBA, - &ctx->Separable2D.Filter[colStart], - format, type, column, &ctx->Unpack, - 0); /* transferOps */ - - _mesa_scale_and_bias_rgba(height, - (GLfloat (*)[4]) (ctx->Separable2D.Filter + colStart), - ctx->Pixel.ConvolutionFilterScale[2][0], - ctx->Pixel.ConvolutionFilterScale[2][1], - ctx->Pixel.ConvolutionFilterScale[2][2], - ctx->Pixel.ConvolutionFilterScale[2][3], - ctx->Pixel.ConvolutionFilterBias[2][0], - ctx->Pixel.ConvolutionFilterBias[2][1], - ctx->Pixel.ConvolutionFilterBias[2][2], - ctx->Pixel.ConvolutionFilterBias[2][3]); - _mesa_unmap_pbo_source(ctx, &ctx->Unpack); - } - - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - ctx->Unpack.BufferObj); - } - - ctx->NewState |= _NEW_PIXEL; -} - - -/**********************************************************************/ -/*** image convolution functions ***/ -/**********************************************************************/ - -static void -convolve_1d_reduce(GLint srcWidth, const GLfloat src[][4], - GLint filterWidth, const GLfloat filter[][4], - GLfloat dest[][4]) -{ - GLint dstWidth; - GLint i, n; - - if (filterWidth >= 1) - dstWidth = srcWidth - (filterWidth - 1); - else - dstWidth = srcWidth; - - if (dstWidth <= 0) - return; /* null result */ - - for (i = 0; i < dstWidth; i++) { - GLfloat sumR = 0.0; - GLfloat sumG = 0.0; - GLfloat sumB = 0.0; - GLfloat sumA = 0.0; - for (n = 0; n < filterWidth; n++) { - sumR += src[i + n][RCOMP] * filter[n][RCOMP]; - sumG += src[i + n][GCOMP] * filter[n][GCOMP]; - sumB += src[i + n][BCOMP] * filter[n][BCOMP]; - sumA += src[i + n][ACOMP] * filter[n][ACOMP]; - } - dest[i][RCOMP] = sumR; - dest[i][GCOMP] = sumG; - dest[i][BCOMP] = sumB; - dest[i][ACOMP] = sumA; - } -} - - -static void -convolve_1d_constant(GLint srcWidth, const GLfloat src[][4], - GLint filterWidth, const GLfloat filter[][4], - GLfloat dest[][4], - const GLfloat borderColor[4]) -{ - const GLint halfFilterWidth = filterWidth / 2; - GLint i, n; - - for (i = 0; i < srcWidth; i++) { - GLfloat sumR = 0.0; - GLfloat sumG = 0.0; - GLfloat sumB = 0.0; - GLfloat sumA = 0.0; - for (n = 0; n < filterWidth; n++) { - if (i + n < halfFilterWidth || i + n - halfFilterWidth >= srcWidth) { - sumR += borderColor[RCOMP] * filter[n][RCOMP]; - sumG += borderColor[GCOMP] * filter[n][GCOMP]; - sumB += borderColor[BCOMP] * filter[n][BCOMP]; - sumA += borderColor[ACOMP] * filter[n][ACOMP]; - } - else { - sumR += src[i + n - halfFilterWidth][RCOMP] * filter[n][RCOMP]; - sumG += src[i + n - halfFilterWidth][GCOMP] * filter[n][GCOMP]; - sumB += src[i + n - halfFilterWidth][BCOMP] * filter[n][BCOMP]; - sumA += src[i + n - halfFilterWidth][ACOMP] * filter[n][ACOMP]; - } - } - dest[i][RCOMP] = sumR; - dest[i][GCOMP] = sumG; - dest[i][BCOMP] = sumB; - dest[i][ACOMP] = sumA; - } -} - - -static void -convolve_1d_replicate(GLint srcWidth, const GLfloat src[][4], - GLint filterWidth, const GLfloat filter[][4], - GLfloat dest[][4]) -{ - const GLint halfFilterWidth = filterWidth / 2; - GLint i, n; - - for (i = 0; i < srcWidth; i++) { - GLfloat sumR = 0.0; - GLfloat sumG = 0.0; - GLfloat sumB = 0.0; - GLfloat sumA = 0.0; - for (n = 0; n < filterWidth; n++) { - if (i + n < halfFilterWidth) { - sumR += src[0][RCOMP] * filter[n][RCOMP]; - sumG += src[0][GCOMP] * filter[n][GCOMP]; - sumB += src[0][BCOMP] * filter[n][BCOMP]; - sumA += src[0][ACOMP] * filter[n][ACOMP]; - } - else if (i + n - halfFilterWidth >= srcWidth) { - sumR += src[srcWidth - 1][RCOMP] * filter[n][RCOMP]; - sumG += src[srcWidth - 1][GCOMP] * filter[n][GCOMP]; - sumB += src[srcWidth - 1][BCOMP] * filter[n][BCOMP]; - sumA += src[srcWidth - 1][ACOMP] * filter[n][ACOMP]; - } - else { - sumR += src[i + n - halfFilterWidth][RCOMP] * filter[n][RCOMP]; - sumG += src[i + n - halfFilterWidth][GCOMP] * filter[n][GCOMP]; - sumB += src[i + n - halfFilterWidth][BCOMP] * filter[n][BCOMP]; - sumA += src[i + n - halfFilterWidth][ACOMP] * filter[n][ACOMP]; - } - } - dest[i][RCOMP] = sumR; - dest[i][GCOMP] = sumG; - dest[i][BCOMP] = sumB; - dest[i][ACOMP] = sumA; - } -} - - -static void -convolve_2d_reduce(GLint srcWidth, GLint srcHeight, - const GLfloat src[][4], - GLint filterWidth, GLint filterHeight, - const GLfloat filter[][4], - GLfloat dest[][4]) -{ - GLint dstWidth, dstHeight; - GLint i, j, n, m; - - if (filterWidth >= 1) - dstWidth = srcWidth - (filterWidth - 1); - else - dstWidth = srcWidth; - - if (filterHeight >= 1) - dstHeight = srcHeight - (filterHeight - 1); - else - dstHeight = srcHeight; - - if (dstWidth <= 0 || dstHeight <= 0) - return; - - for (j = 0; j < dstHeight; j++) { - for (i = 0; i < dstWidth; i++) { - GLfloat sumR = 0.0; - GLfloat sumG = 0.0; - GLfloat sumB = 0.0; - GLfloat sumA = 0.0; - for (m = 0; m < filterHeight; m++) { - for (n = 0; n < filterWidth; n++) { - const GLint k = (j + m) * srcWidth + i + n; - const GLint f = m * filterWidth + n; - sumR += src[k][RCOMP] * filter[f][RCOMP]; - sumG += src[k][GCOMP] * filter[f][GCOMP]; - sumB += src[k][BCOMP] * filter[f][BCOMP]; - sumA += src[k][ACOMP] * filter[f][ACOMP]; - } - } - dest[j * dstWidth + i][RCOMP] = sumR; - dest[j * dstWidth + i][GCOMP] = sumG; - dest[j * dstWidth + i][BCOMP] = sumB; - dest[j * dstWidth + i][ACOMP] = sumA; - } - } -} - - -static void -convolve_2d_constant(GLint srcWidth, GLint srcHeight, - const GLfloat src[][4], - GLint filterWidth, GLint filterHeight, - const GLfloat filter[][4], - GLfloat dest[][4], - const GLfloat borderColor[4]) -{ - const GLint halfFilterWidth = filterWidth / 2; - const GLint halfFilterHeight = filterHeight / 2; - GLint i, j, n, m; - - for (j = 0; j < srcHeight; j++) { - for (i = 0; i < srcWidth; i++) { - GLfloat sumR = 0.0; - GLfloat sumG = 0.0; - GLfloat sumB = 0.0; - GLfloat sumA = 0.0; - for (m = 0; m < filterHeight; m++) { - for (n = 0; n < filterWidth; n++) { - const GLint f = m * filterWidth + n; - const GLint is = i + n - halfFilterWidth; - const GLint js = j + m - halfFilterHeight; - if (is < 0 || is >= srcWidth || - js < 0 || js >= srcHeight) { - sumR += borderColor[RCOMP] * filter[f][RCOMP]; - sumG += borderColor[GCOMP] * filter[f][GCOMP]; - sumB += borderColor[BCOMP] * filter[f][BCOMP]; - sumA += borderColor[ACOMP] * filter[f][ACOMP]; - } - else { - const GLint k = js * srcWidth + is; - sumR += src[k][RCOMP] * filter[f][RCOMP]; - sumG += src[k][GCOMP] * filter[f][GCOMP]; - sumB += src[k][BCOMP] * filter[f][BCOMP]; - sumA += src[k][ACOMP] * filter[f][ACOMP]; - } - } - } - dest[j * srcWidth + i][RCOMP] = sumR; - dest[j * srcWidth + i][GCOMP] = sumG; - dest[j * srcWidth + i][BCOMP] = sumB; - dest[j * srcWidth + i][ACOMP] = sumA; - } - } -} - - -static void -convolve_2d_replicate(GLint srcWidth, GLint srcHeight, - const GLfloat src[][4], - GLint filterWidth, GLint filterHeight, - const GLfloat filter[][4], - GLfloat dest[][4]) -{ - const GLint halfFilterWidth = filterWidth / 2; - const GLint halfFilterHeight = filterHeight / 2; - GLint i, j, n, m; - - for (j = 0; j < srcHeight; j++) { - for (i = 0; i < srcWidth; i++) { - GLfloat sumR = 0.0; - GLfloat sumG = 0.0; - GLfloat sumB = 0.0; - GLfloat sumA = 0.0; - for (m = 0; m < filterHeight; m++) { - for (n = 0; n < filterWidth; n++) { - const GLint f = m * filterWidth + n; - GLint is = i + n - halfFilterWidth; - GLint js = j + m - halfFilterHeight; - GLint k; - if (is < 0) - is = 0; - else if (is >= srcWidth) - is = srcWidth - 1; - if (js < 0) - js = 0; - else if (js >= srcHeight) - js = srcHeight - 1; - k = js * srcWidth + is; - sumR += src[k][RCOMP] * filter[f][RCOMP]; - sumG += src[k][GCOMP] * filter[f][GCOMP]; - sumB += src[k][BCOMP] * filter[f][BCOMP]; - sumA += src[k][ACOMP] * filter[f][ACOMP]; - } - } - dest[j * srcWidth + i][RCOMP] = sumR; - dest[j * srcWidth + i][GCOMP] = sumG; - dest[j * srcWidth + i][BCOMP] = sumB; - dest[j * srcWidth + i][ACOMP] = sumA; - } - } -} - - -static void -convolve_sep_reduce(GLint srcWidth, GLint srcHeight, - const GLfloat src[][4], - GLint filterWidth, GLint filterHeight, - const GLfloat rowFilt[][4], - const GLfloat colFilt[][4], - GLfloat dest[][4]) -{ - GLint dstWidth, dstHeight; - GLint i, j, n, m; - - if (filterWidth >= 1) - dstWidth = srcWidth - (filterWidth - 1); - else - dstWidth = srcWidth; - - if (filterHeight >= 1) - dstHeight = srcHeight - (filterHeight - 1); - else - dstHeight = srcHeight; - if (dstWidth <= 0 || dstHeight <= 0) - return; - - for (j = 0; j < dstHeight; j++) { - for (i = 0; i < dstWidth; i++) { - GLfloat sumR = 0.0; - GLfloat sumG = 0.0; - GLfloat sumB = 0.0; - GLfloat sumA = 0.0; - for (m = 0; m < filterHeight; m++) { - for (n = 0; n < filterWidth; n++) { - GLint k = (j + m) * srcWidth + i + n; - sumR += src[k][RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP]; - sumG += src[k][GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP]; - sumB += src[k][BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP]; - sumA += src[k][ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP]; - } - } - dest[j * dstWidth + i][RCOMP] = sumR; - dest[j * dstWidth + i][GCOMP] = sumG; - dest[j * dstWidth + i][BCOMP] = sumB; - dest[j * dstWidth + i][ACOMP] = sumA; - } - } -} - - -static void -convolve_sep_constant(GLint srcWidth, GLint srcHeight, - const GLfloat src[][4], - GLint filterWidth, GLint filterHeight, - const GLfloat rowFilt[][4], - const GLfloat colFilt[][4], - GLfloat dest[][4], - const GLfloat borderColor[4]) -{ - const GLint halfFilterWidth = filterWidth / 2; - const GLint halfFilterHeight = filterHeight / 2; - GLint i, j, n, m; - - for (j = 0; j < srcHeight; j++) { - for (i = 0; i < srcWidth; i++) { - GLfloat sumR = 0.0; - GLfloat sumG = 0.0; - GLfloat sumB = 0.0; - GLfloat sumA = 0.0; - for (m = 0; m < filterHeight; m++) { - for (n = 0; n < filterWidth; n++) { - const GLint is = i + n - halfFilterWidth; - const GLint js = j + m - halfFilterHeight; - if (is < 0 || is >= srcWidth || - js < 0 || js >= srcHeight) { - sumR += borderColor[RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP]; - sumG += borderColor[GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP]; - sumB += borderColor[BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP]; - sumA += borderColor[ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP]; - } - else { - GLint k = js * srcWidth + is; - sumR += src[k][RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP]; - sumG += src[k][GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP]; - sumB += src[k][BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP]; - sumA += src[k][ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP]; - } - - } - } - dest[j * srcWidth + i][RCOMP] = sumR; - dest[j * srcWidth + i][GCOMP] = sumG; - dest[j * srcWidth + i][BCOMP] = sumB; - dest[j * srcWidth + i][ACOMP] = sumA; - } - } -} - - -static void -convolve_sep_replicate(GLint srcWidth, GLint srcHeight, - const GLfloat src[][4], - GLint filterWidth, GLint filterHeight, - const GLfloat rowFilt[][4], - const GLfloat colFilt[][4], - GLfloat dest[][4]) -{ - const GLint halfFilterWidth = filterWidth / 2; - const GLint halfFilterHeight = filterHeight / 2; - GLint i, j, n, m; - - for (j = 0; j < srcHeight; j++) { - for (i = 0; i < srcWidth; i++) { - GLfloat sumR = 0.0; - GLfloat sumG = 0.0; - GLfloat sumB = 0.0; - GLfloat sumA = 0.0; - for (m = 0; m < filterHeight; m++) { - for (n = 0; n < filterWidth; n++) { - GLint is = i + n - halfFilterWidth; - GLint js = j + m - halfFilterHeight; - GLint k; - if (is < 0) - is = 0; - else if (is >= srcWidth) - is = srcWidth - 1; - if (js < 0) - js = 0; - else if (js >= srcHeight) - js = srcHeight - 1; - k = js * srcWidth + is; - sumR += src[k][RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP]; - sumG += src[k][GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP]; - sumB += src[k][BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP]; - sumA += src[k][ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP]; - } - } - dest[j * srcWidth + i][RCOMP] = sumR; - dest[j * srcWidth + i][GCOMP] = sumG; - dest[j * srcWidth + i][BCOMP] = sumB; - dest[j * srcWidth + i][ACOMP] = sumA; - } - } -} - - - -void -_mesa_convolve_1d_image(const GLcontext *ctx, GLsizei *width, - const GLfloat *srcImage, GLfloat *dstImage) -{ - switch (ctx->Pixel.ConvolutionBorderMode[0]) { - case GL_REDUCE: - convolve_1d_reduce(*width, (const GLfloat (*)[4]) srcImage, - ctx->Convolution1D.Width, - (const GLfloat (*)[4]) ctx->Convolution1D.Filter, - (GLfloat (*)[4]) dstImage); - *width = *width - (MAX2(ctx->Convolution1D.Width, 1) - 1); - break; - case GL_CONSTANT_BORDER: - convolve_1d_constant(*width, (const GLfloat (*)[4]) srcImage, - ctx->Convolution1D.Width, - (const GLfloat (*)[4]) ctx->Convolution1D.Filter, - (GLfloat (*)[4]) dstImage, - ctx->Pixel.ConvolutionBorderColor[0]); - break; - case GL_REPLICATE_BORDER: - convolve_1d_replicate(*width, (const GLfloat (*)[4]) srcImage, - ctx->Convolution1D.Width, - (const GLfloat (*)[4]) ctx->Convolution1D.Filter, - (GLfloat (*)[4]) dstImage); - break; - default: - ; - } -} - - -void -_mesa_convolve_2d_image(const GLcontext *ctx, GLsizei *width, GLsizei *height, - const GLfloat *srcImage, GLfloat *dstImage) -{ - switch (ctx->Pixel.ConvolutionBorderMode[1]) { - case GL_REDUCE: - convolve_2d_reduce(*width, *height, - (const GLfloat (*)[4]) srcImage, - ctx->Convolution2D.Width, - ctx->Convolution2D.Height, - (const GLfloat (*)[4]) ctx->Convolution2D.Filter, - (GLfloat (*)[4]) dstImage); - *width = *width - (MAX2(ctx->Convolution2D.Width, 1) - 1); - *height = *height - (MAX2(ctx->Convolution2D.Height, 1) - 1); - break; - case GL_CONSTANT_BORDER: - convolve_2d_constant(*width, *height, - (const GLfloat (*)[4]) srcImage, - ctx->Convolution2D.Width, - ctx->Convolution2D.Height, - (const GLfloat (*)[4]) ctx->Convolution2D.Filter, - (GLfloat (*)[4]) dstImage, - ctx->Pixel.ConvolutionBorderColor[1]); - break; - case GL_REPLICATE_BORDER: - convolve_2d_replicate(*width, *height, - (const GLfloat (*)[4]) srcImage, - ctx->Convolution2D.Width, - ctx->Convolution2D.Height, - (const GLfloat (*)[4])ctx->Convolution2D.Filter, - (GLfloat (*)[4]) dstImage); - break; - default: - ; - } -} - - -void -_mesa_convolve_sep_image(const GLcontext *ctx, - GLsizei *width, GLsizei *height, - const GLfloat *srcImage, GLfloat *dstImage) -{ - const GLfloat *rowFilter = ctx->Separable2D.Filter; - const GLfloat *colFilter = rowFilter + 4 * MAX_CONVOLUTION_WIDTH; - - switch (ctx->Pixel.ConvolutionBorderMode[2]) { - case GL_REDUCE: - convolve_sep_reduce(*width, *height, - (const GLfloat (*)[4]) srcImage, - ctx->Separable2D.Width, - ctx->Separable2D.Height, - (const GLfloat (*)[4]) rowFilter, - (const GLfloat (*)[4]) colFilter, - (GLfloat (*)[4]) dstImage); - *width = *width - (MAX2(ctx->Separable2D.Width, 1) - 1); - *height = *height - (MAX2(ctx->Separable2D.Height, 1) - 1); - break; - case GL_CONSTANT_BORDER: - convolve_sep_constant(*width, *height, - (const GLfloat (*)[4]) srcImage, - ctx->Separable2D.Width, - ctx->Separable2D.Height, - (const GLfloat (*)[4]) rowFilter, - (const GLfloat (*)[4]) colFilter, - (GLfloat (*)[4]) dstImage, - ctx->Pixel.ConvolutionBorderColor[2]); - break; - case GL_REPLICATE_BORDER: - convolve_sep_replicate(*width, *height, - (const GLfloat (*)[4]) srcImage, - ctx->Separable2D.Width, - ctx->Separable2D.Height, - (const GLfloat (*)[4]) rowFilter, - (const GLfloat (*)[4]) colFilter, - (GLfloat (*)[4]) dstImage); - break; - default: - ; - } + _mesa_error(ctx, GL_INVALID_ENUM, "glSeparableFilter2D"); } - - -/* - * This function computes an image's size after convolution. - * If the convolution border mode is GL_REDUCE, the post-convolution - * image will be smaller than the original. - */ -void -_mesa_adjust_image_for_convolution(const GLcontext *ctx, GLuint dimensions, - GLsizei *width, GLsizei *height) -{ - if (ctx->Pixel.Convolution1DEnabled - && dimensions == 1 - && ctx->Pixel.ConvolutionBorderMode[0] == GL_REDUCE) { - *width = *width - (MAX2(ctx->Convolution1D.Width, 1) - 1); - } - else if (ctx->Pixel.Convolution2DEnabled - && dimensions > 1 - && ctx->Pixel.ConvolutionBorderMode[1] == GL_REDUCE) { - *width = *width - (MAX2(ctx->Convolution2D.Width, 1) - 1); - *height = *height - (MAX2(ctx->Convolution2D.Height, 1) - 1); - } - else if (ctx->Pixel.Separable2DEnabled - && dimensions > 1 - && ctx->Pixel.ConvolutionBorderMode[2] == GL_REDUCE) { - *width = *width - (MAX2(ctx->Separable2D.Width, 1) - 1); - *height = *height - (MAX2(ctx->Separable2D.Height, 1) - 1); - } -} - - void _mesa_init_convolve_dispatch(struct _glapi_table *disp) { diff --git a/src/mesa/main/convolve.h b/src/mesa/main/convolve.h index 80caf942fba..0277917433d 100644 --- a/src/mesa/main/convolve.h +++ b/src/mesa/main/convolve.h @@ -33,32 +33,6 @@ #if FEATURE_convolve -extern void GLAPIENTRY -_mesa_ConvolutionFilter1D(GLenum target, GLenum internalformat, GLsizei width, - GLenum format, GLenum type, const GLvoid *image); - -extern void GLAPIENTRY -_mesa_ConvolutionFilter2D(GLenum target, GLenum internalformat, GLsizei width, - GLsizei height, GLenum format, GLenum type, - const GLvoid *image); - -extern void -_mesa_convolve_1d_image(const GLcontext *ctx, GLsizei *width, - const GLfloat *srcImage, GLfloat *dstImage); - -extern void -_mesa_convolve_2d_image(const GLcontext *ctx, GLsizei *width, GLsizei *height, - const GLfloat *srcImage, GLfloat *dstImage); - -extern void -_mesa_convolve_sep_image(const GLcontext *ctx, - GLsizei *width, GLsizei *height, - const GLfloat *srcImage, GLfloat *dstImage); - -extern void -_mesa_adjust_image_for_convolution(const GLcontext *ctx, GLuint dimensions, - GLsizei *width, GLsizei *height); - extern void _mesa_init_convolve_dispatch(struct _glapi_table *disp); @@ -66,50 +40,6 @@ _mesa_init_convolve_dispatch(struct _glapi_table *disp); #include "main/compiler.h" -static INLINE void GLAPIENTRY -_mesa_ConvolutionFilter1D(GLenum target, GLenum internalformat, GLsizei width, - GLenum format, GLenum type, const GLvoid *image) -{ - ASSERT_NO_FEATURE(); -} - -static INLINE void GLAPIENTRY -_mesa_ConvolutionFilter2D(GLenum target, GLenum internalformat, GLsizei width, - GLsizei height, GLenum format, GLenum type, - const GLvoid *image) -{ - ASSERT_NO_FEATURE(); -} - -static INLINE void -_mesa_convolve_1d_image(const GLcontext *ctx, GLsizei *width, - const GLfloat *srcImage, GLfloat *dstImage) -{ - ASSERT_NO_FEATURE(); -} - -static INLINE void -_mesa_convolve_2d_image(const GLcontext *ctx, GLsizei *width, GLsizei *height, - const GLfloat *srcImage, GLfloat *dstImage) -{ - ASSERT_NO_FEATURE(); -} - - -static INLINE void -_mesa_convolve_sep_image(const GLcontext *ctx, - GLsizei *width, GLsizei *height, - const GLfloat *srcImage, GLfloat *dstImage) -{ - ASSERT_NO_FEATURE(); -} - -static INLINE void -_mesa_adjust_image_for_convolution(const GLcontext *ctx, GLuint dimensions, - GLsizei *width, GLsizei *height) -{ -} - static INLINE void _mesa_init_convolve_dispatch(struct _glapi_table *disp) { diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 8a20a663632..46d26cf901d 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -558,15 +558,6 @@ struct dd_function_table { void (*CopyColorSubTable)( GLcontext *ctx, GLenum target, GLsizei start, GLint x, GLint y, GLsizei width ); - - void (*CopyConvolutionFilter1D)( GLcontext *ctx, GLenum target, - GLenum internalFormat, - GLint x, GLint y, GLsizei width ); - - void (*CopyConvolutionFilter2D)( GLcontext *ctx, GLenum target, - GLenum internalFormat, - GLint x, GLint y, - GLsizei width, GLsizei height ); /*@}*/ diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 2c8c000f9f4..15ce2d12254 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -712,29 +712,6 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state) ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled = state; break; - /* GL_EXT_convolution */ - case GL_CONVOLUTION_1D: - CHECK_EXTENSION(EXT_convolution, cap); - if (ctx->Pixel.Convolution1DEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.Convolution1DEnabled = state; - break; - case GL_CONVOLUTION_2D: - CHECK_EXTENSION(EXT_convolution, cap); - if (ctx->Pixel.Convolution2DEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.Convolution2DEnabled = state; - break; - case GL_SEPARABLE_2D: - CHECK_EXTENSION(EXT_convolution, cap); - if (ctx->Pixel.Separable2DEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.Separable2DEnabled = state; - break; - /* GL_ARB_texture_cube_map */ case GL_TEXTURE_CUBE_MAP_ARB: CHECK_EXTENSION(ARB_texture_cube_map, cap); @@ -1327,17 +1304,6 @@ _mesa_IsEnabled( GLenum cap ) CHECK_EXTENSION(SGI_texture_color_table); return ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled; - /* GL_EXT_convolution */ - case GL_CONVOLUTION_1D: - CHECK_EXTENSION(EXT_convolution); - return ctx->Pixel.Convolution1DEnabled; - case GL_CONVOLUTION_2D: - CHECK_EXTENSION(EXT_convolution); - return ctx->Pixel.Convolution2DEnabled; - case GL_SEPARABLE_2D: - CHECK_EXTENSION(EXT_convolution); - return ctx->Pixel.Separable2DEnabled; - /* GL_ARB_texture_cube_map */ case GL_TEXTURE_CUBE_MAP_ARB: CHECK_EXTENSION(ARB_texture_cube_map); diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 3f86973e3ea..c5febc77cff 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -116,7 +116,6 @@ static const struct { { OFF, "GL_EXT_clip_volume_hint", F(EXT_clip_volume_hint) }, { OFF, "GL_EXT_cull_vertex", F(EXT_cull_vertex) }, { ON, "GL_EXT_compiled_vertex_array", F(EXT_compiled_vertex_array) }, - { OFF, "GL_EXT_convolution", F(EXT_convolution) }, { ON, "GL_EXT_copy_texture", F(EXT_copy_texture) }, { OFF, "GL_EXT_depth_bounds_test", F(EXT_depth_bounds_test) }, { OFF, "GL_EXT_draw_buffers2", F(EXT_draw_buffers2) }, @@ -303,7 +302,6 @@ _mesa_enable_sw_extensions(GLcontext *ctx) ctx->Extensions.EXT_blend_logic_op = GL_TRUE; ctx->Extensions.EXT_blend_minmax = GL_TRUE; ctx->Extensions.EXT_blend_subtract = GL_TRUE; - ctx->Extensions.EXT_convolution = GL_TRUE; ctx->Extensions.EXT_depth_bounds_test = GL_TRUE; ctx->Extensions.EXT_draw_buffers2 = GL_TRUE; ctx->Extensions.EXT_fog_coord = GL_TRUE; @@ -393,7 +391,6 @@ _mesa_enable_imaging_extensions(GLcontext *ctx) ctx->Extensions.EXT_blend_logic_op = GL_TRUE; ctx->Extensions.EXT_blend_minmax = GL_TRUE; ctx->Extensions.EXT_blend_subtract = GL_TRUE; - ctx->Extensions.EXT_convolution = GL_TRUE; } diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 33ea81b83a6..cb456fb64d8 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -276,7 +276,6 @@ EXTRA_EXT(NV_fragment_program); EXTRA_EXT(NV_texture_rectangle); EXTRA_EXT(EXT_stencil_two_side); EXTRA_EXT(NV_light_max_exponent); -EXTRA_EXT(EXT_convolution); EXTRA_EXT(SGI_texture_color_table); EXTRA_EXT(EXT_depth_bounds_test); EXTRA_EXT(ARB_depth_clamp); @@ -880,38 +879,6 @@ static const struct value_desc values[] = { CONTEXT_MATRIX_T(ProjectionMatrixStack.Top), NO_EXTRA }, { GL_TRANSPOSE_TEXTURE_MATRIX_ARB, CONTEXT_MATRIX_T(TextureMatrixStack), NO_EXTRA }, - /* GL_EXT_convolution (also in 1.2 imaging) */ - { GL_CONVOLUTION_1D_EXT, CONTEXT_BOOL(Pixel.Convolution1DEnabled), - extra_EXT_convolution }, - { GL_CONVOLUTION_2D_EXT, CONTEXT_BOOL(Pixel.Convolution2DEnabled), - extra_EXT_convolution }, - { GL_SEPARABLE_2D_EXT, CONTEXT_BOOL(Pixel.Separable2DEnabled), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_RED_SCALE_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionScale[0]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_GREEN_SCALE_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionScale[1]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_BLUE_SCALE_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionScale[2]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_ALPHA_SCALE_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionScale[3]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_RED_BIAS_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionBias[0]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_GREEN_BIAS_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionBias[1]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_BLUE_BIAS_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionBias[2]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_ALPHA_BIAS_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionBias[3]), - extra_EXT_convolution }, - /* GL_SGI_texture_color_table */ { GL_TEXTURE_COLOR_TABLE_SGI, LOC_TEXUNIT, TYPE_BOOLEAN, offsetof(struct gl_texture_unit, ColorTableEnabled), diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 788584ae85f..029d2fef8a6 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1866,23 +1866,7 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps, if (transferOps & IMAGE_MAP_COLOR_BIT) { _mesa_map_rgba( ctx, n, rgba ); } - /* convolution */ - if (transferOps & IMAGE_CONVOLUTION_BIT) { - /* this has to be done in the calling code */ - _mesa_problem(ctx, "IMAGE_CONVOLUTION_BIT set in _mesa_apply_transfer_ops"); - } - /* GL_POST_CONVOLUTION_RED/GREEN/BLUE/ALPHA_SCALE/BIAS */ - if (transferOps & IMAGE_POST_CONVOLUTION_SCALE_BIAS) { - _mesa_scale_and_bias_rgba(n, rgba, - ctx->Pixel.PostConvolutionScale[RCOMP], - ctx->Pixel.PostConvolutionScale[GCOMP], - ctx->Pixel.PostConvolutionScale[BCOMP], - ctx->Pixel.PostConvolutionScale[ACOMP], - ctx->Pixel.PostConvolutionBias[RCOMP], - ctx->Pixel.PostConvolutionBias[GCOMP], - ctx->Pixel.PostConvolutionBias[BCOMP], - ctx->Pixel.PostConvolutionBias[ACOMP]); - } + /* clamping to [0,1] */ if (transferOps & IMAGE_CLAMP_BIT) { GLuint i; @@ -1988,8 +1972,7 @@ _mesa_apply_stencil_transfer_ops(const GLcontext *ctx, GLuint n, /** * Used to pack an array [][4] of RGBA float colors as specified - * by the dstFormat, dstType and dstPacking. Used by glReadPixels, - * glGetConvolutionFilter(), etc. + * by the dstFormat, dstType and dstPacking. Used by glReadPixels. * Note: the rgba values will be modified by this function when any pixel * transfer ops are enabled. */ diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index c982f55e825..d7c5d28c2cf 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -800,20 +800,6 @@ struct gl_hint_attrib GLenum FragmentShaderDerivative; /**< GL_ARB_fragment_shader */ }; - -/** - * Image convolution state. - */ -struct gl_convolution_attrib -{ - GLenum Format; - GLenum InternalFormat; - GLuint Width; - GLuint Height; - GLfloat Filter[MAX_CONVOLUTION_WIDTH * MAX_CONVOLUTION_HEIGHT * 4]; -}; - - /** * Light state flags. */ @@ -954,17 +940,6 @@ struct gl_pixel_attrib GLboolean MapColorFlag; GLboolean MapStencilFlag; - /* Convolution (GL_EXT_convolution) */ - GLboolean Convolution1DEnabled; - GLboolean Convolution2DEnabled; - GLboolean Separable2DEnabled; - GLfloat ConvolutionBorderColor[3][4]; /**< RGBA */ - GLenum ConvolutionBorderMode[3]; - GLfloat ConvolutionFilterScale[3][4]; /**< RGBA */ - GLfloat ConvolutionFilterBias[3][4]; /**< RGBA */ - GLfloat PostConvolutionScale[4]; /**< RGBA */ - GLfloat PostConvolutionBias[4]; /**< RGBA */ - /*--- End Pixel Transfer State ---*/ /** glPixelZoom */ @@ -2528,8 +2503,6 @@ struct gl_constants GLfloat LineWidthGranularity; GLuint MaxColorTableSize; - GLuint MaxConvolutionWidth; - GLuint MaxConvolutionHeight; GLuint MaxClipPlanes; GLuint MaxLights; @@ -2652,7 +2625,6 @@ struct gl_extensions GLboolean EXT_blend_subtract; GLboolean EXT_clip_volume_hint; GLboolean EXT_cull_vertex; - GLboolean EXT_convolution; GLboolean EXT_compiled_vertex_array; GLboolean EXT_copy_texture; GLboolean EXT_depth_bounds_test; @@ -2769,20 +2741,13 @@ struct gl_matrix_stack #define IMAGE_SCALE_BIAS_BIT 0x1 #define IMAGE_SHIFT_OFFSET_BIT 0x2 #define IMAGE_MAP_COLOR_BIT 0x4 -#define IMAGE_CONVOLUTION_BIT 0x10 -#define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20 #define IMAGE_CLAMP_BIT 0x800 -/** Pixel Transfer ops up to convolution */ -#define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \ - IMAGE_SHIFT_OFFSET_BIT | \ - IMAGE_MAP_COLOR_BIT) - -/** Pixel transfer ops after convolution */ -#define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS) -/*@}*/ - +/** Pixel Transfer ops */ +#define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \ + IMAGE_SHIFT_OFFSET_BIT | \ + IMAGE_MAP_COLOR_BIT) /** * \name Bits to indicate what state has changed. @@ -3135,9 +3100,6 @@ struct __GLcontextRec /** \name Other assorted state (not pushed/popped on attribute stack) */ /*@{*/ struct gl_pixelmaps PixelMaps; - struct gl_convolution_attrib Convolution1D; - struct gl_convolution_attrib Convolution2D; - struct gl_convolution_attrib Separable2D; struct gl_evaluators EvalMap; /**< All evaluators */ struct gl_feedback Feedback; /**< Feedback */ diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index 5e900b4eed9..1d378e4d9f7 100644 --- a/src/mesa/main/pixel.c +++ b/src/mesa/main/pixel.c @@ -566,54 +566,6 @@ _mesa_PixelTransferf( GLenum pname, GLfloat param ) FLUSH_VERTICES(ctx, _NEW_PIXEL); ctx->Pixel.DepthBias = param; break; - case GL_POST_CONVOLUTION_RED_SCALE: - if (ctx->Pixel.PostConvolutionScale[0] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostConvolutionScale[0] = param; - break; - case GL_POST_CONVOLUTION_RED_BIAS: - if (ctx->Pixel.PostConvolutionBias[0] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostConvolutionBias[0] = param; - break; - case GL_POST_CONVOLUTION_GREEN_SCALE: - if (ctx->Pixel.PostConvolutionScale[1] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostConvolutionScale[1] = param; - break; - case GL_POST_CONVOLUTION_GREEN_BIAS: - if (ctx->Pixel.PostConvolutionBias[1] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostConvolutionBias[1] = param; - break; - case GL_POST_CONVOLUTION_BLUE_SCALE: - if (ctx->Pixel.PostConvolutionScale[2] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostConvolutionScale[2] = param; - break; - case GL_POST_CONVOLUTION_BLUE_BIAS: - if (ctx->Pixel.PostConvolutionBias[2] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostConvolutionBias[2] = param; - break; - case GL_POST_CONVOLUTION_ALPHA_SCALE: - if (ctx->Pixel.PostConvolutionScale[3] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostConvolutionScale[3] = param; - break; - case GL_POST_CONVOLUTION_ALPHA_BIAS: - if (ctx->Pixel.PostConvolutionBias[3] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostConvolutionBias[3] = param; - break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glPixelTransfer(pname)" ); return; @@ -654,22 +606,6 @@ update_image_transfer_state(GLcontext *ctx) if (ctx->Pixel.MapColorFlag) mask |= IMAGE_MAP_COLOR_BIT; - if (ctx->Pixel.Convolution1DEnabled || - ctx->Pixel.Convolution2DEnabled || - ctx->Pixel.Separable2DEnabled) { - mask |= IMAGE_CONVOLUTION_BIT; - if (ctx->Pixel.PostConvolutionScale[0] != 1.0F || - ctx->Pixel.PostConvolutionScale[1] != 1.0F || - ctx->Pixel.PostConvolutionScale[2] != 1.0F || - ctx->Pixel.PostConvolutionScale[3] != 1.0F || - ctx->Pixel.PostConvolutionBias[0] != 0.0F || - ctx->Pixel.PostConvolutionBias[1] != 0.0F || - ctx->Pixel.PostConvolutionBias[2] != 0.0F || - ctx->Pixel.PostConvolutionBias[3] != 0.0F) { - mask |= IMAGE_POST_CONVOLUTION_SCALE_BIAS; - } - } - ctx->_ImageTransferState = mask; } @@ -721,8 +657,6 @@ init_pixelmap(struct gl_pixelmap *map) void _mesa_init_pixel( GLcontext *ctx ) { - int i; - /* Pixel group */ ctx->Pixel.RedBias = 0.0; ctx->Pixel.RedScale = 1.0; @@ -750,22 +684,6 @@ _mesa_init_pixel( GLcontext *ctx ) init_pixelmap(&ctx->PixelMaps.GtoG); init_pixelmap(&ctx->PixelMaps.BtoB); init_pixelmap(&ctx->PixelMaps.AtoA); - ctx->Pixel.Convolution1DEnabled = GL_FALSE; - ctx->Pixel.Convolution2DEnabled = GL_FALSE; - ctx->Pixel.Separable2DEnabled = GL_FALSE; - for (i = 0; i < 3; i++) { - ASSIGN_4V(ctx->Pixel.ConvolutionBorderColor[i], 0.0, 0.0, 0.0, 0.0); - ctx->Pixel.ConvolutionBorderMode[i] = GL_REDUCE; - ASSIGN_4V(ctx->Pixel.ConvolutionFilterScale[i], 1.0, 1.0, 1.0, 1.0); - ASSIGN_4V(ctx->Pixel.ConvolutionFilterBias[i], 0.0, 0.0, 0.0, 0.0); - } - for (i = 0; i < MAX_CONVOLUTION_WIDTH * MAX_CONVOLUTION_WIDTH * 4; i++) { - ctx->Convolution1D.Filter[i] = 0.0; - ctx->Convolution2D.Filter[i] = 0.0; - ctx->Separable2D.Filter[i] = 0.0; - } - ASSIGN_4V(ctx->Pixel.PostConvolutionScale, 1.0, 1.0, 1.0, 1.0); - ASSIGN_4V(ctx->Pixel.PostConvolutionBias, 0.0, 0.0, 0.0, 0.0); /* GL_SGI_texture_color_table */ ASSIGN_4V(ctx->Pixel.TextureColorTableScale, 1.0, 1.0, 1.0, 1.0); ASSIGN_4V(ctx->Pixel.TextureColorTableBias, 0.0, 0.0, 0.0, 0.0); diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c index c8b45bd3a55..3d8996c2fdc 100644 --- a/src/mesa/main/texcompress_fxt1.c +++ b/src/mesa/main/texcompress_fxt1.c @@ -32,7 +32,6 @@ #include "glheader.h" #include "imports.h" #include "colormac.h" -#include "convolve.h" #include "image.h" #include "macros.h" #include "mipmap.h" @@ -86,7 +85,6 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS) srcPacking); if (!tempImage) return GL_FALSE; /* out of memory */ - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); pixels = tempImage; srcRowStride = 3 * srcWidth; srcFormat = GL_RGB; @@ -143,7 +141,6 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS) srcPacking); if (!tempImage) return GL_FALSE; /* out of memory */ - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); pixels = tempImage; srcRowStride = 4 * srcWidth; srcFormat = GL_RGBA; diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c index 8e059802625..551203f0125 100644 --- a/src/mesa/main/texcompress_s3tc.c +++ b/src/mesa/main/texcompress_s3tc.c @@ -36,7 +36,6 @@ #include "glheader.h" #include "imports.h" #include "colormac.h" -#include "convolve.h" #include "dlopen.h" #include "image.h" #include "macros.h" @@ -187,7 +186,6 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS) srcPacking); if (!tempImage) return GL_FALSE; /* out of memory */ - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); pixels = tempImage; srcRowStride = 3 * srcWidth; srcFormat = GL_RGB; @@ -250,7 +248,6 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS) srcPacking); if (!tempImage) return GL_FALSE; /* out of memory */ - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); pixels = tempImage; srcRowStride = 4 * srcWidth; srcFormat = GL_RGBA; @@ -312,7 +309,6 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS) srcPacking); if (!tempImage) return GL_FALSE; /* out of memory */ - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); pixels = tempImage; srcRowStride = 4 * srcWidth; } @@ -373,7 +369,6 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS) srcPacking); if (!tempImage) return GL_FALSE; /* out of memory */ - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); pixels = tempImage; srcRowStride = 4 * srcWidth; } diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index ca1bd6096e2..614f0014dab 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -33,7 +33,6 @@ #include "glheader.h" #include "bufferobj.h" #include "context.h" -#include "convolve.h" #include "enums.h" #include "fbobject.h" #include "framebuffer.h" @@ -2243,12 +2242,6 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, internalFormat = override_internal_format(internalFormat, width, 1); -#if FEATURE_convolve - if (_mesa_is_color_format(internalFormat)) { - _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL); - } -#endif - if (target == GL_TEXTURE_1D) { /* non-proxy target */ struct gl_texture_object *texObj; @@ -2354,13 +2347,6 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, internalFormat = override_internal_format(internalFormat, width, height); -#if FEATURE_convolve - if (_mesa_is_color_format(internalFormat)) { - _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, - &postConvHeight); - } -#endif - if (target == GL_TEXTURE_2D || (ctx->Extensions.ARB_texture_cube_map && target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && @@ -2649,13 +2635,6 @@ _mesa_TexSubImage1D( GLenum target, GLint level, if (ctx->NewState & _MESA_NEW_TRANSFER_STATE) _mesa_update_state(ctx); -#if FEATURE_convolve - /* XXX should test internal format */ - if (_mesa_is_color_format(format)) { - _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL); - } -#endif - if (subtexture_error_check(ctx, 1, target, level, xoffset, 0, 0, postConvWidth, 1, 1, format, type)) { return; /* error was detected */ @@ -2715,14 +2694,6 @@ _mesa_TexSubImage2D( GLenum target, GLint level, if (ctx->NewState & _MESA_NEW_TRANSFER_STATE) _mesa_update_state(ctx); -#if FEATURE_convolve - /* XXX should test internal format */ - if (_mesa_is_color_format(format)) { - _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, - &postConvHeight); - } -#endif - if (subtexture_error_check(ctx, 2, target, level, xoffset, yoffset, 0, postConvWidth, postConvHeight, 1, format, type)) { return; /* error was detected */ @@ -2843,12 +2814,6 @@ _mesa_CopyTexImage1D( GLenum target, GLint level, if (ctx->NewState & NEW_COPY_TEX_STATE) _mesa_update_state(ctx); -#if FEATURE_convolve - if (_mesa_is_color_format(internalFormat)) { - _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL); - } -#endif - if (copytexture_error_check(ctx, 1, target, level, internalFormat, postConvWidth, 1, border)) return; @@ -2918,13 +2883,6 @@ _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat, if (ctx->NewState & NEW_COPY_TEX_STATE) _mesa_update_state(ctx); -#if FEATURE_convolve - if (_mesa_is_color_format(internalFormat)) { - _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, - &postConvHeight); - } -#endif - if (copytexture_error_check(ctx, 2, target, level, internalFormat, postConvWidth, postConvHeight, border)) return; @@ -3004,12 +2962,6 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level, { texImage = _mesa_select_tex_image(ctx, texObj, target, level); -#if FEATURE_convolve - if (texImage && _mesa_is_color_format(texImage->InternalFormat)) { - _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL); - } -#endif - if (copytexsubimage_error_check2(ctx, 1, target, level, xoffset, 0, 0, postConvWidth, 1, texImage)) { @@ -3064,13 +3016,6 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level, { texImage = _mesa_select_tex_image(ctx, texObj, target, level); -#if FEATURE_convolve - if (texImage && _mesa_is_color_format(texImage->InternalFormat)) { - _mesa_adjust_image_for_convolution(ctx, 2, - &postConvWidth, &postConvHeight); - } -#endif - if (copytexsubimage_error_check2(ctx, 2, target, level, xoffset, yoffset, 0, postConvWidth, postConvHeight, @@ -3127,13 +3072,6 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level, { texImage = _mesa_select_tex_image(ctx, texObj, target, level); -#if FEATURE_convolve - if (texImage && _mesa_is_color_format(texImage->InternalFormat)) { - _mesa_adjust_image_for_convolution(ctx, 2, - &postConvWidth, &postConvHeight); - } -#endif - if (copytexsubimage_error_check2(ctx, 3, target, level, xoffset, yoffset, zoffset, postConvWidth, postConvHeight, texImage)) { diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 2989fdb72ed..a1574e6cd83 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -45,7 +45,7 @@ * Texture image processing is actually kind of complicated. We have to do: * Format/type conversions * pixel unpacking - * pixel transfer (scale, bais, lookup, convolution!, etc) + * pixel transfer (scale, bais, lookup, etc) * * These functions can handle most everything, including processing full * images and sub-images. @@ -55,7 +55,6 @@ #include "glheader.h" #include "bufferobj.h" #include "colormac.h" -#include "convolve.h" #include "image.h" #include "macros.h" #include "mipmap.h" @@ -310,6 +309,11 @@ make_temp_float_image(GLcontext *ctx, GLuint dims, { GLuint transferOps = ctx->_ImageTransferState; GLfloat *tempImage; + const GLint components = _mesa_components_in_format(logicalBaseFormat); + const GLint srcStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLfloat *dst; + GLint img, row; ASSERT(dims >= 1 && dims <= 3); @@ -331,126 +335,24 @@ make_temp_float_image(GLcontext *ctx, GLuint dims, textureBaseFormat == GL_COLOR_INDEX || textureBaseFormat == GL_DEPTH_COMPONENT); - /* conventional color image */ - - if ((dims == 1 && ctx->Pixel.Convolution1DEnabled) || - (dims >= 2 && ctx->Pixel.Convolution2DEnabled) || - (dims >= 2 && ctx->Pixel.Separable2DEnabled)) { - /* need image convolution */ - const GLuint preConvTransferOps - = (transferOps & IMAGE_PRE_CONVOLUTION_BITS) | IMAGE_CLAMP_BIT; - const GLuint postConvTransferOps - = (transferOps & IMAGE_POST_CONVOLUTION_BITS) | IMAGE_CLAMP_BIT; - GLint img, row; - GLint convWidth = srcWidth, convHeight = srcHeight; - GLfloat *convImage; - - /* pre-convolution image buffer (3D) */ - tempImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth - * 4 * sizeof(GLfloat)); - if (!tempImage) - return NULL; - - /* post-convolution image buffer (2D) */ - convImage = (GLfloat *) malloc(srcWidth * srcHeight - * 4 * sizeof(GLfloat)); - if (!convImage) { - free(tempImage); - return NULL; - } - - /* loop over 3D image slices */ - for (img = 0; img < srcDepth; img++) { - GLfloat *dst = tempImage + img * (srcWidth * srcHeight * 4); - - /* unpack and do transfer ops up to convolution */ - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, - srcFormat, srcType, img, row, 0); - _mesa_unpack_color_span_float(ctx, srcWidth, GL_RGBA, dst, - srcFormat, srcType, src, - srcPacking, - preConvTransferOps); - dst += srcWidth * 4; - } - - /* size after optional convolution */ - convWidth = srcWidth; - convHeight = srcHeight; - -#if FEATURE_convolve - /* do convolution */ - { - GLfloat *src = tempImage + img * (srcWidth * srcHeight * 4); - if (dims == 1) { - ASSERT(ctx->Pixel.Convolution1DEnabled); - _mesa_convolve_1d_image(ctx, &convWidth, src, convImage); - } - else { - if (ctx->Pixel.Convolution2DEnabled) { - _mesa_convolve_2d_image(ctx, &convWidth, &convHeight, - src, convImage); - } - else { - ASSERT(ctx->Pixel.Separable2DEnabled); - _mesa_convolve_sep_image(ctx, &convWidth, &convHeight, - src, convImage); - } - } - } -#endif - /* do post-convolution transfer and pack into tempImage */ - { - const GLint logComponents - = _mesa_components_in_format(logicalBaseFormat); - const GLfloat *src = convImage; - GLfloat *dst = tempImage + img * (convWidth * convHeight * 4); - for (row = 0; row < convHeight; row++) { - _mesa_pack_rgba_span_float(ctx, convWidth, - (GLfloat (*)[4]) src, - logicalBaseFormat, GL_FLOAT, - dst, &ctx->DefaultPacking, - postConvTransferOps); - src += convWidth * 4; - dst += convWidth * logComponents; - } - } - } /* loop over 3D image slices */ - - free(convImage); - - /* might need these below */ - srcWidth = convWidth; - srcHeight = convHeight; - } - else { - /* no convolution */ - const GLint components = _mesa_components_in_format(logicalBaseFormat); - const GLint srcStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLfloat *dst; - GLint img, row; - - tempImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth - * components * sizeof(GLfloat)); - if (!tempImage) - return NULL; + tempImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth + * components * sizeof(GLfloat)); + if (!tempImage) + return NULL; - dst = tempImage; - for (img = 0; img < srcDepth; img++) { - const GLubyte *src - = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - img, 0, 0); - for (row = 0; row < srcHeight; row++) { - _mesa_unpack_color_span_float(ctx, srcWidth, logicalBaseFormat, - dst, srcFormat, srcType, src, - srcPacking, transferOps); - dst += srcWidth * components; - src += srcStride; - } + dst = tempImage; + for (img = 0; img < srcDepth; img++) { + const GLubyte *src + = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + _mesa_unpack_color_span_float(ctx, srcWidth, logicalBaseFormat, + dst, srcFormat, srcType, src, + srcPacking, transferOps); + dst += srcWidth * components; + src += srcStride; } } @@ -536,7 +438,6 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims, { GLuint transferOps = ctx->_ImageTransferState; const GLint components = _mesa_components_in_format(logicalBaseFormat); - GLboolean freeSrcImage = GL_FALSE; GLint img, row; GLchan *tempImage, *dst; @@ -556,37 +457,10 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims, textureBaseFormat == GL_ALPHA || textureBaseFormat == GL_INTENSITY); -#if FEATURE_convolve - if ((dims == 1 && ctx->Pixel.Convolution1DEnabled) || - (dims >= 2 && ctx->Pixel.Convolution2DEnabled) || - (dims >= 2 && ctx->Pixel.Separable2DEnabled)) { - /* get convolved image */ - GLfloat *convImage = make_temp_float_image(ctx, dims, - logicalBaseFormat, - logicalBaseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, - srcAddr, srcPacking); - if (!convImage) - return NULL; - /* the convolved image is our new source image */ - srcAddr = convImage; - srcFormat = logicalBaseFormat; - srcType = GL_FLOAT; - srcPacking = &ctx->DefaultPacking; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - transferOps = 0; - freeSrcImage = GL_TRUE; - } -#endif - /* unpack and transfer the source image */ tempImage = (GLchan *) malloc(srcWidth * srcHeight * srcDepth * components * sizeof(GLchan)); if (!tempImage) { - if (freeSrcImage) { - free((void *) srcAddr); - } return NULL; } @@ -608,11 +482,6 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims, } } - /* If we made a temporary image for convolution, free it here */ - if (freeSrcImage) { - free((void *) srcAddr); - } - if (logicalBaseFormat != textureBaseFormat) { /* one more conversion step */ GLint texComponents = _mesa_components_in_format(textureBaseFormat); @@ -1238,7 +1107,6 @@ _mesa_texstore_rgb565(TEXSTORE_PARAMS) GLint img, row, col; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -1365,7 +1233,6 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS) GLint img, row, col; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -1567,7 +1434,6 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) GLint img, row, col; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -1697,7 +1563,6 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS) GLint img, row, col; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -1824,7 +1689,6 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS) GLint img, row, col; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -1882,7 +1746,6 @@ _mesa_texstore_argb4444(TEXSTORE_PARAMS) GLint img, row, col; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -1951,7 +1814,6 @@ _mesa_texstore_rgba5551(TEXSTORE_PARAMS) GLint img, row, col; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -2010,7 +1872,6 @@ _mesa_texstore_argb1555(TEXSTORE_PARAMS) GLint img, row, col; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -2115,7 +1976,6 @@ _mesa_texstore_al88(TEXSTORE_PARAMS) GLint img, row, col; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -2186,7 +2046,6 @@ _mesa_texstore_al1616(TEXSTORE_PARAMS) GLint img, row, col; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -2257,7 +2116,6 @@ _mesa_texstore_rgba_16(TEXSTORE_PARAMS) GLint img, row, col; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -2327,8 +2185,6 @@ _mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS) if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - /* Note: tempImage is always float[4] / RGBA. We convert to 1, 2, * 3 or 4 components/pixel here. */ @@ -2390,7 +2246,6 @@ _mesa_texstore_rgb332(TEXSTORE_PARAMS) GLint img, row, col; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -2479,7 +2334,6 @@ _mesa_texstore_a8(TEXSTORE_PARAMS) GLint img, row, col; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -2710,7 +2564,6 @@ _mesa_texstore_signed_r8(TEXSTORE_PARAMS) GLint img, row, col; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -2755,7 +2608,6 @@ _mesa_texstore_signed_rg88(TEXSTORE_PARAMS) GLint img, row, col; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -2800,7 +2652,6 @@ _mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS) GLint img, row, col; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -2912,7 +2763,6 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS) GLint img, row, col; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -3186,7 +3036,6 @@ _mesa_texstore_rgba_float32(TEXSTORE_PARAMS) GLint img, row; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); bytesPerRow = srcWidth * components * sizeof(GLfloat); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr @@ -3254,7 +3103,6 @@ _mesa_texstore_rgba_float16(TEXSTORE_PARAMS) GLint img, row; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -3318,7 +3166,6 @@ _mesa_texstore_rgba_int8(TEXSTORE_PARAMS) GLint img, row; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -3382,7 +3229,6 @@ _mesa_texstore_rgba_int16(TEXSTORE_PARAMS) GLint img, row; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -3446,7 +3292,6 @@ _mesa_texstore_rgba_int32(TEXSTORE_PARAMS) GLint img, row; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -3510,7 +3355,6 @@ _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) GLint img, row; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -3574,7 +3418,6 @@ _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) GLint img, row; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -3638,7 +3481,6 @@ _mesa_texstore_rgba_uint32(TEXSTORE_PARAMS) GLint img, row; if (!tempImage) return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = (GLubyte *) dstAddr + dstImageOffsets[dstZoffset + img] * texelBytes @@ -4057,9 +3899,6 @@ texture_row_stride(const struct gl_texture_image *texImage) * This is the software fallback for Driver.TexImage1D() * and Driver.CopyTexImage1D(). * \sa _mesa_store_teximage2d() - * Note that the width may not be the actual texture width since it may - * be changed by convolution w/ GL_REDUCE. The texImage->Width field will - * have the actual texture size. */ void _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level, @@ -4114,9 +3953,6 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level, * * This function is oriented toward storing images in main memory, rather * than VRAM. Device driver's can easily plug in their own replacement. - * - * Note: width and height may be pre-convolved dimensions, but - * texImage->Width and texImage->Height will be post-convolved dimensions. */ void _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level, diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 6ab03ec9391..d9e9a527f63 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -338,9 +338,6 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, assert(ctx->ReadBuffer->Width > 0); - /* XXX convolution not done yet */ - assert((transferOps & IMAGE_CONVOLUTION_BIT) == 0); - st_validate_state(st); /* Do all needed clipping here, so that we can forget about it later */ diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 0a4f8508ec2..526417df3ba 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -545,11 +545,6 @@ st_TexImage(GLcontext * ctx, DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__, _mesa_lookup_enum_by_nr(target), level, width, height, depth, border); - /* The Mesa/Gallium state tracker does not implement the imaging extensions - * such as convolution. - */ - assert(!ctx->Extensions.EXT_convolution); - /* switch to "normal" */ if (stObj->surface_based) { _mesa_clear_texture_object(ctx, texObj); diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index a9b4cb80818..c35494e3857 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -27,7 +27,6 @@ #include "main/context.h" #include "main/colormac.h" #include "main/condrender.h" -#include "main/convolve.h" #include "main/image.h" #include "main/macros.h" #include "main/imports.h" @@ -94,98 +93,6 @@ regions_overlap(GLint srcx, GLint srcy, /** - * RGBA copypixels with convolution. - */ -static void -copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, - GLint width, GLint height, GLint destx, GLint desty) -{ - GLint row; - const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; - const GLbitfield transferOps = ctx->_ImageTransferState; - GLfloat *dest, *tmpImage, *convImage; - SWspan span; - - INIT_SPAN(span, GL_BITMAP); - _swrast_span_default_attribs(ctx, &span); - span.arrayMask = SPAN_RGBA; - span.arrayAttribs = FRAG_BIT_COL0; - - /* allocate space for GLfloat image */ - tmpImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - if (!tmpImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels"); - return; - } - convImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - if (!convImage) { - free(tmpImage); - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels"); - return; - } - - /* read source image as float/RGBA */ - dest = tmpImage; - for (row = 0; row < height; row++) { - _swrast_read_rgba_span(ctx, ctx->ReadBuffer->_ColorReadBuffer, - width, srcx, srcy + row, GL_FLOAT, dest); - dest += 4 * width; - } - - /* do the image transfer ops which preceed convolution */ - for (row = 0; row < height; row++) { - GLfloat (*rgba)[4] = (GLfloat (*)[4]) (tmpImage + row * width * 4); - _mesa_apply_rgba_transfer_ops(ctx, - transferOps & IMAGE_PRE_CONVOLUTION_BITS, - width, rgba); - } - - /* do convolution */ - if (ctx->Pixel.Convolution2DEnabled) { - _mesa_convolve_2d_image(ctx, &width, &height, tmpImage, convImage); - } - else { - ASSERT(ctx->Pixel.Separable2DEnabled); - _mesa_convolve_sep_image(ctx, &width, &height, tmpImage, convImage); - } - free(tmpImage); - - /* do remaining post-convolution image transfer ops */ - for (row = 0; row < height; row++) { - GLfloat (*rgba)[4] = (GLfloat (*)[4]) (convImage + row * width * 4); - _mesa_apply_rgba_transfer_ops(ctx, - transferOps & IMAGE_POST_CONVOLUTION_BITS, - width, rgba); - } - - /* write the new image */ - for (row = 0; row < height; row++) { - const GLfloat *src = convImage + row * width * 4; - GLfloat *rgba = (GLfloat *) span.array->attribs[FRAG_ATTRIB_COL0]; - - /* copy convolved colors into span array */ - memcpy(rgba, src, width * 4 * sizeof(GLfloat)); - - /* write span */ - span.x = destx; - span.y = desty + row; - span.end = width; - span.array->ChanType = GL_FLOAT; - if (zoom) { - _swrast_write_zoomed_rgba_span(ctx, destx, desty, &span, rgba); - } - else { - _swrast_write_rgba_span(ctx, &span); - } - } - /* restore this */ - span.array->ChanType = CHAN_TYPE; - - free(convImage); -} - - -/** * RGBA copypixels */ static void @@ -204,16 +111,6 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, return; } - if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) { - copy_conv_rgba_pixels(ctx, srcx, srcy, width, height, destx, desty); - return; - } - else if (ctx->Pixel.Convolution1DEnabled) { - /* make sure we don't apply 1D convolution */ - transferOps &= ~(IMAGE_CONVOLUTION_BIT | - IMAGE_POST_CONVOLUTION_SCALE_BIAS); - } - if (ctx->DrawBuffer == ctx->ReadBuffer) { overlapping = regions_overlap(srcx, srcy, destx, desty, width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY); diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 9bc0e9043ba..7778820c5cd 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -27,7 +27,6 @@ #include "main/bufferobj.h" #include "main/condrender.h" #include "main/context.h" -#include "main/convolve.h" #include "main/image.h" #include "main/macros.h" #include "main/imports.h" @@ -484,62 +483,6 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, span.arrayMask = SPAN_RGBA; span.arrayAttribs = FRAG_BIT_COL0; /* we're fill in COL0 attrib values */ - if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) { - /* Convolution has to be handled specially. We'll create an - * intermediate image, applying all pixel transfer operations - * up to convolution. Then we'll convolve the image. Then - * we'll proceed with the rest of the transfer operations and - * rasterize the image. - */ - GLint row; - GLfloat *dest, *tmpImage; - - tmpImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - if (!tmpImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels"); - return; - } - convImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - if (!convImage) { - free(tmpImage); - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels"); - return; - } - - /* Unpack the image and apply transfer ops up to convolution */ - dest = tmpImage; - for (row = 0; row < height; row++) { - const GLvoid *source = _mesa_image_address2d(unpack, - pixels, width, height, format, type, row, 0); - _mesa_unpack_color_span_float(ctx, width, GL_RGBA, (GLfloat *) dest, - format, type, source, unpack, - transferOps & IMAGE_PRE_CONVOLUTION_BITS); - dest += width * 4; - } - - /* do convolution */ - if (ctx->Pixel.Convolution2DEnabled) { - _mesa_convolve_2d_image(ctx, &width, &height, tmpImage, convImage); - } - else { - ASSERT(ctx->Pixel.Separable2DEnabled); - _mesa_convolve_sep_image(ctx, &width, &height, tmpImage, convImage); - } - free(tmpImage); - - /* continue transfer ops and draw the convolved image */ - unpack = &ctx->DefaultPacking; - pixels = convImage; - format = GL_RGBA; - type = GL_FLOAT; - transferOps &= IMAGE_POST_CONVOLUTION_BITS; - } - else if (ctx->Pixel.Convolution1DEnabled) { - /* we only want to apply 1D convolution to glTexImage1D */ - transferOps &= ~(IMAGE_CONVOLUTION_BIT | - IMAGE_POST_CONVOLUTION_SCALE_BIAS); - } - if (ctx->DrawBuffer->_NumColorDrawBuffers > 0 && ctx->DrawBuffer->_ColorDrawBuffers[0]->DataType != GL_FLOAT && ctx->Color.ClampFragmentColor != GL_FALSE) { diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index 1de481248b1..b0a3d36420a 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -26,7 +26,6 @@ #include "main/glheader.h" #include "main/bufferobj.h" #include "main/colormac.h" -#include "main/convolve.h" #include "main/feedback.h" #include "main/formats.h" #include "main/image.h" @@ -326,57 +325,7 @@ read_rgba_pixels( GLcontext *ctx, /* width should never be > MAX_WIDTH since we did clipping earlier */ ASSERT(width <= MAX_WIDTH); - if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) { - GLfloat *dest, *src, *tmpImage, *convImage; - GLint row; - - tmpImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - if (!tmpImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); - return; - } - convImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - if (!convImage) { - free(tmpImage); - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); - return; - } - - /* read full RGBA, FLOAT image */ - dest = tmpImage; - for (row = 0; row < height; row++, y++) { - _swrast_read_rgba_span(ctx, rb, width, x, y, GL_FLOAT, dest); - _mesa_apply_rgba_transfer_ops(ctx, - transferOps & IMAGE_PRE_CONVOLUTION_BITS, - width, (GLfloat (*)[4]) dest); - dest += width * 4; - } - - /* do convolution */ - if (ctx->Pixel.Convolution2DEnabled) { - _mesa_convolve_2d_image(ctx, &width, &height, tmpImage, convImage); - } - else { - ASSERT(ctx->Pixel.Separable2DEnabled); - _mesa_convolve_sep_image(ctx, &width, &height, tmpImage, convImage); - } - free(tmpImage); - - /* finish transfer ops and pack the resulting image */ - src = convImage; - for (row = 0; row < height; row++) { - GLvoid *dest; - dest = _mesa_image_address2d(packing, pixels, width, height, - format, type, row, 0); - _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) src, - format, type, dest, packing, - transferOps & IMAGE_POST_CONVOLUTION_BITS); - src += width * 4; - } - free(convImage); - } - else { - /* no convolution */ + do { const GLint dstStride = _mesa_image_row_stride(packing, width, format, type); GLfloat (*rgba)[4] = swrast->SpanArrays->attribs[FRAG_ATTRIB_COL0]; @@ -385,10 +334,6 @@ read_rgba_pixels( GLcontext *ctx, = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height, format, type, 0, 0); - /* make sure we don't apply 1D convolution */ - transferOps &= ~(IMAGE_CONVOLUTION_BIT | - IMAGE_POST_CONVOLUTION_SCALE_BIAS); - for (row = 0; row < height; row++, y++) { /* Get float rgba pixels */ @@ -407,7 +352,7 @@ read_rgba_pixels( GLcontext *ctx, dst += dstStride; } - } + } while (0); } |