diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2004-10-31 16:35:06 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2004-10-31 16:35:06 +0000 |
commit | 1c868139226c07b1537e1951ad237bc070585161 (patch) | |
tree | 426864e5a7c4829f902434bd2869e0903f958ada /src/mesa/main | |
parent | b46712ca9d379d9c091f5543500088d82cf9776c (diff) |
PBO support for glGetCompressedTexImage().
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/teximage.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 726ba37d9b..4d8780d3ba 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1975,8 +1975,12 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, return; } + /* XXX - someday the rest of this function should be moved into a + * fallback routine called via ctx->Driver.GetTexImage() + */ + if (ctx->Pack.BufferObj->Name) { - /* pack texture imaage into a PBO */ + /* pack texture image into a PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(&ctx->Pack, texImage->Width, texImage->Height, texImage->Depth, @@ -3384,9 +3388,40 @@ _mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img) return; } - if (!img) + /* XXX - someday the rest of this function should be moved into a + * fallback routine called via ctx->Driver.GetCompressedTexImage() + */ + + if (ctx->Pack.BufferObj->Name) { + /* pack texture image into a PBO */ + GLubyte *buf; + if ((const GLubyte *) img + texImage->CompressedSize > + (const GLubyte *) ctx->Pack.BufferObj->Size) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetCompressedTexImage(invalid PBO access)"); + return; + } + buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, + GL_WRITE_ONLY_ARB, + ctx->Pack.BufferObj); + if (!buf) { + /* buffer is already mapped - that's an error */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetCompressedTexImage(PBO is mapped)"); + return; + } + img = ADD_POINTERS(buf, img); + } + else if (!img) { + /* not an error */ return; + } /* just memcpy, no pixelstore or pixel transfer */ MEMCPY(img, texImage->Data, texImage->CompressedSize); + + if (ctx->Pack.BufferObj->Name) { + ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, + ctx->Pack.BufferObj); + } } |