From a429a25cd55b8c16356a60452de92228bb6c71b0 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 21 Mar 2008 13:41:00 -0600 Subject: add a number of PBO validate/map/unmap functions Helper functions for (some) drivers, including swrast. --- src/mesa/swrast/s_drawpix.c | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) (limited to 'src/mesa/swrast/s_drawpix.c') diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 4733d10bb5..09ff96fd32 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -817,7 +817,6 @@ draw_depth_stencil_pixels(GLcontext *ctx, GLint x, GLint y, } - /** * Execute software-based glDrawPixels. * By time we get here, all error checking will have been done. @@ -840,27 +839,10 @@ _swrast_DrawPixels( GLcontext *ctx, if (swrast->NewState) _swrast_validate_derived( ctx ); - if (unpack->BufferObj->Name) { - /* unpack from PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(2, unpack, width, height, 1, - format, type, pixels)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawPixels(invalid PBO access)"); - RENDER_FINISH(swrast, ctx); - return; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, - unpack->BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(PBO is mapped)"); - RENDER_FINISH(swrast, ctx); - return; - } - pixels = ADD_POINTERS(buf, pixels); - } + pixels = _mesa_validate_and_map_drawpix_pbo(ctx, width, height, + format, type, unpack, pixels); + if (!pixels) + return; switch (format) { case GL_STENCIL_INDEX: @@ -899,11 +881,7 @@ _swrast_DrawPixels( GLcontext *ctx, RENDER_FINISH(swrast,ctx); - if (unpack->BufferObj->Name) { - /* done with PBO so unmap it now */ - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - unpack->BufferObj); - } + _mesa_unmap_drapix_pbo(ctx, unpack); } -- cgit v1.2.3