diff options
author | Brian <[email protected]> | 2008-03-21 13:41:00 -0600 |
---|---|---|
committer | Brian <[email protected]> | 2008-03-21 13:41:00 -0600 |
commit | a429a25cd55b8c16356a60452de92228bb6c71b0 (patch) | |
tree | f743a3bc4e3a9a52582e8e4bbaf8545de132fb6c /src/mesa/swrast/s_readpix.c | |
parent | 85ea7ff25cec703a00d79246df49a4ae6192c395 (diff) |
add a number of PBO validate/map/unmap functions
Helper functions for (some) drivers, including swrast.
Diffstat (limited to 'src/mesa/swrast/s_readpix.c')
-rw-r--r-- | src/mesa/swrast/s_readpix.c | 34 |
1 files changed, 7 insertions, 27 deletions
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index 8df15c8704e..050506b0d05 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -574,28 +574,12 @@ _swrast_ReadPixels( GLcontext *ctx, return; } - 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)"); - RENDER_FINISH(swrast, ctx); - return; - } - 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)"); - RENDER_FINISH(swrast, ctx); - return; - } - 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: read_index_pixels(ctx, x, y, width, height, type, pixels, @@ -634,9 +618,5 @@ _swrast_ReadPixels( GLcontext *ctx, 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); } |