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.
This commit is contained in:
Brian Paul
2004-11-10 15:46:52 +00:00
parent f00d7edd74
commit 60909388ab
20 changed files with 308 additions and 226 deletions

View File

@@ -839,8 +839,8 @@ r200PointsBitmap( GLcontext *ctx, GLint px, GLint py,
*/ */
for (row=0; row<height; row++) { for (row=0; row<height; row++) {
const GLubyte *src = (const GLubyte *) const GLubyte *src = (const GLubyte *)
_mesa_image_address( unpack, bitmap, width, height, _mesa_image_address2d(unpack, bitmap, width, height,
GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 ); GL_COLOR_INDEX, GL_BITMAP, row, 0 );
if (unpack->LsbFirst) { if (unpack->LsbFirst) {
/* Lsb first */ /* Lsb first */

View File

@@ -146,8 +146,8 @@ radeonPointsBitmap( GLsizei width, GLsizei height,
if (ctx->_RotateMode) { if (ctx->_RotateMode) {
for (col=0; col<width; col++) { for (col=0; col<width; col++) {
const GLubyte *src = (const GLubyte *) const GLubyte *src = (const GLubyte *)
_mesa_image_address( unpack, bitmap, height, width, _mesa_image_address2d(unpack, bitmap, height, width,
GL_COLOR_INDEX, GL_BITMAP, 0, col, 0 ); GL_COLOR_INDEX, GL_BITMAP, col, 0 );
/* Msb first */ /* Msb first */
GLubyte mask = 128U >> (unpack->SkipPixels & 0x7); GLubyte mask = 128U >> (unpack->SkipPixels & 0x7);
@@ -166,8 +166,8 @@ radeonPointsBitmap( GLsizei width, GLsizei height,
else { else {
for (row=0; row<height; row++) { for (row=0; row<height; row++) {
const GLubyte *src = (const GLubyte *) const GLubyte *src = (const GLubyte *)
_mesa_image_address( unpack, bitmap, width, height, _mesa_image_address2d(unpack, bitmap, width, height,
GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 ); GL_COLOR_INDEX, GL_BITMAP, row, 0 );
/* Msb first */ /* Msb first */
GLubyte mask = 128U >> (unpack->SkipPixels & 0x7); GLubyte mask = 128U >> (unpack->SkipPixels & 0x7);

View File

@@ -264,10 +264,10 @@ tdfx_bitmap_R5G6B5(GLcontext * ctx, GLint px, GLint py,
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
const GLubyte *src = const GLubyte *src =
(const GLubyte *) _mesa_image_address(finalUnpack, (const GLubyte *) _mesa_image_address2d(finalUnpack,
bitmap, width, height, bitmap, width, height,
GL_COLOR_INDEX, GL_COLOR_INDEX,
GL_BITMAP, 0, row, 0); GL_BITMAP, row, 0);
if (finalUnpack->LsbFirst) { if (finalUnpack->LsbFirst) {
/* least significan bit first */ /* least significan bit first */
GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7); 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 */ /* compute dest address of bottom-left pixel in bitmap */
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
const GLubyte *src = const GLubyte *src =
(const GLubyte *) _mesa_image_address(finalUnpack, (const GLubyte *) _mesa_image_address2d(finalUnpack,
bitmap, width, height, bitmap, width, height,
GL_COLOR_INDEX, GL_COLOR_INDEX,
GL_BITMAP, 0, row, 0); GL_BITMAP, row, 0);
if (finalUnpack->LsbFirst) { if (finalUnpack->LsbFirst) {
/* least significan bit first */ /* least significan bit first */
GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7); 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); GL_FRONT) ? (fxMesa->screen_width) : (info.strideInBytes / 2);
const GLushort *src = (const GLushort *) info.lfbPtr const GLushort *src = (const GLushort *) info.lfbPtr
+ scrY * srcStride + scrX; + scrY * srcStride + scrX;
GLubyte *dst = (GLubyte *) _mesa_image_address(packing, GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing,
dstImage, width, height, format, type, 0, 0, 0); dstImage, width, height, format, type, 0, 0);
const GLint dstStride = _mesa_image_row_stride(packing, const GLint dstStride = _mesa_image_row_stride(packing,
width, format, type); width, format, type);
@@ -573,8 +573,8 @@ tdfx_readpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
+ scrY * srcStride + scrX; + scrY * srcStride + scrX;
const GLint dstStride = const GLint dstStride =
_mesa_image_row_stride(packing, width, format, type); _mesa_image_row_stride(packing, width, format, type);
GLubyte *dst = (GLubyte *) _mesa_image_address(packing, GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing,
dstImage, width, height, format, type, 0, 0, 0); dstImage, width, height, format, type, 0, 0);
const GLint widthInBytes = width * 4; const GLint widthInBytes = width * 4;
{ {
@@ -667,8 +667,8 @@ tdfx_drawpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
+ scrY * dstStride + scrX * 4; + scrY * dstStride + scrX * 4;
const GLint srcStride = const GLint srcStride =
_mesa_image_row_stride(unpack, width, format, type); _mesa_image_row_stride(unpack, width, format, type);
const GLubyte *src = (GLubyte *) _mesa_image_address(unpack, const GLubyte *src = (GLubyte *) _mesa_image_address2d(unpack,
pixels, width, height, format, type, 0, 0, 0); pixels, width, height, format, type, 0, 0);
const GLint widthInBytes = width * 4; const GLint widthInBytes = width * 4;
if ((format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8) || if ((format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8) ||

View File

@@ -525,10 +525,10 @@ fxDDDrawBitmap2 (GLcontext *ctx, GLint px, GLint py,
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
const GLubyte *src = const GLubyte *src =
(const GLubyte *) _mesa_image_address(finalUnpack, (const GLubyte *) _mesa_image_address2d(finalUnpack,
bitmap, width, height, bitmap, width, height,
GL_COLOR_INDEX, GL_BITMAP, GL_COLOR_INDEX, GL_BITMAP,
0, row, 0); row, 0);
if (finalUnpack->LsbFirst) { if (finalUnpack->LsbFirst) {
/* least significan bit first */ /* least significan bit first */
GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7); GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7);
@@ -684,10 +684,10 @@ fxDDDrawBitmap4 (GLcontext *ctx, GLint px, GLint py,
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
const GLubyte *src = const GLubyte *src =
(const GLubyte *) _mesa_image_address(finalUnpack, (const GLubyte *) _mesa_image_address2d(finalUnpack,
bitmap, width, height, bitmap, width, height,
GL_COLOR_INDEX, GL_BITMAP, GL_COLOR_INDEX, GL_BITMAP,
0, row, 0); row, 0);
if (finalUnpack->LsbFirst) { if (finalUnpack->LsbFirst) {
/* least significan bit first */ /* least significan bit first */
GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7); GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7);
@@ -762,9 +762,9 @@ fxDDReadPixels565 (GLcontext * ctx,
const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */ const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
const GLushort *src = (const GLushort *) info.lfbPtr const GLushort *src = (const GLushort *) info.lfbPtr
+ (winY - y) * srcStride + (winX + x); + (winY - y) * srcStride + (winX + x);
GLubyte *dst = (GLubyte *) _mesa_image_address(packing, dstImage, GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dstImage,
width, height, format, width, height, format,
type, 0, 0, 0); type, 0, 0);
GLint dstStride = GLint dstStride =
_mesa_image_row_stride(packing, width, format, type); _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 GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
const GLushort *src = (const GLushort *) info.lfbPtr const GLushort *src = (const GLushort *) info.lfbPtr
+ (winY - y) * srcStride + (winX + x); + (winY - y) * srcStride + (winX + x);
GLubyte *dst = (GLubyte *) _mesa_image_address(packing, dstImage, GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dstImage,
width, height, format, width, height, format,
type, 0, 0, 0); type, 0, 0);
GLint dstStride = GLint dstStride =
_mesa_image_row_stride(packing, width, format, type); _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 GLint srcStride = info.strideInBytes / 4; /* stride in GLuints */
const GLuint *src = (const GLuint *) info.lfbPtr const GLuint *src = (const GLuint *) info.lfbPtr
+ (winY - y) * srcStride + (winX + x); + (winY - y) * srcStride + (winX + x);
GLubyte *dst = (GLubyte *) _mesa_image_address(packing, dstImage, GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dstImage,
width, height, format, width, height, format,
type, 0, 0, 0); type, 0, 0);
GLint dstStride = GLint dstStride =
_mesa_image_row_stride(packing, width, format, type); _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) { if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
GLint row; GLint row;
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels, GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
width, height, format, pixels, width, height, format, type, row, 0);
type, 0, row, 0);
GLint col; GLint col;
for (col = 0; col < width; col++) { for (col = 0; col < width; col++) {
dst[col] = TDFXPACKCOLOR1555(src[2], src[1], src[0], src[3]); 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) { else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
GLint row; GLint row;
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels, GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
width, height, format, pixels, width, height, format, type, row, 0);
type, 0, row, 0);
GLint col; GLint col;
for (col = 0; col < width; col++) { for (col = 0; col < width; col++) {
dst[col] = TDFXPACKCOLOR1555(src[2], src[1], src[0], 255); 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) { if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
GLint row; GLint row;
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels, GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
width, height, format, pixels, width, height, format, type, row, 0);
type, 0, row, 0);
GLint col; GLint col;
for (col = 0; col < width; col++) { for (col = 0; col < width; col++) {
dst[col] = TDFXPACKCOLOR565(src[2], src[1], src[0]); 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) { else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
GLint row; GLint row;
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels, GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
width, height, format, pixels, width, height, format, type, row, 0);
type, 0, row, 0);
GLint col; GLint col;
for (col = 0; col < width; col++) { for (col = 0; col < width; col++) {
dst[col] = TDFXPACKCOLOR565(src[2], src[1], src[0]); 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) { if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
GLint row; GLint row;
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels, GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
width, height, format, pixels, width, height, format, type, row, 0);
type, 0, row, 0);
GLint col; GLint col;
for (col = 0; col < width; col++) { for (col = 0; col < width; col++) {
dst[col] = TDFXPACKCOLOR565(src[0], src[1], src[2]); 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) { else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
GLint row; GLint row;
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels, GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
width, height, format, pixels, width, height, format, type, row, 0);
type, 0, row, 0);
GLint col; GLint col;
for (col = 0; col < width; col++) { for (col = 0; col < width; col++) {
dst[col] = TDFXPACKCOLOR565(src[0], src[1], src[2]); 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; const GLint widthInBytes = width * 4;
GLint row; GLint row;
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels, GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
width, height, format, pixels, width, height, format, type, row, 0);
type, 0, row, 0);
MEMCPY(dst, src, widthInBytes); MEMCPY(dst, src, widthInBytes);
dst += dstStride; dst += dstStride;
} }
@@ -1578,9 +1571,8 @@ fxDDDrawPixels8888 (GLcontext * ctx, GLint x, GLint y,
else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) { else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
GLint row; GLint row;
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
GLubyte *src = (GLubyte *) _mesa_image_address(finalUnpack, pixels, GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
width, height, format, pixels, width, height, format, type, 0, row, 0);
type, 0, row, 0);
GLint col; GLint col;
for (col = 0; col < width; col++) { for (col = 0; col < width; col++) {
dst[col] = TDFXPACKCOLOR8888(src[2], src[1], src[0], 255); dst[col] = TDFXPACKCOLOR8888(src[2], src[1], src[0], 255);

View File

@@ -846,7 +846,7 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx,
if (unpack->BufferObj->Name) { if (unpack->BufferObj->Name) {
/* unpack from PBO */ /* unpack from PBO */
GLubyte *buf; GLubyte *buf;
if (!_mesa_validate_pbo_access(unpack, width, height, 1, if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
format, type, pixels)) { format, type, pixels)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glDrawPixels(invalid PBO access)"); "glDrawPixels(invalid PBO access)");
@@ -949,7 +949,7 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx,
if (unpack->BufferObj->Name) { if (unpack->BufferObj->Name) {
/* unpack from PBO */ /* unpack from PBO */
GLubyte *buf; GLubyte *buf;
if (!_mesa_validate_pbo_access(unpack, width, height, 1, if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
format, type, pixels)) { format, type, pixels)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glDrawPixels(invalid PBO access)"); "glDrawPixels(invalid PBO access)");

View File

@@ -429,7 +429,8 @@ _mesa_init_buffer_objects( GLcontext *ctx )
* go out of bounds. * go out of bounds.
*/ */
GLboolean 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, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const GLvoid *ptr) GLenum format, GLenum type, const GLvoid *ptr)
{ {
@@ -442,11 +443,11 @@ _mesa_validate_pbo_access(const struct gl_pixelstore_attrib *pack,
return GL_FALSE; return GL_FALSE;
/* get address of first pixel we'll read */ /* 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); format, type, 0, 0, 0);
/* get address just past the last pixel we'll read */ /* 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); format, type, depth-1, height-1, width);

View File

@@ -78,7 +78,8 @@ _mesa_buffer_unmap( GLcontext *ctx, GLenum target,
struct gl_buffer_object * bufObj ); struct gl_buffer_object * bufObj );
extern GLboolean 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, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const GLvoid *ptr); GLenum format, GLenum type, const GLvoid *ptr);

View File

@@ -195,7 +195,7 @@ store_colortable_entries(GLcontext *ctx, struct gl_color_table *table,
if (ctx->Unpack.BufferObj->Name) { if (ctx->Unpack.BufferObj->Name) {
/* Get/unpack the color table data from a PBO */ /* Get/unpack the color table data from a PBO */
GLubyte *buf; 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)) { format, type, data)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glColor[Sub]Table(bad PBO access)"); "glColor[Sub]Table(bad PBO access)");
@@ -891,7 +891,7 @@ _mesa_GetColorTable( GLenum target, GLenum format,
if (ctx->Pack.BufferObj->Name) { if (ctx->Pack.BufferObj->Name) {
/* pack color table into PBO */ /* pack color table into PBO */
GLubyte *buf; 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)) { format, type, data)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glGetColorTable(invalid PBO access)"); "glGetColorTable(invalid PBO access)");

View File

@@ -147,7 +147,7 @@ _mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, G
if (ctx->Unpack.BufferObj->Name) { if (ctx->Unpack.BufferObj->Name) {
/* unpack filter from PBO */ /* unpack filter from PBO */
GLubyte *buf; 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)) { format, type, image)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glConvolutionFilter1D(invalid PBO access)"); "glConvolutionFilter1D(invalid PBO access)");
@@ -245,7 +245,7 @@ _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, G
if (ctx->Unpack.BufferObj->Name) { if (ctx->Unpack.BufferObj->Name) {
/* unpack filter from PBO */ /* unpack filter from PBO */
GLubyte *buf; 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)) { format, type, image)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glConvolutionFilter2D(invalid PBO access)"); "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. */ /* Unpack filter image. We always store filters in RGBA format. */
for (i = 0; i < height; i++) { for (i = 0; i < height; i++) {
const GLvoid *src = _mesa_image_address(&ctx->Unpack, image, width, const GLvoid *src = _mesa_image_address2d(&ctx->Unpack, image, width,
height, format, type, 0, i, 0); height, format, type, i, 0);
GLfloat *dst = ctx->Convolution2D.Filter + i * width * 4; GLfloat *dst = ctx->Convolution2D.Filter + i * width * 4;
_mesa_unpack_color_span_float(ctx, width, GL_RGBA, dst, _mesa_unpack_color_span_float(ctx, width, GL_RGBA, dst,
format, type, src, &ctx->Unpack, format, type, src, &ctx->Unpack,
@@ -600,7 +600,8 @@ _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid *im
if (ctx->Pack.BufferObj->Name) { if (ctx->Pack.BufferObj->Name) {
/* Pack the filter into a PBO */ /* Pack the filter into a PBO */
GLubyte *buf; 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)) { 1, format, type, image)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glGetConvolutionFilter(invalid PBO access)"); "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++) { for (row = 0; row < filter->Height; row++) {
GLvoid *dst = _mesa_image_address( &ctx->Pack, image, filter->Width, GLvoid *dst = _mesa_image_address2d(&ctx->Pack, image, filter->Width,
filter->Height, format, type, filter->Height, format, type,
0, row, 0); row, 0);
const GLfloat *src = filter->Filter + row * filter->Width * 4; const GLfloat *src = filter->Filter + row * filter->Width * 4;
_mesa_pack_rgba_span_float(ctx, filter->Width, _mesa_pack_rgba_span_float(ctx, filter->Width,
(const GLfloat (*)[4]) src, (const GLfloat (*)[4]) src,
@@ -802,13 +803,13 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row,
if (ctx->Pack.BufferObj->Name) { if (ctx->Pack.BufferObj->Name) {
/* Pack filter into PBO */ /* Pack filter into PBO */
GLubyte *buf; 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)) { format, type, row)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glGetSeparableFilter(invalid PBO access, width)"); "glGetSeparableFilter(invalid PBO access, width)");
return; 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)) { format, type, column)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glGetSeparableFilter(invalid PBO access, height)"); "glGetSeparableFilter(invalid PBO access, height)");
@@ -829,9 +830,8 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row,
/* Row filter */ /* Row filter */
if (row) { if (row) {
GLvoid *dst = _mesa_image_address( &ctx->Pack, row, filter->Width, GLvoid *dst = _mesa_image_address1d(&ctx->Pack, row, filter->Width,
filter->Height, format, type, format, type, 0);
0, 0, 0);
_mesa_pack_rgba_span_float(ctx, filter->Width, _mesa_pack_rgba_span_float(ctx, filter->Width,
(const GLfloat (*)[4]) filter->Filter, (const GLfloat (*)[4]) filter->Filter,
format, type, dst, &ctx->Pack, 0); format, type, dst, &ctx->Pack, 0);
@@ -839,9 +839,8 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row,
/* Column filter */ /* Column filter */
if (column) { if (column) {
GLvoid *dst = _mesa_image_address( &ctx->Pack, column, filter->Width, GLvoid *dst = _mesa_image_address1d(&ctx->Pack, column, filter->Height,
1, format, type, format, type, 0);
0, 0, 0);
const GLfloat *src = filter->Filter + colStart; const GLfloat *src = filter->Filter + colStart;
_mesa_pack_rgba_span_float(ctx, filter->Height, _mesa_pack_rgba_span_float(ctx, filter->Height,
(const GLfloat (*)[4]) src, (const GLfloat (*)[4]) src,
@@ -908,13 +907,13 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs
if (ctx->Unpack.BufferObj->Name) { if (ctx->Unpack.BufferObj->Name) {
/* unpack filter from PBO */ /* unpack filter from PBO */
GLubyte *buf; 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)) { format, type, row)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glSeparableFilter2D(invalid PBO access, width)"); "glSeparableFilter2D(invalid PBO access, width)");
return; 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)) { format, type, column)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glSeparableFilter2D(invalid PBO access, height)"); "glSeparableFilter2D(invalid PBO access, height)");

View File

@@ -810,19 +810,19 @@ _mesa_init_lists( void )
* \todo This won't suffice when the PBO is really in VRAM/GPU memory. * \todo This won't suffice when the PBO is really in VRAM/GPU memory.
*/ */
static GLvoid * 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, GLenum format, GLenum type, const GLvoid *pixels,
const struct gl_pixelstore_attrib *unpack ) const struct gl_pixelstore_attrib *unpack )
{ {
if (unpack->BufferObj->Name == 0) { if (unpack->BufferObj->Name == 0) {
/* no PBO */ /* no PBO */
return _mesa_unpack_image(width, height, depth, format, type, return _mesa_unpack_image(dimensions, width, height, depth, format, type,
pixels, unpack); pixels, unpack);
} }
else if (_mesa_validate_pbo_access(unpack, width, height, depth, format, else if (_mesa_validate_pbo_access(dimensions, unpack, width, height, depth,
type, pixels)) { format, type, pixels)) {
const GLubyte *src = ADD_POINTERS(unpack->BufferObj->Data, 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); src, unpack);
} }
/* bad access! */ /* bad access! */
@@ -1296,7 +1296,7 @@ static void GLAPIENTRY save_ColorTable( GLenum target, GLenum internalFormat,
format, type, table ); format, type, table );
} }
else { else {
GLvoid *image = unpack_image(width, 1, 1, format, type, table, GLvoid *image = unpack_image(1, width, 1, 1, format, type, table,
&ctx->Unpack); &ctx->Unpack);
Node *n; Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); 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) const GLvoid *table)
{ {
GET_CURRENT_CONTEXT(ctx); 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); &ctx->Unpack);
Node *n; Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); 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) GLenum format, GLenum type, const GLvoid *filter)
{ {
GET_CURRENT_CONTEXT(ctx); 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); &ctx->Unpack);
Node *n; Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
@@ -1485,7 +1485,7 @@ save_ConvolutionFilter2D(GLenum target, GLenum internalFormat,
GLenum type, const GLvoid *filter) GLenum type, const GLvoid *filter)
{ {
GET_CURRENT_CONTEXT(ctx); 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); &ctx->Unpack);
Node *n; Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
@@ -1850,7 +1850,7 @@ static void GLAPIENTRY save_DrawPixels( GLsizei width, GLsizei height,
const GLvoid *pixels ) const GLvoid *pixels )
{ {
GET_CURRENT_CONTEXT(ctx); 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); pixels, &ctx->Unpack);
Node *n; Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
@@ -3418,7 +3418,7 @@ static void GLAPIENTRY save_TexImage1D( GLenum target,
border, format, type, pixels ); border, format, type, pixels );
} }
else { else {
GLvoid *image = unpack_image(width, 1, 1, format, type, GLvoid *image = unpack_image(1, width, 1, 1, format, type,
pixels, &ctx->Unpack); pixels, &ctx->Unpack);
Node *n; Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
@@ -3457,7 +3457,7 @@ static void GLAPIENTRY save_TexImage2D( GLenum target,
height, border, format, type, pixels ); height, border, format, type, pixels );
} }
else { else {
GLvoid *image = unpack_image(width, height, 1, format, type, GLvoid *image = unpack_image(2, width, height, 1, format, type,
pixels, &ctx->Unpack); pixels, &ctx->Unpack);
Node *n; Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
@@ -3499,7 +3499,7 @@ static void GLAPIENTRY save_TexImage3D( GLenum target,
} }
else { else {
Node *n; Node *n;
GLvoid *image = unpack_image(width, height, depth, format, type, GLvoid *image = unpack_image(3, width, height, depth, format, type,
pixels, &ctx->Unpack); pixels, &ctx->Unpack);
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE3D, 10 ); 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); GET_CURRENT_CONTEXT(ctx);
Node *n; Node *n;
GLvoid *image = unpack_image(width, 1, 1, format, type, GLvoid *image = unpack_image(1, width, 1, 1, format, type,
pixels, &ctx->Unpack); pixels, &ctx->Unpack);
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 ); 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); GET_CURRENT_CONTEXT(ctx);
Node *n; Node *n;
GLvoid *image = unpack_image(width, height, 1, format, type, GLvoid *image = unpack_image(2, width, height, 1, format, type,
pixels, &ctx->Unpack); pixels, &ctx->Unpack);
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 ); 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); GET_CURRENT_CONTEXT(ctx);
Node *n; Node *n;
GLvoid *image = unpack_image(width, height, depth, format, type, GLvoid *image = unpack_image(3, width, height, depth, format, type,
pixels, &ctx->Unpack); pixels, &ctx->Unpack);
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 ); n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );

View File

@@ -717,7 +717,7 @@ _mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvo
if (ctx->Pack.BufferObj->Name) { if (ctx->Pack.BufferObj->Name) {
/* pack min/max values into a PBO */ /* pack min/max values into a PBO */
GLubyte *buf; 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)) { format, type, values)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glGetMinMax(invalid PBO access)"); "glGetMinMax(invalid PBO access)");
@@ -801,7 +801,7 @@ _mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, G
if (ctx->Pack.BufferObj->Name) { if (ctx->Pack.BufferObj->Name) {
/* pack min/max values into a PBO */ /* pack min/max values into a PBO */
GLubyte *buf; 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)) { format, type, values)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glGetHistogram(invalid PBO access)"); "glGetHistogram(invalid PBO access)");

View File

@@ -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. * Pixel unpacking/packing parameters are observed according to \p packing.
* *
* \param image start of image data. * \param dimensions either 1, 2 or 3 to indicate dimensionality of image
* \param width image width. * \param image starting address of image data
* \param height image height. * \param width the image width
* \param format pixel format. * \param height theimage height
* \param type pixel data type. * \param format the pixel format
* \param type the pixel data type
* \param packing the pixelstore attributes * \param packing the pixelstore attributes
* \param img which image in the volume (0 for 1D or 2D images) * \param img which image in the volume (0 for 1D or 2D images)
* \param row of pixel in the image * \param row row of pixel in the image (0 for 1D images)
* \param column of pixel in the image * \param column column of pixel in the image
* *
* \return address of pixel on success, or NULL on error. * \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. * \sa gl_pixelstore_attrib.
*/ */
GLvoid * GLvoid *
_mesa_image_address( const struct gl_pixelstore_attrib *packing, _mesa_image_address( GLuint dimensions,
const GLvoid *image, GLsizei width, const struct gl_pixelstore_attrib *packing,
GLsizei height, GLenum format, GLenum type, const GLvoid *image,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
GLint img, GLint row, GLint column ) GLint img, GLint row, GLint column )
{ {
GLint alignment; /* 1, 2 or 4 */ 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 */ GLint skipimages; /* for 3-D volume images */
GLubyte *pixel_addr; GLubyte *pixel_addr;
ASSERT(dimensions >= 1 && dimensions <= 3);
alignment = packing->Alignment; alignment = packing->Alignment;
if (packing->RowLength > 0) { if (packing->RowLength > 0) {
pixels_per_row = packing->RowLength; pixels_per_row = packing->RowLength;
@@ -499,9 +501,12 @@ _mesa_image_address( const struct gl_pixelstore_attrib *packing,
else { else {
rows_per_image = height; rows_per_image = height;
} }
skiprows = packing->SkipRows;
skippixels = packing->SkipPixels; 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) { if (type == GL_BITMAP) {
/* BITMAP data */ /* 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. * Compute the stride between image rows.
* *
@@ -744,8 +786,8 @@ _mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels,
dst = buffer; dst = buffer;
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
const GLubyte *src = (const GLubyte *) const GLubyte *src = (const GLubyte *)
_mesa_image_address(packing, pixels, width, height, _mesa_image_address2d(packing, pixels, width, height,
GL_COLOR_INDEX, GL_BITMAP, 0, row, 0); GL_COLOR_INDEX, GL_BITMAP, row, 0);
if (!src) { if (!src) {
FREE(buffer); FREE(buffer);
return NULL; return NULL;
@@ -838,8 +880,8 @@ _mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source,
width_in_bytes = CEILING( width, 8 ); width_in_bytes = CEILING( width, 8 );
src = source; src = source;
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
GLubyte *dst = (GLubyte *) _mesa_image_address( packing, dest, GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dest,
width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 ); width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0);
if (!dst) if (!dst)
return; 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. * need a copy of the data in a standard format.
*/ */
void * 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, GLenum format, GLenum type, const GLvoid *pixels,
const struct gl_pixelstore_attrib *unpack ) const struct gl_pixelstore_attrib *unpack )
{ {
@@ -4036,7 +4079,7 @@ _mesa_unpack_image( GLsizei width, GLsizei height, GLsizei depth,
dst = destBuffer; dst = destBuffer;
for (img = 0; img < depth; img++) { for (img = 0; img < depth; img++) {
for (row = 0; row < height; row++) { 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); width, height, format, type, img, row, 0);
MEMCPY(dst, src, bytesPerRow); MEMCPY(dst, src, bytesPerRow);
/* byte flipping/swapping */ /* byte flipping/swapping */

View File

@@ -58,9 +58,32 @@ _mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type );
extern GLvoid * extern GLvoid *
_mesa_image_address( const struct gl_pixelstore_attrib *packing, _mesa_image_address( GLuint dimensions,
const GLvoid *image, GLsizei width, const struct gl_pixelstore_attrib *packing,
GLsizei height, GLenum format, GLenum type, 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 ); GLint img, GLint row, GLint column );
@@ -171,7 +194,8 @@ _mesa_pack_depth_span( const GLcontext *ctx, GLuint n, GLvoid *dest,
extern void * 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, GLenum format, GLenum type, const GLvoid *pixels,
const struct gl_pixelstore_attrib *unpack ); const struct gl_pixelstore_attrib *unpack );

View File

@@ -362,7 +362,7 @@ _mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values )
GLubyte *buf; GLubyte *buf;
/* Note, need to use DefaultPacking and Unpack's buffer object */ /* Note, need to use DefaultPacking and Unpack's buffer object */
ctx->DefaultPacking.BufferObj = ctx->Unpack.BufferObj; 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)) { GL_INTENSITY, GL_FLOAT, values)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glPixelMapfv(invalid PBO access)"); "glPixelMapfv(invalid PBO access)");
@@ -422,7 +422,7 @@ _mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values )
GLubyte *buf; GLubyte *buf;
/* Note, need to use DefaultPacking and Unpack's buffer object */ /* Note, need to use DefaultPacking and Unpack's buffer object */
ctx->DefaultPacking.BufferObj = ctx->Unpack.BufferObj; 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)) { GL_INTENSITY, GL_UNSIGNED_INT, values)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glPixelMapuiv(invalid PBO access)"); "glPixelMapuiv(invalid PBO access)");
@@ -496,7 +496,7 @@ _mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values )
GLubyte *buf; GLubyte *buf;
/* Note, need to use DefaultPacking and Unpack's buffer object */ /* Note, need to use DefaultPacking and Unpack's buffer object */
ctx->DefaultPacking.BufferObj = ctx->Unpack.BufferObj; 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, GL_INTENSITY, GL_UNSIGNED_SHORT,
values)) { values)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
@@ -590,7 +590,7 @@ _mesa_GetPixelMapfv( GLenum map, GLfloat *values )
GLubyte *buf; GLubyte *buf;
/* Note, need to use DefaultPacking and Pack's buffer object */ /* Note, need to use DefaultPacking and Pack's buffer object */
ctx->DefaultPacking.BufferObj = ctx->Pack.BufferObj; 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)) { GL_INTENSITY, GL_FLOAT, values)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glGetPixelMapfv(invalid PBO access)"); "glGetPixelMapfv(invalid PBO access)");
@@ -673,7 +673,7 @@ _mesa_GetPixelMapuiv( GLenum map, GLuint *values )
GLubyte *buf; GLubyte *buf;
/* Note, need to use DefaultPacking and Pack's buffer object */ /* Note, need to use DefaultPacking and Pack's buffer object */
ctx->DefaultPacking.BufferObj = ctx->Pack.BufferObj; 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)) { GL_INTENSITY, GL_UNSIGNED_INT, values)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glGetPixelMapuiv(invalid PBO access)"); "glGetPixelMapuiv(invalid PBO access)");
@@ -768,7 +768,7 @@ _mesa_GetPixelMapusv( GLenum map, GLushort *values )
GLubyte *buf; GLubyte *buf;
/* Note, need to use DefaultPacking and Pack's buffer object */ /* Note, need to use DefaultPacking and Pack's buffer object */
ctx->DefaultPacking.BufferObj = ctx->Pack.BufferObj; 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, GL_INTENSITY, GL_UNSIGNED_SHORT,
values)) { values)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,

View File

@@ -196,7 +196,7 @@ _mesa_polygon_stipple(GLcontext *ctx, const GLubyte *pattern)
if (ctx->Unpack.BufferObj->Name) { if (ctx->Unpack.BufferObj->Name) {
/* Get/unpack the stipple pattern from a PBO */ /* Get/unpack the stipple pattern from a PBO */
GLubyte *buf; 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)) { GL_COLOR_INDEX, GL_BITMAP, pattern)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glPolygonStipple(bad PBO access)"); "glPolygonStipple(bad PBO access)");
@@ -261,7 +261,7 @@ _mesa_GetPolygonStipple( GLubyte *dest )
if (ctx->Pack.BufferObj->Name) { if (ctx->Pack.BufferObj->Name) {
/* Put/pack the stipple pattern into a PBO */ /* Put/pack the stipple pattern into a PBO */
GLubyte *buf; 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)) { GL_COLOR_INDEX, GL_BITMAP, dest)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glGetPolygonStipple(bad PBO access)"); "glGetPolygonStipple(bad PBO access)");

View File

@@ -1901,6 +1901,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
const struct gl_texture_object *texObj; const struct gl_texture_object *texObj;
const struct gl_texture_image *texImage; const struct gl_texture_image *texImage;
GLint maxLevels = 0; GLint maxLevels = 0;
GLuint dimensions;
GET_CURRENT_CONTEXT(ctx); GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
@@ -1975,6 +1976,8 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
return; return;
} }
dimensions = (target == GL_TEXTURE_3D) ? 3 : 2;
/* XXX - someday the rest of this function should be moved into a /* XXX - someday the rest of this function should be moved into a
* fallback routine called via ctx->Driver.GetTexImage() * fallback routine called via ctx->Driver.GetTexImage()
*/ */
@@ -1982,7 +1985,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
if (ctx->Pack.BufferObj->Name) { if (ctx->Pack.BufferObj->Name) {
/* pack texture image into a PBO */ /* pack texture image into a PBO */
GLubyte *buf; 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, texImage->Height, texImage->Depth,
format, type, pixels)) { format, type, pixels)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _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 (img = 0; img < depth; img++) {
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
/* compute destination address in client memory */ /* 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, width, height, format, type,
img, row, 0); img, row, 0);
assert(dest); assert(dest);

View File

@@ -227,7 +227,7 @@ make_temp_float_image(GLcontext *ctx, GLuint dims,
/* unpack and do transfer ops up to convolution */ /* unpack and do transfer ops up to convolution */
for (row = 0; row < srcHeight; row++) { for (row = 0; row < srcHeight; row++) {
const GLvoid *src = _mesa_image_address(srcPacking, const GLvoid *src = _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcAddr, srcWidth, srcHeight,
srcFormat, srcType, img, row, 0); srcFormat, srcType, img, row, 0);
_mesa_unpack_color_span_float(ctx, srcWidth, GL_RGBA, dst, _mesa_unpack_color_span_float(ctx, srcWidth, GL_RGBA, dst,
@@ -299,7 +299,7 @@ make_temp_float_image(GLcontext *ctx, GLuint dims,
dst = tempImage; dst = tempImage;
for (img = 0; img < srcDepth; img++) { for (img = 0; img < srcDepth; img++) {
const GLubyte *src const GLubyte *src
= (const GLubyte *) _mesa_image_address(srcPacking, srcAddr, = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
srcWidth, srcHeight, srcWidth, srcHeight,
srcFormat, srcType, srcFormat, srcType,
img, 0, 0); img, 0, 0);
@@ -449,7 +449,7 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims,
srcWidth, srcFormat, srcWidth, srcFormat,
srcType); srcType);
const GLubyte *src const GLubyte *src
= (const GLubyte *) _mesa_image_address(srcPacking, srcAddr, = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
srcWidth, srcHeight, srcWidth, srcHeight,
srcFormat, srcType, srcFormat, srcType,
img, 0, 0); img, 0, 0);
@@ -522,7 +522,8 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims,
* 1D, 2D and 3D images supported. * 1D, 2D and 3D images supported.
*/ */
static void static void
memcpy_texture(const struct gl_texture_format *dstFormat, memcpy_texture(GLuint dimensions,
const struct gl_texture_format *dstFormat,
GLvoid *dstAddr, GLvoid *dstAddr,
GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
GLint dstRowStride, GLint dstImageStride, GLint dstRowStride, GLint dstImageStride,
@@ -535,8 +536,8 @@ memcpy_texture(const struct gl_texture_format *dstFormat,
srcFormat, srcType); srcFormat, srcType);
const GLint srcImageStride = _mesa_image_image_stride(srcPacking, const GLint srcImageStride = _mesa_image_image_stride(srcPacking,
srcWidth, srcHeight, srcFormat, srcType); srcWidth, srcHeight, srcFormat, srcType);
const GLubyte *srcImage = (const GLubyte *) _mesa_image_address(srcPacking, const GLubyte *srcImage = (const GLubyte *) _mesa_image_address(dimensions,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0); srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
const GLint bytesPerRow = srcWidth * dstFormat->TexelBytes; const GLint bytesPerRow = srcWidth * dstFormat->TexelBytes;
const GLint bytesPerImage = srcHeight * bytesPerRow; const GLint bytesPerImage = srcHeight * bytesPerRow;
const GLint bytesPerTexture = srcDepth * bytesPerImage; const GLint bytesPerTexture = srcDepth * bytesPerImage;
@@ -626,7 +627,8 @@ _mesa_texstore_rgba(GLcontext *ctx, GLuint dims,
baseInternalFormat == srcFormat && baseInternalFormat == srcFormat &&
srcType == CHAN_TYPE) { srcType == CHAN_TYPE) {
/* simple memcpy path */ /* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, memcpy_texture(dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride, dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking); srcAddr, srcPacking);
@@ -645,8 +647,8 @@ _mesa_texstore_rgba(GLcontext *ctx, GLuint dims,
for (img = 0; img < srcDepth; img++) { for (img = 0; img < srcDepth; img++) {
const GLint srcRowStride = _mesa_image_row_stride(srcPacking, const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
srcWidth, srcFormat, srcType); srcWidth, srcFormat, srcType);
GLchan *srcRow = (GLchan *) _mesa_image_address(srcPacking, srcAddr, GLchan *srcRow = (GLchan *) _mesa_image_address(dims, srcPacking,
srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
GLchan *dstRow = dstImage; GLchan *dstRow = dstImage;
for (row = 0; row < srcHeight; row++) { for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) { for (col = 0; col < srcWidth; col++) {
@@ -711,7 +713,8 @@ _mesa_texstore_depth_component_float32(STORE_PARAMS)
srcFormat == GL_DEPTH_COMPONENT && srcFormat == GL_DEPTH_COMPONENT &&
srcType == GL_FLOAT) { srcType == GL_FLOAT) {
/* simple memcpy path */ /* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, memcpy_texture(dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride, dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking); srcAddr, srcPacking);
@@ -726,7 +729,7 @@ _mesa_texstore_depth_component_float32(STORE_PARAMS)
for (img = 0; img < srcDepth; img++) { for (img = 0; img < srcDepth; img++) {
GLubyte *dstRow = dstImage; GLubyte *dstRow = dstImage;
for (row = 0; row < srcHeight; row++) { 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); srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
_mesa_unpack_depth_span(ctx, srcWidth, (GLfloat *) dstRow, _mesa_unpack_depth_span(ctx, srcWidth, (GLfloat *) dstRow,
srcType, src, srcPacking); srcType, src, srcPacking);
@@ -755,7 +758,8 @@ _mesa_texstore_depth_component16(STORE_PARAMS)
srcFormat == GL_DEPTH_COMPONENT && srcFormat == GL_DEPTH_COMPONENT &&
srcType == GL_UNSIGNED_SHORT) { srcType == GL_UNSIGNED_SHORT) {
/* simple memcpy path */ /* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, memcpy_texture(dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride, dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking); srcAddr, srcPacking);
@@ -771,7 +775,7 @@ _mesa_texstore_depth_component16(STORE_PARAMS)
GLubyte *dstRow = dstImage; GLubyte *dstRow = dstImage;
for (row = 0; row < srcHeight; row++) { for (row = 0; row < srcHeight; row++) {
GLfloat depthTemp[MAX_WIDTH]; 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); srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
GLushort *dst16 = (GLushort *) dstRow; GLushort *dst16 = (GLushort *) dstRow;
_mesa_unpack_depth_span(ctx, srcWidth, depthTemp, _mesa_unpack_depth_span(ctx, srcWidth, depthTemp,
@@ -805,7 +809,8 @@ _mesa_texstore_rgb565(STORE_PARAMS)
srcFormat == GL_RGB && srcFormat == GL_RGB &&
srcType == GL_UNSIGNED_SHORT_5_6_5) { srcType == GL_UNSIGNED_SHORT_5_6_5) {
/* simple memcpy path */ /* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, memcpy_texture(dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride, dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking); srcAddr, srcPacking);
@@ -820,7 +825,7 @@ _mesa_texstore_rgb565(STORE_PARAMS)
const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth,
srcFormat, srcType); srcFormat, srcType);
const GLubyte *src = (const GLubyte *) 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); srcFormat, srcType, 0, 0, 0);
GLubyte *dst = (GLubyte *) dstAddr GLubyte *dst = (GLubyte *) dstAddr
+ dstZoffset * dstImageStride + dstZoffset * dstImageStride
@@ -909,7 +914,8 @@ _mesa_texstore_rgba8888(STORE_PARAMS)
((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) || ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
(srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV))) { (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV))) {
/* simple memcpy path */ /* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, memcpy_texture(dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride, dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking); srcAddr, srcPacking);
@@ -981,7 +987,8 @@ _mesa_texstore_argb8888(STORE_PARAMS)
((srcType == GL_UNSIGNED_BYTE && littleEndian) || ((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) { srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) {
/* simple memcpy path (little endian) */ /* simple memcpy path (little endian) */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, memcpy_texture(dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride, dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking); srcAddr, srcPacking);
@@ -994,7 +1001,8 @@ _mesa_texstore_argb8888(STORE_PARAMS)
((srcType == GL_UNSIGNED_BYTE && !littleEndian) || ((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
srcType == GL_UNSIGNED_INT_8_8_8_8)) { srcType == GL_UNSIGNED_INT_8_8_8_8)) {
/* simple memcpy path (big endian) */ /* simple memcpy path (big endian) */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, memcpy_texture(dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride, dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking); srcAddr, srcPacking);
@@ -1064,7 +1072,8 @@ _mesa_texstore_rgb888(STORE_PARAMS)
srcType == GL_UNSIGNED_BYTE && srcType == GL_UNSIGNED_BYTE &&
littleEndian) { littleEndian) {
/* simple memcpy path */ /* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, memcpy_texture(dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride, dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking); srcAddr, srcPacking);
@@ -1082,8 +1091,8 @@ _mesa_texstore_rgb888(STORE_PARAMS)
for (img = 0; img < srcDepth; img++) { for (img = 0; img < srcDepth; img++) {
const GLint srcRowStride = _mesa_image_row_stride(srcPacking, const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
srcWidth, srcFormat, srcType); srcWidth, srcFormat, srcType);
GLubyte *srcRow = (GLubyte *) _mesa_image_address(srcPacking, srcAddr, GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
GLubyte *dstRow = dstImage; GLubyte *dstRow = dstImage;
for (row = 0; row < srcHeight; row++) { for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) { for (col = 0; col < srcWidth; col++) {
@@ -1168,7 +1177,8 @@ _mesa_texstore_bgr888(STORE_PARAMS)
srcType == GL_UNSIGNED_BYTE && srcType == GL_UNSIGNED_BYTE &&
littleEndian) { littleEndian) {
/* simple memcpy path */ /* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, memcpy_texture(dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride, dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking); srcAddr, srcPacking);
@@ -1186,8 +1196,8 @@ _mesa_texstore_bgr888(STORE_PARAMS)
for (img = 0; img < srcDepth; img++) { for (img = 0; img < srcDepth; img++) {
const GLint srcRowStride = _mesa_image_row_stride(srcPacking, const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
srcWidth, srcFormat, srcType); srcWidth, srcFormat, srcType);
GLubyte *srcRow = (GLubyte *) _mesa_image_address(srcPacking, srcAddr, GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
GLubyte *dstRow = dstImage; GLubyte *dstRow = dstImage;
for (row = 0; row < srcHeight; row++) { for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) { for (col = 0; col < srcWidth; col++) {
@@ -1251,7 +1261,8 @@ _mesa_texstore_argb4444(STORE_PARAMS)
srcFormat == GL_BGRA && srcFormat == GL_BGRA &&
srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV) { srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV) {
/* simple memcpy path */ /* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, memcpy_texture(dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride, dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking); srcAddr, srcPacking);
@@ -1320,7 +1331,8 @@ _mesa_texstore_argb1555(STORE_PARAMS)
srcFormat == GL_BGRA && srcFormat == GL_BGRA &&
srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV) { srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV) {
/* simple memcpy path */ /* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, memcpy_texture(dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride, dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking); srcAddr, srcPacking);
@@ -1392,7 +1404,8 @@ _mesa_texstore_al88(STORE_PARAMS)
srcType == GL_UNSIGNED_BYTE && srcType == GL_UNSIGNED_BYTE &&
littleEndian) { littleEndian) {
/* simple memcpy path */ /* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, memcpy_texture(dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride, dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking); srcAddr, srcPacking);
@@ -1455,7 +1468,8 @@ _mesa_texstore_rgb332(STORE_PARAMS)
baseInternalFormat == GL_RGB && baseInternalFormat == GL_RGB &&
srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE_3_3_2) { srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE_3_3_2) {
/* simple memcpy path */ /* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, memcpy_texture(dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride, dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking); srcAddr, srcPacking);
@@ -1512,7 +1526,8 @@ _mesa_texstore_a8(STORE_PARAMS)
baseInternalFormat == srcFormat && baseInternalFormat == srcFormat &&
srcType == GL_UNSIGNED_BYTE) { srcType == GL_UNSIGNED_BYTE) {
/* simple memcpy path */ /* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, memcpy_texture(dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride, dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking); srcAddr, srcPacking);
@@ -1565,7 +1580,8 @@ _mesa_texstore_ci8(STORE_PARAMS)
srcFormat == GL_COLOR_INDEX && srcFormat == GL_COLOR_INDEX &&
srcType == GL_UNSIGNED_BYTE) { srcType == GL_UNSIGNED_BYTE) {
/* simple memcpy path */ /* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, memcpy_texture(dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride, dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking); srcAddr, srcPacking);
@@ -1580,7 +1596,7 @@ _mesa_texstore_ci8(STORE_PARAMS)
for (img = 0; img < srcDepth; img++) { for (img = 0; img < srcDepth; img++) {
GLubyte *dstRow = dstImage; GLubyte *dstRow = dstImage;
for (row = 0; row < srcHeight; row++) { 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); srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
_mesa_unpack_index_span(ctx, srcWidth, GL_UNSIGNED_BYTE, dstRow, _mesa_unpack_index_span(ctx, srcWidth, GL_UNSIGNED_BYTE, dstRow,
srcType, src, srcPacking, srcType, src, srcPacking,
@@ -1614,7 +1630,8 @@ _mesa_texstore_ycbcr(STORE_PARAMS)
ASSERT(baseInternalFormat == GL_YCBCR_MESA); ASSERT(baseInternalFormat == GL_YCBCR_MESA);
/* always just memcpy since no pixel transfer ops apply */ /* 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, dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking); srcAddr, srcPacking);
@@ -1678,7 +1695,8 @@ _mesa_texstore_rgba_float32(STORE_PARAMS)
baseInternalFormat == srcFormat && baseInternalFormat == srcFormat &&
srcType == GL_FLOAT) { srcType == GL_FLOAT) {
/* simple memcpy path */ /* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, memcpy_texture(dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride, dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking); srcAddr, srcPacking);
@@ -1745,7 +1763,8 @@ _mesa_texstore_rgba_float16(STORE_PARAMS)
baseInternalFormat == srcFormat && baseInternalFormat == srcFormat &&
srcType == GL_HALF_FLOAT_ARB) { srcType == GL_HALF_FLOAT_ARB) {
/* simple memcpy path */ /* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, memcpy_texture(dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride, dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking); srcAddr, srcPacking);
@@ -1795,7 +1814,7 @@ _mesa_texstore_rgba_float16(STORE_PARAMS)
* The caller _must_ call unmap_teximage_pbo() too! * The caller _must_ call unmap_teximage_pbo() too!
*/ */
static const GLvoid * static const GLvoid *
validate_pbo_teximage(GLcontext *ctx, validate_pbo_teximage(GLcontext *ctx, GLuint dimensions,
GLsizei width, GLsizei height, GLsizei depth, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const GLvoid *pixels, GLenum format, GLenum type, const GLvoid *pixels,
const struct gl_pixelstore_attrib *unpack, const struct gl_pixelstore_attrib *unpack,
@@ -1807,8 +1826,8 @@ validate_pbo_teximage(GLcontext *ctx,
/* no PBO */ /* no PBO */
return pixels; return pixels;
} }
if (!_mesa_validate_pbo_access(unpack, width, height, depth, format, if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth,
type, pixels)) { format, type, pixels)) {
_mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access"); _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access");
return NULL; return NULL;
} }
@@ -1915,7 +1934,7 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
return; 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"); packing, "glTexImage1D");
if (!pixels) if (!pixels)
return; return;
@@ -1994,8 +2013,8 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
return; return;
} }
pixels = validate_pbo_teximage(ctx, width, height, 1, format, type, pixels, pixels = validate_pbo_teximage(ctx, 2, width, height, 1, format, type,
packing, "glTexImage2D"); pixels, packing, "glTexImage2D");
if (!pixels) if (!pixels)
return; return;
@@ -2070,7 +2089,7 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
return; 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"); pixels, packing, "glTexImage3D");
if (!pixels) if (!pixels)
return; return;
@@ -2125,7 +2144,7 @@ _mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj, struct gl_texture_object *texObj,
struct gl_texture_image *texImage) 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"); packing, "glTexSubImage1D");
if (!pixels) if (!pixels)
return; return;
@@ -2171,8 +2190,8 @@ _mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj, struct gl_texture_object *texObj,
struct gl_texture_image *texImage) struct gl_texture_image *texImage)
{ {
pixels = validate_pbo_teximage(ctx, width, height, 1, format, type, pixels, pixels = validate_pbo_teximage(ctx, 2, width, height, 1, format, type,
packing, "glTexSubImage2D"); pixels, packing, "glTexSubImage2D");
if (!pixels) if (!pixels)
return; return;
@@ -2223,7 +2242,7 @@ _mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj, struct gl_texture_object *texObj,
struct gl_texture_image *texImage) 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"); pixels, packing, "glTexSubImage3D");
if (!pixels) if (!pixels)
return; return;

View File

@@ -58,7 +58,7 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
if (unpack->BufferObj->Name) { if (unpack->BufferObj->Name) {
/* unpack from PBO */ /* unpack from PBO */
GLubyte *buf; 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, GL_COLOR_INDEX, GL_BITMAP,
(GLvoid *) bitmap)) { (GLvoid *) bitmap)) {
_mesa_error(ctx, GL_INVALID_OPERATION,"glBitmap(invalid PBO access)"); _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); _swrast_span_default_texcoords(ctx, &span);
for (row = 0; row < height; row++, span.y++) { for (row = 0; row < height; row++, span.y++) {
const GLubyte *src = (const GLubyte *) _mesa_image_address( unpack, const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack,
bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 ); bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0);
if (unpack->LsbFirst) { if (unpack->LsbFirst) {
/* Lsb first */ /* Lsb first */
@@ -226,8 +226,8 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
_swrast_span_default_texcoords(ctx, &span); _swrast_span_default_texcoords(ctx, &span);
for (row=0; row<height; row++, span.y++) { for (row=0; row<height; row++, span.y++) {
const GLubyte *src = (const GLubyte *) _mesa_image_address( unpack, const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack,
bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 ); bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0);
if (unpack->LsbFirst) { if (unpack->LsbFirst) {
/* Lsb first */ /* Lsb first */

View File

@@ -476,10 +476,10 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y,
? MAX_WIDTH : (width - skipPixels); ? MAX_WIDTH : (width - skipPixels);
ASSERT(spanEnd <= MAX_WIDTH); ASSERT(spanEnd <= MAX_WIDTH);
for (row = 0; row < height; row++, spanY++) { for (row = 0; row < height; row++, spanY++) {
const GLvoid *source = _mesa_image_address(unpack, pixels, const GLvoid *source = _mesa_image_address2d(unpack, pixels,
width, height, width, height,
GL_COLOR_INDEX, type, GL_COLOR_INDEX, type,
0, row, skipPixels); row, skipPixels);
_mesa_unpack_index_span(ctx, spanEnd, GL_UNSIGNED_INT, _mesa_unpack_index_span(ctx, spanEnd, GL_UNSIGNED_INT,
span.array->index, type, source, unpack, span.array->index, type, source, unpack,
ctx->_ImageTransferState); ctx->_ImageTransferState);
@@ -543,10 +543,10 @@ draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y,
GLstencil values[MAX_WIDTH]; GLstencil values[MAX_WIDTH];
GLenum destType = (sizeof(GLstencil) == sizeof(GLubyte)) GLenum destType = (sizeof(GLstencil) == sizeof(GLubyte))
? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT; ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT;
const GLvoid *source = _mesa_image_address(unpack, pixels, const GLvoid *source = _mesa_image_address2d(unpack, pixels,
width, height, width, height,
GL_COLOR_INDEX, type, GL_COLOR_INDEX, type,
0, row, skipPixels); row, skipPixels);
_mesa_unpack_index_span(ctx, spanWidth, destType, values, _mesa_unpack_index_span(ctx, spanWidth, destType, values,
type, source, unpack, type, source, unpack,
ctx->_ImageTransferState); ctx->_ImageTransferState);
@@ -616,8 +616,8 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
GLint row, spanY = y; GLint row, spanY = y;
for (row = 0; row < height; row++, spanY++) { for (row = 0; row < height; row++, spanY++) {
const GLushort *zSrc = (const GLushort *) const GLushort *zSrc = (const GLushort *)
_mesa_image_address(unpack, pixels, width, height, _mesa_image_address2d(unpack, pixels, width, height,
GL_DEPTH_COMPONENT, type, 0, row, 0); GL_DEPTH_COMPONENT, type, row, 0);
GLint i; GLint i;
for (i = 0; i < width; i++) for (i = 0; i < width; i++)
span.array->z[i] = zSrc[i]; span.array->z[i] = zSrc[i];
@@ -638,8 +638,8 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
GLint row, spanY = y; GLint row, spanY = y;
for (row = 0; row < height; row++, spanY++) { for (row = 0; row < height; row++, spanY++) {
const GLuint *zSrc = (const GLuint *) const GLuint *zSrc = (const GLuint *)
_mesa_image_address(unpack, pixels, width, height, _mesa_image_address2d(unpack, pixels, width, height,
GL_DEPTH_COMPONENT, type, 0, row, 0); GL_DEPTH_COMPONENT, type, row, 0);
if (shift == 0) { if (shift == 0) {
MEMCPY(span.array->z, zSrc, width * sizeof(GLdepth)); 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); ASSERT(span.end <= MAX_WIDTH);
for (row = 0; row < height; row++, spanY++) { for (row = 0; row < height; row++, spanY++) {
GLfloat floatSpan[MAX_WIDTH]; GLfloat floatSpan[MAX_WIDTH];
const GLvoid *zSrc = _mesa_image_address(unpack, const GLvoid *zSrc = _mesa_image_address2d(unpack,
pixels, width, height, pixels, width, height,
GL_DEPTH_COMPONENT, type, GL_DEPTH_COMPONENT, type,
0, row, skipPixels); row, skipPixels);
/* Set these for each row since the _swrast_write_* function may /* Set these for each row since the _swrast_write_* function may
* change them while clipping. * 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 */ /* Unpack the image and apply transfer ops up to convolution */
dest = tmpImage; dest = tmpImage;
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
const GLvoid *source = _mesa_image_address(unpack, const GLvoid *source = _mesa_image_address2d(unpack,
pixels, width, height, format, type, 0, row, 0); pixels, width, height, format, type, row, 0);
_mesa_unpack_color_span_float(ctx, width, GL_RGBA, (GLfloat *) dest, _mesa_unpack_color_span_float(ctx, width, GL_RGBA, (GLfloat *) dest,
format, type, source, unpack, format, type, source, unpack,
transferOps & IMAGE_PRE_CONVOLUTION_BITS); transferOps & IMAGE_PRE_CONVOLUTION_BITS);
@@ -819,8 +819,8 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
ASSERT(span.end <= MAX_WIDTH); ASSERT(span.end <= MAX_WIDTH);
for (row = 0; row < height; row++, spanY++) { for (row = 0; row < height; row++, spanY++) {
const GLvoid *source = _mesa_image_address(unpack, const GLvoid *source = _mesa_image_address2d(unpack,
pixels, width, height, format, type, 0, row, skipPixels); pixels, width, height, format, type, row, skipPixels);
/* Set these for each row since the _swrast_write_* function may /* Set these for each row since the _swrast_write_* function may
* change them while clipping. * change them while clipping.
@@ -888,7 +888,7 @@ _swrast_DrawPixels( GLcontext *ctx,
if (unpack->BufferObj->Name) { if (unpack->BufferObj->Name) {
/* unpack from PBO */ /* unpack from PBO */
GLubyte *buf; GLubyte *buf;
if (!_mesa_validate_pbo_access(unpack, width, height, 1, if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
format, type, pixels)) { format, type, pixels)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glDrawPixels(invalid PBO access)"); "glDrawPixels(invalid PBO access)");

View File

@@ -84,8 +84,8 @@ read_index_pixels( GLcontext *ctx,
(*swrast->Driver.ReadCI32Span)(ctx, readWidth, x, y + i, index); (*swrast->Driver.ReadCI32Span)(ctx, readWidth, x, y + i, index);
dest = _mesa_image_address(packing, pixels, width, height, dest = _mesa_image_address2d(packing, pixels, width, height,
GL_COLOR_INDEX, type, 0, i, 0); GL_COLOR_INDEX, type, i, 0);
_mesa_pack_index_span(ctx, readWidth, type, dest, index, _mesa_pack_index_span(ctx, readWidth, type, dest, index,
&ctx->Pack, ctx->_ImageTransferState); &ctx->Pack, ctx->_ImageTransferState);
@@ -138,8 +138,8 @@ read_depth_pixels( GLcontext *ctx,
GLint j; GLint j;
for (j=0;j<height;j++,y++) { for (j=0;j<height;j++,y++) {
GLdepth depth[MAX_WIDTH]; GLdepth depth[MAX_WIDTH];
GLushort *dst = (GLushort*) _mesa_image_address( packing, pixels, GLushort *dst = (GLushort*) _mesa_image_address2d(packing, pixels,
width, height, GL_DEPTH_COMPONENT, type, 0, j, 0 ); width, height, GL_DEPTH_COMPONENT, type, j, 0);
GLint i; GLint i;
_swrast_read_depth_span(ctx, width, x, y, depth); _swrast_read_depth_span(ctx, width, x, y, depth);
for (i = 0; i < width; i++) for (i = 0; i < width; i++)
@@ -151,8 +151,8 @@ read_depth_pixels( GLcontext *ctx,
/* Special case: directly read 32-bit unsigned depth values. */ /* Special case: directly read 32-bit unsigned depth values. */
GLint j; GLint j;
for (j=0;j<height;j++,y++) { for (j=0;j<height;j++,y++) {
GLdepth *dst = (GLdepth *) _mesa_image_address( packing, pixels, GLdepth *dst = (GLdepth *) _mesa_image_address2d(packing, pixels,
width, height, GL_DEPTH_COMPONENT, type, 0, j, 0 ); width, height, GL_DEPTH_COMPONENT, type, j, 0);
_swrast_read_depth_span(ctx, width, x, y, dst); _swrast_read_depth_span(ctx, width, x, y, dst);
} }
} }
@@ -165,8 +165,8 @@ read_depth_pixels( GLcontext *ctx,
_swrast_read_depth_span_float(ctx, readWidth, x, y, depth); _swrast_read_depth_span_float(ctx, readWidth, x, y, depth);
dest = _mesa_image_address(packing, pixels, width, height, dest = _mesa_image_address2d(packing, pixels, width, height,
GL_DEPTH_COMPONENT, type, 0, j, 0); GL_DEPTH_COMPONENT, type, j, 0);
_mesa_pack_depth_span(ctx, readWidth, (GLdepth *) dest, type, _mesa_pack_depth_span(ctx, readWidth, (GLdepth *) dest, type,
depth, packing); depth, packing);
@@ -215,8 +215,8 @@ read_stencil_pixels( GLcontext *ctx,
_swrast_read_stencil_span(ctx, readWidth, x, y, stencil); _swrast_read_stencil_span(ctx, readWidth, x, y, stencil);
dest = _mesa_image_address(packing, pixels, width, height, dest = _mesa_image_address2d(packing, pixels, width, height,
GL_STENCIL_INDEX, type, 0, j, 0); GL_STENCIL_INDEX, type, j, 0);
_mesa_pack_stencil_span(ctx, readWidth, type, dest, stencil, packing); _mesa_pack_stencil_span(ctx, readWidth, type, dest, stencil, packing);
} }
@@ -423,8 +423,8 @@ read_rgba_pixels( GLcontext *ctx,
src = convImage; src = convImage;
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
GLvoid *dest; GLvoid *dest;
dest = _mesa_image_address(packing, pixels, readWidth, height, dest = _mesa_image_address2d(packing, pixels, readWidth, height,
format, type, 0, row, 0); format, type, row, 0);
_mesa_pack_rgba_span_float(ctx, readWidth, _mesa_pack_rgba_span_float(ctx, readWidth,
(const GLfloat (*)[4]) src, (const GLfloat (*)[4]) src,
format, type, dest, packing, format, type, dest, packing,
@@ -449,8 +449,8 @@ read_rgba_pixels( GLcontext *ctx,
} }
_mesa_map_ci_to_rgba_chan(ctx, readWidth, index, rgba); _mesa_map_ci_to_rgba_chan(ctx, readWidth, index, rgba);
} }
dst = _mesa_image_address(packing, pixels, width, height, dst = _mesa_image_address2d(packing, pixels, width, height,
format, type, 0, row, 0); format, type, row, 0);
if (ctx->Visual.redBits < CHAN_BITS || if (ctx->Visual.redBits < CHAN_BITS ||
ctx->Visual.greenBits < CHAN_BITS || ctx->Visual.greenBits < CHAN_BITS ||
ctx->Visual.blueBits < CHAN_BITS) { ctx->Visual.blueBits < CHAN_BITS) {
@@ -510,7 +510,7 @@ _swrast_ReadPixels( GLcontext *ctx,
if (clippedPacking.BufferObj->Name) { if (clippedPacking.BufferObj->Name) {
/* pack into PBO */ /* pack into PBO */
GLubyte *buf; GLubyte *buf;
if (!_mesa_validate_pbo_access(&clippedPacking, width, height, 1, if (!_mesa_validate_pbo_access(2, &clippedPacking, width, height, 1,
format, type, pixels)) { format, type, pixels)) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
"glReadPixels(invalid PBO access)"); "glReadPixels(invalid PBO access)");