summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/x11/xm_dd.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2004-10-31 15:49:59 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2004-10-31 15:49:59 +0000
commitba164c4614288f1642fc8e2f83d2895991b22d70 (patch)
treeadb19111709d974569d27c828078262c20002256 /src/mesa/drivers/x11/xm_dd.c
parent355467bed8cf34cf5967c7be3c5f1b87ff08f845 (diff)
Removed _swrast_validate_pbo_access().
In x11 driver, map/unmap PBO as needed in DrawPixels functions.
Diffstat (limited to 'src/mesa/drivers/x11/xm_dd.c')
-rw-r--r--src/mesa/drivers/x11/xm_dd.c60
1 files changed, 52 insertions, 8 deletions
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c
index db94e40c21..a83c5ec3ec 100644
--- a/src/mesa/drivers/x11/xm_dd.c
+++ b/src/mesa/drivers/x11/xm_dd.c
@@ -843,10 +843,27 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx,
int srcY = unpack->SkipRows;
int rowLength = unpack->RowLength ? unpack->RowLength : width;
- 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);
+ }
if (_swrast_clip_pixelrect(ctx, &dstX, &dstY, &w, &h, &srcX, &srcY)) {
/* This is a little tricky since all coordinates up to now have
@@ -872,6 +889,11 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx,
dstY = FLIP(xmesa->xm_draw_buffer, dstY) - h + 1;
XPutImage(dpy, buffer, gc, &ximage, 0, 0, dstX, dstY, w, h);
}
+
+ if (unpack->BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ unpack->BufferObj);
+ }
}
else {
/* software fallback */
@@ -924,10 +946,27 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx,
int srcY = unpack->SkipRows;
int rowLength = unpack->RowLength ? unpack->RowLength : width;
- 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);
+ }
if (_swrast_clip_pixelrect(ctx, &dstX, &dstY, &w, &h, &srcX, &srcY)) {
/* This is a little tricky since all coordinates up to now have
@@ -953,6 +992,11 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx,
dstY = FLIP(xmesa->xm_draw_buffer, dstY) - h + 1;
XPutImage(dpy, buffer, gc, &ximage, 0, 0, dstX, dstY, w, h);
}
+
+ if (unpack->BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ unpack->BufferObj);
+ }
}
else {
/* software fallback */