00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
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
00069
00070 st->pipe->winsys->flush_frontbuffer( st->pipe->winsys, front_surf,
00071 st->pipe->priv );
00072
00073
00074
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
00085
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 }