diff options
author | Brian Paul <brianp@vmware.com> | 2011-04-26 14:54:41 -0600 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2011-04-26 14:54:41 -0600 |
commit | 6b329b9274b18c50f4177eef7ee087d50ebc1525 (patch) | |
tree | bdce359cdb3ccddf55b98778849d2be0a950464b /src/mesa/main/texgetimage.c | |
parent | 37642518b8864ce751754957b08cdb437998f4e7 (diff) |
Squashed commit of the following:
commit 864fe253b04105b7469e5f7b064dc37637b944f8
Author: Brian Paul <brianp@vmware.com>
Date: Thu Apr 21 20:13:07 2011 -0600
mesa: s/exec/disp/ in _mesa_init_histogram_dispatch()
This function isn't normally compiled (FEATURE_histogram).
commit f4bf45e2b94b582cacd19cdca873c5be627e4250
Author: nobled <nobled@dreamwidth.org>
Date: Thu Apr 21 07:53:58 2011 -0600
mesa: hook up GL_ARB_robustness dispatch functions
...and advertise the extension.
Signed-off-by: Brian Paul <brianp@vmware.com>
commit 2b89e38e5f572dc40cebc06381ae7c5d04386998
Author: nobled <nobled@dreamwidth.org>
Date: Thu Apr 21 07:53:58 2011 -0600
mesa: regenerated API files for GL_ARB_robustness
Signed-off-by: Brian Paul <brianp@vmware.com>
commit 5d5ebfb7135cec9d833adef86cbf4d0f3d9beca8
Author: nobled <nobled@dreamwidth.org>
Date: Thu Apr 21 07:53:57 2011 -0600
glapi: add ARB_robustness xml
Signed-off-by: Brian Paul <brianp@vmware.com>
commit 0159d1d6d99f4bbc18381dc2081c20d3aff17ac9
Author: nobled <nobled@dreamwidth.org>
Date: Thu Apr 21 07:53:57 2011 -0600
mesa: implement GL_ARB_robustness functions
Signed-off-by: Brian Paul <brianp@vmware.com>
commit 938fd71f4c4742f274922d53492a7290ab8d9c9b
Author: nobled <nobled@dreamwidth.org>
Date: Thu Apr 21 07:53:57 2011 -0600
mesa: add context fields for GL_ARB_robustness
Signed-off-by: Brian Paul <brianp@vmware.com>
commit 72075137bc79e65be03dac7e97b6dba93c3a86a4
Author: nobled <nobled@dreamwidth.org>
Date: Thu Apr 21 07:53:57 2011 -0600
mesa: standardize more bounds-checking error messages
Signed-off-by: Brian Paul <brianp@vmware.com>
commit 32a3fc23746db49da903fbc08afa0135af3007d2
Author: nobled <nobled@dreamwidth.org>
Date: Thu Apr 21 07:53:57 2011 -0600
mesa: standardize some bounds-checking error messages
Signed-off-by: Brian Paul <brianp@vmware.com>
commit cecbf1f4d164207de373dec0cadee2e84e1f9656
Author: nobled <nobled@dreamwidth.org>
Date: Thu Apr 21 07:53:57 2011 -0600
mesa: add more bounds-checking support for client memory buffers
Signed-off-by: Brian Paul <brianp@vmware.com>
commit edc895b52383d5bd274422db56adead1d81daf5f
Author: nobled <nobled@dreamwidth.org>
Date: Thu Apr 21 07:53:57 2011 -0600
mesa: add bounds-checking support for client memory buffers
Signed-off-by: Brian Paul <brianp@vmware.com>
commit 3a96ef28a538f158a219b406cd090dee70470c85
Author: nobled <nobled@dreamwidth.org>
Date: Thu Apr 21 07:53:57 2011 -0600
mesa: use is_bufferobj() helper function
Signed-off-by: Brian Paul <brianp@vmware.com>
Diffstat (limited to 'src/mesa/main/texgetimage.c')
-rw-r--r-- | src/mesa/main/texgetimage.c | 84 |
1 files changed, 56 insertions, 28 deletions
diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 7070a29fb9d..467baa20af4 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -623,11 +623,13 @@ _mesa_get_compressed_teximage(struct gl_context *ctx, GLenum target, GLint level */ static GLboolean getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level, - GLenum format, GLenum type, GLvoid *pixels ) + GLenum format, GLenum type, GLsizei clientMemSize, + GLvoid *pixels ) { struct gl_texture_object *texObj; struct gl_texture_image *texImage; const GLint maxLevels = _mesa_max_texture_levels(ctx, target); + const GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2; GLenum baseFormat; if (maxLevels == 0) { @@ -730,17 +732,21 @@ getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level, return GL_TRUE; } - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* packing texture image into a PBO */ - const GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2; - if (!_mesa_validate_pbo_access(dimensions, &ctx->Pack, texImage->Width, - texImage->Height, texImage->Depth, - format, type, pixels)) { + if (!_mesa_validate_pbo_access(dimensions, &ctx->Pack, texImage->Width, + texImage->Height, texImage->Depth, + format, type, clientMemSize, pixels)) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetTexImage(out of bounds PBO write)"); - return GL_TRUE; + "glGetTexImage(out of bounds PBO access)"); + } else { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetnTexImageARB(out of bounds access:" + " bufSize (%d) is too small)", clientMemSize); } + return GL_TRUE; + } + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* PBO should not be mapped */ if (_mesa_bufferobj_mapped(ctx->Pack.BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, @@ -761,18 +767,20 @@ getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level, * \param level image level. * \param format pixel data format for returned image. * \param type pixel data type for returned image. + * \param bufSize size of the pixels data buffer. * \param pixels returned pixel data. */ void GLAPIENTRY -_mesa_GetTexImage( GLenum target, GLint level, GLenum format, - GLenum type, GLvoid *pixels ) +_mesa_GetnTexImageARB( GLenum target, GLint level, GLenum format, + GLenum type, GLsizei bufSize, GLvoid *pixels ) { struct gl_texture_object *texObj; struct gl_texture_image *texImage; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (getteximage_error_check(ctx, target, level, format, type, pixels)) { + if (getteximage_error_check(ctx, target, level, format, type, + bufSize, pixels)) { return; } @@ -802,6 +810,13 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, } +void GLAPIENTRY +_mesa_GetTexImage( GLenum target, GLint level, GLenum format, + GLenum type, GLvoid *pixels ) +{ + _mesa_GetnTexImageARB(target, level, format, type, INT_MAX, pixels); +} + /** * Do error checking for a glGetCompressedTexImage() call. @@ -809,11 +824,12 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, */ static GLboolean getcompressedteximage_error_check(struct gl_context *ctx, GLenum target, - GLint level, GLvoid *img) + GLint level, GLsizei clientMemSize, GLvoid *img) { struct gl_texture_object *texObj; struct gl_texture_image *texImage; const GLint maxLevels = _mesa_max_texture_levels(ctx, target); + GLuint compressedSize; if (maxLevels == 0) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImage(target=0x%x)", @@ -855,26 +871,31 @@ getcompressedteximage_error_check(struct gl_context *ctx, GLenum target, return GL_TRUE; } - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - GLuint compressedSize; + compressedSize = _mesa_format_image_size(texImage->TexFormat, + texImage->Width, + texImage->Height, + texImage->Depth); - /* make sure PBO is not mapped */ - if (_mesa_bufferobj_mapped(ctx->Pack.BufferObj)) { + if (!_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + /* do bounds checking on writing to client memory */ + if (clientMemSize < compressedSize) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetCompressedTexImage(PBO is mapped)"); - return GL_TRUE; + "glGetnCompressedTexImageARB(out of bounds access:" + " bufSize (%d) is too small)", clientMemSize); } - - compressedSize = _mesa_format_image_size(texImage->TexFormat, - texImage->Width, - texImage->Height, - texImage->Depth); - + } else { /* do bounds checking on PBO write */ if ((const GLubyte *) img + compressedSize > (const GLubyte *) ctx->Pack.BufferObj->Size) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetCompressedTexImage(out of bounds PBO write)"); + "glGetCompressedTexImage(out of bounds PBO access)"); + return GL_TRUE; + } + + /* make sure PBO is not mapped */ + if (_mesa_bufferobj_mapped(ctx->Pack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetCompressedTexImage(PBO is mapped)"); return GL_TRUE; } } @@ -884,14 +905,15 @@ getcompressedteximage_error_check(struct gl_context *ctx, GLenum target, void GLAPIENTRY -_mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img) +_mesa_GetnCompressedTexImageARB(GLenum target, GLint level, GLsizei bufSize, + GLvoid *img) { struct gl_texture_object *texObj; struct gl_texture_image *texImage; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (getcompressedteximage_error_check(ctx, target, level, img)) { + if (getcompressedteximage_error_check(ctx, target, level, bufSize, img)) { return; } @@ -918,3 +940,9 @@ _mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img) } _mesa_unlock_texture(ctx, texObj); } + +void GLAPIENTRY +_mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img) +{ + _mesa_GetnCompressedTexImageARB(target, level, INT_MAX, img); +} |