diff options
-rw-r--r-- | src/mesa/main/texgetimage.c | 12 | ||||
-rw-r--r-- | src/mesa/main/texstore.c | 43 |
2 files changed, 27 insertions, 28 deletions
diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 3e3951b1c4..341ce6103f 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -322,10 +322,15 @@ _mesa_get_compressed_teximage(GLcontext *ctx, GLenum target, GLint level, { GLuint size; + /* don't use texImage->CompressedSize since that may be padded out */ + size = _mesa_compressed_texture_size(ctx, texImage->Width, texImage->Height, + texImage->Depth, + texImage->TexFormat); + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* pack texture image into a PBO */ GLubyte *buf; - if ((const GLubyte *) img + texImage->CompressedSize > + if ((const GLubyte *) img + size > (const GLubyte *) ctx->Pack.BufferObj->Size) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetCompressedTexImage(invalid PBO access)"); @@ -347,11 +352,6 @@ _mesa_get_compressed_teximage(GLcontext *ctx, GLenum target, GLint level, return; } - /* don't use texImage->CompressedSize since that may be padded out */ - size = _mesa_compressed_texture_size(ctx, texImage->Width, texImage->Height, - texImage->Depth, - texImage->TexFormat); - /* just memcpy, no pixelstore or pixel transfer */ _mesa_memcpy(img, texImage->Data, size); diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 07421b6657..0fa8c44817 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -440,8 +440,8 @@ make_temp_float_image(GLcontext *ctx, GLuint dims, else { /* no convolution */ const GLint components = _mesa_components_in_format(logicalBaseFormat); - const GLint srcStride = _mesa_image_row_stride(srcPacking, - srcWidth, srcFormat, srcType); + const GLint srcStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); GLfloat *dst; GLint img, row; @@ -601,14 +601,13 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims, dst = tempImage; for (img = 0; img < srcDepth; img++) { - const GLint srcStride = _mesa_image_row_stride(srcPacking, - srcWidth, srcFormat, - srcType); - const GLubyte *src - = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - img, 0, 0); + const GLint srcStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + const GLubyte *src = + (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); for (row = 0; row < srcHeight; row++) { _mesa_unpack_color_span_chan(ctx, srcWidth, logicalBaseFormat, dst, srcFormat, srcType, src, srcPacking, @@ -1136,8 +1135,8 @@ _mesa_texstore_rgb565(TEXSTORE_PARAMS) srcType == GL_UNSIGNED_BYTE && dims == 2) { /* do optimized tex store */ - const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, - srcFormat, srcType); + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); const GLubyte *src = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0); @@ -1389,8 +1388,8 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) srcType == GL_UNSIGNED_BYTE) { int img, row, col; for (img = 0; img < srcDepth; img++) { - const GLint srcRowStride = _mesa_image_row_stride(srcPacking, - srcWidth, srcFormat, srcType); + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); GLubyte *dstRow = (GLubyte *) dstAddr @@ -1425,8 +1424,8 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) * Strangely the same isn't required for the RGB path, above. */ for (img = 0; img < srcDepth; img++) { - const GLint srcRowStride = _mesa_image_row_stride(srcPacking, - srcWidth, srcFormat, srcType); + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); GLubyte *dstRow = (GLubyte *) dstAddr @@ -1563,8 +1562,8 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS) /* extract RGB from RGBA */ GLint img, row, col; for (img = 0; img < srcDepth; img++) { - const GLint srcRowStride = _mesa_image_row_stride(srcPacking, - srcWidth, srcFormat, srcType); + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); GLubyte *dstRow = (GLubyte *) dstAddr @@ -1690,8 +1689,8 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS) /* extract BGR from RGBA */ int img, row, col; for (img = 0; img < srcDepth; img++) { - const GLint srcRowStride = _mesa_image_row_stride(srcPacking, - srcWidth, srcFormat, srcType); + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); GLubyte *dstRow = (GLubyte *) dstAddr @@ -2358,8 +2357,8 @@ _mesa_texstore_dudv8(TEXSTORE_PARAMS) else { /* general path - note this is defined for 2d textures only */ const GLint components = _mesa_components_in_format(baseInternalFormat); - const GLint srcStride = _mesa_image_row_stride(srcPacking, - srcWidth, srcFormat, srcType); + const GLint srcStride = _mesa_image_row_stride(srcPacking, srcWidth, + srcFormat, srcType); GLbyte *tempImage, *dst, *src; GLint row; |