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 #include "pipe/p_defines.h"
00030 #include "pipe/p_winsys.h"
00031 #include "util/u_memory.h"
00032 #include "pipe/p_context.h"
00033
00034 #include "fo_context.h"
00035 #include "fo_winsys.h"
00036
00037
00038
00039 static void failover_destroy( struct pipe_context *pipe )
00040 {
00041 struct failover_context *failover = failover_context( pipe );
00042
00043 free( failover );
00044 }
00045
00046
00047
00048 static boolean failover_draw_elements( struct pipe_context *pipe,
00049 struct pipe_buffer *indexBuffer,
00050 unsigned indexSize,
00051 unsigned prim, unsigned start, unsigned count)
00052 {
00053 struct failover_context *failover = failover_context( pipe );
00054
00055
00056
00057
00058 if (failover->dirty) {
00059 failover->mode = FO_HW;
00060 }
00061
00062
00063
00064 if (failover->mode == FO_HW) {
00065 if (!failover->hw->draw_elements( failover->hw,
00066 indexBuffer,
00067 indexSize,
00068 prim,
00069 start,
00070 count )) {
00071
00072 failover->hw->flush( failover->hw, ~0, NULL );
00073 failover->mode = FO_SW;
00074 }
00075 }
00076
00077
00078
00079 if (failover->mode == FO_SW) {
00080
00081 if (failover->dirty)
00082 failover_state_emit( failover );
00083
00084 failover->sw->draw_elements( failover->sw,
00085 indexBuffer,
00086 indexSize,
00087 prim,
00088 start,
00089 count );
00090
00091
00092
00093
00094
00095 failover->sw->flush( failover->sw, ~0, NULL );
00096 }
00097
00098 return TRUE;
00099 }
00100
00101
00102 static boolean failover_draw_arrays( struct pipe_context *pipe,
00103 unsigned prim, unsigned start, unsigned count)
00104 {
00105 return failover_draw_elements(pipe, NULL, 0, prim, start, count);
00106 }
00107
00108
00109
00110 struct pipe_context *failover_create( struct pipe_context *hw,
00111 struct pipe_context *sw )
00112 {
00113 struct failover_context *failover = CALLOC_STRUCT(failover_context);
00114 if (failover == NULL)
00115 return NULL;
00116
00117 failover->hw = hw;
00118 failover->sw = sw;
00119 failover->pipe.winsys = hw->winsys;
00120 failover->pipe.screen = hw->screen;
00121 failover->pipe.destroy = failover_destroy;
00122 #if 0
00123 failover->pipe.is_format_supported = hw->is_format_supported;
00124 failover->pipe.get_name = hw->get_name;
00125 failover->pipe.get_vendor = hw->get_vendor;
00126 failover->pipe.get_param = hw->get_param;
00127 failover->pipe.get_paramf = hw->get_paramf;
00128 #endif
00129
00130 failover->pipe.draw_arrays = failover_draw_arrays;
00131 failover->pipe.draw_elements = failover_draw_elements;
00132 failover->pipe.clear = hw->clear;
00133
00134
00135
00136
00137
00138 failover->pipe.begin_query = hw->begin_query;
00139 failover->pipe.end_query = hw->end_query;
00140
00141 failover_init_state_functions( failover );
00142
00143 failover->pipe.surface_copy = hw->surface_copy;
00144 failover->pipe.surface_fill = hw->surface_fill;
00145
00146 #if 0
00147 failover->pipe.texture_create = hw->texture_create;
00148 failover->pipe.texture_release = hw->texture_release;
00149 failover->pipe.get_tex_surface = hw->get_tex_surface;
00150 failover->pipe.texture_update = hw->texture_update;
00151 #endif
00152
00153 failover->pipe.flush = hw->flush;
00154
00155 failover->dirty = 0;
00156
00157 return &failover->pipe;
00158 }
00159