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.
This commit is contained in:
@@ -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 */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 |
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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) */
|
||||
|
||||
Reference in New Issue
Block a user