Go to the source code of this file.
Functions | |
static void | FUNC (struct draw_pt_front_end *frontend, pt_elt_func get_elt, const void *elts, unsigned count) |
static void FUNC | ( | struct draw_pt_front_end * | frontend, | |
pt_elt_func | get_elt, | |||
const void * | elts, | |||
unsigned | count | |||
) | [static] |
Definition at line 2 of file draw_pt_varray_tmp.h.
References assert, debug_printf(), varray_frontend::draw, draw, DRAW_PIPE_EDGE_FLAG_0, DRAW_PIPE_EDGE_FLAG_1, DRAW_PIPE_EDGE_FLAG_2, DRAW_PIPE_EDGE_FLAG_ALL, DRAW_PIPE_RESET_STIPPLE, draw_pt_split_prim(), FETCH_MAX, draw_context::first, pipe_rasterizer_state::flatshade, pipe_rasterizer_state::flatshade_first, varray_frontend::input_prim, LINE, MIN2, PIPE_PRIM_LINE_LOOP, PIPE_PRIM_LINE_STRIP, PIPE_PRIM_LINES, PIPE_PRIM_POINTS, PIPE_PRIM_POLYGON, PIPE_PRIM_QUAD_STRIP, PIPE_PRIM_QUADS, PIPE_PRIM_TRIANGLE_FAN, PIPE_PRIM_TRIANGLE_STRIP, PIPE_PRIM_TRIANGLES, POINT, QUAD, draw_context::rasterizer, and TRIANGLE.
00006 { 00007 struct varray_frontend *varray = (struct varray_frontend *)frontend; 00008 struct draw_context *draw = varray->draw; 00009 unsigned start = (unsigned)elts; 00010 00011 boolean flatfirst = (draw->rasterizer->flatshade && 00012 draw->rasterizer->flatshade_first); 00013 unsigned i, j; 00014 ushort flags; 00015 unsigned first, incr; 00016 00017 varray->fetch_start = start; 00018 00019 draw_pt_split_prim(varray->input_prim, &first, &incr); 00020 00021 #if 0 00022 debug_printf("%s (%d) %d/%d\n", __FUNCTION__, 00023 varray->input_prim, 00024 start, count); 00025 #endif 00026 00027 switch (varray->input_prim) { 00028 case PIPE_PRIM_POINTS: 00029 for (j = 0; j + first <= count; j += i) { 00030 unsigned end = MIN2(FETCH_MAX, count - j); 00031 end -= (end % incr); 00032 for (i = 0; i < end; i++) { 00033 POINT(varray, i + 0); 00034 } 00035 i = end; 00036 fetch_init(varray, end); 00037 varray_flush(varray); 00038 } 00039 break; 00040 00041 case PIPE_PRIM_LINES: 00042 for (j = 0; j + first <= count; j += i) { 00043 unsigned end = MIN2(FETCH_MAX, count - j); 00044 end -= (end % incr); 00045 for (i = 0; i+1 < end; i += 2) { 00046 LINE(varray, DRAW_PIPE_RESET_STIPPLE, 00047 i + 0, i + 1); 00048 } 00049 i = end; 00050 fetch_init(varray, end); 00051 varray_flush(varray); 00052 } 00053 break; 00054 00055 case PIPE_PRIM_LINE_LOOP: 00056 if (count >= 2) { 00057 flags = DRAW_PIPE_RESET_STIPPLE; 00058 00059 for (j = 0; j + first <= count; j += i) { 00060 unsigned end = MIN2(FETCH_MAX, count - j); 00061 end -= (end % incr); 00062 for (i = 1; i < end; i++, flags = 0) { 00063 LINE(varray, flags, i - 1, i); 00064 } 00065 LINE(varray, flags, i - 1, 0); 00066 i = end; 00067 fetch_init(varray, end); 00068 varray_flush(varray); 00069 } 00070 } 00071 break; 00072 00073 case PIPE_PRIM_LINE_STRIP: 00074 flags = DRAW_PIPE_RESET_STIPPLE; 00075 for (j = 0; j + first <= count; j += i) { 00076 unsigned end = MIN2(FETCH_MAX, count - j); 00077 end -= (end % incr); 00078 for (i = 1; i < end; i++, flags = 0) { 00079 LINE(varray, flags, i - 1, i); 00080 } 00081 i = end; 00082 fetch_init(varray, end); 00083 varray_flush(varray); 00084 } 00085 break; 00086 00087 case PIPE_PRIM_TRIANGLES: 00088 for (j = 0; j + first <= count; j += i) { 00089 unsigned end = MIN2(FETCH_MAX, count - j); 00090 end -= (end % incr); 00091 for (i = 0; i+2 < end; i += 3) { 00092 TRIANGLE(varray, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, 00093 i + 0, i + 1, i + 2); 00094 } 00095 i = end; 00096 fetch_init(varray, end); 00097 varray_flush(varray); 00098 } 00099 break; 00100 00101 case PIPE_PRIM_TRIANGLE_STRIP: 00102 if (flatfirst) { 00103 for (j = 0; j + first <= count; j += i) { 00104 unsigned end = MIN2(FETCH_MAX, count - j); 00105 end -= (end % incr); 00106 for (i = 0; i+2 < end; i++) { 00107 TRIANGLE(varray, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, 00108 i + 0, i + 1 + (i&1), i + 2 - (i&1)); 00109 } 00110 i = end; 00111 fetch_init(varray, end); 00112 varray_flush(varray); 00113 if (j + first + i <= count) { 00114 varray->fetch_start -= 2; 00115 i -= 2; 00116 } 00117 } 00118 } 00119 else { 00120 for (j = 0; j + first <= count; j += i) { 00121 unsigned end = MIN2(FETCH_MAX, count - j); 00122 end -= (end % incr); 00123 for (i = 0; i + 2 < end; i++) { 00124 TRIANGLE(varray, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, 00125 i + 0 + (i&1), i + 1 - (i&1), i + 2); 00126 } 00127 i = end; 00128 fetch_init(varray, end); 00129 varray_flush(varray); 00130 if (j + first + i <= count) { 00131 varray->fetch_start -= 2; 00132 i -= 2; 00133 } 00134 } 00135 } 00136 break; 00137 00138 case PIPE_PRIM_TRIANGLE_FAN: 00139 if (count >= 3) { 00140 if (flatfirst) { 00141 flags = DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL; 00142 for (j = 0; j + first <= count; j += i) { 00143 unsigned end = MIN2(FETCH_MAX, count - j); 00144 end -= (end % incr); 00145 for (i = 0; i+2 < end; i++) { 00146 TRIANGLE(varray, flags, i + 1, i + 2, 0); 00147 } 00148 i = end; 00149 fetch_init(varray, end); 00150 varray_flush(varray); 00151 } 00152 } 00153 else { 00154 flags = DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL; 00155 for (j = 0; j + first <= count; j += i) { 00156 unsigned end = MIN2(FETCH_MAX, count - j); 00157 end -= (end % incr); 00158 for (i = 0; i+2 < end; i++) { 00159 TRIANGLE(varray, flags, 0, i + 1, i + 2); 00160 } 00161 i = end; 00162 fetch_init(varray, end); 00163 varray_flush(varray); 00164 } 00165 } 00166 } 00167 break; 00168 00169 case PIPE_PRIM_QUADS: 00170 for (j = 0; j + first <= count; j += i) { 00171 unsigned end = MIN2(FETCH_MAX, count - j); 00172 end -= (end % incr); 00173 for (i = 0; i+3 < end; i += 4) { 00174 QUAD(varray, i + 0, i + 1, i + 2, i + 3); 00175 } 00176 i = end; 00177 fetch_init(varray, end); 00178 varray_flush(varray); 00179 } 00180 break; 00181 00182 case PIPE_PRIM_QUAD_STRIP: 00183 for (j = 0; j + first <= count; j += i) { 00184 unsigned end = MIN2(FETCH_MAX, count - j); 00185 end -= (end % incr); 00186 for (i = 0; i+3 < end; i += 2) { 00187 QUAD(varray, i + 2, i + 0, i + 1, i + 3); 00188 } 00189 i = end; 00190 fetch_init(varray, end); 00191 varray_flush(varray); 00192 if (j + first + i <= count) { 00193 varray->fetch_start -= 2; 00194 i -= 2; 00195 } 00196 } 00197 break; 00198 00199 case PIPE_PRIM_POLYGON: 00200 { 00201 /* These bitflags look a little odd because we submit the 00202 * vertices as (1,2,0) to satisfy flatshade requirements. 00203 */ 00204 const ushort edge_first = DRAW_PIPE_EDGE_FLAG_2; 00205 const ushort edge_middle = DRAW_PIPE_EDGE_FLAG_0; 00206 const ushort edge_last = DRAW_PIPE_EDGE_FLAG_1; 00207 00208 flags = DRAW_PIPE_RESET_STIPPLE | edge_first | edge_middle; 00209 for (j = 0; j + first <= count; j += i) { 00210 unsigned end = MIN2(FETCH_MAX, count - j); 00211 end -= (end % incr); 00212 for (i = 0; i+2 < end; i++, flags = edge_middle) { 00213 00214 if (i + 3 == count) 00215 flags |= edge_last; 00216 00217 TRIANGLE(varray, flags, i + 1, i + 2, 0); 00218 } 00219 i = end; 00220 fetch_init(varray, end); 00221 varray_flush(varray); 00222 } 00223 } 00224 break; 00225 00226 default: 00227 assert(0); 00228 break; 00229 } 00230 00231 varray_flush(varray); 00232 }