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
00038 #include "sp_context.h"
00039 #include "sp_setup.h"
00040 #include "sp_state.h"
00041 #include "sp_prim_setup.h"
00042 #include "draw/draw_pipe.h"
00043 #include "draw/draw_vertex.h"
00044 #include "util/u_memory.h"
00045
00050 struct setup_stage {
00051 struct draw_stage stage;
00053 struct setup_context *setup;
00054 };
00055
00056
00057
00061 static INLINE struct setup_stage *setup_stage( struct draw_stage *stage )
00062 {
00063 return (struct setup_stage *)stage;
00064 }
00065
00066
00067 typedef const float (*cptrf4)[4];
00068
00069 static void
00070 do_tri(struct draw_stage *stage, struct prim_header *prim)
00071 {
00072 struct setup_stage *setup = setup_stage( stage );
00073
00074 setup_tri( setup->setup,
00075 (cptrf4)prim->v[0]->data,
00076 (cptrf4)prim->v[1]->data,
00077 (cptrf4)prim->v[2]->data );
00078 }
00079
00080 static void
00081 do_line(struct draw_stage *stage, struct prim_header *prim)
00082 {
00083 struct setup_stage *setup = setup_stage( stage );
00084
00085 setup_line( setup->setup,
00086 (cptrf4)prim->v[0]->data,
00087 (cptrf4)prim->v[1]->data );
00088 }
00089
00090 static void
00091 do_point(struct draw_stage *stage, struct prim_header *prim)
00092 {
00093 struct setup_stage *setup = setup_stage( stage );
00094
00095 setup_point( setup->setup,
00096 (cptrf4)prim->v[0]->data );
00097 }
00098
00099
00100
00101
00102 static void setup_begin( struct draw_stage *stage )
00103 {
00104 struct setup_stage *setup = setup_stage(stage);
00105
00106 setup_prepare( setup->setup );
00107
00108 stage->point = do_point;
00109 stage->line = do_line;
00110 stage->tri = do_tri;
00111 }
00112
00113
00114 static void setup_first_point( struct draw_stage *stage,
00115 struct prim_header *header )
00116 {
00117 setup_begin(stage);
00118 stage->point( stage, header );
00119 }
00120
00121 static void setup_first_line( struct draw_stage *stage,
00122 struct prim_header *header )
00123 {
00124 setup_begin(stage);
00125 stage->line( stage, header );
00126 }
00127
00128
00129 static void setup_first_tri( struct draw_stage *stage,
00130 struct prim_header *header )
00131 {
00132 setup_begin(stage);
00133 stage->tri( stage, header );
00134 }
00135
00136
00137
00138 static void setup_flush( struct draw_stage *stage,
00139 unsigned flags )
00140 {
00141 stage->point = setup_first_point;
00142 stage->line = setup_first_line;
00143 stage->tri = setup_first_tri;
00144 }
00145
00146
00147 static void reset_stipple_counter( struct draw_stage *stage )
00148 {
00149 }
00150
00151
00152 static void render_destroy( struct draw_stage *stage )
00153 {
00154 struct setup_stage *ssetup = setup_stage(stage);
00155 setup_destroy_context(ssetup->setup);
00156 FREE( stage );
00157 }
00158
00159
00163 struct draw_stage *sp_draw_render_stage( struct softpipe_context *softpipe )
00164 {
00165 struct setup_stage *sstage = CALLOC_STRUCT(setup_stage);
00166
00167 sstage->setup = setup_create_context(softpipe);
00168 sstage->stage.draw = softpipe->draw;
00169 sstage->stage.point = setup_first_point;
00170 sstage->stage.line = setup_first_line;
00171 sstage->stage.tri = setup_first_tri;
00172 sstage->stage.flush = setup_flush;
00173 sstage->stage.reset_stipple_counter = reset_stipple_counter;
00174 sstage->stage.destroy = render_destroy;
00175
00176 return (struct draw_stage *)sstage;
00177 }
00178
00179 struct setup_context *
00180 sp_draw_setup_context( struct draw_stage *stage )
00181 {
00182 struct setup_stage *ssetup = setup_stage(stage);
00183 return ssetup->setup;
00184 }
00185
00186 void
00187 sp_draw_flush( struct draw_stage *stage )
00188 {
00189 stage->flush( stage, 0 );
00190 }