From ff938bf059a41a9bdf4c2c93cebe4a3b8a89c201 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 21 Mar 2008 13:43:07 -0600 Subject: add a number of PBO validate/map/unmap functions Helper functions for (some) drivers, including swrast. cherry-picked from Mesa/master --- src/mesa/swrast/s_readpix.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) (limited to 'src/mesa/swrast/s_readpix.c') diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index fe9a70f4ea..f4f882ae84 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -572,25 +572,11 @@ _swrast_ReadPixels( GLcontext *ctx, goto end; } - if (clippedPacking.BufferObj->Name) { - /* pack into PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(2, &clippedPacking, width, height, 1, - format, type, pixels)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(invalid PBO access)"); - goto end; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - GL_WRITE_ONLY_ARB, - clippedPacking.BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(PBO is mapped)"); - goto end; - } - pixels = ADD_POINTERS(buf, pixels); - } + pixels = _mesa_validate_and_map_readpix_pbo(ctx, x, y, width, height, + format, type, + &clippedPacking, pixels); + if (!pixels) + return; switch (format) { case GL_COLOR_INDEX: @@ -632,9 +618,5 @@ _swrast_ReadPixels( GLcontext *ctx, end: RENDER_FINISH(swrast, ctx); - if (clippedPacking.BufferObj->Name) { - /* done with PBO so unmap it now */ - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - clippedPacking.BufferObj); - } + _mesa_unmap_readpix_pbo(ctx, &clippedPacking); } -- cgit v1.2.3