00001
00002
00003 static void FUNC( struct draw_pt_front_end *frontend,
00004 pt_elt_func get_elt,
00005 const void *elts,
00006 unsigned count )
00007 {
00008 struct vcache_frontend *vcache = (struct vcache_frontend *)frontend;
00009 struct draw_context *draw = vcache->draw;
00010
00011 boolean flatfirst = (draw->rasterizer->flatshade &&
00012 draw->rasterizer->flatshade_first);
00013 unsigned i;
00014 ushort flags;
00015
00016 if (0) debug_printf("%s %d\n", __FUNCTION__, count);
00017
00018
00019 switch (vcache->input_prim) {
00020 case PIPE_PRIM_POINTS:
00021 for (i = 0; i < count; i ++) {
00022 POINT( vcache,
00023 get_elt(elts, i + 0) );
00024 }
00025 break;
00026
00027 case PIPE_PRIM_LINES:
00028 for (i = 0; i+1 < count; i += 2) {
00029 LINE( vcache,
00030 DRAW_PIPE_RESET_STIPPLE,
00031 get_elt(elts, i + 0),
00032 get_elt(elts, i + 1));
00033 }
00034 break;
00035
00036 case PIPE_PRIM_LINE_LOOP:
00037 if (count >= 2) {
00038 flags = DRAW_PIPE_RESET_STIPPLE;
00039
00040 for (i = 1; i < count; i++, flags = 0) {
00041 LINE( vcache,
00042 flags,
00043 get_elt(elts, i - 1),
00044 get_elt(elts, i ));
00045 }
00046
00047 LINE( vcache,
00048 flags,
00049 get_elt(elts, i - 1),
00050 get_elt(elts, 0 ));
00051 }
00052 break;
00053
00054 case PIPE_PRIM_LINE_STRIP:
00055 flags = DRAW_PIPE_RESET_STIPPLE;
00056 for (i = 1; i < count; i++, flags = 0) {
00057 LINE( vcache,
00058 flags,
00059 get_elt(elts, i - 1),
00060 get_elt(elts, i ));
00061 }
00062 break;
00063
00064 case PIPE_PRIM_TRIANGLES:
00065 for (i = 0; i+2 < count; i += 3) {
00066 TRIANGLE( vcache,
00067 DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
00068 get_elt(elts, i + 0),
00069 get_elt(elts, i + 1),
00070 get_elt(elts, i + 2 ));
00071 }
00072 break;
00073
00074 case PIPE_PRIM_TRIANGLE_STRIP:
00075 if (flatfirst) {
00076 for (i = 0; i+2 < count; i++) {
00077 TRIANGLE( vcache,
00078 DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
00079 get_elt(elts, i + 0),
00080 get_elt(elts, i + 1 + (i&1)),
00081 get_elt(elts, i + 2 - (i&1)));
00082 }
00083 }
00084 else {
00085 for (i = 0; i+2 < count; i++) {
00086 TRIANGLE( vcache,
00087 DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
00088 get_elt(elts, i + 0 + (i&1)),
00089 get_elt(elts, i + 1 - (i&1)),
00090 get_elt(elts, i + 2 ));
00091 }
00092 }
00093 break;
00094
00095 case PIPE_PRIM_TRIANGLE_FAN:
00096 if (count >= 3) {
00097 if (flatfirst) {
00098 for (i = 0; i+2 < count; i++) {
00099 TRIANGLE( vcache,
00100 DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
00101 get_elt(elts, i + 1),
00102 get_elt(elts, i + 2),
00103 get_elt(elts, 0 ));
00104 }
00105 }
00106 else {
00107 for (i = 0; i+2 < count; i++) {
00108 TRIANGLE( vcache,
00109 DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
00110 get_elt(elts, 0),
00111 get_elt(elts, i + 1),
00112 get_elt(elts, i + 2 ));
00113 }
00114 }
00115 }
00116 break;
00117
00118
00119 case PIPE_PRIM_QUADS:
00120 for (i = 0; i+3 < count; i += 4) {
00121 QUAD( vcache,
00122 get_elt(elts, i + 0),
00123 get_elt(elts, i + 1),
00124 get_elt(elts, i + 2),
00125 get_elt(elts, i + 3));
00126 }
00127 break;
00128
00129 case PIPE_PRIM_QUAD_STRIP:
00130 for (i = 0; i+3 < count; i += 2) {
00131 QUAD( vcache,
00132 get_elt(elts, i + 2),
00133 get_elt(elts, i + 0),
00134 get_elt(elts, i + 1),
00135 get_elt(elts, i + 3));
00136 }
00137 break;
00138
00139 case PIPE_PRIM_POLYGON:
00140 {
00141
00142
00143
00144 const ushort edge_first = DRAW_PIPE_EDGE_FLAG_2;
00145 const ushort edge_middle = DRAW_PIPE_EDGE_FLAG_0;
00146 const ushort edge_last = DRAW_PIPE_EDGE_FLAG_1;
00147
00148 flags = DRAW_PIPE_RESET_STIPPLE | edge_first | edge_middle;
00149
00150 for (i = 0; i+2 < count; i++, flags = edge_middle) {
00151
00152 if (i + 3 == count)
00153 flags |= edge_last;
00154
00155 TRIANGLE( vcache,
00156 flags,
00157 get_elt(elts, i + 1),
00158 get_elt(elts, i + 2),
00159 get_elt(elts, 0));
00160 }
00161 }
00162 break;
00163
00164 default:
00165 assert(0);
00166 break;
00167 }
00168
00169 vcache_flush( vcache );
00170 }
00171
00172
00173 #undef TRIANGLE
00174 #undef QUAD
00175 #undef POINT
00176 #undef LINE
00177 #undef FUNC