summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast/s_readpix.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2006-03-22 22:02:07 +0000
committerBrian Paul <[email protected]>2006-03-22 22:02:07 +0000
commitf756924fa59b53f4951e2f817144bcb5e5765535 (patch)
tree923e495d3cf5537d9720469a34a805e63b1be2b6 /src/mesa/swrast/s_readpix.c
parent4fafe6390bff5c746b3e46116d1fcada887bf3df (diff)
Need to check for new state and do readpixels/drawpixels clipping after
we call RENDER_START since that may involve validating the drawable and updating its dimensions.
Diffstat (limited to 'src/mesa/swrast/s_readpix.c')
-rw-r--r--src/mesa/swrast/s_readpix.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index c5a5fc8f1d4..3fdd4c727a8 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -2,7 +2,7 @@
* Mesa 3-D graphics library
* Version: 6.5
*
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -33,6 +33,7 @@
#include "macros.h"
#include "imports.h"
#include "pixel.h"
+#include "state.h"
#include "s_context.h"
#include "s_depth.h"
@@ -509,6 +510,15 @@ _swrast_ReadPixels( GLcontext *ctx,
SWcontext *swrast = SWRAST_CONTEXT(ctx);
struct gl_pixelstore_attrib clippedPacking = *packing;
+ /* Need to do RENDER_START before clipping or anything else since this
+ * is where a driver may grab the hw lock and get an updated window
+ * size.
+ */
+ RENDER_START(swrast, ctx);
+
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
if (swrast->NewState)
_swrast_validate_derived( ctx );
@@ -525,7 +535,7 @@ _swrast_ReadPixels( GLcontext *ctx,
format, type, pixels)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glReadPixels(invalid PBO access)");
- return;
+ goto end;
}
buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
GL_WRITE_ONLY_ARB,
@@ -533,13 +543,11 @@ _swrast_ReadPixels( GLcontext *ctx,
if (!buf) {
/* buffer is already mapped - that's an error */
_mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(PBO is mapped)");
- return;
+ goto end;
}
pixels = ADD_POINTERS(buf, pixels);
}
- RENDER_START(swrast, ctx);
-
switch (format) {
case GL_COLOR_INDEX:
read_index_pixels(ctx, x, y, width, height, type, pixels,
@@ -576,6 +584,8 @@ _swrast_ReadPixels( GLcontext *ctx,
/* don't return yet, clean-up */
}
+
+end:
RENDER_FINISH(swrast, ctx);
if (clippedPacking.BufferObj->Name) {