diff options
author | Brian Paul <[email protected]> | 2008-04-09 16:59:14 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2008-04-09 16:59:14 -0600 |
commit | 54d7c399a888283711bdc00f93cb54a3ce0b30eb (patch) | |
tree | 7177409c22706af004f34868b7310a39eae70ef3 /src/mesa/state_tracker/st_cb_flush.c | |
parent | 4ecbd5a70fba3e7d5f8b56ede34867ea5964afc6 (diff) |
gallium: more flush/finish changes
New, separate is_front_buffer_dirty() function.
Diffstat (limited to 'src/mesa/state_tracker/st_cb_flush.c')
-rw-r--r-- | src/mesa/state_tracker/st_cb_flush.c | 70 |
1 files changed, 40 insertions, 30 deletions
diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c index 6bda877bb07..1bcd1b4cd98 100644 --- a/src/mesa/state_tracker/st_cb_flush.c +++ b/src/mesa/state_tracker/st_cb_flush.c @@ -44,14 +44,13 @@ #include "pipe/p_winsys.h" -static void -flush_front_buffer(struct st_context *st, uint pipeFlushFlags, - struct pipe_fence_handle **fence) +static GLboolean +is_front_buffer_dirty(struct st_context *st) { GLframebuffer *fb = st->ctx->DrawBuffer; if (!fb) - return; + return GL_FALSE; /* XXX: temporary hack. This flag should only be set if we do any * rendering to the front buffer. @@ -68,26 +67,26 @@ flush_front_buffer(struct st_context *st, uint pipeFlushFlags, st->flags.frontbuffer_dirty = (fb->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT); - if (st->flags.frontbuffer_dirty) { - struct st_renderbuffer *strb - = st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer); - struct pipe_surface *front_surf = strb->surface; - - /* If we aren't rendering to the frontbuffer, this is a noop. - * This should be uncontroversial for glFlush, though people may - * feel more strongly about glFinish. - * - * Additionally, need to make sure that the frontbuffer_dirty - * flag really gets set on frontbuffer rendering. - */ - st->pipe->flush( st->pipe, pipeFlushFlags, fence ); - - /* Hook for copying "fake" frontbuffer if necessary: - */ - st->pipe->winsys->flush_frontbuffer( st->pipe->winsys, front_surf, - st->pipe->priv ); - st->flags.frontbuffer_dirty = 0; - } + return st->flags.frontbuffer_dirty; +} + + +/** + * Tell the winsys to display the front color buffer on-screen. + */ +static void +display_front_buffer(struct st_context *st) +{ + GLframebuffer *fb = st->ctx->DrawBuffer; + struct st_renderbuffer *strb + = st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer); + struct pipe_surface *front_surf = strb->surface; + + /* Hook for copying "fake" frontbuffer if necessary: + */ + st->pipe->winsys->flush_frontbuffer( st->pipe->winsys, front_surf, + st->pipe->priv ); + st->flags.frontbuffer_dirty = 0; } @@ -102,6 +101,9 @@ void st_flush( struct st_context *st, uint pipeFlushFlags, } +/** + * Flush, and wait for completion. + */ void st_finish( struct st_context *st ) { struct pipe_fence_handle *fence = NULL; @@ -119,11 +121,15 @@ void st_finish( struct st_context *st ) */ static void st_glFlush(GLcontext *ctx) { - st_flush_bitmap_cache(ctx->st); - - FLUSH_VERTICES(ctx, 0); + struct st_context *st = ctx->st; - flush_front_buffer(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + if (is_front_buffer_dirty(st)) { + st_finish(st); + display_front_buffer(st); + } + else { + st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL); + } } @@ -132,9 +138,13 @@ static void st_glFlush(GLcontext *ctx) */ static void st_glFinish(GLcontext *ctx) { - st_finish( ctx->st ); + struct st_context *st = ctx->st; - flush_front_buffer(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + st_finish(st); + + if (is_front_buffer_dirty(st)) { + display_front_buffer(st); + } } |