From 6d6e7a08c7e1fd36dc96953a2fd1f39eccf36104 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 20 Mar 2006 15:48:12 +0000 Subject: [PATCH] Fix up intelSwapBuffers: - get gl_framebuffer pointer from dPriv. - flush current context if bound to window we're swapping. Previous code could try to flush a non-current context. --- src/mesa/drivers/dri/i915/intel_buffers.c | 29 +++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/mesa/drivers/dri/i915/intel_buffers.c b/src/mesa/drivers/dri/i915/intel_buffers.c index d3cbbcc0430..f5c03d0b57e 100644 --- a/src/mesa/drivers/dri/i915/intel_buffers.c +++ b/src/mesa/drivers/dri/i915/intel_buffers.c @@ -36,6 +36,10 @@ #include "framebuffer.h" #include "swrast/swrast.h" + +/** + * XXX move this into a new dri/common/cliprects.c file. + */ GLboolean intel_intersect_cliprects( drm_clip_rect_t *dst, const drm_clip_rect_t *a, const drm_clip_rect_t *b ) @@ -98,6 +102,9 @@ static void intelBufferSize(GLframebuffer *buffer, * information is used to resize Mesa's software buffers, so it has * to be correct. */ + /* XXX This isn't 100% correct, the given buffer might not be + * bound to the current context! + */ LOCK_HARDWARE(intel); if (intel->driDrawable) { *width = intel->driDrawable->w; @@ -464,22 +471,24 @@ static void intelPageFlip( const __DRIdrawablePrivate *dPriv ) void intelSwapBuffers( __DRIdrawablePrivate *dPriv ) { - if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) { - struct intel_context *intel; - GLcontext *ctx; - intel = (struct intel_context *) dPriv->driContextPriv->driverPrivate; - ctx = &intel->ctx; - if (ctx->Visual.doubleBufferMode) { - _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */ + if (dPriv->driverPrivate) { + const struct gl_framebuffer *fb + = (struct gl_framebuffer *) dPriv->driverPrivate; + if (fb->Visual.doubleBufferMode) { + GET_CURRENT_CONTEXT(ctx); + if (ctx && ctx->DrawBuffer == fb) { + _mesa_notifySwapBuffers( ctx ); /* flush pending rendering */ + } if ( 0 /*intel->doPageFlip*/ ) { /* doPageFlip is never set !!! */ intelPageFlip( dPriv ); } else { intelCopyBuffer( dPriv ); } } - } else { - /* XXX this shouldn't be an error but we can't handle it for now */ - fprintf(stderr, "%s: drawable has no context!\n", __FUNCTION__); + } + else { + _mesa_problem(NULL, + "dPriv has no gl_framebuffer pointer in intelSwapBuffers"); } }