aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast/s_readpix.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-03-21 13:43:07 -0600
committerBrian Paul <[email protected]>2008-03-21 13:43:07 -0600
commitff938bf059a41a9bdf4c2c93cebe4a3b8a89c201 (patch)
tree217262bef9a78fafab75ac3f7953b607ce87c4c8 /src/mesa/swrast/s_readpix.c
parentc80a380ebb58c15db87309d466ef57fb006b40ae (diff)
add a number of PBO validate/map/unmap functions
Helper functions for (some) drivers, including swrast. cherry-picked from Mesa/master
Diffstat (limited to 'src/mesa/swrast/s_readpix.c')
-rw-r--r--src/mesa/swrast/s_readpix.c30
1 files changed, 6 insertions, 24 deletions
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index fe9a70f4eae..f4f882ae840 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);
}