From 60909388ab136d849d99eab49e782a53772a618f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 10 Nov 2004 15:46:52 +0000 Subject: [PATCH] GL_(UN)PACK_SKIP_IMAGES should only be applied to 3D texture pack/unpacking and ignored for 1D and 2D images. Need to pass in image dimensions (1,2,3) to the _mesa_image_address() function. This change gets propogated to some other routines. Also added new _mesa_image_address[123]d() convenience functions. --- src/mesa/drivers/dri/r200/r200_swtcl.c | 4 +- src/mesa/drivers/dri/radeon/radeon_subset_bitmap.c | 8 +- src/mesa/drivers/dri/tdfx/tdfx_pixels.c | 28 +++--- src/mesa/drivers/glide/fxdd.c | 68 ++++++------- src/mesa/drivers/x11/xm_dd.c | 4 +- src/mesa/main/bufferobj.c | 7 +- src/mesa/main/bufferobj.h | 3 +- src/mesa/main/colortab.c | 4 +- src/mesa/main/convolve.c | 35 ++++--- src/mesa/main/dlist.c | 32 +++--- src/mesa/main/histogram.c | 4 +- src/mesa/main/image.c | 91 ++++++++++++----- src/mesa/main/image.h | 32 +++++- src/mesa/main/pixel.c | 12 +-- src/mesa/main/polygon.c | 4 +- src/mesa/main/teximage.c | 7 +- src/mesa/main/texstore.c | 109 ++++++++++++--------- src/mesa/swrast/s_bitmap.c | 10 +- src/mesa/swrast/s_drawpix.c | 42 ++++---- src/mesa/swrast/s_readpix.c | 30 +++--- 20 files changed, 308 insertions(+), 226 deletions(-) diff --git a/src/mesa/drivers/dri/r200/r200_swtcl.c b/src/mesa/drivers/dri/r200/r200_swtcl.c index 7fb91a0..43f8365 100644 --- a/src/mesa/drivers/dri/r200/r200_swtcl.c +++ b/src/mesa/drivers/dri/r200/r200_swtcl.c @@ -839,8 +839,8 @@ r200PointsBitmap( GLcontext *ctx, GLint px, GLint py, */ for (row=0; rowLsbFirst) { /* Lsb first */ diff --git a/src/mesa/drivers/dri/radeon/radeon_subset_bitmap.c b/src/mesa/drivers/dri/radeon/radeon_subset_bitmap.c index cb4a514..3ac20bd 100644 --- a/src/mesa/drivers/dri/radeon/radeon_subset_bitmap.c +++ b/src/mesa/drivers/dri/radeon/radeon_subset_bitmap.c @@ -146,8 +146,8 @@ radeonPointsBitmap( GLsizei width, GLsizei height, if (ctx->_RotateMode) { for (col=0; col> (unpack->SkipPixels & 0x7); @@ -166,8 +166,8 @@ radeonPointsBitmap( GLsizei width, GLsizei height, else { for (row=0; row> (unpack->SkipPixels & 0x7); diff --git a/src/mesa/drivers/dri/tdfx/tdfx_pixels.c b/src/mesa/drivers/dri/tdfx/tdfx_pixels.c index aaee401..7ec6302 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_pixels.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_pixels.c @@ -264,10 +264,10 @@ tdfx_bitmap_R5G6B5(GLcontext * ctx, GLint px, GLint py, for (row = 0; row < height; row++) { const GLubyte *src = - (const GLubyte *) _mesa_image_address(finalUnpack, - bitmap, width, height, - GL_COLOR_INDEX, - GL_BITMAP, 0, row, 0); + (const GLubyte *) _mesa_image_address2d(finalUnpack, + bitmap, width, height, + GL_COLOR_INDEX, + GL_BITMAP, row, 0); if (finalUnpack->LsbFirst) { /* least significan bit first */ GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7); @@ -423,10 +423,10 @@ tdfx_bitmap_R8G8B8A8(GLcontext * ctx, GLint px, GLint py, /* compute dest address of bottom-left pixel in bitmap */ for (row = 0; row < height; row++) { const GLubyte *src = - (const GLubyte *) _mesa_image_address(finalUnpack, - bitmap, width, height, - GL_COLOR_INDEX, - GL_BITMAP, 0, row, 0); + (const GLubyte *) _mesa_image_address2d(finalUnpack, + bitmap, width, height, + GL_COLOR_INDEX, + GL_BITMAP, row, 0); if (finalUnpack->LsbFirst) { /* least significan bit first */ GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7); @@ -512,8 +512,8 @@ tdfx_readpixels_R5G6B5(GLcontext * ctx, GLint x, GLint y, GL_FRONT) ? (fxMesa->screen_width) : (info.strideInBytes / 2); const GLushort *src = (const GLushort *) info.lfbPtr + scrY * srcStride + scrX; - GLubyte *dst = (GLubyte *) _mesa_image_address(packing, - dstImage, width, height, format, type, 0, 0, 0); + GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, + dstImage, width, height, format, type, 0, 0); const GLint dstStride = _mesa_image_row_stride(packing, width, format, type); @@ -573,8 +573,8 @@ tdfx_readpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y, + scrY * srcStride + scrX; const GLint dstStride = _mesa_image_row_stride(packing, width, format, type); - GLubyte *dst = (GLubyte *) _mesa_image_address(packing, - dstImage, width, height, format, type, 0, 0, 0); + GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, + dstImage, width, height, format, type, 0, 0); const GLint widthInBytes = width * 4; { @@ -667,8 +667,8 @@ tdfx_drawpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y, + scrY * dstStride + scrX * 4; const GLint srcStride = _mesa_image_row_stride(unpack, width, format, type); - const GLubyte *src = (GLubyte *) _mesa_image_address(unpack, - pixels, width, height, format, type, 0, 0, 0); + const GLubyte *src = (GLubyte *) _mesa_image_address2d(unpack, + pixels, width, height, format, type, 0, 0); const GLint widthInBytes = width * 4; if ((format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8) || diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c index 74d0dc0..69c1d7e 100644 --- a/src/mesa/drivers/glide/fxdd.c +++ b/src/mesa/drivers/glide/fxdd.c @@ -525,10 +525,10 @@ fxDDDrawBitmap2 (GLcontext *ctx, GLint px, GLint py, for (row = 0; row < height; row++) { const GLubyte *src = - (const GLubyte *) _mesa_image_address(finalUnpack, - bitmap, width, height, - GL_COLOR_INDEX, GL_BITMAP, - 0, row, 0); + (const GLubyte *) _mesa_image_address2d(finalUnpack, + bitmap, width, height, + GL_COLOR_INDEX, GL_BITMAP, + row, 0); if (finalUnpack->LsbFirst) { /* least significan bit first */ GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7); @@ -684,10 +684,10 @@ fxDDDrawBitmap4 (GLcontext *ctx, GLint px, GLint py, for (row = 0; row < height; row++) { const GLubyte *src = - (const GLubyte *) _mesa_image_address(finalUnpack, - bitmap, width, height, - GL_COLOR_INDEX, GL_BITMAP, - 0, row, 0); + (const GLubyte *) _mesa_image_address2d(finalUnpack, + bitmap, width, height, + GL_COLOR_INDEX, GL_BITMAP, + row, 0); if (finalUnpack->LsbFirst) { /* least significan bit first */ GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7); @@ -762,9 +762,9 @@ fxDDReadPixels565 (GLcontext * ctx, const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */ const GLushort *src = (const GLushort *) info.lfbPtr + (winY - y) * srcStride + (winX + x); - GLubyte *dst = (GLubyte *) _mesa_image_address(packing, dstImage, + GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dstImage, width, height, format, - type, 0, 0, 0); + type, 0, 0); GLint dstStride = _mesa_image_row_stride(packing, width, format, type); @@ -875,9 +875,9 @@ fxDDReadPixels555 (GLcontext * ctx, const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */ const GLushort *src = (const GLushort *) info.lfbPtr + (winY - y) * srcStride + (winX + x); - GLubyte *dst = (GLubyte *) _mesa_image_address(packing, dstImage, + GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dstImage, width, height, format, - type, 0, 0, 0); + type, 0, 0); GLint dstStride = _mesa_image_row_stride(packing, width, format, type); @@ -988,9 +988,9 @@ fxDDReadPixels8888 (GLcontext * ctx, const GLint srcStride = info.strideInBytes / 4; /* stride in GLuints */ const GLuint *src = (const GLuint *) info.lfbPtr + (winY - y) * srcStride + (winX + x); - GLubyte *dst = (GLubyte *) _mesa_image_address(packing, dstImage, + GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dstImage, width, height, format, - type, 0, 0, 0); + type, 0, 0); GLint dstStride = _mesa_image_row_stride(packing, width, format, type); @@ -1155,9 +1155,8 @@ fxDDDrawPixels555 (GLcontext * ctx, GLint x, GLint y, if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) { GLint row; for (row = 0; row < height; row++) { - GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels, - width, height, format, - type, 0, row, 0); + GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack, + pixels, width, height, format, type, row, 0); GLint col; for (col = 0; col < width; col++) { dst[col] = TDFXPACKCOLOR1555(src[2], src[1], src[0], src[3]); @@ -1169,9 +1168,8 @@ fxDDDrawPixels555 (GLcontext * ctx, GLint x, GLint y, else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) { GLint row; for (row = 0; row < height; row++) { - GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels, - width, height, format, - type, 0, row, 0); + GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack, + pixels, width, height, format, type, row, 0); GLint col; for (col = 0; col < width; col++) { dst[col] = TDFXPACKCOLOR1555(src[2], src[1], src[0], 255); @@ -1292,9 +1290,8 @@ fxDDDrawPixels565 (GLcontext * ctx, GLint x, GLint y, if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) { GLint row; for (row = 0; row < height; row++) { - GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels, - width, height, format, - type, 0, row, 0); + GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack, + pixels, width, height, format, type, row, 0); GLint col; for (col = 0; col < width; col++) { dst[col] = TDFXPACKCOLOR565(src[2], src[1], src[0]); @@ -1306,9 +1303,8 @@ fxDDDrawPixels565 (GLcontext * ctx, GLint x, GLint y, else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) { GLint row; for (row = 0; row < height; row++) { - GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels, - width, height, format, - type, 0, row, 0); + GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack, + pixels, width, height, format, type, row, 0); GLint col; for (col = 0; col < width; col++) { dst[col] = TDFXPACKCOLOR565(src[2], src[1], src[0]); @@ -1429,9 +1425,8 @@ fxDDDrawPixels565_rev (GLcontext * ctx, GLint x, GLint y, if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) { GLint row; for (row = 0; row < height; row++) { - GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels, - width, height, format, - type, 0, row, 0); + GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack, + pixels, width, height, format, type, row, 0); GLint col; for (col = 0; col < width; col++) { dst[col] = TDFXPACKCOLOR565(src[0], src[1], src[2]); @@ -1443,9 +1438,8 @@ fxDDDrawPixels565_rev (GLcontext * ctx, GLint x, GLint y, else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) { GLint row; for (row = 0; row < height; row++) { - GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels, - width, height, format, - type, 0, row, 0); + GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack, + pixels, width, height, format, type, row, 0); GLint col; for (col = 0; col < width; col++) { dst[col] = TDFXPACKCOLOR565(src[0], src[1], src[2]); @@ -1568,9 +1562,8 @@ fxDDDrawPixels8888 (GLcontext * ctx, GLint x, GLint y, const GLint widthInBytes = width * 4; GLint row; for (row = 0; row < height; row++) { - GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels, - width, height, format, - type, 0, row, 0); + GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack, + pixels, width, height, format, type, row, 0); MEMCPY(dst, src, widthInBytes); dst += dstStride; } @@ -1578,9 +1571,8 @@ fxDDDrawPixels8888 (GLcontext * ctx, GLint x, GLint y, else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) { GLint row; for (row = 0; row < height; row++) { - GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels, - width, height, format, - type, 0, row, 0); + GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack, + pixels, width, height, format, type, 0, row, 0); GLint col; for (col = 0; col < width; col++) { dst[col] = TDFXPACKCOLOR8888(src[2], src[1], src[0], 255); diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index bee46a5..cbdcd99 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -846,7 +846,7 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx, if (unpack->BufferObj->Name) { /* unpack from PBO */ GLubyte *buf; - if (!_mesa_validate_pbo_access(unpack, width, height, 1, + if (!_mesa_validate_pbo_access(2, unpack, width, height, 1, format, type, pixels)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(invalid PBO access)"); @@ -949,7 +949,7 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx, if (unpack->BufferObj->Name) { /* unpack from PBO */ GLubyte *buf; - if (!_mesa_validate_pbo_access(unpack, width, height, 1, + if (!_mesa_validate_pbo_access(2, unpack, width, height, 1, format, type, pixels)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(invalid PBO access)"); diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index c795d2f..990d2d1 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -429,7 +429,8 @@ _mesa_init_buffer_objects( GLcontext *ctx ) * go out of bounds. */ GLboolean -_mesa_validate_pbo_access(const struct gl_pixelstore_attrib *pack, +_mesa_validate_pbo_access(GLuint dimensions, + const struct gl_pixelstore_attrib *pack, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *ptr) { @@ -442,11 +443,11 @@ _mesa_validate_pbo_access(const struct gl_pixelstore_attrib *pack, return GL_FALSE; /* get address of first pixel we'll read */ - start = _mesa_image_address(pack, ptr, width, height, + start = _mesa_image_address(dimensions, pack, ptr, width, height, format, type, 0, 0, 0); /* get address just past the last pixel we'll read */ - end = _mesa_image_address(pack, ptr, width, height, + end = _mesa_image_address(dimensions, pack, ptr, width, height, format, type, depth-1, height-1, width); diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 635975d..bc10053 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -78,7 +78,8 @@ _mesa_buffer_unmap( GLcontext *ctx, GLenum target, struct gl_buffer_object * bufObj ); extern GLboolean -_mesa_validate_pbo_access(const struct gl_pixelstore_attrib *pack, +_mesa_validate_pbo_access(GLuint dimensions, + const struct gl_pixelstore_attrib *pack, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *ptr); diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c index 3fdab6a..e6752d0 100644 --- a/src/mesa/main/colortab.c +++ b/src/mesa/main/colortab.c @@ -195,7 +195,7 @@ store_colortable_entries(GLcontext *ctx, struct gl_color_table *table, if (ctx->Unpack.BufferObj->Name) { /* Get/unpack the color table data from a PBO */ GLubyte *buf; - if (!_mesa_validate_pbo_access(&ctx->Unpack, count, 1, 1, + 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)"); @@ -891,7 +891,7 @@ _mesa_GetColorTable( GLenum target, GLenum format, if (ctx->Pack.BufferObj->Name) { /* pack color table into PBO */ GLubyte *buf; - if (!_mesa_validate_pbo_access(&ctx->Pack, table->Size, 1, 1, + 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)"); diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c index fae5668..6b97c7f 100644 --- a/src/mesa/main/convolve.c +++ b/src/mesa/main/convolve.c @@ -147,7 +147,7 @@ _mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, G if (ctx->Unpack.BufferObj->Name) { /* unpack filter from PBO */ GLubyte *buf; - if (!_mesa_validate_pbo_access(&ctx->Unpack, width, 1, 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)"); @@ -245,7 +245,7 @@ _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, G if (ctx->Unpack.BufferObj->Name) { /* unpack filter from PBO */ GLubyte *buf; - if (!_mesa_validate_pbo_access(&ctx->Unpack, width, height, 1, + if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1, format, type, image)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glConvolutionFilter2D(invalid PBO access)"); @@ -268,8 +268,8 @@ _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, G /* Unpack filter image. We always store filters in RGBA format. */ for (i = 0; i < height; i++) { - const GLvoid *src = _mesa_image_address(&ctx->Unpack, image, width, - height, format, type, 0, i, 0); + 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, @@ -600,7 +600,8 @@ _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid *im if (ctx->Pack.BufferObj->Name) { /* Pack the filter into a PBO */ GLubyte *buf; - if (!_mesa_validate_pbo_access(&ctx->Pack, filter->Width, filter->Height, + 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)"); @@ -619,9 +620,9 @@ _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid *im } for (row = 0; row < filter->Height; row++) { - GLvoid *dst = _mesa_image_address( &ctx->Pack, image, filter->Width, - filter->Height, format, type, - 0, row, 0); + GLvoid *dst = _mesa_image_address2d(&ctx->Pack, image, filter->Width, + filter->Height, format, type, + row, 0); const GLfloat *src = filter->Filter + row * filter->Width * 4; _mesa_pack_rgba_span_float(ctx, filter->Width, (const GLfloat (*)[4]) src, @@ -802,13 +803,13 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row, if (ctx->Pack.BufferObj->Name) { /* Pack filter into PBO */ GLubyte *buf; - if (!_mesa_validate_pbo_access(&ctx->Pack, filter->Width, 1, 1, + 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(&ctx->Pack, filter->Height, 1, 1, + 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)"); @@ -829,9 +830,8 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row, /* Row filter */ if (row) { - GLvoid *dst = _mesa_image_address( &ctx->Pack, row, filter->Width, - filter->Height, format, type, - 0, 0, 0); + GLvoid *dst = _mesa_image_address1d(&ctx->Pack, row, filter->Width, + format, type, 0); _mesa_pack_rgba_span_float(ctx, filter->Width, (const GLfloat (*)[4]) filter->Filter, format, type, dst, &ctx->Pack, 0); @@ -839,9 +839,8 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row, /* Column filter */ if (column) { - GLvoid *dst = _mesa_image_address( &ctx->Pack, column, filter->Width, - 1, format, type, - 0, 0, 0); + GLvoid *dst = _mesa_image_address1d(&ctx->Pack, column, filter->Height, + format, type, 0); const GLfloat *src = filter->Filter + colStart; _mesa_pack_rgba_span_float(ctx, filter->Height, (const GLfloat (*)[4]) src, @@ -908,13 +907,13 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs if (ctx->Unpack.BufferObj->Name) { /* unpack filter from PBO */ GLubyte *buf; - if (!_mesa_validate_pbo_access(&ctx->Unpack, width, 1, 1, + 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(&ctx->Unpack, height, 1, 1, + 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)"); diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 9f4b911..1f36411 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -810,19 +810,19 @@ _mesa_init_lists( void ) * \todo This won't suffice when the PBO is really in VRAM/GPU memory. */ static GLvoid * -unpack_image( GLsizei width, GLsizei height, GLsizei depth, +unpack_image( GLuint dimensions, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *unpack ) { if (unpack->BufferObj->Name == 0) { /* no PBO */ - return _mesa_unpack_image(width, height, depth, format, type, + return _mesa_unpack_image(dimensions, width, height, depth, format, type, pixels, unpack); } - else if (_mesa_validate_pbo_access(unpack, width, height, depth, format, - type, pixels)) { + else if (_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, + format, type, pixels)) { const GLubyte *src = ADD_POINTERS(unpack->BufferObj->Data, pixels); - return _mesa_unpack_image(width, height, depth, format, type, + return _mesa_unpack_image(dimensions, width, height, depth, format, type, src, unpack); } /* bad access! */ @@ -1296,7 +1296,7 @@ static void GLAPIENTRY save_ColorTable( GLenum target, GLenum internalFormat, format, type, table ); } else { - GLvoid *image = unpack_image(width, 1, 1, format, type, table, + GLvoid *image = unpack_image(1, width, 1, 1, format, type, table, &ctx->Unpack); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); @@ -1385,7 +1385,7 @@ static void GLAPIENTRY save_ColorSubTable( GLenum target, GLsizei start, GLsizei const GLvoid *table) { GET_CURRENT_CONTEXT(ctx); - GLvoid *image = unpack_image(count, 1, 1, format, type, table, + GLvoid *image = unpack_image(1, count, 1, 1, format, type, table, &ctx->Unpack); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); @@ -1456,7 +1456,7 @@ save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *filter) { GET_CURRENT_CONTEXT(ctx); - GLvoid *image = unpack_image(width, 1, 1, format, type, filter, + GLvoid *image = unpack_image(1, width, 1, 1, format, type, filter, &ctx->Unpack); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); @@ -1485,7 +1485,7 @@ save_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLenum type, const GLvoid *filter) { GET_CURRENT_CONTEXT(ctx); - GLvoid *image = unpack_image(width, height, 1, format, type, filter, + GLvoid *image = unpack_image(2, width, height, 1, format, type, filter, &ctx->Unpack); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); @@ -1850,7 +1850,7 @@ static void GLAPIENTRY save_DrawPixels( GLsizei width, GLsizei height, const GLvoid *pixels ) { GET_CURRENT_CONTEXT(ctx); - GLvoid *image = unpack_image(width, height, 1, format, type, + GLvoid *image = unpack_image(2, width, height, 1, format, type, pixels, &ctx->Unpack); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); @@ -3418,7 +3418,7 @@ static void GLAPIENTRY save_TexImage1D( GLenum target, border, format, type, pixels ); } else { - GLvoid *image = unpack_image(width, 1, 1, format, type, + GLvoid *image = unpack_image(1, width, 1, 1, format, type, pixels, &ctx->Unpack); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); @@ -3457,7 +3457,7 @@ static void GLAPIENTRY save_TexImage2D( GLenum target, height, border, format, type, pixels ); } else { - GLvoid *image = unpack_image(width, height, 1, format, type, + GLvoid *image = unpack_image(2, width, height, 1, format, type, pixels, &ctx->Unpack); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); @@ -3499,7 +3499,7 @@ static void GLAPIENTRY save_TexImage3D( GLenum target, } else { Node *n; - GLvoid *image = unpack_image(width, height, depth, format, type, + GLvoid *image = unpack_image(3, width, height, depth, format, type, pixels, &ctx->Unpack); ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE3D, 10 ); @@ -3532,7 +3532,7 @@ static void GLAPIENTRY save_TexSubImage1D( GLenum target, GLint level, GLint xof { GET_CURRENT_CONTEXT(ctx); Node *n; - GLvoid *image = unpack_image(width, 1, 1, format, type, + GLvoid *image = unpack_image(1, width, 1, 1, format, type, pixels, &ctx->Unpack); ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 ); @@ -3563,7 +3563,7 @@ static void GLAPIENTRY save_TexSubImage2D( GLenum target, GLint level, { GET_CURRENT_CONTEXT(ctx); Node *n; - GLvoid *image = unpack_image(width, height, 1, format, type, + GLvoid *image = unpack_image(2, width, height, 1, format, type, pixels, &ctx->Unpack); ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 ); @@ -3596,7 +3596,7 @@ static void GLAPIENTRY save_TexSubImage3D( GLenum target, GLint level, { GET_CURRENT_CONTEXT(ctx); Node *n; - GLvoid *image = unpack_image(width, height, depth, format, type, + GLvoid *image = unpack_image(3, width, height, depth, format, type, pixels, &ctx->Unpack); ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 ); diff --git a/src/mesa/main/histogram.c b/src/mesa/main/histogram.c index 129ce7a..29aced0 100644 --- a/src/mesa/main/histogram.c +++ b/src/mesa/main/histogram.c @@ -717,7 +717,7 @@ _mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvo if (ctx->Pack.BufferObj->Name) { /* pack min/max values into a PBO */ GLubyte *buf; - if (!_mesa_validate_pbo_access(&ctx->Pack, 2, 1, 1, + if (!_mesa_validate_pbo_access(1, &ctx->Pack, 2, 1, 1, format, type, values)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinMax(invalid PBO access)"); @@ -801,7 +801,7 @@ _mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, G if (ctx->Pack.BufferObj->Name) { /* pack min/max values into a PBO */ GLubyte *buf; - if (!_mesa_validate_pbo_access(&ctx->Pack, ctx->Histogram.Width, 1, 1, + 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)"); diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 17737ca..5e65bf6 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -451,31 +451,31 @@ _mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type ) /** - * Get the address of a pixel in an image (actually a volume). + * Return the address of a specific pixel in an image (1D, 2D or 3D). * * Pixel unpacking/packing parameters are observed according to \p packing. * - * \param image start of image data. - * \param width image width. - * \param height image height. - * \param format pixel format. - * \param type pixel data type. - * \param packing the pixelstore attributes - * \param img which image in the volume (0 for 1D or 2D images) - * \param row of pixel in the image - * \param column of pixel in the image + * \param dimensions either 1, 2 or 3 to indicate dimensionality of image + * \param image starting address of image data + * \param width the image width + * \param height theimage height + * \param format the pixel format + * \param type the pixel data type + * \param packing the pixelstore attributes + * \param img which image in the volume (0 for 1D or 2D images) + * \param row row of pixel in the image (0 for 1D images) + * \param column column of pixel in the image * * \return address of pixel on success, or NULL on error. * - * According to the \p packing information calculates the number of pixel/bytes - * per row/image and refers it. - * * \sa gl_pixelstore_attrib. */ GLvoid * -_mesa_image_address( const struct gl_pixelstore_attrib *packing, - const GLvoid *image, GLsizei width, - GLsizei height, GLenum format, GLenum type, +_mesa_image_address( GLuint dimensions, + const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, GLsizei height, + GLenum format, GLenum type, GLint img, GLint row, GLint column ) { GLint alignment; /* 1, 2 or 4 */ @@ -486,6 +486,8 @@ _mesa_image_address( const struct gl_pixelstore_attrib *packing, GLint skipimages; /* for 3-D volume images */ GLubyte *pixel_addr; + ASSERT(dimensions >= 1 && dimensions <= 3); + alignment = packing->Alignment; if (packing->RowLength > 0) { pixels_per_row = packing->RowLength; @@ -499,9 +501,12 @@ _mesa_image_address( const struct gl_pixelstore_attrib *packing, else { rows_per_image = height; } - skiprows = packing->SkipRows; + skippixels = packing->SkipPixels; - skipimages = packing->SkipImages; + /* Note: SKIP_ROWS _is_ used for 1D images */ + skiprows = packing->SkipRows; + /* Note: SKIP_IMAGES is only used for 3D images */ + skipimages = (dimensions == 3) ? packing->SkipImages : 0; if (type == GL_BITMAP) { /* BITMAP data */ @@ -572,6 +577,43 @@ _mesa_image_address( const struct gl_pixelstore_attrib *packing, } +GLvoid * +_mesa_image_address1d( const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, + GLenum format, GLenum type, + GLint column ) +{ + return _mesa_image_address(1, packing, image, width, 1, + format, type, 0, 0, column); +} + + +GLvoid * +_mesa_image_address2d( const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLint row, GLint column ) +{ + return _mesa_image_address(2, packing, image, width, height, + format, type, 0, row, column); +} + + +GLvoid * +_mesa_image_address3d( const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLint img, GLint row, GLint column ) +{ + return _mesa_image_address(3, packing, image, width, height, + format, type, img, row, column); +} + + + /** * Compute the stride between image rows. * @@ -744,8 +786,8 @@ _mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels, dst = buffer; for (row = 0; row < height; row++) { const GLubyte *src = (const GLubyte *) - _mesa_image_address(packing, pixels, width, height, - GL_COLOR_INDEX, GL_BITMAP, 0, row, 0); + _mesa_image_address2d(packing, pixels, width, height, + GL_COLOR_INDEX, GL_BITMAP, row, 0); if (!src) { FREE(buffer); return NULL; @@ -838,8 +880,8 @@ _mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source, width_in_bytes = CEILING( width, 8 ); src = source; for (row = 0; row < height; row++) { - GLubyte *dst = (GLubyte *) _mesa_image_address( packing, dest, - width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 ); + GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dest, + width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0); if (!dst) return; @@ -3992,7 +4034,8 @@ _mesa_pack_depth_span( const GLcontext *ctx, GLuint n, GLvoid *dest, * need a copy of the data in a standard format. */ void * -_mesa_unpack_image( GLsizei width, GLsizei height, GLsizei depth, +_mesa_unpack_image( GLuint dimensions, + GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *unpack ) { @@ -4036,7 +4079,7 @@ _mesa_unpack_image( GLsizei width, GLsizei height, GLsizei depth, dst = destBuffer; for (img = 0; img < depth; img++) { for (row = 0; row < height; row++) { - const GLvoid *src = _mesa_image_address(unpack, pixels, + const GLvoid *src = _mesa_image_address(dimensions, unpack, pixels, width, height, format, type, img, row, 0); MEMCPY(dst, src, bytesPerRow); /* byte flipping/swapping */ diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h index 6ebdbde..6b76fd8 100644 --- a/src/mesa/main/image.h +++ b/src/mesa/main/image.h @@ -58,11 +58,34 @@ _mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type ); extern GLvoid * -_mesa_image_address( const struct gl_pixelstore_attrib *packing, - const GLvoid *image, GLsizei width, - GLsizei height, GLenum format, GLenum type, +_mesa_image_address( GLuint dimensions, + const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, GLsizei height, + GLenum format, GLenum type, GLint img, GLint row, GLint column ); +extern GLvoid * +_mesa_image_address1d( const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, + GLenum format, GLenum type, + GLint column ); + +extern GLvoid * +_mesa_image_address2d( const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLint row, GLint column ); + +extern GLvoid * +_mesa_image_address3d( const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLint img, GLint row, GLint column ); + extern GLint _mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, @@ -171,7 +194,8 @@ _mesa_pack_depth_span( const GLcontext *ctx, GLuint n, GLvoid *dest, extern void * -_mesa_unpack_image( GLsizei width, GLsizei height, GLsizei depth, +_mesa_unpack_image( GLuint dimensions, + GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *unpack ); diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index 2a0df1f..2b1434b 100644 --- a/src/mesa/main/pixel.c +++ b/src/mesa/main/pixel.c @@ -362,7 +362,7 @@ _mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values ) GLubyte *buf; /* Note, need to use DefaultPacking and Unpack's buffer object */ ctx->DefaultPacking.BufferObj = ctx->Unpack.BufferObj; - if (!_mesa_validate_pbo_access(&ctx->DefaultPacking, mapsize, 1, 1, + 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)"); @@ -422,7 +422,7 @@ _mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values ) GLubyte *buf; /* Note, need to use DefaultPacking and Unpack's buffer object */ ctx->DefaultPacking.BufferObj = ctx->Unpack.BufferObj; - if (!_mesa_validate_pbo_access(&ctx->DefaultPacking, mapsize, 1, 1, + 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)"); @@ -496,7 +496,7 @@ _mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values ) GLubyte *buf; /* Note, need to use DefaultPacking and Unpack's buffer object */ ctx->DefaultPacking.BufferObj = ctx->Unpack.BufferObj; - if (!_mesa_validate_pbo_access(&ctx->DefaultPacking, mapsize, 1, 1, + if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1, GL_INTENSITY, GL_UNSIGNED_SHORT, values)) { _mesa_error(ctx, GL_INVALID_OPERATION, @@ -590,7 +590,7 @@ _mesa_GetPixelMapfv( GLenum map, GLfloat *values ) GLubyte *buf; /* Note, need to use DefaultPacking and Pack's buffer object */ ctx->DefaultPacking.BufferObj = ctx->Pack.BufferObj; - if (!_mesa_validate_pbo_access(&ctx->DefaultPacking, mapsize, 1, 1, + 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)"); @@ -673,7 +673,7 @@ _mesa_GetPixelMapuiv( GLenum map, GLuint *values ) GLubyte *buf; /* Note, need to use DefaultPacking and Pack's buffer object */ ctx->DefaultPacking.BufferObj = ctx->Pack.BufferObj; - if (!_mesa_validate_pbo_access(&ctx->DefaultPacking, mapsize, 1, 1, + 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)"); @@ -768,7 +768,7 @@ _mesa_GetPixelMapusv( GLenum map, GLushort *values ) GLubyte *buf; /* Note, need to use DefaultPacking and Pack's buffer object */ ctx->DefaultPacking.BufferObj = ctx->Pack.BufferObj; - if (!_mesa_validate_pbo_access(&ctx->DefaultPacking, mapsize, 1, 1, + if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1, GL_INTENSITY, GL_UNSIGNED_SHORT, values)) { _mesa_error(ctx, GL_INVALID_OPERATION, diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c index 7fd6e6e..6dbf81c 100644 --- a/src/mesa/main/polygon.c +++ b/src/mesa/main/polygon.c @@ -196,7 +196,7 @@ _mesa_polygon_stipple(GLcontext *ctx, const GLubyte *pattern) if (ctx->Unpack.BufferObj->Name) { /* Get/unpack the stipple pattern from a PBO */ GLubyte *buf; - if (!_mesa_validate_pbo_access(&ctx->Unpack, 32, 32, 1, + 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)"); @@ -261,7 +261,7 @@ _mesa_GetPolygonStipple( GLubyte *dest ) if (ctx->Pack.BufferObj->Name) { /* Put/pack the stipple pattern into a PBO */ GLubyte *buf; - if (!_mesa_validate_pbo_access(&ctx->Pack, 32, 32, 1, + 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)"); diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 4d8780d..3e0ab88 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1901,6 +1901,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, const struct gl_texture_object *texObj; const struct gl_texture_image *texImage; GLint maxLevels = 0; + GLuint dimensions; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); @@ -1975,6 +1976,8 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, return; } + dimensions = (target == GL_TEXTURE_3D) ? 3 : 2; + /* XXX - someday the rest of this function should be moved into a * fallback routine called via ctx->Driver.GetTexImage() */ @@ -1982,7 +1985,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, if (ctx->Pack.BufferObj->Name) { /* pack texture image into a PBO */ GLubyte *buf; - if (!_mesa_validate_pbo_access(&ctx->Pack, texImage->Width, + if (!_mesa_validate_pbo_access(dimensions, &ctx->Pack, texImage->Width, texImage->Height, texImage->Depth, format, type, pixels)) { _mesa_error(ctx, GL_INVALID_OPERATION, @@ -2015,7 +2018,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, for (img = 0; img < depth; img++) { for (row = 0; row < height; row++) { /* compute destination address in client memory */ - GLvoid *dest = _mesa_image_address( &ctx->Pack, pixels, + GLvoid *dest = _mesa_image_address( dimensions, &ctx->Pack, pixels, width, height, format, type, img, row, 0); assert(dest); diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 2ca9b59..36bb957 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -227,7 +227,7 @@ make_temp_float_image(GLcontext *ctx, GLuint dims, /* unpack and do transfer ops up to convolution */ for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(srcPacking, + 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, @@ -299,7 +299,7 @@ make_temp_float_image(GLcontext *ctx, GLuint dims, dst = tempImage; for (img = 0; img < srcDepth; img++) { const GLubyte *src - = (const GLubyte *) _mesa_image_address(srcPacking, srcAddr, + = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); @@ -449,7 +449,7 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims, srcWidth, srcFormat, srcType); const GLubyte *src - = (const GLubyte *) _mesa_image_address(srcPacking, srcAddr, + = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); @@ -522,7 +522,8 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims, * 1D, 2D and 3D images supported. */ static void -memcpy_texture(const struct gl_texture_format *dstFormat, +memcpy_texture(GLuint dimensions, + const struct gl_texture_format *dstFormat, GLvoid *dstAddr, GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, GLint dstRowStride, GLint dstImageStride, @@ -535,8 +536,8 @@ memcpy_texture(const struct gl_texture_format *dstFormat, srcFormat, srcType); const GLint srcImageStride = _mesa_image_image_stride(srcPacking, srcWidth, srcHeight, srcFormat, srcType); - const GLubyte *srcImage = (const GLubyte *) _mesa_image_address(srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0); + const GLubyte *srcImage = (const GLubyte *) _mesa_image_address(dimensions, + srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0); const GLint bytesPerRow = srcWidth * dstFormat->TexelBytes; const GLint bytesPerImage = srcHeight * bytesPerRow; const GLint bytesPerTexture = srcDepth * bytesPerImage; @@ -626,7 +627,8 @@ _mesa_texstore_rgba(GLcontext *ctx, GLuint dims, baseInternalFormat == srcFormat && srcType == CHAN_TYPE) { /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + memcpy_texture(dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -645,8 +647,8 @@ _mesa_texstore_rgba(GLcontext *ctx, GLuint dims, for (img = 0; img < srcDepth; img++) { const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLchan *srcRow = (GLchan *) _mesa_image_address(srcPacking, srcAddr, - srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); + GLchan *srcRow = (GLchan *) _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); GLchan *dstRow = dstImage; for (row = 0; row < srcHeight; row++) { for (col = 0; col < srcWidth; col++) { @@ -711,7 +713,8 @@ _mesa_texstore_depth_component_float32(STORE_PARAMS) srcFormat == GL_DEPTH_COMPONENT && srcType == GL_FLOAT) { /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + memcpy_texture(dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -726,7 +729,7 @@ _mesa_texstore_depth_component_float32(STORE_PARAMS) for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = dstImage; for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(srcPacking, + const GLvoid *src = _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); _mesa_unpack_depth_span(ctx, srcWidth, (GLfloat *) dstRow, srcType, src, srcPacking); @@ -755,7 +758,8 @@ _mesa_texstore_depth_component16(STORE_PARAMS) srcFormat == GL_DEPTH_COMPONENT && srcType == GL_UNSIGNED_SHORT) { /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + memcpy_texture(dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -771,7 +775,7 @@ _mesa_texstore_depth_component16(STORE_PARAMS) GLubyte *dstRow = dstImage; for (row = 0; row < srcHeight; row++) { GLfloat depthTemp[MAX_WIDTH]; - const GLvoid *src = _mesa_image_address(srcPacking, + const GLvoid *src = _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); GLushort *dst16 = (GLushort *) dstRow; _mesa_unpack_depth_span(ctx, srcWidth, depthTemp, @@ -805,7 +809,8 @@ _mesa_texstore_rgb565(STORE_PARAMS) srcFormat == GL_RGB && srcType == GL_UNSIGNED_SHORT_5_6_5) { /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + memcpy_texture(dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -820,7 +825,7 @@ _mesa_texstore_rgb565(STORE_PARAMS) const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); const GLubyte *src = (const GLubyte *) - _mesa_image_address(srcPacking, srcAddr, srcWidth, srcHeight, + _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0); GLubyte *dst = (GLubyte *) dstAddr + dstZoffset * dstImageStride @@ -909,7 +914,8 @@ _mesa_texstore_rgba8888(STORE_PARAMS) ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) || (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV))) { /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + memcpy_texture(dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -981,7 +987,8 @@ _mesa_texstore_argb8888(STORE_PARAMS) ((srcType == GL_UNSIGNED_BYTE && littleEndian) || srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) { /* simple memcpy path (little endian) */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + memcpy_texture(dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -994,7 +1001,8 @@ _mesa_texstore_argb8888(STORE_PARAMS) ((srcType == GL_UNSIGNED_BYTE && !littleEndian) || srcType == GL_UNSIGNED_INT_8_8_8_8)) { /* simple memcpy path (big endian) */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + memcpy_texture(dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1064,7 +1072,8 @@ _mesa_texstore_rgb888(STORE_PARAMS) srcType == GL_UNSIGNED_BYTE && littleEndian) { /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + memcpy_texture(dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1082,8 +1091,8 @@ _mesa_texstore_rgb888(STORE_PARAMS) for (img = 0; img < srcDepth; img++) { const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLubyte *srcRow = (GLubyte *) _mesa_image_address(srcPacking, srcAddr, - srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); + GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); GLubyte *dstRow = dstImage; for (row = 0; row < srcHeight; row++) { for (col = 0; col < srcWidth; col++) { @@ -1168,7 +1177,8 @@ _mesa_texstore_bgr888(STORE_PARAMS) srcType == GL_UNSIGNED_BYTE && littleEndian) { /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + memcpy_texture(dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1186,8 +1196,8 @@ _mesa_texstore_bgr888(STORE_PARAMS) for (img = 0; img < srcDepth; img++) { const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLubyte *srcRow = (GLubyte *) _mesa_image_address(srcPacking, srcAddr, - srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); + GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); GLubyte *dstRow = dstImage; for (row = 0; row < srcHeight; row++) { for (col = 0; col < srcWidth; col++) { @@ -1251,7 +1261,8 @@ _mesa_texstore_argb4444(STORE_PARAMS) srcFormat == GL_BGRA && srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV) { /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + memcpy_texture(dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1320,7 +1331,8 @@ _mesa_texstore_argb1555(STORE_PARAMS) srcFormat == GL_BGRA && srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV) { /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + memcpy_texture(dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1392,7 +1404,8 @@ _mesa_texstore_al88(STORE_PARAMS) srcType == GL_UNSIGNED_BYTE && littleEndian) { /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + memcpy_texture(dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1455,7 +1468,8 @@ _mesa_texstore_rgb332(STORE_PARAMS) baseInternalFormat == GL_RGB && srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE_3_3_2) { /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + memcpy_texture(dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1512,7 +1526,8 @@ _mesa_texstore_a8(STORE_PARAMS) baseInternalFormat == srcFormat && srcType == GL_UNSIGNED_BYTE) { /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + memcpy_texture(dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1565,7 +1580,8 @@ _mesa_texstore_ci8(STORE_PARAMS) srcFormat == GL_COLOR_INDEX && srcType == GL_UNSIGNED_BYTE) { /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + memcpy_texture(dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1580,7 +1596,7 @@ _mesa_texstore_ci8(STORE_PARAMS) for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = dstImage; for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(srcPacking, + const GLvoid *src = _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); _mesa_unpack_index_span(ctx, srcWidth, GL_UNSIGNED_BYTE, dstRow, srcType, src, srcPacking, @@ -1614,7 +1630,8 @@ _mesa_texstore_ycbcr(STORE_PARAMS) ASSERT(baseInternalFormat == GL_YCBCR_MESA); /* always just memcpy since no pixel transfer ops apply */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + memcpy_texture(dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1678,7 +1695,8 @@ _mesa_texstore_rgba_float32(STORE_PARAMS) baseInternalFormat == srcFormat && srcType == GL_FLOAT) { /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + memcpy_texture(dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1745,7 +1763,8 @@ _mesa_texstore_rgba_float16(STORE_PARAMS) baseInternalFormat == srcFormat && srcType == GL_HALF_FLOAT_ARB) { /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + memcpy_texture(dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); @@ -1795,7 +1814,7 @@ _mesa_texstore_rgba_float16(STORE_PARAMS) * The caller _must_ call unmap_teximage_pbo() too! */ static const GLvoid * -validate_pbo_teximage(GLcontext *ctx, +validate_pbo_teximage(GLcontext *ctx, GLuint dimensions, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *unpack, @@ -1807,8 +1826,8 @@ validate_pbo_teximage(GLcontext *ctx, /* no PBO */ return pixels; } - if (!_mesa_validate_pbo_access(unpack, width, height, depth, format, - type, pixels)) { + if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, + format, type, pixels)) { _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access"); return NULL; } @@ -1915,7 +1934,7 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level, return; } - pixels = validate_pbo_teximage(ctx, width, 1, 1, format, type, pixels, + pixels = validate_pbo_teximage(ctx, 1, width, 1, 1, format, type, pixels, packing, "glTexImage1D"); if (!pixels) return; @@ -1994,8 +2013,8 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level, return; } - pixels = validate_pbo_teximage(ctx, width, height, 1, format, type, pixels, - packing, "glTexImage2D"); + pixels = validate_pbo_teximage(ctx, 2, width, height, 1, format, type, + pixels, packing, "glTexImage2D"); if (!pixels) return; @@ -2070,7 +2089,7 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level, return; } - pixels = validate_pbo_teximage(ctx, width, height, depth, format, type, + pixels = validate_pbo_teximage(ctx, 3, width, height, depth, format, type, pixels, packing, "glTexImage3D"); if (!pixels) return; @@ -2125,7 +2144,7 @@ _mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level, struct gl_texture_object *texObj, struct gl_texture_image *texImage) { - pixels = validate_pbo_teximage(ctx, width, 1, 1, format, type, pixels, + pixels = validate_pbo_teximage(ctx, 1, width, 1, 1, format, type, pixels, packing, "glTexSubImage1D"); if (!pixels) return; @@ -2171,8 +2190,8 @@ _mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level, struct gl_texture_object *texObj, struct gl_texture_image *texImage) { - pixels = validate_pbo_teximage(ctx, width, height, 1, format, type, pixels, - packing, "glTexSubImage2D"); + pixels = validate_pbo_teximage(ctx, 2, width, height, 1, format, type, + pixels, packing, "glTexSubImage2D"); if (!pixels) return; @@ -2223,7 +2242,7 @@ _mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level, struct gl_texture_object *texObj, struct gl_texture_image *texImage) { - pixels = validate_pbo_teximage(ctx, width, height, depth, format, type, + pixels = validate_pbo_teximage(ctx, 3, width, height, depth, format, type, pixels, packing, "glTexSubImage3D"); if (!pixels) return; diff --git a/src/mesa/swrast/s_bitmap.c b/src/mesa/swrast/s_bitmap.c index be72891..1afb487 100644 --- a/src/mesa/swrast/s_bitmap.c +++ b/src/mesa/swrast/s_bitmap.c @@ -58,7 +58,7 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, if (unpack->BufferObj->Name) { /* unpack from PBO */ GLubyte *buf; - if (!_mesa_validate_pbo_access(unpack, width, height, 1, + if (!_mesa_validate_pbo_access(2, unpack, width, height, 1, GL_COLOR_INDEX, GL_BITMAP, (GLvoid *) bitmap)) { _mesa_error(ctx, GL_INVALID_OPERATION,"glBitmap(invalid PBO access)"); @@ -104,8 +104,8 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, _swrast_span_default_texcoords(ctx, &span); for (row = 0; row < height; row++, span.y++) { - const GLubyte *src = (const GLubyte *) _mesa_image_address( unpack, - bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 ); + const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack, + bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0); if (unpack->LsbFirst) { /* Lsb first */ @@ -226,8 +226,8 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, _swrast_span_default_texcoords(ctx, &span); for (row=0; rowLsbFirst) { /* Lsb first */ diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 74c820c..5b0a24b 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -476,10 +476,10 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y, ? MAX_WIDTH : (width - skipPixels); ASSERT(spanEnd <= MAX_WIDTH); for (row = 0; row < height; row++, spanY++) { - const GLvoid *source = _mesa_image_address(unpack, pixels, - width, height, - GL_COLOR_INDEX, type, - 0, row, skipPixels); + const GLvoid *source = _mesa_image_address2d(unpack, pixels, + width, height, + GL_COLOR_INDEX, type, + row, skipPixels); _mesa_unpack_index_span(ctx, spanEnd, GL_UNSIGNED_INT, span.array->index, type, source, unpack, ctx->_ImageTransferState); @@ -543,10 +543,10 @@ draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y, GLstencil values[MAX_WIDTH]; GLenum destType = (sizeof(GLstencil) == sizeof(GLubyte)) ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT; - const GLvoid *source = _mesa_image_address(unpack, pixels, - width, height, - GL_COLOR_INDEX, type, - 0, row, skipPixels); + const GLvoid *source = _mesa_image_address2d(unpack, pixels, + width, height, + GL_COLOR_INDEX, type, + row, skipPixels); _mesa_unpack_index_span(ctx, spanWidth, destType, values, type, source, unpack, ctx->_ImageTransferState); @@ -616,8 +616,8 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, GLint row, spanY = y; for (row = 0; row < height; row++, spanY++) { const GLushort *zSrc = (const GLushort *) - _mesa_image_address(unpack, pixels, width, height, - GL_DEPTH_COMPONENT, type, 0, row, 0); + _mesa_image_address2d(unpack, pixels, width, height, + GL_DEPTH_COMPONENT, type, row, 0); GLint i; for (i = 0; i < width; i++) span.array->z[i] = zSrc[i]; @@ -638,8 +638,8 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, GLint row, spanY = y; for (row = 0; row < height; row++, spanY++) { const GLuint *zSrc = (const GLuint *) - _mesa_image_address(unpack, pixels, width, height, - GL_DEPTH_COMPONENT, type, 0, row, 0); + _mesa_image_address2d(unpack, pixels, width, height, + GL_DEPTH_COMPONENT, type, row, 0); if (shift == 0) { MEMCPY(span.array->z, zSrc, width * sizeof(GLdepth)); } @@ -667,10 +667,10 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, ASSERT(span.end <= MAX_WIDTH); for (row = 0; row < height; row++, spanY++) { GLfloat floatSpan[MAX_WIDTH]; - const GLvoid *zSrc = _mesa_image_address(unpack, - pixels, width, height, - GL_DEPTH_COMPONENT, type, - 0, row, skipPixels); + const GLvoid *zSrc = _mesa_image_address2d(unpack, + pixels, width, height, + GL_DEPTH_COMPONENT, type, + row, skipPixels); /* Set these for each row since the _swrast_write_* function may * change them while clipping. @@ -776,8 +776,8 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, /* Unpack the image and apply transfer ops up to convolution */ dest = tmpImage; for (row = 0; row < height; row++) { - const GLvoid *source = _mesa_image_address(unpack, - pixels, width, height, format, type, 0, row, 0); + 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); @@ -819,8 +819,8 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, ASSERT(span.end <= MAX_WIDTH); for (row = 0; row < height; row++, spanY++) { - const GLvoid *source = _mesa_image_address(unpack, - pixels, width, height, format, type, 0, row, skipPixels); + const GLvoid *source = _mesa_image_address2d(unpack, + pixels, width, height, format, type, row, skipPixels); /* Set these for each row since the _swrast_write_* function may * change them while clipping. @@ -888,7 +888,7 @@ _swrast_DrawPixels( GLcontext *ctx, if (unpack->BufferObj->Name) { /* unpack from PBO */ GLubyte *buf; - if (!_mesa_validate_pbo_access(unpack, width, height, 1, + if (!_mesa_validate_pbo_access(2, unpack, width, height, 1, format, type, pixels)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(invalid PBO access)"); diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index aec796e..7d8112f 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -84,8 +84,8 @@ read_index_pixels( GLcontext *ctx, (*swrast->Driver.ReadCI32Span)(ctx, readWidth, x, y + i, index); - dest = _mesa_image_address(packing, pixels, width, height, - GL_COLOR_INDEX, type, 0, i, 0); + dest = _mesa_image_address2d(packing, pixels, width, height, + GL_COLOR_INDEX, type, i, 0); _mesa_pack_index_span(ctx, readWidth, type, dest, index, &ctx->Pack, ctx->_ImageTransferState); @@ -138,8 +138,8 @@ read_depth_pixels( GLcontext *ctx, GLint j; for (j=0;jVisual.redBits < CHAN_BITS || ctx->Visual.greenBits < CHAN_BITS || ctx->Visual.blueBits < CHAN_BITS) { @@ -510,7 +510,7 @@ _swrast_ReadPixels( GLcontext *ctx, if (clippedPacking.BufferObj->Name) { /* pack into PBO */ GLubyte *buf; - if (!_mesa_validate_pbo_access(&clippedPacking, width, height, 1, + if (!_mesa_validate_pbo_access(2, &clippedPacking, width, height, 1, format, type, pixels)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(invalid PBO access)"); -- 2.7.4