aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i915/intel_batchbuffer.c
diff options
context:
space:
mode:
authorDave Airlie <airliedfreedesktop.org>2006-02-06 00:09:58 +0000
committerDave Airlie <airliedfreedesktop.org>2006-02-06 00:09:58 +0000
commit4cd0e24f86a5e3fa67774be546f922ca241cb0ea (patch)
treef1136bdc585fae8b4510d5383835a4ea5d1be079 /src/mesa/drivers/dri/i915/intel_batchbuffer.c
parent640ef7f8908a3c25390125f5727d154ca66c9505 (diff)
add vblank support to i915 driver
Diffstat (limited to 'src/mesa/drivers/dri/i915/intel_batchbuffer.c')
-rw-r--r--src/mesa/drivers/dri/i915/intel_batchbuffer.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i915/intel_batchbuffer.c b/src/mesa/drivers/dri/i915/intel_batchbuffer.c
index 323d0b22122..508900de308 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;
}