summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-05-01 12:25:42 -0600
committerBrian Paul <[email protected]>2009-05-01 12:25:42 -0600
commitb85b315ebbe25efbd118887bdc87a562d4334fcc (patch)
tree1db456c924ce8f0247f56c27c409d5dc9a122127 /src/mesa
parent30b3d800917cc5b41ec508fd38a0ae1da8624a36 (diff)
st: added st_renderbuffer::defined flag
Indicates whether there's defined image contents, or garbage/don't care. This is set when we draw into a renderbuffer and cleared when we resize/ reallocate a renderbuffer or do a buffer swap (back buffer becomes undefined). We use this to determine whether the front color buffer has been drawn to, and whether to display its contents upon glFlush/Finish(), when the new st_swapbuffers() function is used.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_atom_framebuffer.c1
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c2
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.h1
-rw-r--r--src/mesa/state_tracker/st_cb_flush.c11
-rw-r--r--src/mesa/state_tracker/st_context.h3
-rw-r--r--src/mesa/state_tracker/st_framebuffer.c12
6 files changed, 28 insertions, 2 deletions
diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c
index df0f0931eab..f23186c73de 100644
--- a/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -123,6 +123,7 @@ update_framebuffer_state( struct st_context *st )
framebuffer->cbufs[framebuffer->nr_cbufs] = strb->surface;
framebuffer->nr_cbufs++;
}
+ strb->defined = GL_TRUE; /* we'll be drawing something */
}
}
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 0b88d9bf7eb..fe9befaa2c6 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -125,6 +125,8 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
strb->Base.Height = height;
init_renderbuffer_bits(strb, template.format);
+ strb->defined = GL_FALSE; /* undefined contents now */
+
/* Probably need dedicated flags for surface usage too:
*/
surface_usage = (PIPE_BUFFER_USAGE_GPU_READ |
diff --git a/src/mesa/state_tracker/st_cb_fbo.h b/src/mesa/state_tracker/st_cb_fbo.h
index 44fa9fe9a4f..fd77d0a95b0 100644
--- a/src/mesa/state_tracker/st_cb_fbo.h
+++ b/src/mesa/state_tracker/st_cb_fbo.h
@@ -44,6 +44,7 @@ struct st_renderbuffer
struct pipe_texture *texture;
struct pipe_surface *surface; /* temporary view into texture */
enum pipe_format format; /** preferred format, or PIPE_FORMAT_NONE */
+ GLboolean defined; /**< defined contents? */
struct st_texture_object *rtt; /**< GL render to texture's texture */
int rtt_level, rtt_face, rtt_slice;
diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c
index fbaffd154f9..8ceeeabcd37 100644
--- a/src/mesa/state_tracker/st_cb_flush.c
+++ b/src/mesa/state_tracker/st_cb_flush.c
@@ -47,10 +47,19 @@
#include "util/u_blit.h"
+/** Check if we have a front color buffer and if it's been drawn to. */
static INLINE GLboolean
is_front_buffer_dirty(struct st_context *st)
{
- return st->frontbuffer_status == FRONT_STATUS_DIRTY;
+ if (st->frontbuffer_status == FRONT_STATUS_DIRTY) {
+ return GL_TRUE;
+ }
+ else {
+ GLframebuffer *fb = st->ctx->DrawBuffer;
+ struct st_renderbuffer *strb
+ = st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+ return strb && strb->defined;
+ }
}
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 6ffed56d9a0..18adb35e872 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -45,6 +45,7 @@ struct blit_state;
struct bitmap_cache;
+/** XXX we'd like to get rid of these */
#define FRONT_STATUS_UNDEFINED 0
#define FRONT_STATUS_DIRTY 1
#define FRONT_STATUS_COPY_OF_BACK 2
@@ -111,7 +112,7 @@ struct st_context
struct gl_fragment_program *fragment_program;
} cb;
- GLuint frontbuffer_status; /**< one of FRONT_STATUS_ */
+ GLuint frontbuffer_status; /**< one of FRONT_STATUS_ (XXX to be removed) */
char vendor[100];
char renderer[100];
diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c
index 07ccaa6aab5..639373fff7e 100644
--- a/src/mesa/state_tracker/st_framebuffer.c
+++ b/src/mesa/state_tracker/st_framebuffer.c
@@ -331,6 +331,12 @@ st_swapbuffers(struct st_framebuffer *stfb,
st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
*front_left = strb->surface;
}
+ /* mark back buffer contents as undefined */
+ {
+ struct st_renderbuffer *back =
+ st_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
+ back->defined = GL_FALSE;
+ }
}
else {
/* no front buffer, display the back buffer */
@@ -354,6 +360,12 @@ st_swapbuffers(struct st_framebuffer *stfb,
st_renderbuffer(fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer);
*front_right = strb->surface;
}
+ /* mark back buffer contents as undefined */
+ {
+ struct st_renderbuffer *back =
+ st_renderbuffer(fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer);
+ back->defined = GL_FALSE;
+ }
}
else {
/* no front right buffer, display back right buffer (if exists) */