summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Jerez <currojerez@riseup.net>2010-09-14 21:29:44 +0200
committerFrancisco Jerez <currojerez@riseup.net>2010-09-16 19:44:22 +0200
commitbfc7518ab993b006dffaad5f605137e94ff9d7bc (patch)
treeaf242c667b75c7cf3b31e7fef3a8f124095131c4
parent39658f32eaf1acc9603a9a5a2242fba8fd49e08f (diff)
dri/nouveau: Don't request a fake front unnecessarily.
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_context.c37
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_fbo.c1
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_fbo.h1
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_screen.c2
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_state.c8
5 files changed, 32 insertions, 17 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c
index c7e5789a83..244733e133 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c
@@ -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);
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
index a02a052c6d..f0caf4c629 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
@@ -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;
}
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fbo.h b/src/mesa/drivers/dri/nouveau/nouveau_fbo.h
index 5ae984bbff..0fe6c08be5 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_fbo.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.h
@@ -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))
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
index 78987f633c..4330c8d947 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
@@ -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;
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c
index a57df2d9dc..691e51e738 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_state.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c
@@ -113,14 +113,9 @@ nouveau_depth_range(GLcontext *ctx, GLclampd nearval, GLclampd farval)
}
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;