summaryrefslogtreecommitdiff
path: root/src/mesa/swrast/s_drawpix.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2004-10-31 15:39:04 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2004-10-31 15:39:04 +0000
commit355467bed8cf34cf5967c7be3c5f1b87ff08f845 (patch)
tree8911b6e824ea657194bb0a867aadab89be3468f9 /src/mesa/swrast/s_drawpix.c
parentc6136ea62c40e24bb571105a73eca1f5b1e95318 (diff)
Allow the software fallback glDrawPixels, glReadPixels, glBitmap commands to
work with real, hardware-based PBOs in the future by mapping/unmapping the PBO buffer as needed.
Diffstat (limited to 'src/mesa/swrast/s_drawpix.c')
-rw-r--r--src/mesa/swrast/s_drawpix.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index 205022a89d..00cc5e83c0 100644
--- a/src/mesa/swrast/s_drawpix.c
+++ b/src/mesa/swrast/s_drawpix.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 6.2
+ * Version: 6.3
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
@@ -24,6 +24,7 @@
#include "glheader.h"
+#include "bufferobj.h"
#include "context.h"
#include "convolve.h"
#include "image.h"
@@ -931,10 +932,25 @@ _swrast_DrawPixels( GLcontext *ctx,
if (swrast->NewState)
_swrast_validate_derived( ctx );
- pixels = _swrast_validate_pbo_access(unpack, width, height, 1,
- format, type, (GLvoid *) pixels);
- if (!pixels)
- return;
+ if (unpack->BufferObj->Name) {
+ /* unpack from PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(unpack, width, height, 1,
+ format, type, pixels)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glDrawPixels(invalid PBO access)");
+ 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)");
+ return;
+ }
+ pixels = ADD_POINTERS(buf, pixels);
+ }
RENDER_START(swrast,ctx);
@@ -966,9 +982,16 @@ _swrast_DrawPixels( GLcontext *ctx,
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glDrawPixels(format)" );
+ /* don't return yet, clean-up */
}
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);
+ }
}