dri/nouveau: Don't request a fake front unnecessarily.
authorFrancisco Jerez <currojerez@riseup.net>
Tue, 14 Sep 2010 19:29:44 +0000 (21:29 +0200)
committerFrancisco Jerez <currojerez@riseup.net>
Thu, 16 Sep 2010 17:44:22 +0000 (19:44 +0200)
src/mesa/drivers/dri/nouveau/nouveau_context.c
src/mesa/drivers/dri/nouveau/nouveau_fbo.c
src/mesa/drivers/dri/nouveau/nouveau_fbo.h
src/mesa/drivers/dri/nouveau/nouveau_screen.c
src/mesa/drivers/dri/nouveau/nouveau_state.c

index c7e5789a832d79f8332273da66cbd8100e470f3b..244733e133e6ccb564fb4e815890086f941cac15 100644 (file)
@@ -183,6 +183,7 @@ nouveau_update_renderbuffers(__DRIcontext *dri_ctx, __DRIdrawable *draw)
        GLcontext *ctx = dri_ctx->driverPrivate;
        __DRIscreen *screen = dri_ctx->driScreenPriv;
        struct gl_framebuffer *fb = draw->driverPrivate;
+       struct nouveau_framebuffer *nfb = to_nouveau_framebuffer(fb);
        unsigned int attachments[10];
        __DRIbuffer *buffers = NULL;
        int i = 0, count, ret;
@@ -191,7 +192,8 @@ nouveau_update_renderbuffers(__DRIcontext *dri_ctx, __DRIdrawable *draw)
                return;
        draw->lastStamp = *draw->pStamp;
 
-       attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
+       if (nfb->need_front)
+               attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
        if (fb->Visual.doubleBufferMode)
                attachments[i++] = __DRI_BUFFER_BACK_LEFT;
        if (fb->Visual.haveDepthBuffer && fb->Visual.haveStencilBuffer)
@@ -327,6 +329,25 @@ nouveau_fallback(GLcontext *ctx, enum nouveau_fallback mode)
                FIRE_RING(context_chan(ctx));
 }
 
+static void
+validate_framebuffer(__DRIcontext *dri_ctx, __DRIdrawable *draw,
+                    int *stamp)
+{
+       struct gl_framebuffer *fb = draw->driverPrivate;
+       struct nouveau_framebuffer *nfb = to_nouveau_framebuffer(fb);
+       GLboolean need_front =
+               (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT ||
+                fb->_ColorReadBufferIndex == BUFFER_FRONT_LEFT);
+
+       if (nfb->need_front != need_front) {
+               nfb->need_front = need_front;
+               dri2InvalidateDrawable(draw);
+       }
+
+       if (*draw->pStamp != *stamp)
+               update_framebuffer(dri_ctx, draw, stamp);
+}
+
 void
 nouveau_validate_framebuffer(GLcontext *ctx)
 {
@@ -334,15 +355,13 @@ nouveau_validate_framebuffer(GLcontext *ctx)
        __DRIdrawable *dri_draw = dri_ctx->driDrawablePriv;
        __DRIdrawable *dri_read = dri_ctx->driReadablePriv;
 
-       if (ctx->DrawBuffer->Name == 0 &&
-           dri_ctx->dri2.draw_stamp != *dri_draw->pStamp)
-               update_framebuffer(dri_ctx, dri_draw,
-                                  &dri_ctx->dri2.draw_stamp);
+       if (ctx->DrawBuffer->Name == 0)
+               validate_framebuffer(dri_ctx, dri_draw,
+                                    &dri_ctx->dri2.draw_stamp);
 
-       if (ctx->ReadBuffer->Name == 0 && dri_draw != dri_read &&
-           dri_ctx->dri2.read_stamp != *dri_read->pStamp)
-               update_framebuffer(dri_ctx, dri_read,
-                                  &dri_ctx->dri2.read_stamp);
+       if (ctx->ReadBuffer->Name == 0)
+               validate_framebuffer(dri_ctx, dri_read,
+                                    &dri_ctx->dri2.read_stamp);
 
        if (nouveau_next_dirty_state(ctx) >= 0) {
                nouveau_state_emit(ctx);
index a02a052c6d4f8d485799a28ca49226ef34500e4a..f0caf4c629199b9d007a65884adfca3962161964 100644 (file)
@@ -189,6 +189,7 @@ nouveau_framebuffer_dri_new(const GLvisual *visual)
                return NULL;
 
        _mesa_initialize_window_framebuffer(&nfb->base, visual);
+       nfb->need_front = !visual->doubleBufferMode;
 
        return &nfb->base;
 }
index 5ae984bbff426e51288232e6bc02b10006820d32..0fe6c08be552ea689ed8ba01c30bd178966b408d 100644 (file)
@@ -30,6 +30,7 @@
 struct nouveau_framebuffer {
        struct gl_framebuffer base;
        struct nouveau_bo *lma_bo;
+       GLboolean need_front;
 };
 #define to_nouveau_framebuffer(x) ((struct nouveau_framebuffer *)(x))
 
index 78987f633cc8a172f6afe2c47b06a94ede49c43a..4330c8d94736bfc6b1046fd7c50a4da884db8296 100644 (file)
@@ -156,7 +156,7 @@ nouveau_create_buffer(__DRIscreen *dri_screen,
                      const __GLcontextModes *visual,
                      GLboolean is_pixmap)
 {
-       struct gl_renderbuffer  *rb;
+       struct gl_renderbuffer *rb;
        struct gl_framebuffer *fb;
        GLenum color_format;
 
index a57df2d9dcd9adf4117958428d1128478782b07b..691e51e738d2745df44886dbc067360dd1421b40 100644 (file)
@@ -112,15 +112,10 @@ nouveau_depth_range(GLcontext *ctx, GLclampd nearval, GLclampd farval)
        context_dirty(ctx, VIEWPORT);
 }
 
-static void
-nouveau_draw_buffer(GLcontext *ctx, GLenum buffer)
-{
-       context_dirty(ctx, FRAMEBUFFER);
-}
-
 static void
 nouveau_draw_buffers(GLcontext *ctx, GLsizei n, const GLenum *buffers)
 {
+       nouveau_validate_framebuffer(ctx);
        context_dirty(ctx, FRAMEBUFFER);
 }
 
@@ -519,7 +514,6 @@ nouveau_state_init(GLcontext *ctx)
        ctx->Driver.DepthFunc = nouveau_depth_func;
        ctx->Driver.DepthMask = nouveau_depth_mask;
        ctx->Driver.DepthRange = nouveau_depth_range;
-       ctx->Driver.DrawBuffer = nouveau_draw_buffer;
        ctx->Driver.DrawBuffers = nouveau_draw_buffers;
        ctx->Driver.Enable = nouveau_enable;
        ctx->Driver.Fogfv = nouveau_fog;