From 4cd0e24f86a5e3fa67774be546f922ca241cb0ea Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 6 Feb 2006 00:09:58 +0000 Subject: add vblank support to i915 driver --- src/mesa/drivers/dri/i915/intel_batchbuffer.c | 50 +++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/mesa/drivers/dri/i915/intel_batchbuffer.c') diff --git a/src/mesa/drivers/dri/i915/intel_batchbuffer.c b/src/mesa/drivers/dri/i915/intel_batchbuffer.c index 323d0b2212..508900de30 100644 --- a/src/mesa/drivers/dri/i915/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i915/intel_batchbuffer.c @@ -32,6 +32,7 @@ #include "mtypes.h" #include "context.h" #include "enums.h" +#include "vblank.h" #include "intel_reg.h" #include "intel_batchbuffer.h" @@ -329,6 +330,38 @@ GLuint *intelEmitInlinePrimitiveLocked(intelContextPtr intel, } +static void intelWaitForFrameCompletion( intelContextPtr intel ) +{ + drm_i915_sarea_t *sarea = (drm_i915_sarea_t *)intel->sarea; + + if (intel->do_irqs) { + if (intelGetLastFrame(intel) < sarea->last_dispatch) { + if (!intel->irqsEmitted) { + while (intelGetLastFrame (intel) < sarea->last_dispatch) + ; + } + else { + UNLOCK_HARDWARE( intel ); + intelWaitIrq( intel, intel->alloc.irq_emitted ); + LOCK_HARDWARE( intel ); + } + intel->irqsEmitted = 10; + } + + if (intel->irqsEmitted) { + intelEmitIrqLocked( intel ); + intel->irqsEmitted--; + } + } + else { + while (intelGetLastFrame (intel) < sarea->last_dispatch) { + UNLOCK_HARDWARE( intel ); + if (intel->do_usleeps) + DO_USLEEP( 1 ); + LOCK_HARDWARE( intel ); + } + } +} /* * Copy the back buffer to the front buffer. @@ -336,6 +369,8 @@ GLuint *intelEmitInlinePrimitiveLocked(intelContextPtr intel, void intelCopyBuffer( const __DRIdrawablePrivate *dPriv ) { intelContextPtr intel; + GLboolean missed_target; + int64_t ust; if (0) fprintf(stderr, "%s\n", __FUNCTION__); @@ -347,6 +382,12 @@ void intelCopyBuffer( const __DRIdrawablePrivate *dPriv ) intel = (intelContextPtr) dPriv->driContextPriv->driverPrivate; intelFlush( &intel->ctx ); + + LOCK_HARDWARE( intel ); + intelWaitForFrameCompletion( intel ); + UNLOCK_HARDWARE( intel ); + driWaitForVBlank( dPriv, &intel->vbl_seq, intel->vblank_flags, & missed_target ); + LOCK_HARDWARE( intel ); { const intelScreenPrivate *intelScreen = intel->intelScreen; @@ -412,6 +453,15 @@ void intelCopyBuffer( const __DRIdrawablePrivate *dPriv ) } intelFlushBatchLocked( intel, GL_TRUE, GL_TRUE, GL_TRUE ); UNLOCK_HARDWARE( intel ); + + intel->swap_count++; + (*dri_interface->getUST)(&ust); + if (missed_target) { + intel->swap_missed_count++; + intel->swap_missed_ust = ust - intel->swap_ust; + } + + intel->swap_ust = ust; } -- cgit v1.2.3