bugfixes (wrt fb updates), cleanups
authorRoland Scheidegger <sroland@tungstengraphics.com>
Fri, 13 Jul 2007 18:47:17 +0000 (20:47 +0200)
committerRoland Scheidegger <sroland@tungstengraphics.com>
Fri, 13 Jul 2007 18:47:17 +0000 (20:47 +0200)
move drawable validation back to where it was now that the driDrawable
information isn't used directly anymore.
Fix bogus fb updates (the context we get for SwapBuffer processing
may not have the drawable being processed attached!)
glthreads behaves a bit better but still not correct.

src/mesa/drivers/dri/i915tex/intel_blit.c
src/mesa/drivers/dri/i915tex/intel_context.c
src/mesa/drivers/dri/i915tex/intel_context.h
src/mesa/drivers/dri/i915tex/intel_fbo.c
src/mesa/drivers/dri/i915tex/intel_fbo.h
src/mesa/drivers/dri/i915tex/intel_screen.c

index 2a0a63931522d1699ff5a4b76442f8ec84742958..db72f59a2c7bb0d35f7e725f610da3eaeffa90c9 100644 (file)
@@ -79,13 +79,6 @@ intelCopyBuffer(__DRIdrawablePrivate * dPriv,
     */
    LOCK_HARDWARE(intel);
 
-      if (intel->revalidateDrawable) {
-        __DRIscreenPrivate *sPriv = intel->driScreen;
-        if (dPriv) {
-           DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
-        }
-      }
-
    if (dPriv && dPriv->numClipRects) {
       struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
       const struct intel_region *frontRegion
@@ -190,9 +183,14 @@ intelCopyBuffer(__DRIdrawablePrivate * dPriv,
 
    UNLOCK_HARDWARE(intel);
 
-   if (intel->revalidateDrawable) {
-      intel->revalidateDrawable = GL_FALSE;
-      intelWindowMoved(intel);
+   /* XXX this is bogus. The context here may not even be bound to this drawable! */
+   if (intel->lastStamp != dPriv->lastStamp) {
+      GET_CURRENT_CONTEXT(currctx);
+      struct intel_context *intelcurrent = intel_context(currctx);
+      if (intelcurrent == intel && intelcurrent->driDrawable == dPriv) {
+         intelWindowMoved(intel);
+         intel->lastStamp = dPriv->lastStamp;
+      }
    }
 
 }
index 451c7fd1ba5d88a7b4c286fe19c719fca11b0af6..41eaafece2369a9f8f629e67ed58e8f2b38b2fa7 100644 (file)
@@ -572,7 +572,6 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
                  __DRIdrawablePrivate * driDrawPriv,
                  __DRIdrawablePrivate * driReadPriv)
 {
-   GLuint updatebufsize = GL_FALSE;
 
 #if 0
    if (driDrawPriv) {
@@ -620,22 +619,18 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
          }
       }
 
-      /* only update GLframebuffer size to match window
-         if here for the first time */
-      if (intel->ctx.FirstTimeCurrent) {
-        updatebufsize = GL_TRUE;
-        driUpdateFramebufferSize(&intel->ctx, driDrawPriv);
+      /* update GLframebuffer size to match window if needed */
+      driUpdateFramebufferSize(&intel->ctx, driDrawPriv);
 
-        if (driReadPriv != driDrawPriv) {
-           driUpdateFramebufferSize(&intel->ctx, driReadPriv);
-        }
+      if (driReadPriv != driDrawPriv) {
+         driUpdateFramebufferSize(&intel->ctx, driReadPriv);
       }
 
       _mesa_make_current(&intel->ctx, &intel_fb->Base, readFb);
 
       /* The drawbuffer won't always be updated by _mesa_make_current: 
        */
-      if (updatebufsize && intel->ctx.DrawBuffer == &intel_fb->Base) {
+      if (intel->ctx.DrawBuffer == &intel_fb->Base) {
 
         if (intel->driDrawable != driDrawPriv) {
            intel_fb->vblank_flags = (intel->intelScreen->irq_active != 0)
@@ -646,9 +641,11 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
                                  &intel_fb->vbl_seq);
            intel->driDrawable = driDrawPriv;
            intelWindowMoved(intel);
+           intel->lastStamp = driDrawPriv->lastStamp;
+        }
+        else if (intel->lastStamp != driDrawPriv->lastStamp) {
+           intel_draw_buffer(&intel->ctx, &intel_fb->Base);
         }
-
-        intel_draw_buffer(&intel->ctx, &intel_fb->Base);
       }
    }
    else {
@@ -677,8 +674,7 @@ intelContendedLock(struct intel_context *intel, GLuint flags)
     * checking must be done *after* this call:
     */
    if (dPriv)
-      intel->revalidateDrawable = GL_TRUE;
-//      DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
+      DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
 
    if (sarea->width != intelScreen->width ||
        sarea->height != intelScreen->height ||
index f85b3a6362715bde79e6403a9eac37b5fac80628..b5defdc47e4b469216c811bcac0630bf37179d98 100644 (file)
@@ -272,7 +272,6 @@ struct intel_context
    drmI830Sarea *sarea;
 
    GLuint lastStamp;
-   GLuint revalidateDrawable;
 
    /**
     * Configuration cache
index aeb909cce17f5ac364685fe97e88677d4aa9d7ac..afee07c6898e7dce87642ba26661fb235706078d 100644 (file)
@@ -299,7 +299,7 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
 }
 
 
-
+#if 0
 /**
  * Called for each hardware renderbuffer when a _window_ is resized.
  * Just update fields.
@@ -316,6 +316,7 @@ intel_alloc_window_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
 
    return GL_TRUE;
 }
+#endif
 
 static void
 intel_resize_buffers(GLcontext *ctx, struct gl_framebuffer *fb,
@@ -352,7 +353,7 @@ intel_nop_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
 }
 
 
-
+#if 0
 /**
  * Create a new intel_renderbuffer which corresponds to an on-screen window,
  * not a user-created renderbuffer.
@@ -452,15 +453,16 @@ intel_create_renderbuffer(GLenum intFormat, GLsizei width, GLsizei height,
 
    return irb;
 }
+#endif
 
-struct gl_renderbuffer *
-intel_new_renderbuffer_fb(GLcontext * ctx, GLuint intFormat)
+struct intel_renderbuffer *
+intel_new_renderbuffer_fb(GLuint intFormat)
 {
    struct intel_renderbuffer *irb;
 
    irb = CALLOC_STRUCT(intel_renderbuffer);
    if (!irb) {
-      _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer");
+      _mesa_error(NULL, GL_OUT_OF_MEMORY, "creating renderbuffer");
       return NULL;
    }
 
@@ -474,7 +476,7 @@ intel_new_renderbuffer_fb(GLcontext * ctx, GLuint intFormat)
    irb->Base.GetPointer = intel_get_pointer;
    /* span routines set in alloc_storage function */
 
-   return &irb->Base;
+   return irb;
 }
 
 /**
index 963f5e706f4b39948fb5831e32e451fba9148a5f..762aac594e8acdbb7f7490459e42c7273f0c6801 100644 (file)
@@ -84,7 +84,7 @@ struct intel_renderbuffer
    GLuint vbl_pending;   /**< vblank sequence number of pending flip */
 };
 
-
+#if 0
 extern struct intel_renderbuffer *intel_create_renderbuffer(GLenum intFormat,
                                                             GLsizei width,
                                                             GLsizei height,
@@ -92,7 +92,9 @@ extern struct intel_renderbuffer *intel_create_renderbuffer(GLenum intFormat,
                                                             int pitch,
                                                             int cpp,
                                                             void *map);
+#endif
 
+extern struct intel_renderbuffer *intel_new_renderbuffer_fb(GLuint intFormat);
 
 extern void intel_fbo_init(struct intel_context *intel);
 
index 08057a6600623095626fe694c92e60d775af144a..dcc29923834044b668dc72ffc3cece509460a4c9 100644 (file)
@@ -680,14 +680,14 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
         /* XXX allocation should only happen in the unusual case
             it's actually needed */
          intel_fb->color_rb[0]
-            = intel_new_renderbuffer_fb(NULL, rgbFormat);
+            = intel_new_renderbuffer_fb(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);
+            = intel_new_renderbuffer_fb(rgbFormat);
          _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT,
                                &intel_fb->color_rb[1]->Base);
 
@@ -695,14 +695,14 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
            struct gl_renderbuffer *tmp_rb = NULL;
 
            intel_fb->color_rb[2]
-              = intel_new_renderbuffer_fb(NULL, rgbFormat);
+              = intel_new_renderbuffer_fb(rgbFormat);
            _mesa_reference_renderbuffer(&tmp_rb, &intel_fb->color_rb[2]->Base);
         }
       }
       if (mesaVis->depthBits == 24 && mesaVis->stencilBits == 8) {
          /* combined depth/stencil buffer */
          struct intel_renderbuffer *depthStencilRb
-            = intel_new_renderbuffer_fb(NULL, GL_DEPTH24_STENCIL8_EXT);
+            = intel_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT);
          /* note: bind RB to two attachment points */
          _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH,
                                &depthStencilRb->Base);
@@ -712,7 +712,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
       else if (mesaVis->depthBits == 16) {
          /* just 16-bit depth buffer, no hw stencil */
          struct intel_renderbuffer *depthRb
-            = intel_new_renderbuffer_fb(NULL, GL_DEPTH_COMPONENT16);
+            = intel_new_renderbuffer_fb(GL_DEPTH_COMPONENT16);
          _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, &depthRb->Base);
       }
 
@@ -987,18 +987,19 @@ struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen)
    * context at screen creation. For now just use the current context.
    */
 
-/*  GET_CURRENT_CONTEXT(ctx);
+  GET_CURRENT_CONTEXT(ctx);
   if (ctx == NULL) {
-     _mesa_problem(NULL, "No current context in intelScreenContext\n");
-     return NULL;
+/*     _mesa_problem(NULL, "No current context in intelScreenContext\n");
+     return NULL; */
+     /* need a context for the first time makecurrent is called (for hw lock
+        when allocating priv buffers) */
+     if (intelScreen->dummyctxptr == NULL) {
+        _mesa_problem(NULL, "No current context in intelScreenContext\n");
+        return NULL;
+     }
+     return intelScreen->dummyctxptr;
   }
   return intel_context(ctx);
-*/
-  if (intelScreen->dummyctxptr == NULL) {
-     _mesa_problem(NULL, "No current context in intelScreenContext\n");
-     return NULL;
-  }
-  return intelScreen->dummyctxptr;
 
 }