st_cb_flush.c

Go to the documentation of this file.
00001 /**************************************************************************
00002  * 
00003  * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
00004  * All Rights Reserved.
00005  * 
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  * 
00014  * The above copyright notice and this permission notice (including the
00015  * next paragraph) shall be included in all copies or substantial portions
00016  * of the Software.
00017  * 
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
00022  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025  * 
00026  **************************************************************************/
00027 
00028  /*
00029   * Authors:
00030   *   Keith Whitwell <keith@tungstengraphics.com>
00031   *   Brian Paul
00032   */
00033 
00034 #include "main/glheader.h"
00035 #include "main/macros.h"
00036 #include "main/context.h"
00037 #include "st_context.h"
00038 #include "st_cb_bitmap.h"
00039 #include "st_cb_flush.h"
00040 #include "st_cb_clear.h"
00041 #include "st_cb_fbo.h"
00042 #include "st_public.h"
00043 #include "pipe/p_context.h"
00044 #include "pipe/p_defines.h"
00045 #include "pipe/p_winsys.h"
00046 #include "util/u_gen_mipmap.h"
00047 #include "util/u_blit.h"
00048 
00049 
00050 static INLINE GLboolean
00051 is_front_buffer_dirty(struct st_context *st)
00052 {
00053    return st->frontbuffer_status == FRONT_STATUS_DIRTY;
00054 }
00055 
00056 
00060 static void
00061 display_front_buffer(struct st_context *st)
00062 {
00063    GLframebuffer *fb = st->ctx->DrawBuffer;
00064    struct st_renderbuffer *strb
00065       = st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
00066    struct pipe_surface *front_surf = strb->surface;
00067 
00068    /* Hook for copying "fake" frontbuffer if necessary:
00069     */
00070    st->pipe->winsys->flush_frontbuffer( st->pipe->winsys, front_surf,
00071                                         st->pipe->priv );
00072 
00073    /*
00074    st->frontbuffer_status = FRONT_STATUS_UNDEFINED;
00075    */
00076 }
00077 
00078 
00079 void st_flush( struct st_context *st, uint pipeFlushFlags,
00080                struct pipe_fence_handle **fence )
00081 {
00082    FLUSH_VERTICES(st->ctx, 0);
00083 
00084    /* Release any vertex buffers that might potentially be accessed in
00085     * successive frames:
00086     */
00087    st_flush_bitmap(st);
00088    st_flush_clear(st);
00089    util_blit_flush(st->blit);
00090    util_gen_mipmap_flush(st->gen_mipmap);
00091 
00092    st->pipe->flush( st->pipe, pipeFlushFlags, fence );
00093 }
00094 
00095 
00099 void st_finish( struct st_context *st )
00100 {
00101    struct pipe_fence_handle *fence = NULL;
00102 
00103    st_flush(st, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, &fence);
00104 
00105    if(fence) {
00106       st->pipe->winsys->fence_finish(st->pipe->winsys, fence, 0);
00107       st->pipe->winsys->fence_reference(st->pipe->winsys, &fence, NULL);
00108    }
00109 }
00110 
00111 
00112 
00116 static void st_glFlush(GLcontext *ctx)
00117 {
00118    struct st_context *st = ctx->st;
00119 
00120    if (is_front_buffer_dirty(st)) {
00121       st_finish(st);
00122       display_front_buffer(st);
00123    }
00124    else {
00125       st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL);
00126    }
00127 }
00128 
00129 
00133 static void st_glFinish(GLcontext *ctx)
00134 {
00135    struct st_context *st = ctx->st;
00136 
00137    st_finish(st);
00138 
00139    if (is_front_buffer_dirty(st)) {
00140       display_front_buffer(st);
00141    }
00142 }
00143 
00144 
00145 void st_init_flush_functions(struct dd_function_table *functions)
00146 {
00147    functions->Flush = st_glFlush;
00148    functions->Finish = st_glFinish;
00149 }

Generated on Tue Sep 29 06:25:18 2009 for Gallium3D by  doxygen 1.5.4