some fixes, fake frontbuffer
authorRoland Scheidegger <sroland@tungstengraphics.com>
Wed, 11 Jul 2007 12:20:39 +0000 (14:20 +0200)
committerRoland Scheidegger <sroland@tungstengraphics.com>
Wed, 11 Jul 2007 12:20:39 +0000 (14:20 +0200)
still doesn't work quite right (resize).
Fake frontbuffer doesn't copy in real frontbuffer.
Don't even think about doing rotation/page flip/triple buffering for now...
More cleanups needed (fake cliprects etc.)

src/mesa/drivers/dri/i915tex/i915_vtbl.c
src/mesa/drivers/dri/i915tex/intel_blit.c
src/mesa/drivers/dri/i915tex/intel_buffers.c
src/mesa/drivers/dri/i915tex/intel_context.c
src/mesa/drivers/dri/i915tex/intel_screen.c
src/mesa/drivers/dri/i915tex/intel_state.c

index f80e8d6327f3dc071a8b04af47334f204d9a5599..51aff68840209a5691bf1820bbf0bfbc0e774d1f 100644 (file)
@@ -463,6 +463,7 @@ i915_state_draw_region(struct intel_context *intel,
     * Set stride/cpp values
     */
    if (color_region) {
+//      fprintf(stderr, "color pitch %d\n", color_region->pitch);
       state->Buffer[I915_DESTREG_CBUFADDR0] = _3DSTATE_BUF_INFO_CMD;
       state->Buffer[I915_DESTREG_CBUFADDR1] =
          (BUF_3D_ID_COLOR_BACK |
@@ -471,6 +472,7 @@ i915_state_draw_region(struct intel_context *intel,
    }
 
    if (depth_region) {
+//      fprintf(stderr, "depth pitch %d\n", depth_region->pitch);
       state->Buffer[I915_DESTREG_DBUFADDR0] = _3DSTATE_BUF_INFO_CMD;
       state->Buffer[I915_DESTREG_DBUFADDR1] =
          (BUF_3D_ID_DEPTH |
index b4fc1691e6b66b98a9d782917a4819769b4bb388..d6651f62be1dcfab0d71e9510b7e2d9e9226be8c 100644 (file)
@@ -82,9 +82,11 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv,
    if (dPriv && dPriv->numClipRects) {
       struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
       const struct intel_region *frontRegion
-        = intel_get_rb_region(&intel_fb->Base, BUFFER_FRONT_LEFT);
+        = intelScreen->front_region;
       const struct intel_region *backRegion
-        = intel_get_rb_region(&intel_fb->Base, BUFFER_BACK_LEFT);
+        = intel->ctx.DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT ?
+          intel_get_rb_region(&intel_fb->Base, BUFFER_FRONT_LEFT) :
+          intel_get_rb_region(&intel_fb->Base, BUFFER_BACK_LEFT);
       const int nbox = dPriv->numClipRects;
       const drm_clip_rect_t *pbox = dPriv->pClipRects;
       const int pitch = frontRegion->pitch;
@@ -100,7 +102,7 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv,
 //      ASSERT(frontRegion->pitch == backRegion->pitch);
       ASSERT(frontRegion->cpp == backRegion->cpp);
 
-      DBG("copy buffer, front pitch %d back pitch %d\n",
+      DBG("front pitch %d back pitch %d\n",
         frontRegion->pitch, backRegion->pitch);
 
       if (cpp == 2) {
@@ -138,6 +140,11 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv,
               continue;
         }
 
+        DBG("box x1 x2 y1 y2 %d %d %d %d\n",
+             box.x1, box.x2, box.y1, box.y2);
+
+        /* XXX should make sure only the minimum area based on
+           old draw buffer and new front clip rects is copied */
         sbox.x1 = box.x1 - dPriv->x;
         sbox.y1 = box.y1 - dPriv->y;
 
@@ -417,9 +424,8 @@ intelClearWithBlit(GLcontext * ctx, GLbitfield mask)
             b = *box;
          }
 
-         if (0)
-            _mesa_printf("clear %d,%d..%d,%d, mask %x\n",
-                         b.x1, b.y1, b.x2, b.y2, mask);
+         DBG("clear %d,%d..%d,%d, mask %x\n",
+                      b.x1, b.y1, b.x2, b.y2, mask);
 
          /* Loop over all renderbuffers */
          for (buf = 0; buf < BUFFER_COUNT && clearMask; buf++) {
index e8dd7cd524048f764efa92c55a0b7de6c8c159e5..fbaa4ee4f31123f288706552ea595412ca12eda2 100644 (file)
@@ -930,7 +930,7 @@ intelSwapBuffers(__DRIdrawablePrivate * dPriv)
         GLboolean missed_target;
         struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
         int64_t ust;
-         
+
         _mesa_notifySwapBuffers(ctx);  /* flush pending rendering comands */
 
          if (screen->current_rotation != 0 ||
@@ -956,6 +956,16 @@ intelSwapBuffers(__DRIdrawablePrivate * dPriv)
 
         intel_fb->swap_ust = ust;
       }
+      if (dPriv && intel->lastStamp != dPriv->lastStamp) {
+        /* XXX this doesn't appear to work quite right.
+            And in any case, it will never get called with single buffered
+            rendering here...
+           And if it's only a window move (not resize), don't need to do anything. */
+        if (INTEL_DEBUG & DEBUG_LOCK)
+           _mesa_printf("doing defered drawable update\n");
+        intelWindowMoved(intel);
+        intel->lastStamp = dPriv->lastStamp;
+      }
    }
    else {
       /* XXX this shouldn't be an error but we can't handle it for now */
@@ -1068,21 +1078,12 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
     * And set up cliprects.
     */
    if (fb->Name == 0) {
+      intelSetPrivbufClipRects(intel);
       /* drawing to window system buffer */
       if (front) {
-#if 0
-         intelSetFrontClipRects(intel);
-#else
-         intelSetPrivbufClipRects(intel);
-#endif
          colorRegion = intel_get_rb_region(fb, BUFFER_FRONT_LEFT);
       }
       else {
-#if 0
-         intelSetBackClipRects(intel);
-#else
-         intelSetPrivbufClipRects(intel);
-#endif
          colorRegion = intel_get_rb_region(fb, BUFFER_BACK_LEFT);
       }
    }
index 028e57e5ab6ab88521adc006daab25cdda4c09d8..76426e3c882eec8f68852691acdee74c68e5c129 100644 (file)
@@ -282,18 +282,22 @@ intelFlush(GLcontext * ctx)
  * Check if we need to rotate/warp the front color buffer to the
  * rotated screen.  We generally need to do this when we get a glFlush
  * or glFinish after drawing to the front color buffer.
+ * If no rotation, just copy the private fake front buffer to the real one.
  */
 static void
-intelCheckFrontRotate(GLcontext * ctx)
+intelCheckFrontUpdate(GLcontext * ctx)
 {
    struct intel_context *intel = intel_context(ctx);
    if (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0] ==
        BUFFER_BIT_FRONT_LEFT) {
       intelScreenPrivate *screen = intel->intelScreen;
+      __DRIdrawablePrivate *dPriv = intel->driDrawable;
       if (screen->current_rotation != 0) {
-         __DRIdrawablePrivate *dPriv = intel->driDrawable;
          intelRotateWindow(intel, dPriv, BUFFER_BIT_FRONT_LEFT);
       }
+      else {
+         intelCopyBuffer(dPriv, NULL);
+      }
    }
 }
 
@@ -305,7 +309,7 @@ static void
 intelglFlush(GLcontext * ctx)
 {
    intelFlush(ctx);
-   intelCheckFrontRotate(ctx);
+   intelCheckFrontUpdate(ctx);
 }
 
 void
@@ -319,7 +323,7 @@ intelFinish(GLcontext * ctx)
       driFenceUnReference(intel->batch->last_fence);
       intel->batch->last_fence = NULL;
    }
-   intelCheckFrontRotate(ctx);
+   intelCheckFrontUpdate(ctx);
 }
 
 
@@ -724,8 +728,10 @@ intelContendedLock(struct intel_context *intel, GLuint flags)
    /* Drawable changed?
     */
    if (dPriv && intel->lastStamp != dPriv->lastStamp) {
-      intelWindowMoved(intel);
-      intel->lastStamp = dPriv->lastStamp;
+      if (INTEL_DEBUG & DEBUG_LOCK)
+         _mesa_printf("drawable change detected but defering update\n");
+/*      intelWindowMoved(intel);
+      intel->lastStamp = dPriv->lastStamp;*/
    }
 }
 
index a5a9c796254b56ea99452021d32b4710834b2490..82b65ea8420021f69c50035e411a14d4f0246d43 100644 (file)
@@ -172,6 +172,7 @@ intel_recreate_static(intelScreenPrivate *intelScreen,
 static void
 intel_recreate_static_regions(intelScreenPrivate *intelScreen)
 {
+/* this is the real front buffer which is only used for blitting to */
    intelScreen->front_region =
       intel_recreate_static(intelScreen,
                            intelScreen->front_region,
@@ -601,6 +602,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
 
       _mesa_initialize_framebuffer(&intel_fb->Base, mesaVis);
 
+#if 0
       /* setup the hardware-based renderbuffers */
       {
          intel_fb->color_rb[0]
@@ -615,7 +617,6 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
                                &intel_fb->color_rb[0]->Base);
       }
 
-#if 0
       if (mesaVis->doubleBufferMode) {
          intel_fb->color_rb[1]
             = intel_create_renderbuffer(rgbFormat,
@@ -672,11 +673,22 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
       }
 
 #else
+      {
+        /* fake frontbuffer */
+        /* XXX allocation should only happen in the unusual case
+            it's actually needed */
+         intel_fb->color_rb[0]
+            = intel_new_renderbuffer_fb(NULL, rgbFormat);
+         _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT,
+                               &intel_fb->color_rb[0]->Base);
+      }
+
       if (mesaVis->doubleBufferMode) {
          intel_fb->color_rb[1]
             = intel_new_renderbuffer_fb(NULL, rgbFormat);
          _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT,
                                &intel_fb->color_rb[1]->Base);
+
         if (screen->third.handle) {
            struct gl_renderbuffer *tmp_rb = NULL;
 
index 271511037e975e75a053aaade24aef2050ddeb57..b2773990e4b15d7240c56e874a1f3abd0b6d1511 100644 (file)
@@ -205,25 +205,17 @@ intelCalcViewport(GLcontext * ctx)
    GLfloat *m = intel->ViewportMatrix.m;
    GLfloat yScale, yBias;
 
-   if (ctx->DrawBuffer->Name) {
-      /* User created FBO */
-      struct intel_renderbuffer *irb
+   struct intel_renderbuffer *irb
          = intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]);
-      if (irb && !irb->RenderToTexture) {
-         /* y=0=top */
-         yScale = -1.0;
-         yBias = irb->Base.Height;
-      }
-      else {
-         /* y=0=bottom */
-         yScale = 1.0;
-         yBias = 0.0;
-      }
+   if (irb && !irb->RenderToTexture) {
+      /* y=0=top */
+      yScale = -1.0;
+      yBias = irb->Base.Height;
    }
    else {
-      /* window buffer, y=0=top */
-      yScale = -1.0;
-      yBias = (intel->driDrawable) ? intel->driDrawable->h : 0.0F;
+      /* y=0=bottom */
+      yScale = 1.0;
+      yBias = 0.0;
    }
 
    m[MAT_SX] = v[MAT_SX];