Index: lib/GL/mesa/src/drv/r200/r200_context.c =================================================================== RCS file: /cvs/dri/xc/xc/lib/GL/mesa/src/drv/r200/r200_context.c,v retrieving revision 1.35 diff -u -d -r1.35 r200_context.c --- lib/GL/mesa/src/drv/r200/r200_context.c 25 Oct 2003 16:06:35 -0000 1.35 +++ lib/GL/mesa/src/drv/r200/r200_context.c 23 Nov 2003 03:17:37 -0000 @@ -593,6 +593,8 @@ r200UpdateViewportOffset( newCtx->glCtx ); } + newCtx->dri.readable = driReadPriv; + _mesa_make_current2( newCtx->glCtx, (GLframebuffer *) driDrawPriv->driverPrivate, (GLframebuffer *) driReadPriv->driverPrivate ); Index: lib/GL/mesa/src/drv/r200/r200_context.h =================================================================== RCS file: /cvs/dri/xc/xc/lib/GL/mesa/src/drv/r200/r200_context.h,v retrieving revision 1.27 diff -u -d -r1.27 r200_context.h --- lib/GL/mesa/src/drv/r200/r200_context.h 25 Oct 2003 16:06:35 -0000 1.27 +++ lib/GL/mesa/src/drv/r200/r200_context.h 23 Nov 2003 03:17:37 -0000 @@ -565,6 +565,14 @@ __DRIcontextPrivate *context; /* DRI context */ __DRIscreenPrivate *screen; /* DRI screen */ __DRIdrawablePrivate *drawable; /* DRI drawable bound to this ctx */ + __DRIdrawablePrivate *readable; /* DRI drawable bound to this ctx */ + + /** + * Drawable currently set for reading via Mesa's \c SetBuffer hook. This + * will either be \c drawable or \c readable. + */ + + __DRIdrawablePrivate *read_source; drmContext hwContext; drmLock *hwLock; Index: lib/GL/mesa/src/drv/r200/r200_screen.c =================================================================== RCS file: /cvs/dri/xc/xc/lib/GL/mesa/src/drv/r200/r200_screen.c,v retrieving revision 1.20 diff -u -d -r1.20 r200_screen.c --- lib/GL/mesa/src/drv/r200/r200_screen.c 5 Nov 2003 16:12:51 -0000 1.20 +++ lib/GL/mesa/src/drv/r200/r200_screen.c 23 Nov 2003 03:17:37 -0000 @@ -272,6 +272,7 @@ (*glx_enable_extension)( psc, "GLX_MESA_swap_control" ); } + (*glx_enable_extension)( psc, "GLX_SGI_make_current_read" ); (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" ); if ( driCompareGLXAPIVersion( 20030818 ) >= 0 ) { Index: lib/GL/mesa/src/drv/r200/r200_span.c =================================================================== RCS file: /cvs/dri/xc/xc/lib/GL/mesa/src/drv/r200/r200_span.c,v retrieving revision 1.6 diff -u -d -r1.6 r200_span.c --- lib/GL/mesa/src/drv/r200/r200_span.c 16 Sep 2003 20:45:08 -0000 1.6 +++ lib/GL/mesa/src/drv/r200/r200_span.c 23 Nov 2003 03:17:37 -0000 @@ -47,15 +47,15 @@ #define DBG 0 #define LOCAL_VARS \ - r200ContextPtr rmesa = R200_CONTEXT(ctx); \ + r200ContextPtr rmesa = R200_CONTEXT(ctx); \ r200ScreenPtr r200Screen = rmesa->r200Screen; \ __DRIscreenPrivate *sPriv = rmesa->dri.screen; \ - __DRIdrawablePrivate *dPriv = rmesa->dri.drawable; \ + __DRIdrawablePrivate *dPriv = rmesa->dri.read_source; \ GLuint pitch = r200Screen->frontPitch * r200Screen->cpp; \ GLuint height = dPriv->h; \ char *buf = (char *)(sPriv->pFB + \ rmesa->state.color.drawOffset + \ - (dPriv->x * r200Screen->cpp) + \ + (dPriv->x * r200Screen->cpp) + \ (dPriv->y * pitch)); \ char *read_buf = (char *)(sPriv->pFB + \ rmesa->state.pixel.readOffset + \ @@ -65,14 +65,14 @@ (void) read_buf; (void) buf; (void) p #define LOCAL_DEPTH_VARS \ - r200ContextPtr rmesa = R200_CONTEXT(ctx); \ + r200ContextPtr rmesa = R200_CONTEXT(ctx); \ r200ScreenPtr r200Screen = rmesa->r200Screen; \ __DRIscreenPrivate *sPriv = rmesa->dri.screen; \ - __DRIdrawablePrivate *dPriv = rmesa->dri.drawable; \ + __DRIdrawablePrivate *dPriv = rmesa->dri.read_source; \ GLuint height = dPriv->h; \ GLuint xo = dPriv->x; \ GLuint yo = dPriv->y; \ - char *buf = (char *)(sPriv->pFB + r200Screen->depthOffset); \ + char *buf = (char *)(sPriv->pFB + r200Screen->depthOffset); \ (void) buf #define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS @@ -300,6 +300,16 @@ { r200ContextPtr rmesa = R200_CONTEXT(ctx); + + fprintf( stderr, "read_source is the drawable (%s)\n", + (bufferBit == FRONT_LEFT_BIT) ? "front" : "back" ); + + assert( (colorBuffer == rmesa->dri.drawable->driverPrivate) + || (colorBuffer == rmesa->dri.readable->driverPrivate) ); + + rmesa->dri.read_source = (colorBuffer == rmesa->dri.drawable->driverPrivate) + ? rmesa->dri.drawable : rmesa->dri.readable; + switch ( bufferBit ) { case FRONT_LEFT_BIT: if ( rmesa->doPageFlip && rmesa->sarea->pfCurrentPage == 1 ) {