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;
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)
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)
{
__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);
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);
}
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;