i915tex: Only wait for vblank when really necessary.
authorMichel Dänzer <michel@tungstengraphics.com>
Tue, 10 Jul 2007 08:54:51 +0000 (10:54 +0200)
committerMichel Dänzer <michel@tungstengraphics.com>
Tue, 10 Jul 2007 09:14:25 +0000 (11:14 +0200)
This avoids superfluous waits for vblank timing out under some circumstances.

src/mesa/drivers/dri/i915tex/intel_buffers.c
src/mesa/drivers/dri/i915tex/intel_context.c

index 62ff54b00751c3241967742edd1a6375205bba99..15d02f8e2cf0771619309c5c6ab4b68ea9d4524c 100644 (file)
@@ -316,7 +316,8 @@ intelWindowMoved(struct intel_context *intel)
         flags = intel_fb->vblank_flags & ~VBLANK_FLAG_SECONDARY;
       }
 
-      if (flags != intel_fb->vblank_flags) {
+      if (flags != intel_fb->vblank_flags && intel_fb->vblank_flags &&
+         !(intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ)) {
         drmVBlank vbl;
         int i;
 
@@ -327,7 +328,9 @@ intelWindowMoved(struct intel_context *intel)
         }
 
         for (i = 0; i < intel_fb->pf_num_pages; i++) {
-           if (!intel_fb->color_rb[i])
+           if (!intel_fb->color_rb[i] ||
+               (intel_fb->vbl_waited - intel_fb->color_rb[i]->vbl_pending) <=
+               (1<<23))
               continue;
 
            vbl.request.sequence = intel_fb->color_rb[i]->vbl_pending;
@@ -828,7 +831,8 @@ intelScheduleSwap(const __DRIdrawablePrivate * dPriv, GLboolean *missed_target)
    drm_i915_vblank_swap_t swap;
    GLboolean ret;
 
-   if ((intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ) ||
+   if (!intel_fb->vblank_flags ||
+       (intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ) ||
        intelScreen->current_rotation != 0 ||
        intelScreen->drmMinor < (intel_fb->pf_active ? 9 : 6))
       return GL_FALSE;
index c927dca8e5aab4f7f40c808044ed10fc2c074814..5334efd63d4d360ff3611a792edaa0695414ebbd 100644 (file)
@@ -619,12 +619,23 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
       if (intel->ctx.DrawBuffer == &intel_fb->Base) {
 
         if (intel->driDrawable != driDrawPriv) {
-           intel_fb->vblank_flags = (intel->intelScreen->irq_active != 0)
-              ? driGetDefaultVBlankFlags(&intel->optionCache)
-              : VBLANK_FLAG_NO_IRQ;
-           (*dri_interface->getUST) (&intel_fb->swap_ust);
-           driDrawableInitVBlank(driDrawPriv, intel_fb->vblank_flags,
-                                 &intel_fb->vbl_seq);
+           if (driDrawPriv->pdraw->swap_interval == (unsigned)-1) {
+              int i;
+
+              intel_fb->vblank_flags = (intel->intelScreen->irq_active != 0)
+                 ? driGetDefaultVBlankFlags(&intel->optionCache)
+                : VBLANK_FLAG_NO_IRQ;
+
+              (*dri_interface->getUST) (&intel_fb->swap_ust);
+              driDrawableInitVBlank(driDrawPriv, intel_fb->vblank_flags,
+                                    &intel_fb->vbl_seq);
+              intel_fb->vbl_waited = intel_fb->vbl_seq;
+
+              for (i = 0; i < (intel->intelScreen->third.handle ? 3 : 2); i++) {
+                 if (intel_fb->color_rb[i])
+                    intel_fb->color_rb[i]->vbl_pending = intel_fb->vbl_seq;
+              }
+           }
            intel->driDrawable = driDrawPriv;
            intelWindowMoved(intel);
         }
@@ -741,7 +752,9 @@ void LOCK_HARDWARE( struct intel_context *intel )
                                    BUFFER_BACK_LEFT);
     }
 
-    if (intel_rb && (intel_fb->vbl_waited - intel_rb->vbl_pending) > (1<<23)) {
+    if (intel_rb && intel_fb->vblank_flags &&
+       !(intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ) &&
+       (intel_fb->vbl_waited - intel_rb->vbl_pending) > (1<<23)) {
        drmVBlank vbl;
 
        vbl.request.type = DRM_VBLANK_ABSOLUTE;