From 434ec3ada841915a00ffc23f699401eb3e7b37ee Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 12 Aug 2009 13:46:16 -0600 Subject: mesa: use _mesa_is_bufferobj() --- src/mesa/main/convolve.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/mesa/main/convolve.c') diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c index 814c6a0a5a..69dba72ed3 100644 --- a/src/mesa/main/convolve.c +++ b/src/mesa/main/convolve.c @@ -144,7 +144,7 @@ _mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, G ctx->Convolution1D.Width = width; ctx->Convolution1D.Height = 1; - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { /* unpack filter from PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(1, &ctx->Unpack, width, 1, 1, @@ -173,7 +173,7 @@ _mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, G format, type, image, &ctx->Unpack, 0); /* transferOps */ - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, ctx->Unpack.BufferObj); } @@ -242,7 +242,7 @@ _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, G ctx->Convolution2D.Width = width; ctx->Convolution2D.Height = height; - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { /* unpack filter from PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1, @@ -276,7 +276,7 @@ _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, G 0); /* transferOps */ } - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, ctx->Unpack.BufferObj); } @@ -598,7 +598,7 @@ _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, return; } - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* Pack the filter into a PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(2, &ctx->Pack, @@ -629,7 +629,7 @@ _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, format, type, dst, &ctx->Pack, 0x0); } - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, ctx->Pack.BufferObj); } @@ -802,7 +802,7 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, filter = &ctx->Separable2D; - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* Pack filter into PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(1, &ctx->Pack, filter->Width, 1, 1, @@ -850,7 +850,7 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, (void) span; /* unused at this time */ - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* Pack filter into PBO */ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, ctx->Unpack.BufferObj); @@ -905,7 +905,7 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs ctx->Separable2D.Width = width; ctx->Separable2D.Height = height; - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { /* unpack filter from PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(1, &ctx->Unpack, width, 1, 1, @@ -971,7 +971,7 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs ctx->Pixel.ConvolutionFilterBias[2][3]); } - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, ctx->Unpack.BufferObj); } -- cgit v1.2.3 From 203f395aaf717a6faf21a76979cc24d544ae148b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 3 Sep 2009 10:41:14 -0600 Subject: mesa: use new _mesa_map_pbo_source/dest() functions in more places This trims down the code a bit. The next step would be to combine the validate and map operations into one helper... --- src/mesa/main/colortab.c | 63 +++++------- src/mesa/main/convolve.c | 100 +++++++------------ src/mesa/main/histogram.c | 67 +++++-------- src/mesa/main/pixel.c | 239 ++++++++++++++++------------------------------ src/mesa/main/polygon.c | 77 ++++++--------- 5 files changed, 192 insertions(+), 354 deletions(-) (limited to 'src/mesa/main/convolve.c') diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c index 36304065eb..91c29882ec 100644 --- a/src/mesa/main/colortab.c +++ b/src/mesa/main/colortab.c @@ -179,27 +179,22 @@ store_colortable_entries(GLcontext *ctx, struct gl_color_table *table, GLfloat bScale, GLfloat bBias, GLfloat aScale, GLfloat aBias) { - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - /* Get/unpack the color table data from a PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(1, &ctx->Unpack, count, 1, 1, - format, type, data)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glColor[Sub]Table(bad PBO access)"); - return; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, - ctx->Unpack.BufferObj); - if (!buf) { + if (!_mesa_validate_pbo_access(1, &ctx->Unpack, count, 1, 1, + format, type, data)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glColor[Sub]Table(bad PBO access)"); + return; + } + + data = _mesa_map_pbo_source(ctx, &ctx->Unpack, data); + if (!data) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glColor[Sub]Table(PBO mapped)"); - return; } - data = ADD_POINTERS(buf, data); + return; } - { /* convert user-provided data to GLfloat values */ GLfloat tempTab[MAX_COLOR_TABLE_SIZE * 4]; @@ -279,10 +274,7 @@ store_colortable_entries(GLcontext *ctx, struct gl_color_table *table, } } - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - ctx->Unpack.BufferObj); - } + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); } @@ -696,34 +688,27 @@ _mesa_GetColorTable( GLenum target, GLenum format, return; } - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* pack color table into PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(1, &ctx->Pack, table->Size, 1, 1, - format, type, data)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetColorTable(invalid PBO access)"); - return; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - GL_WRITE_ONLY_ARB, - ctx->Pack.BufferObj); - if (!buf) { + if (!_mesa_validate_pbo_access(1, &ctx->Pack, table->Size, 1, 1, + format, type, data)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetColorTable(invalid PBO access)"); + return; + } + + data = _mesa_map_pbo_dest(ctx, &ctx->Pack, data); + if (!data) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* buffer is already mapped - that's an error */ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetColorTable(PBO is mapped)"); - return; } - data = ADD_POINTERS(buf, data); + return; } _mesa_pack_rgba_span_float(ctx, table->Size, rgba, format, type, data, &ctx->Pack, 0x0); - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - ctx->Pack.BufferObj); - } + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); } diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c index 69dba72ed3..7e0761e68b 100644 --- a/src/mesa/main/convolve.c +++ b/src/mesa/main/convolve.c @@ -144,27 +144,19 @@ _mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, G ctx->Convolution1D.Width = width; ctx->Convolution1D.Height = 1; - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - /* unpack filter from PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(1, &ctx->Unpack, width, 1, 1, - format, type, image)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glConvolutionFilter1D(invalid PBO access)"); - return; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, - ctx->Unpack.BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ + if (!_mesa_validate_pbo_access(1, &ctx->Unpack, width, 1, 1, + format, type, image)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glConvolutionFilter1D(invalid PBO access)"); + return; + } + + image = _mesa_map_pbo_source(ctx, &ctx->Unpack, image); + if (!image) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glConvolutionFilter1D(PBO is mapped)"); - return; } - image = ADD_POINTERS(buf, image); - } - else if (!image) { return; } @@ -173,10 +165,7 @@ _mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, G format, type, image, &ctx->Unpack, 0); /* transferOps */ - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - ctx->Unpack.BufferObj); - } + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); _mesa_scale_and_bias_rgba(width, (GLfloat (*)[4]) ctx->Convolution1D.Filter, @@ -242,27 +231,19 @@ _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, G ctx->Convolution2D.Width = width; ctx->Convolution2D.Height = height; - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - /* unpack filter from PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1, - format, type, image)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glConvolutionFilter2D(invalid PBO access)"); - return; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, - ctx->Unpack.BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ + if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1, + format, type, image)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glConvolutionFilter2D(invalid PBO access)"); + return; + } + + image = _mesa_map_pbo_source(ctx, &ctx->Unpack, image); + if (!image) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glConvolutionFilter2D(PBO is mapped)"); - return; } - image = ADD_POINTERS(buf, image); - } - else if (!image) { return; } @@ -276,10 +257,7 @@ _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, G 0); /* transferOps */ } - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - ctx->Unpack.BufferObj); - } + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); _mesa_scale_and_bias_rgba(width * height, (GLfloat (*)[4]) ctx->Convolution2D.Filter, @@ -598,26 +576,21 @@ _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, return; } - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* Pack the filter into a PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(2, &ctx->Pack, - filter->Width, filter->Height, - 1, format, type, image)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetConvolutionFilter(invalid PBO access)"); - return; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - GL_WRITE_ONLY_ARB, - ctx->Pack.BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ + if (!_mesa_validate_pbo_access(2, &ctx->Pack, + filter->Width, filter->Height, + 1, format, type, image)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetConvolutionFilter(invalid PBO access)"); + return; + } + + image = _mesa_map_pbo_dest(ctx, &ctx->Pack, image); + if (!image) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetConvolutionFilter(PBO is mapped)"); - return; } - image = ADD_POINTERS(image, buf); + return; } for (row = 0; row < filter->Height; row++) { @@ -629,10 +602,7 @@ _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, format, type, dst, &ctx->Pack, 0x0); } - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - ctx->Pack.BufferObj); - } + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); } diff --git a/src/mesa/main/histogram.c b/src/mesa/main/histogram.c index 726a50d3b1..f1d01cdb62 100644 --- a/src/mesa/main/histogram.c +++ b/src/mesa/main/histogram.c @@ -649,27 +649,19 @@ _mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvo return; } - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* pack min/max values into a PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(1, &ctx->Pack, 2, 1, 1, - format, type, values)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetMinMax(invalid PBO access)"); - return; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - GL_WRITE_ONLY_ARB, - ctx->Pack.BufferObj); - if (!buf) { + if (!_mesa_validate_pbo_access(1, &ctx->Pack, 2, 1, 1, + format, type, values)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetMinMax(invalid PBO access)"); + return; + } + + values = _mesa_map_pbo_dest(ctx, &ctx->Pack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* buffer is already mapped - that's an error */ _mesa_error(ctx, GL_INVALID_OPERATION,"glGetMinMax(PBO is mapped)"); - return; } - values = ADD_POINTERS(buf, values); - } - else if (!values) { - /* not an error */ return; } @@ -687,10 +679,7 @@ _mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvo format, type, values, &ctx->Pack, 0x0); } - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - ctx->Pack.BufferObj); - } + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); if (reset) { _mesa_ResetMinmax(GL_MINMAX); @@ -733,27 +722,18 @@ _mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, G return; } - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* pack min/max values into a PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(1, &ctx->Pack, ctx->Histogram.Width, 1, 1, - format, type, values)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetHistogram(invalid PBO access)"); - return; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - GL_WRITE_ONLY_ARB, - ctx->Pack.BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ + if (!_mesa_validate_pbo_access(1, &ctx->Pack, ctx->Histogram.Width, 1, 1, + format, type, values)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetHistogram(invalid PBO access)"); + return; + } + + values = _mesa_map_pbo_dest(ctx, &ctx->Pack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { _mesa_error(ctx,GL_INVALID_OPERATION,"glGetHistogram(PBO is mapped)"); - return; } - values = ADD_POINTERS(buf, values); - } - else if (!values) { - /* not an error */ return; } @@ -761,10 +741,7 @@ _mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, G (CONST GLuint (*)[4]) ctx->Histogram.Count, format, type, values, &ctx->Pack); - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - ctx->Pack.BufferObj); - } + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); if (reset) { GLuint i; diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index 25f55a422f..fcef6dfd42 100644 --- a/src/mesa/main/pixel.c +++ b/src/mesa/main/pixel.c @@ -136,6 +136,33 @@ store_pixelmap(GLcontext *ctx, GLenum map, GLsizei mapsize, } +/** + * Convenience wrapper for _mesa_validate_pbo_access() for gl[Get]PixelMap(). + */ +static GLboolean +validate_pbo_access(GLcontext *ctx, struct gl_pixelstore_attrib *pack, + GLsizei mapsize, GLenum format, GLenum type, + const GLvoid *ptr) +{ + GLboolean ok; + + /* Note, need to use DefaultPacking and Unpack's buffer object */ + ctx->DefaultPacking.BufferObj = pack->BufferObj; + + ok = _mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1, + format, type, ptr); + + /* restore */ + ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj; + + if (!ok) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glPixelMap(invalid PBO access)"); + } + return ok; +} + + void GLAPIENTRY _mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values ) { @@ -158,40 +185,23 @@ _mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values ) FLUSH_VERTICES(ctx, _NEW_PIXEL); - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - /* unpack pixelmap from PBO */ - GLubyte *buf; - /* Note, need to use DefaultPacking and Unpack's buffer object */ - ctx->DefaultPacking.BufferObj = ctx->Unpack.BufferObj; - if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1, - GL_INTENSITY, GL_FLOAT, values)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glPixelMapfv(invalid PBO access)"); - return; - } - /* restore */ - ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj; - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, - ctx->Unpack.BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ + if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, + GL_INTENSITY, GL_FLOAT, values)) { + return; + } + + values = (const GLfloat *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glPixelMapfv(PBO is mapped)"); - return; } - values = (const GLfloat *) ADD_POINTERS(buf, values); - } - else if (!values) { return; } store_pixelmap(ctx, map, mapsize, values); - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - ctx->Unpack.BufferObj); - } + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); } @@ -217,31 +227,17 @@ _mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values ) FLUSH_VERTICES(ctx, _NEW_PIXEL); - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - /* unpack pixelmap from PBO */ - GLubyte *buf; - /* Note, need to use DefaultPacking and Unpack's buffer object */ - ctx->DefaultPacking.BufferObj = ctx->Unpack.BufferObj; - if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1, - GL_INTENSITY, GL_UNSIGNED_INT, values)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glPixelMapuiv(invalid PBO access)"); - return; - } - /* restore */ - ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj; - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, - ctx->Unpack.BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ + if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, + GL_INTENSITY, GL_UNSIGNED_INT, values)) { + return; + } + + values = (const GLuint *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glPixelMapuiv(PBO is mapped)"); - return; } - values = (const GLuint *) ADD_POINTERS(buf, values); - } - else if (!values) { return; } @@ -259,10 +255,7 @@ _mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values ) } } - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - ctx->Unpack.BufferObj); - } + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); store_pixelmap(ctx, map, mapsize, fvalues); } @@ -290,32 +283,17 @@ _mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values ) FLUSH_VERTICES(ctx, _NEW_PIXEL); - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - /* unpack pixelmap from PBO */ - GLubyte *buf; - /* Note, need to use DefaultPacking and Unpack's buffer object */ - ctx->DefaultPacking.BufferObj = ctx->Unpack.BufferObj; - if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1, - GL_INTENSITY, GL_UNSIGNED_SHORT, - values)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glPixelMapusv(invalid PBO access)"); - return; - } - /* restore */ - ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj; - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, - ctx->Unpack.BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ + if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, + GL_INTENSITY, GL_UNSIGNED_SHORT, values)) { + return; + } + + values = (const GLushort *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glPixelMapusv(PBO is mapped)"); - return; } - values = (const GLushort *) ADD_POINTERS(buf, values); - } - else if (!values) { return; } @@ -333,10 +311,7 @@ _mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values ) } } - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - ctx->Unpack.BufferObj); - } + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); store_pixelmap(ctx, map, mapsize, fvalues); } @@ -359,31 +334,17 @@ _mesa_GetPixelMapfv( GLenum map, GLfloat *values ) mapsize = pm->Size; - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* pack pixelmap into PBO */ - GLubyte *buf; - /* Note, need to use DefaultPacking and Pack's buffer object */ - ctx->DefaultPacking.BufferObj = ctx->Pack.BufferObj; - if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1, - GL_INTENSITY, GL_FLOAT, values)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetPixelMapfv(invalid PBO access)"); - return; - } - /* restore */ - ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj; - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - GL_WRITE_ONLY_ARB, - ctx->Pack.BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ + if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, + GL_INTENSITY, GL_FLOAT, values)) { + return; + } + + values = (GLfloat *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetPixelMapfv(PBO is mapped)"); - return; } - values = (GLfloat *) ADD_POINTERS(buf, values); - } - else if (!values) { return; } @@ -397,10 +358,7 @@ _mesa_GetPixelMapfv( GLenum map, GLfloat *values ) MEMCPY(values, pm->Map, mapsize * sizeof(GLfloat)); } - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - ctx->Pack.BufferObj); - } + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); } @@ -420,31 +378,17 @@ _mesa_GetPixelMapuiv( GLenum map, GLuint *values ) } mapsize = pm->Size; - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* pack pixelmap into PBO */ - GLubyte *buf; - /* Note, need to use DefaultPacking and Pack's buffer object */ - ctx->DefaultPacking.BufferObj = ctx->Pack.BufferObj; - if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1, - GL_INTENSITY, GL_UNSIGNED_INT, values)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetPixelMapuiv(invalid PBO access)"); - return; - } - /* restore */ - ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj; - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - GL_WRITE_ONLY_ARB, - ctx->Pack.BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ + if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, + GL_INTENSITY, GL_UNSIGNED_INT, values)) { + return; + } + + values = (GLuint *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetPixelMapuiv(PBO is mapped)"); - return; } - values = (GLuint *) ADD_POINTERS(buf, values); - } - else if (!values) { return; } @@ -458,10 +402,7 @@ _mesa_GetPixelMapuiv( GLenum map, GLuint *values ) } } - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - ctx->Pack.BufferObj); - } + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); } @@ -481,32 +422,17 @@ _mesa_GetPixelMapusv( GLenum map, GLushort *values ) } mapsize = pm ? pm->Size : 0; - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* pack pixelmap into PBO */ - GLubyte *buf; - /* Note, need to use DefaultPacking and Pack's buffer object */ - ctx->DefaultPacking.BufferObj = ctx->Pack.BufferObj; - if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1, - GL_INTENSITY, GL_UNSIGNED_SHORT, - values)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetPixelMapusv(invalid PBO access)"); - return; - } - /* restore */ - ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj; - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - GL_WRITE_ONLY_ARB, - ctx->Pack.BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ + if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, + GL_INTENSITY, GL_UNSIGNED_SHORT, values)) { + return; + } + + values = (GLushort *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetPixelMapusv(PBO is mapped)"); - return; } - values = (GLushort *) ADD_POINTERS(buf, values); - } - else if (!values) { return; } @@ -528,10 +454,7 @@ _mesa_GetPixelMapusv( GLenum map, GLushort *values ) } } - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - ctx->Pack.BufferObj); - } + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); } diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c index d11c9424d5..e327a52415 100644 --- a/src/mesa/main/polygon.c +++ b/src/mesa/main/polygon.c @@ -193,32 +193,25 @@ _mesa_PolygonMode( GLenum face, GLenum mode ) void _mesa_polygon_stipple(GLcontext *ctx, const GLubyte *pattern) { - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - /* Get/unpack the stipple pattern from a PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(2, &ctx->Unpack, 32, 32, 1, - GL_COLOR_INDEX, GL_BITMAP, pattern)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glPolygonStipple(bad PBO access)"); - return; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, - ctx->Unpack.BufferObj); - if (!buf) { + if (!_mesa_validate_pbo_access(2, &ctx->Unpack, 32, 32, 1, + GL_COLOR_INDEX, GL_BITMAP, pattern)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glPolygonStipple(bad PBO access)"); + return; + } + + pattern = _mesa_map_pbo_source(ctx, &ctx->Unpack, pattern); + if (!pattern) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glPolygonStipple(PBO mapped)"); - return; } - buf = ADD_POINTERS(buf, pattern); - _mesa_unpack_polygon_stipple(buf, ctx->PolygonStipple, &ctx->Unpack); - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - ctx->Unpack.BufferObj); - } - else { - /* Get/unpack the stipple pattern from user memory */ - _mesa_unpack_polygon_stipple(pattern, ctx->PolygonStipple, &ctx->Unpack); + return; } + + _mesa_unpack_polygon_stipple(pattern, ctx->PolygonStipple, &ctx->Unpack); + + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); } @@ -255,35 +248,25 @@ _mesa_GetPolygonStipple( GLubyte *dest ) if (MESA_VERBOSE&VERBOSE_API) _mesa_debug(ctx, "glGetPolygonStipple\n"); - /* XXX someday we may put this code into a separate function and call - * it with ctx->Driver.GetPolygonStipple(). - */ - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* Put/pack the stipple pattern into a PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(2, &ctx->Pack, 32, 32, 1, - GL_COLOR_INDEX, GL_BITMAP, dest)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetPolygonStipple(bad PBO access)"); - return; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - GL_WRITE_ONLY_ARB, - ctx->Pack.BufferObj); - if (!buf) { + if (!_mesa_validate_pbo_access(2, &ctx->Pack, 32, 32, 1, + GL_COLOR_INDEX, GL_BITMAP, dest)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetPolygonStipple(bad PBO access)"); + return; + } + + dest = _mesa_map_pbo_dest(ctx, &ctx->Pack, dest); + if (!dest) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetPolygonStipple(PBO mapped)"); - return; } - buf = ADD_POINTERS(buf, dest); - _mesa_pack_polygon_stipple(ctx->PolygonStipple, buf, &ctx->Pack); - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - ctx->Pack.BufferObj); - } - else { - /* Put/pack the stipple pattern into user memory */ - _mesa_pack_polygon_stipple(ctx->PolygonStipple, dest, &ctx->Pack); + return; } + + _mesa_pack_polygon_stipple(ctx->PolygonStipple, dest, &ctx->Pack); + + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); } -- cgit v1.2.3 From 95027a00870bc1d12ea24dfb092a0cad6cbd5035 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 3 Sep 2009 11:23:05 -0600 Subject: mesa: use new combined PBO validate/map helpers --- src/mesa/main/colortab.c | 39 ++++++++----------------------- src/mesa/main/convolve.c | 58 ++++++++++++----------------------------------- src/mesa/main/histogram.c | 34 +++++++-------------------- src/mesa/main/polygon.c | 38 ++++++++----------------------- 4 files changed, 43 insertions(+), 126 deletions(-) (limited to 'src/mesa/main/convolve.c') diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c index 91c29882ec..5a7de5f209 100644 --- a/src/mesa/main/colortab.c +++ b/src/mesa/main/colortab.c @@ -179,21 +179,12 @@ store_colortable_entries(GLcontext *ctx, struct gl_color_table *table, GLfloat bScale, GLfloat bBias, GLfloat aScale, GLfloat aBias) { - if (!_mesa_validate_pbo_access(1, &ctx->Unpack, count, 1, 1, - format, type, data)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glColor[Sub]Table(bad PBO access)"); + data = _mesa_map_validate_pbo_source(ctx, + 1, &ctx->Unpack, count, 1, 1, + format, type, data, + "glColor[Sub]Table"); + if (!data) return; - } - - data = _mesa_map_pbo_source(ctx, &ctx->Unpack, data); - if (!data) { - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glColor[Sub]Table(PBO mapped)"); - } - return; - } { /* convert user-provided data to GLfloat values */ @@ -688,22 +679,12 @@ _mesa_GetColorTable( GLenum target, GLenum format, return; } - if (!_mesa_validate_pbo_access(1, &ctx->Pack, table->Size, 1, 1, - format, type, data)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetColorTable(invalid PBO access)"); + data = _mesa_map_validate_pbo_dest(ctx, + 1, &ctx->Pack, table->Size, 1, 1, + format, type, data, + "glGetColorTable"); + if (!data) return; - } - - data = _mesa_map_pbo_dest(ctx, &ctx->Pack, data); - if (!data) { - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetColorTable(PBO is mapped)"); - } - return; - } _mesa_pack_rgba_span_float(ctx, table->Size, rgba, format, type, data, &ctx->Pack, 0x0); diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c index 7e0761e68b..714909f451 100644 --- a/src/mesa/main/convolve.c +++ b/src/mesa/main/convolve.c @@ -144,21 +144,12 @@ _mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, G ctx->Convolution1D.Width = width; ctx->Convolution1D.Height = 1; - if (!_mesa_validate_pbo_access(1, &ctx->Unpack, width, 1, 1, - format, type, image)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glConvolutionFilter1D(invalid PBO access)"); + image = _mesa_map_validate_pbo_source(ctx, + 1, &ctx->Unpack, width, 1, 1, + format, type, image, + "glConvolutionFilter1D"); + if (!image) return; - } - - image = _mesa_map_pbo_source(ctx, &ctx->Unpack, image); - if (!image) { - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glConvolutionFilter1D(PBO is mapped)"); - } - return; - } _mesa_unpack_color_span_float(ctx, width, GL_RGBA, ctx->Convolution1D.Filter, @@ -231,21 +222,12 @@ _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, G ctx->Convolution2D.Width = width; ctx->Convolution2D.Height = height; - if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1, - format, type, image)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glConvolutionFilter2D(invalid PBO access)"); + image = _mesa_map_validate_pbo_source(ctx, + 2, &ctx->Unpack, width, height, 1, + format, type, image, + "glConvolutionFilter2D"); + if (!image) return; - } - - image = _mesa_map_pbo_source(ctx, &ctx->Unpack, image); - if (!image) { - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glConvolutionFilter2D(PBO is mapped)"); - } - return; - } /* Unpack filter image. We always store filters in RGBA format. */ for (i = 0; i < height; i++) { @@ -576,22 +558,12 @@ _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, return; } - if (!_mesa_validate_pbo_access(2, &ctx->Pack, - filter->Width, filter->Height, - 1, format, type, image)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetConvolutionFilter(invalid PBO access)"); - return; - } - - image = _mesa_map_pbo_dest(ctx, &ctx->Pack, image); - if (!image) { - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetConvolutionFilter(PBO is mapped)"); - } + 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, diff --git a/src/mesa/main/histogram.c b/src/mesa/main/histogram.c index f1d01cdb62..ceb0d5a6a8 100644 --- a/src/mesa/main/histogram.c +++ b/src/mesa/main/histogram.c @@ -649,21 +649,11 @@ _mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvo return; } - if (!_mesa_validate_pbo_access(1, &ctx->Pack, 2, 1, 1, - format, type, values)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetMinMax(invalid PBO access)"); - return; - } - values = _mesa_map_pbo_dest(ctx, &ctx->Pack, values); - if (!values) { - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION,"glGetMinMax(PBO is mapped)"); - } + values = _mesa_map_validate_pbo_dest(ctx, 1, &ctx->Pack, 2, 1, 1, + format, type, values, "glGetMinmax"); + if (!values) return; - } { GLfloat minmax[2][4]; @@ -722,20 +712,12 @@ _mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, G return; } - if (!_mesa_validate_pbo_access(1, &ctx->Pack, ctx->Histogram.Width, 1, 1, - format, type, values)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetHistogram(invalid PBO access)"); + values = _mesa_map_validate_pbo_dest(ctx, 1, &ctx->Pack, + ctx->Histogram.Width, 1, 1, + format, type, values, + "glGetHistogram"); + if (!values) return; - } - - values = _mesa_map_pbo_dest(ctx, &ctx->Pack, values); - if (!values) { - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - _mesa_error(ctx,GL_INVALID_OPERATION,"glGetHistogram(PBO is mapped)"); - } - return; - } pack_histogram(ctx, ctx->Histogram.Width, (CONST GLuint (*)[4]) ctx->Histogram.Count, diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c index e327a52415..376a87a396 100644 --- a/src/mesa/main/polygon.c +++ b/src/mesa/main/polygon.c @@ -193,21 +193,12 @@ _mesa_PolygonMode( GLenum face, GLenum mode ) void _mesa_polygon_stipple(GLcontext *ctx, const GLubyte *pattern) { - if (!_mesa_validate_pbo_access(2, &ctx->Unpack, 32, 32, 1, - GL_COLOR_INDEX, GL_BITMAP, pattern)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glPolygonStipple(bad PBO access)"); + pattern = _mesa_map_validate_pbo_source(ctx, 2, + &ctx->Unpack, 32, 32, 1, + GL_COLOR_INDEX, GL_BITMAP, pattern, + "glPolygonStipple"); + if (!pattern) return; - } - - pattern = _mesa_map_pbo_source(ctx, &ctx->Unpack, pattern); - if (!pattern) { - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glPolygonStipple(PBO mapped)"); - } - return; - } _mesa_unpack_polygon_stipple(pattern, ctx->PolygonStipple, &ctx->Unpack); @@ -248,21 +239,12 @@ _mesa_GetPolygonStipple( GLubyte *dest ) if (MESA_VERBOSE&VERBOSE_API) _mesa_debug(ctx, "glGetPolygonStipple\n"); - if (!_mesa_validate_pbo_access(2, &ctx->Pack, 32, 32, 1, - GL_COLOR_INDEX, GL_BITMAP, dest)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetPolygonStipple(bad PBO access)"); + dest = _mesa_map_validate_pbo_dest(ctx, 2, + &ctx->Pack, 32, 32, 1, + GL_COLOR_INDEX, GL_BITMAP, dest, + "glGetPolygonStipple"); + if (!dest) return; - } - - dest = _mesa_map_pbo_dest(ctx, &ctx->Pack, dest); - if (!dest) { - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetPolygonStipple(PBO mapped)"); - } - return; - } _mesa_pack_polygon_stipple(ctx->PolygonStipple, dest, &ctx->Pack); -- cgit v1.2.3 From 2db37ef659a43267dcb4c7a3c69b410a60a2a5d6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 3 Sep 2009 11:41:29 -0600 Subject: mesa: use new combined PBO validate/map helpers in convolution/filter funcs --- src/mesa/main/convolve.c | 89 +++++++++++++----------------------------------- 1 file changed, 23 insertions(+), 66 deletions(-) (limited to 'src/mesa/main/convolve.c') diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c index 714909f451..4d17f533d7 100644 --- a/src/mesa/main/convolve.c +++ b/src/mesa/main/convolve.c @@ -744,59 +744,35 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, filter = &ctx->Separable2D; - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* Pack filter into PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(1, &ctx->Pack, filter->Width, 1, 1, - format, type, row)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetSeparableFilter(invalid PBO access, width)"); - return; - } - if (!_mesa_validate_pbo_access(1, &ctx->Pack, filter->Height, 1, 1, - format, type, column)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetSeparableFilter(invalid PBO access, height)"); - return; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - GL_WRITE_ONLY_ARB, - ctx->Pack.BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetSeparableFilter(PBO is mapped)"); - return; - } - row = ADD_POINTERS(buf, row); - column = ADD_POINTERS(buf, column); - } - - /* Row filter */ + /* 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); } - /* Column filter */ + /* get column filter */ + column = _mesa_map_validate_pbo_dest(ctx, 1, &ctx->Pack, + filter->Height, 1, 1, + format, type, row, + "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 */ - - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* Pack filter into PBO */ - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - ctx->Unpack.BufferObj); - } } @@ -847,41 +823,16 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs ctx->Separable2D.Width = width; ctx->Separable2D.Height = height; - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - /* unpack filter from PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(1, &ctx->Unpack, width, 1, 1, - format, type, row)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glSeparableFilter2D(invalid PBO access, width)"); - return; - } - if (!_mesa_validate_pbo_access(1, &ctx->Unpack, height, 1, 1, - format, type, column)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glSeparableFilter2D(invalid PBO access, height)"); - return; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, - ctx->Unpack.BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glSeparableFilter2D(PBO is mapped)"); - return; - } - row = ADD_POINTERS(buf, row); - column = ADD_POINTERS(buf, column); - } - /* unpack row filter */ + row = _mesa_map_validate_pbo_source(ctx, 1, &ctx->Unpack, + width, 1, 1, + format, type, row, + "glSeperableFilter2D"); if (row) { _mesa_unpack_color_span_float(ctx, width, GL_RGBA, ctx->Separable2D.Filter, format, type, row, &ctx->Unpack, - 0); /* transferOps */ - + 0x0); /* transferOps */ _mesa_scale_and_bias_rgba(width, (GLfloat (*)[4]) ctx->Separable2D.Filter, ctx->Pixel.ConvolutionFilterScale[2][0], @@ -892,9 +843,14 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs 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, row, + "glSeperableFilter2D"); if (column) { _mesa_unpack_color_span_float(ctx, height, GL_RGBA, &ctx->Separable2D.Filter[colStart], @@ -911,6 +867,7 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs 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)) { -- cgit v1.2.3 From d75a99edd6386ab26d69a3f0cbbed4c79fe5fad4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 3 Sep 2009 12:10:53 -0600 Subject: mesa: fix typos in separable filter functions --- src/mesa/main/convolve.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/mesa/main/convolve.c') diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c index 4d17f533d7..70951112a1 100644 --- a/src/mesa/main/convolve.c +++ b/src/mesa/main/convolve.c @@ -761,7 +761,7 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, /* get column filter */ column = _mesa_map_validate_pbo_dest(ctx, 1, &ctx->Pack, filter->Height, 1, 1, - format, type, row, + format, type, column, "glGetConvolutionFilter"); if (column) { GLvoid *dst = _mesa_image_address1d(&ctx->Pack, column, filter->Height, @@ -827,7 +827,7 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs row = _mesa_map_validate_pbo_source(ctx, 1, &ctx->Unpack, width, 1, 1, format, type, row, - "glSeperableFilter2D"); + "glSeparableFilter2D"); if (row) { _mesa_unpack_color_span_float(ctx, width, GL_RGBA, ctx->Separable2D.Filter, @@ -849,8 +849,8 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs /* unpack column filter */ column = _mesa_map_validate_pbo_source(ctx, 1, &ctx->Unpack, height, 1, 1, - format, type, row, - "glSeperableFilter2D"); + format, type, column, + "glSeparableFilter2D"); if (column) { _mesa_unpack_color_span_float(ctx, height, GL_RGBA, &ctx->Separable2D.Filter[colStart], -- cgit v1.2.3 From ec86469c55c3f531c00ead130a31071ad8aede48 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 7 Sep 2009 17:28:24 +0800 Subject: mesa/main: Make FEATURE_convolve follow feature conventions. As shown in mfeatures.h, this allows users of convolve.h to work without knowing if the feature is available. --- src/mesa/main/api_exec.c | 19 +------------- src/mesa/main/convolve.c | 26 +++++++++++++++++++ src/mesa/main/convolve.h | 67 ++++++++++++++++++++++++++++++++++++++---------- src/mesa/main/teximage.c | 20 --------------- src/mesa/main/texstore.c | 17 +----------- 5 files changed, 82 insertions(+), 67 deletions(-) (limited to 'src/mesa/main/convolve.c') diff --git a/src/mesa/main/api_exec.c b/src/mesa/main/api_exec.c index 30c142e53a..6317639075 100644 --- a/src/mesa/main/api_exec.c +++ b/src/mesa/main/api_exec.c @@ -56,9 +56,7 @@ #include "clip.h" #include "colortab.h" #include "context.h" -#if FEATURE_convolve #include "convolve.h" -#endif #include "depth.h" #if FEATURE_dlist #include "dlist.h" @@ -384,21 +382,7 @@ _mesa_init_exec_table(struct _glapi_table *exec) SET_BlendEquationSeparateEXT(exec, _mesa_BlendEquationSeparateEXT); _mesa_init_colortable_dispatch(exec); - -#if FEATURE_convolve - SET_ConvolutionFilter1D(exec, _mesa_ConvolutionFilter1D); - SET_ConvolutionFilter2D(exec, _mesa_ConvolutionFilter2D); - SET_ConvolutionParameterf(exec, _mesa_ConvolutionParameterf); - SET_ConvolutionParameterfv(exec, _mesa_ConvolutionParameterfv); - SET_ConvolutionParameteri(exec, _mesa_ConvolutionParameteri); - SET_ConvolutionParameteriv(exec, _mesa_ConvolutionParameteriv); - SET_CopyConvolutionFilter1D(exec, _mesa_CopyConvolutionFilter1D); - SET_CopyConvolutionFilter2D(exec, _mesa_CopyConvolutionFilter2D); - SET_GetConvolutionFilter(exec, _mesa_GetConvolutionFilter); - SET_GetConvolutionParameterfv(exec, _mesa_GetConvolutionParameterfv); - SET_GetConvolutionParameteriv(exec, _mesa_GetConvolutionParameteriv); - SET_SeparableFilter2D(exec, _mesa_SeparableFilter2D); -#endif + _mesa_init_convolve_dispatch(exec); #if FEATURE_histogram SET_GetHistogram(exec, _mesa_GetHistogram); SET_GetHistogramParameterfv(exec, _mesa_GetHistogramParameterfv); @@ -406,7 +390,6 @@ _mesa_init_exec_table(struct _glapi_table *exec) SET_GetMinmax(exec, _mesa_GetMinmax); SET_GetMinmaxParameterfv(exec, _mesa_GetMinmaxParameterfv); SET_GetMinmaxParameteriv(exec, _mesa_GetMinmaxParameteriv); - SET_GetSeparableFilter(exec, _mesa_GetSeparableFilter); SET_Histogram(exec, _mesa_Histogram); SET_Minmax(exec, _mesa_Minmax); SET_ResetHistogram(exec, _mesa_ResetHistogram); diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c index 70951112a1..4bca436095 100644 --- a/src/mesa/main/convolve.c +++ b/src/mesa/main/convolve.c @@ -40,6 +40,10 @@ #include "mtypes.h" #include "pixel.h" #include "state.h" +#include "glapi/dispatch.h" + + +#if FEATURE_convolve /* @@ -1425,3 +1429,25 @@ _mesa_adjust_image_for_convolution(const GLcontext *ctx, GLuint dimensions, *height = *height - (MAX2(ctx->Separable2D.Height, 1) - 1); } } + + +void +_mesa_init_convolve_dispatch(struct _glapi_table *disp) +{ + SET_ConvolutionFilter1D(disp, _mesa_ConvolutionFilter1D); + SET_ConvolutionFilter2D(disp, _mesa_ConvolutionFilter2D); + SET_ConvolutionParameterf(disp, _mesa_ConvolutionParameterf); + SET_ConvolutionParameterfv(disp, _mesa_ConvolutionParameterfv); + SET_ConvolutionParameteri(disp, _mesa_ConvolutionParameteri); + SET_ConvolutionParameteriv(disp, _mesa_ConvolutionParameteriv); + SET_CopyConvolutionFilter1D(disp, _mesa_CopyConvolutionFilter1D); + SET_CopyConvolutionFilter2D(disp, _mesa_CopyConvolutionFilter2D); + SET_GetConvolutionFilter(disp, _mesa_GetConvolutionFilter); + SET_GetConvolutionParameterfv(disp, _mesa_GetConvolutionParameterfv); + SET_GetConvolutionParameteriv(disp, _mesa_GetConvolutionParameteriv); + SET_SeparableFilter2D(disp, _mesa_SeparableFilter2D); + SET_GetSeparableFilter(disp, _mesa_GetSeparableFilter); +} + + +#endif /* FEATURE_convolve */ diff --git a/src/mesa/main/convolve.h b/src/mesa/main/convolve.h index 4505cdae01..565a51ef8f 100644 --- a/src/mesa/main/convolve.h +++ b/src/mesa/main/convolve.h @@ -28,10 +28,17 @@ #define CONVOLVE_H -#include "mtypes.h" +#include "main/mtypes.h" -#if _HAVE_FULL_GL +#if FEATURE_convolve + +#define _MESA_INIT_CONVOLVE_FUNCTIONS(driver, impl) \ + do { \ + (driver)->CopyConvolutionFilter1D = impl ## CopyConvolutionFilter1D; \ + (driver)->CopyConvolutionFilter2D = impl ## CopyConvolutionFilter2D; \ + } while (0) + extern void GLAPIENTRY _mesa_ConvolutionFilter1D(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); @@ -83,32 +90,66 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalformat, const GLvoid *row, const GLvoid *column); - 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); -#else -#define _mesa_adjust_image_for_convolution(c, d, w, h) ((void)0) -#define _mesa_convolve_1d_image(c,w,s,d) ((void)0) -#define _mesa_convolve_2d_image(c,w,h,s,d) ((void)0) -#define _mesa_convolve_sep_image(c,w,h,s,d) ((void)0) -#endif +extern void +_mesa_init_convolve_dispatch(struct _glapi_table *disp); + +#else /* FEATURE_convolve */ + +#define _MESA_INIT_CONVOLVE_FUNCTIONS(driver, impl) do { } while (0) + +static INLINE void +_mesa_convolve_1d_image(const GLcontext *ctx, GLsizei *width, + const GLfloat *srcImage, GLfloat *dstImage) +{ + *width = 0; +} + +static INLINE void +_mesa_convolve_2d_image(const GLcontext *ctx, GLsizei *width, GLsizei *height, + const GLfloat *srcImage, GLfloat *dstImage) +{ + *width = 0; + *height = 0; +} + + +static INLINE void +_mesa_convolve_sep_image(const GLcontext *ctx, + GLsizei *width, GLsizei *height, + const GLfloat *srcImage, GLfloat *dstImage) +{ + *width = 0; + *height = 0; +} + +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) +{ +} + +#endif /* FEATURE_convolve */ -#endif +#endif /* CONVOLVE_H */ diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 8228303040..a0304c02d4 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -33,9 +33,7 @@ #include "glheader.h" #include "bufferobj.h" #include "context.h" -#if FEATURE_convolve #include "convolve.h" -#endif #include "fbobject.h" #include "framebuffer.h" #include "hash.h" @@ -2133,11 +2131,9 @@ _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 */ @@ -2232,12 +2228,10 @@ _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 && @@ -2458,12 +2452,10 @@ _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)) { @@ -2518,13 +2510,11 @@ _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)) { @@ -2634,11 +2624,9 @@ _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)) @@ -2699,12 +2687,10 @@ _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)) @@ -2777,11 +2763,9 @@ _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, @@ -2832,12 +2816,10 @@ _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, texImage)) @@ -2887,12 +2869,10 @@ _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, diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index a22db628d3..fce01b185e 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -56,9 +56,7 @@ #include "bufferobj.h" #include "colormac.h" #include "context.h" -#if FEATURE_convolve #include "convolve.h" -#endif #include "image.h" #include "macros.h" #include "mipmap.h" @@ -272,16 +270,6 @@ compute_component_mapping(GLenum inFormat, GLenum outFormat, } -#if !FEATURE_convolve -static void -_mesa_adjust_image_for_convolution(GLcontext *ctx, GLuint dims, - GLsizei *srcWidth, GLsizei *srcHeight) -{ - /* no-op */ -} -#endif - - /** * Make a temporary (color) texture image with GLfloat components. * Apply all needed pixel unpacking and pixel transfer operations. @@ -385,7 +373,6 @@ make_temp_float_image(GLcontext *ctx, GLuint dims, convWidth = srcWidth; convHeight = srcHeight; -#if FEATURE_convolve /* do convolution */ { GLfloat *src = tempImage + img * (srcWidth * srcHeight * 4); @@ -405,7 +392,7 @@ make_temp_float_image(GLcontext *ctx, GLuint dims, } } } -#endif + /* do post-convolution transfer and pack into tempImage */ { const GLint logComponents @@ -562,7 +549,6 @@ _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)) { @@ -584,7 +570,6 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims, transferOps = 0; freeSrcImage = GL_TRUE; } -#endif /* unpack and transfer the source image */ tempImage = (GLchan *) _mesa_malloc(srcWidth * srcHeight * srcDepth -- cgit v1.2.3