Go to the source code of this file.
Data Structures | |
struct | twoside_stage |
Functions | |
static struct twoside_stage * | twoside_stage (struct draw_stage *stage) |
static struct vertex_header * | copy_bfc (struct twoside_stage *twoside, const struct vertex_header *v, unsigned idx) |
Copy back color(s) to front color(s). | |
static void | twoside_tri (struct draw_stage *stage, struct prim_header *header) |
static void | twoside_first_tri (struct draw_stage *stage, struct prim_header *header) |
static void | twoside_flush (struct draw_stage *stage, unsigned flags) |
static void | twoside_reset_stipple_counter (struct draw_stage *stage) |
static void | twoside_destroy (struct draw_stage *stage) |
struct draw_stage * | draw_twoside_stage (struct draw_context *draw) |
Create twoside pipeline stage. |
static struct vertex_header* copy_bfc | ( | struct twoside_stage * | twoside, | |
const struct vertex_header * | v, | |||
unsigned | idx | |||
) | [static, read] |
Copy back color(s) to front color(s).
Definition at line 58 of file draw_pipe_twoside.c.
References twoside_stage::attrib_back0, twoside_stage::attrib_back1, twoside_stage::attrib_front0, twoside_stage::attrib_front1, COPY_4FV, vertex_header::data, dup_vert(), and twoside_stage::stage.
00061 { 00062 struct vertex_header *tmp = dup_vert( &twoside->stage, v, idx ); 00063 00064 if (twoside->attrib_back0) { 00065 COPY_4FV(tmp->data[twoside->attrib_front0], 00066 tmp->data[twoside->attrib_back0]); 00067 } 00068 if (twoside->attrib_back1) { 00069 COPY_4FV(tmp->data[twoside->attrib_front1], 00070 tmp->data[twoside->attrib_back1]); 00071 } 00072 00073 return tmp; 00074 }
struct draw_stage* draw_twoside_stage | ( | struct draw_context * | draw | ) | [read] |
Create twoside pipeline stage.
Definition at line 174 of file draw_pipe_twoside.c.
References CALLOC_STRUCT, draw_stage::destroy, draw_stage::draw, draw_alloc_temp_verts(), draw_pipe_passthrough_line(), draw_pipe_passthrough_point(), draw_stage::flush, draw_stage::line, draw_stage::next, draw_stage::point, draw_stage::reset_stipple_counter, twoside_stage::stage, draw_stage::tri, twoside_destroy(), twoside_first_tri(), twoside_flush(), and twoside_reset_stipple_counter().
00175 { 00176 struct twoside_stage *twoside = CALLOC_STRUCT(twoside_stage); 00177 if (twoside == NULL) 00178 goto fail; 00179 00180 if (!draw_alloc_temp_verts( &twoside->stage, 3 )) 00181 goto fail; 00182 00183 twoside->stage.draw = draw; 00184 twoside->stage.next = NULL; 00185 twoside->stage.point = draw_pipe_passthrough_point; 00186 twoside->stage.line = draw_pipe_passthrough_line; 00187 twoside->stage.tri = twoside_first_tri; 00188 twoside->stage.flush = twoside_flush; 00189 twoside->stage.reset_stipple_counter = twoside_reset_stipple_counter; 00190 twoside->stage.destroy = twoside_destroy; 00191 00192 return &twoside->stage; 00193 00194 fail: 00195 if (twoside) 00196 twoside->stage.destroy( &twoside->stage ); 00197 00198 return NULL; 00199 }
static void twoside_destroy | ( | struct draw_stage * | stage | ) | [static] |
Definition at line 164 of file draw_pipe_twoside.c.
References draw_free_temp_verts(), and FREE.
00165 { 00166 draw_free_temp_verts( stage ); 00167 FREE( stage ); 00168 }
static void twoside_first_tri | ( | struct draw_stage * | stage, | |
struct prim_header * | header | |||
) | [static] |
Definition at line 105 of file draw_pipe_twoside.c.
References twoside_stage::attrib_back0, twoside_stage::attrib_back1, twoside_stage::attrib_front0, twoside_stage::attrib_front1, draw_stage::draw, pipe_rasterizer_state::front_winding, draw_vertex_shader::info, tgsi_shader_info::num_outputs, tgsi_shader_info::output_semantic_index, tgsi_shader_info::output_semantic_name, PIPE_WINDING_CCW, draw_context::rasterizer, twoside_stage::sign, TGSI_SEMANTIC_BCOLOR, TGSI_SEMANTIC_COLOR, draw_stage::tri, twoside_stage(), twoside_tri(), draw_context::vertex_shader, and draw_context::vs.
00107 { 00108 struct twoside_stage *twoside = twoside_stage(stage); 00109 const struct draw_vertex_shader *vs = stage->draw->vs.vertex_shader; 00110 uint i; 00111 00112 twoside->attrib_front0 = 0; 00113 twoside->attrib_front1 = 0; 00114 twoside->attrib_back0 = 0; 00115 twoside->attrib_back1 = 0; 00116 00117 /* Find which vertex shader outputs are front/back colors */ 00118 for (i = 0; i < vs->info.num_outputs; i++) { 00119 if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_COLOR) { 00120 if (vs->info.output_semantic_index[i] == 0) 00121 twoside->attrib_front0 = i; 00122 else 00123 twoside->attrib_front1 = i; 00124 } 00125 if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) { 00126 if (vs->info.output_semantic_index[i] == 0) 00127 twoside->attrib_back0 = i; 00128 else 00129 twoside->attrib_back1 = i; 00130 } 00131 } 00132 00133 if (!twoside->attrib_back0) 00134 twoside->attrib_front0 = 0; 00135 00136 if (!twoside->attrib_back1) 00137 twoside->attrib_front1 = 0; 00138 00139 /* 00140 * We'll multiply the primitive's determinant by this sign to determine 00141 * if the triangle is back-facing (negative). 00142 * sign = -1 for CCW, +1 for CW 00143 */ 00144 twoside->sign = (stage->draw->rasterizer->front_winding == PIPE_WINDING_CCW) ? -1.0f : 1.0f; 00145 00146 stage->tri = twoside_tri; 00147 stage->tri( stage, header ); 00148 }
static void twoside_flush | ( | struct draw_stage * | stage, | |
unsigned | flags | |||
) | [static] |
Definition at line 151 of file draw_pipe_twoside.c.
References draw_stage::flush, draw_stage::next, draw_stage::tri, and twoside_first_tri().
00152 { 00153 stage->tri = twoside_first_tri; 00154 stage->next->flush( stage->next, flags ); 00155 }
static void twoside_reset_stipple_counter | ( | struct draw_stage * | stage | ) | [static] |
Definition at line 158 of file draw_pipe_twoside.c.
References draw_stage::next, and draw_stage::reset_stipple_counter.
00159 { 00160 stage->next->reset_stipple_counter( stage->next ); 00161 }
static struct twoside_stage* twoside_stage | ( | struct draw_stage * | stage | ) | [static, read] |
Definition at line 46 of file draw_pipe_twoside.c.
00047 { 00048 return (struct twoside_stage *)stage; 00049 }
static void twoside_tri | ( | struct draw_stage * | stage, | |
struct prim_header * | header | |||
) | [static] |
Definition at line 79 of file draw_pipe_twoside.c.
References copy_bfc(), prim_header::det, prim_header::flags, draw_stage::next, prim_header::pad, twoside_stage::sign, draw_stage::tri, twoside_stage(), and prim_header::v.
00081 { 00082 struct twoside_stage *twoside = twoside_stage(stage); 00083 00084 if (header->det * twoside->sign < 0.0) { 00085 /* this is a back-facing triangle */ 00086 struct prim_header tmp; 00087 00088 tmp.det = header->det; 00089 tmp.flags = header->flags; 00090 tmp.pad = header->pad; 00091 /* copy back attribs to front attribs */ 00092 tmp.v[0] = copy_bfc(twoside, header->v[0], 0); 00093 tmp.v[1] = copy_bfc(twoside, header->v[1], 1); 00094 tmp.v[2] = copy_bfc(twoside, header->v[2], 2); 00095 00096 stage->next->tri( stage->next, &tmp ); 00097 } 00098 else { 00099 stage->next->tri( stage->next, header ); 00100 } 00101 }