From f2ad1b60c0da11283b399008f491792790cea294 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 31 Mar 2006 15:48:04 +0000 Subject: Dave Reveman's patch for GLX_MESA_copy_sub_buffer support --- src/mesa/drivers/dri/r300/radeon_context.c | 27 +++++++++++++- src/mesa/drivers/dri/r300/radeon_context.h | 2 + src/mesa/drivers/dri/r300/radeon_ioctl.c | 59 +++++++++++++++++++++--------- src/mesa/drivers/dri/r300/radeon_ioctl.h | 3 +- 4 files changed, 72 insertions(+), 19 deletions(-) (limited to 'src/mesa/drivers/dri/r300') diff --git a/src/mesa/drivers/dri/r300/radeon_context.c b/src/mesa/drivers/dri/r300/radeon_context.c index 0a957816db..4e351dd66b 100644 --- a/src/mesa/drivers/dri/r300/radeon_context.c +++ b/src/mesa/drivers/dri/r300/radeon_context.c @@ -231,7 +231,7 @@ void radeonSwapBuffers(__DRIdrawablePrivate * dPriv) if (radeon->doPageFlip) { radeonPageFlip(dPriv); } else { - radeonCopyBuffer(dPriv); + radeonCopyBuffer(dPriv, NULL); } } } else { @@ -241,6 +241,31 @@ void radeonSwapBuffers(__DRIdrawablePrivate * dPriv) } } +void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv, + int x, int y, int w, int h ) +{ + if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) { + radeonContextPtr radeon; + GLcontext *ctx; + + radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate; + ctx = radeon->glCtx; + + if (ctx->Visual.doubleBufferMode) { + drm_clip_rect_t rect; + rect.x1 = x + dPriv->x; + rect.y1 = (dPriv->h - y - h) + dPriv->y; + rect.x2 = rect.x1 + w; + rect.y2 = rect.y1 + h; + _mesa_notifySwapBuffers(ctx); /* flush pending rendering comands */ + radeonCopyBuffer(dPriv, &rect); + } + } else { + /* XXX this shouldn't be an error but we can't handle it for now */ + _mesa_problem(NULL, "%s: drawable has no context!", + __FUNCTION__); + } +} /* Force the context `c' to be the current context and associate with it * buffer `b'. diff --git a/src/mesa/drivers/dri/r300/radeon_context.h b/src/mesa/drivers/dri/r300/radeon_context.h index 671c14df03..4eeb4edcfd 100644 --- a/src/mesa/drivers/dri/r300/radeon_context.h +++ b/src/mesa/drivers/dri/r300/radeon_context.h @@ -203,6 +203,8 @@ struct radeon_context { #define RADEON_CONTEXT(glctx) ((radeonContextPtr)(ctx->DriverCtx)) extern void radeonSwapBuffers(__DRIdrawablePrivate * dPriv); +extern void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv, + int x, int y, int w, int h); extern GLboolean radeonInitContext(radeonContextPtr radeon, struct dd_function_table* functions, const __GLcontextModes * glVisual, diff --git a/src/mesa/drivers/dri/r300/radeon_ioctl.c b/src/mesa/drivers/dri/r300/radeon_ioctl.c index f562762878..798e83c010 100644 --- a/src/mesa/drivers/dri/r300/radeon_ioctl.c +++ b/src/mesa/drivers/dri/r300/radeon_ioctl.c @@ -164,7 +164,8 @@ static void radeonWaitForFrameCompletion(radeonContextPtr radeon) /* Copy the back color buffer to the front color buffer. */ -void radeonCopyBuffer(const __DRIdrawablePrivate * dPriv) +void radeonCopyBuffer(const __DRIdrawablePrivate * dPriv, + const drm_clip_rect_t * rect) { radeonContextPtr radeon; GLint nbox, i, ret; @@ -193,10 +194,13 @@ void radeonCopyBuffer(const __DRIdrawablePrivate * dPriv) * request at a time. */ radeonWaitForFrameCompletion(radeon); - UNLOCK_HARDWARE(radeon); - driWaitForVBlank(dPriv, &radeon->vbl_seq, radeon->vblank_flags, - &missed_target); - LOCK_HARDWARE(radeon); + if (!rect) + { + UNLOCK_HARDWARE(radeon); + driWaitForVBlank(dPriv, &radeon->vbl_seq, radeon->vblank_flags, + &missed_target); + LOCK_HARDWARE(radeon); + } nbox = dPriv->numClipRects; /* must be in locked region */ @@ -206,9 +210,28 @@ void radeonCopyBuffer(const __DRIdrawablePrivate * dPriv) drm_clip_rect_t *b = radeon->sarea->boxes; GLint n = 0; - for (; i < nr; i++) { - *b++ = box[i]; - n++; + for ( ; i < nr ; i++ ) { + + *b = box[i]; + + if (rect) + { + if (rect->x1 > b->x1) + b->x1 = rect->x1; + if (rect->y1 > b->y1) + b->y1 = rect->y1; + if (rect->x2 < b->x2) + b->x2 = rect->x2; + if (rect->y2 < b->y2) + b->y2 = rect->y2; + + if (b->x1 < b->x2 && b->y1 < b->y2) + b++; + } + else + b++; + + n++; } radeon->sarea->nbox = n; @@ -223,22 +246,24 @@ void radeonCopyBuffer(const __DRIdrawablePrivate * dPriv) } UNLOCK_HARDWARE(radeon); - - if (IS_R200_CLASS(radeon->radeonScreen)) + if (!rect) + { + if (IS_R200_CLASS(radeon->radeonScreen)) ((r200ContextPtr)radeon)->hw.all_dirty = GL_TRUE; - else + else ((r300ContextPtr)radeon)->hw.all_dirty = GL_TRUE; - radeon->swap_count++; - (*dri_interface->getUST) (&ust); - if (missed_target) { + radeon->swap_count++; + (*dri_interface->getUST) (&ust); + if (missed_target) { radeon->swap_missed_count++; radeon->swap_missed_ust = ust - radeon->swap_ust; - } + } - radeon->swap_ust = ust; + radeon->swap_ust = ust; - sched_yield(); + sched_yield(); + } } void radeonPageFlip(const __DRIdrawablePrivate * dPriv) diff --git a/src/mesa/drivers/dri/r300/radeon_ioctl.h b/src/mesa/drivers/dri/r300/radeon_ioctl.h index 4ddd776602..b53767510e 100644 --- a/src/mesa/drivers/dri/r300/radeon_ioctl.h +++ b/src/mesa/drivers/dri/r300/radeon_ioctl.h @@ -44,7 +44,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r200_context.h" #include "radeon_drm.h" -extern void radeonCopyBuffer(const __DRIdrawablePrivate * drawable); +extern void radeonCopyBuffer(const __DRIdrawablePrivate * drawable, + const drm_clip_rect_t * rect); extern void radeonPageFlip(const __DRIdrawablePrivate * drawable); extern void radeonFlush(GLcontext * ctx); extern void radeonFinish(GLcontext * ctx); -- cgit v1.2.3