Go to the source code of this file.
Data Structures | |
struct | flat_stage |
subclass of draw_stage More... | |
Defines | |
#define | COPY_3FV(DST, SRC) |
Functions | |
static struct flat_stage * | flat_stage (struct draw_stage *stage) |
static void | copy_colors (struct draw_stage *stage, struct vertex_header *dst, const struct vertex_header *src) |
Copy all the color attributes from 'src' vertex to 'dst' vertex. | |
static void | copy_colors2 (struct draw_stage *stage, struct vertex_header *dst0, struct vertex_header *dst1, const struct vertex_header *src) |
Copy all the color attributes from src vertex to dst0 & dst1 vertices. | |
static void | flatshade_tri_0 (struct draw_stage *stage, struct prim_header *header) |
Flatshade tri. | |
static void | flatshade_tri_2 (struct draw_stage *stage, struct prim_header *header) |
static void | flatshade_line_0 (struct draw_stage *stage, struct prim_header *header) |
Flatshade line. | |
static void | flatshade_line_1 (struct draw_stage *stage, struct prim_header *header) |
static void | flatshade_init_state (struct draw_stage *stage) |
static void | flatshade_first_tri (struct draw_stage *stage, struct prim_header *header) |
static void | flatshade_first_line (struct draw_stage *stage, struct prim_header *header) |
static void | flatshade_flush (struct draw_stage *stage, unsigned flags) |
static void | flatshade_reset_stipple_counter (struct draw_stage *stage) |
static void | flatshade_destroy (struct draw_stage *stage) |
struct draw_stage * | draw_flatshade_stage (struct draw_context *draw) |
Create flatshading drawing stage. |
#define COPY_3FV | ( | DST, | |||
SRC | ) |
Value:
do { \ (DST)[0] = (SRC)[0]; \ (DST)[1] = (SRC)[1]; \ (DST)[2] = (SRC)[2]; \ } while (0)
Definition at line 51 of file draw_pipe_flatshade.c.
static void copy_colors | ( | struct draw_stage * | stage, | |
struct vertex_header * | dst, | |||
const struct vertex_header * | src | |||
) | [static] |
Copy all the color attributes from 'src' vertex to 'dst' vertex.
Definition at line 67 of file draw_pipe_flatshade.c.
References flat_stage::color_attribs, COPY_3FV, COPY_4FV, vertex_header::data, flat_stage(), flat_stage::num_color_attribs, flat_stage::num_spec_attribs, and flat_stage::spec_attribs.
00070 { 00071 const struct flat_stage *flat = flat_stage(stage); 00072 uint i; 00073 00074 for (i = 0; i < flat->num_color_attribs; i++) { 00075 const uint attr = flat->color_attribs[i]; 00076 COPY_4FV(dst->data[attr], src->data[attr]); 00077 } 00078 00079 for (i = 0; i < flat->num_spec_attribs; i++) { 00080 const uint attr = flat->spec_attribs[i]; 00081 COPY_3FV(dst->data[attr], src->data[attr]); 00082 } 00083 }
static void copy_colors2 | ( | struct draw_stage * | stage, | |
struct vertex_header * | dst0, | |||
struct vertex_header * | dst1, | |||
const struct vertex_header * | src | |||
) | [static] |
Copy all the color attributes from src vertex to dst0 & dst1 vertices.
Definition at line 87 of file draw_pipe_flatshade.c.
References flat_stage::color_attribs, COPY_3FV, COPY_4FV, vertex_header::data, flat_stage(), flat_stage::num_color_attribs, flat_stage::num_spec_attribs, and flat_stage::spec_attribs.
00091 { 00092 const struct flat_stage *flat = flat_stage(stage); 00093 uint i; 00094 for (i = 0; i < flat->num_color_attribs; i++) { 00095 const uint attr = flat->color_attribs[i]; 00096 COPY_4FV(dst0->data[attr], src->data[attr]); 00097 COPY_4FV(dst1->data[attr], src->data[attr]); 00098 } 00099 00100 for (i = 0; i < flat->num_spec_attribs; i++) { 00101 const uint attr = flat->spec_attribs[i]; 00102 COPY_3FV(dst0->data[attr], src->data[attr]); 00103 COPY_3FV(dst1->data[attr], src->data[attr]); 00104 } 00105 }
struct draw_stage* draw_flatshade_stage | ( | struct draw_context * | draw | ) | [read] |
Create flatshading drawing stage.
Definition at line 254 of file draw_pipe_flatshade.c.
References CALLOC_STRUCT, draw_stage::destroy, draw_stage::draw, draw_alloc_temp_verts(), draw_pipe_passthrough_point(), flatshade_destroy(), flatshade_first_line(), flatshade_first_tri(), flatshade_flush(), flatshade_reset_stipple_counter(), draw_stage::flush, draw_stage::line, draw_stage::next, draw_stage::point, draw_stage::reset_stipple_counter, flat_stage::stage, and draw_stage::tri.
00255 { 00256 struct flat_stage *flatshade = CALLOC_STRUCT(flat_stage); 00257 if (flatshade == NULL) 00258 goto fail; 00259 00260 if (!draw_alloc_temp_verts( &flatshade->stage, 2 )) 00261 goto fail; 00262 00263 flatshade->stage.draw = draw; 00264 flatshade->stage.next = NULL; 00265 flatshade->stage.point = draw_pipe_passthrough_point; 00266 flatshade->stage.line = flatshade_first_line; 00267 flatshade->stage.tri = flatshade_first_tri; 00268 flatshade->stage.flush = flatshade_flush; 00269 flatshade->stage.reset_stipple_counter = flatshade_reset_stipple_counter; 00270 flatshade->stage.destroy = flatshade_destroy; 00271 00272 return &flatshade->stage; 00273 00274 fail: 00275 if (flatshade) 00276 flatshade->stage.destroy( &flatshade->stage ); 00277 00278 return NULL; 00279 }
static struct flat_stage* flat_stage | ( | struct draw_stage * | stage | ) | [static, read] |
Definition at line 60 of file draw_pipe_flatshade.c.
00061 { 00062 return (struct flat_stage *) stage; 00063 }
static void flatshade_destroy | ( | struct draw_stage * | stage | ) | [static] |
Definition at line 244 of file draw_pipe_flatshade.c.
References draw_free_temp_verts(), and FREE.
00245 { 00246 draw_free_temp_verts( stage ); 00247 FREE( stage ); 00248 }
static void flatshade_first_line | ( | struct draw_stage * | stage, | |
struct prim_header * | header | |||
) | [static] |
Definition at line 221 of file draw_pipe_flatshade.c.
References flatshade_init_state(), and draw_stage::line.
00223 { 00224 flatshade_init_state( stage ); 00225 stage->line( stage, header ); 00226 }
static void flatshade_first_tri | ( | struct draw_stage * | stage, | |
struct prim_header * | header | |||
) | [static] |
Definition at line 214 of file draw_pipe_flatshade.c.
References flatshade_init_state(), and draw_stage::tri.
00216 { 00217 flatshade_init_state( stage ); 00218 stage->tri( stage, header ); 00219 }
static void flatshade_flush | ( | struct draw_stage * | stage, | |
unsigned | flags | |||
) | [static] |
Definition at line 229 of file draw_pipe_flatshade.c.
References flatshade_first_line(), flatshade_first_tri(), draw_stage::flush, draw_stage::line, draw_stage::next, and draw_stage::tri.
00231 { 00232 stage->tri = flatshade_first_tri; 00233 stage->line = flatshade_first_line; 00234 stage->next->flush( stage->next, flags ); 00235 }
static void flatshade_init_state | ( | struct draw_stage * | stage | ) | [static] |
Definition at line 183 of file draw_pipe_flatshade.c.
References flat_stage::color_attribs, draw_stage::draw, flat_stage(), pipe_rasterizer_state::flatshade_first, flatshade_line_0(), flatshade_line_1(), flatshade_tri_0(), flatshade_tri_2(), draw_vertex_shader::info, draw_stage::line, flat_stage::num_color_attribs, tgsi_shader_info::num_outputs, flat_stage::num_spec_attribs, tgsi_shader_info::output_semantic_index, tgsi_shader_info::output_semantic_name, draw_context::rasterizer, flat_stage::spec_attribs, TGSI_SEMANTIC_BCOLOR, TGSI_SEMANTIC_COLOR, draw_stage::tri, draw_context::vertex_shader, and draw_context::vs.
00184 { 00185 struct flat_stage *flat = flat_stage(stage); 00186 const struct draw_vertex_shader *vs = stage->draw->vs.vertex_shader; 00187 uint i; 00188 00189 /* Find which vertex shader outputs are colors, make a list */ 00190 flat->num_color_attribs = 0; 00191 flat->num_spec_attribs = 0; 00192 for (i = 0; i < vs->info.num_outputs; i++) { 00193 if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_COLOR || 00194 vs->info.output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) { 00195 if (vs->info.output_semantic_index[i] == 0) 00196 flat->color_attribs[flat->num_color_attribs++] = i; 00197 else 00198 flat->spec_attribs[flat->num_spec_attribs++] = i; 00199 } 00200 } 00201 00202 /* Choose flatshade routine according to provoking vertex: 00203 */ 00204 if (stage->draw->rasterizer->flatshade_first) { 00205 stage->line = flatshade_line_0; 00206 stage->tri = flatshade_tri_0; 00207 } 00208 else { 00209 stage->line = flatshade_line_1; 00210 stage->tri = flatshade_tri_2; 00211 } 00212 }
static void flatshade_line_0 | ( | struct draw_stage * | stage, | |
struct prim_header * | header | |||
) | [static] |
Flatshade line.
Required for clipping.
Definition at line 154 of file draw_pipe_flatshade.c.
References copy_colors(), dup_vert(), draw_stage::line, draw_stage::next, and prim_header::v.
00156 { 00157 struct prim_header tmp; 00158 00159 tmp.v[0] = header->v[0]; 00160 tmp.v[1] = dup_vert(stage, header->v[1], 0); 00161 00162 copy_colors(stage, tmp.v[1], tmp.v[0]); 00163 00164 stage->next->line( stage->next, &tmp ); 00165 }
static void flatshade_line_1 | ( | struct draw_stage * | stage, | |
struct prim_header * | header | |||
) | [static] |
Definition at line 167 of file draw_pipe_flatshade.c.
References copy_colors(), dup_vert(), draw_stage::line, draw_stage::next, and prim_header::v.
00169 { 00170 struct prim_header tmp; 00171 00172 tmp.v[0] = dup_vert(stage, header->v[0], 0); 00173 tmp.v[1] = header->v[1]; 00174 00175 copy_colors(stage, tmp.v[0], tmp.v[1]); 00176 00177 stage->next->line( stage->next, &tmp ); 00178 }
static void flatshade_reset_stipple_counter | ( | struct draw_stage * | stage | ) | [static] |
Definition at line 238 of file draw_pipe_flatshade.c.
References draw_stage::next, and draw_stage::reset_stipple_counter.
00239 { 00240 stage->next->reset_stipple_counter( stage->next ); 00241 }
static void flatshade_tri_0 | ( | struct draw_stage * | stage, | |
struct prim_header * | header | |||
) | [static] |
Flatshade tri.
Required for clipping and when unfilled tris are active, otherwise handled by hardware.
Definition at line 112 of file draw_pipe_flatshade.c.
References copy_colors2(), prim_header::det, dup_vert(), prim_header::flags, draw_stage::next, prim_header::pad, draw_stage::tri, and prim_header::v.
00114 { 00115 struct prim_header tmp; 00116 00117 tmp.det = header->det; 00118 tmp.flags = header->flags; 00119 tmp.pad = header->pad; 00120 tmp.v[0] = header->v[0]; 00121 tmp.v[1] = dup_vert(stage, header->v[1], 0); 00122 tmp.v[2] = dup_vert(stage, header->v[2], 1); 00123 00124 copy_colors2(stage, tmp.v[1], tmp.v[2], tmp.v[0]); 00125 00126 stage->next->tri( stage->next, &tmp ); 00127 }
static void flatshade_tri_2 | ( | struct draw_stage * | stage, | |
struct prim_header * | header | |||
) | [static] |
Definition at line 130 of file draw_pipe_flatshade.c.
References copy_colors2(), prim_header::det, dup_vert(), prim_header::flags, draw_stage::next, prim_header::pad, draw_stage::tri, and prim_header::v.
00132 { 00133 struct prim_header tmp; 00134 00135 tmp.det = header->det; 00136 tmp.flags = header->flags; 00137 tmp.pad = header->pad; 00138 tmp.v[0] = dup_vert(stage, header->v[0], 0); 00139 tmp.v[1] = dup_vert(stage, header->v[1], 1); 00140 tmp.v[2] = header->v[2]; 00141 00142 copy_colors2(stage, tmp.v[0], tmp.v[1], tmp.v[2]); 00143 00144 stage->next->tri( stage->next, &tmp ); 00145 }