nv50: fix build-predicate function
[mesa.git] / src / gallium / auxiliary / draw / draw_pt_varray_tmp.h
1
2 static void FUNC(struct draw_pt_front_end *frontend,
3 pt_elt_func get_elt,
4 const void *elts,
5 unsigned count)
6 {
7 struct varray_frontend *varray = (struct varray_frontend *)frontend;
8 struct draw_context *draw = varray->draw;
9 unsigned start = (unsigned)elts;
10
11 boolean flatfirst = (draw->rasterizer->flatshade &&
12 draw->rasterizer->flatshade_first);
13 unsigned i, j;
14 ushort flags;
15 unsigned first, incr;
16
17 varray->fetch_start = start;
18
19 draw_pt_split_prim(varray->input_prim, &first, &incr);
20
21 #if 0
22 debug_printf("%s (%d) %d/%d\n", __FUNCTION__,
23 varray->input_prim,
24 start, count);
25 #endif
26
27 switch (varray->input_prim) {
28 case PIPE_PRIM_POINTS:
29 for (j = 0; j + first <= count; j += i) {
30 unsigned end = MIN2(FETCH_MAX, count - j);
31 end -= (end % incr);
32 for (i = 0; i < end; i++) {
33 POINT(varray, i + 0);
34 }
35 i = end;
36 fetch_init(varray, end);
37 varray_flush(varray);
38 }
39 break;
40
41 case PIPE_PRIM_LINES:
42 for (j = 0; j + first <= count; j += i) {
43 unsigned end = MIN2(FETCH_MAX, count - j);
44 end -= (end % incr);
45 for (i = 0; i+1 < end; i += 2) {
46 LINE(varray, DRAW_PIPE_RESET_STIPPLE,
47 i + 0, i + 1);
48 }
49 i = end;
50 fetch_init(varray, end);
51 varray_flush(varray);
52 }
53 break;
54
55 case PIPE_PRIM_LINE_LOOP:
56 if (count >= 2) {
57 flags = DRAW_PIPE_RESET_STIPPLE;
58
59 for (j = 0; j + first <= count; j += i) {
60 unsigned end = MIN2(FETCH_MAX, count - j);
61 end -= (end % incr);
62 for (i = 1; i < end; i++, flags = 0) {
63 LINE(varray, flags, i - 1, i);
64 }
65 LINE(varray, flags, i - 1, 0);
66 i = end;
67 fetch_init(varray, end);
68 varray_flush(varray);
69 }
70 }
71 break;
72
73 case PIPE_PRIM_LINE_STRIP:
74 flags = DRAW_PIPE_RESET_STIPPLE;
75 for (j = 0; j + first <= count; j += i) {
76 unsigned end = MIN2(FETCH_MAX, count - j);
77 end -= (end % incr);
78 for (i = 1; i < end; i++, flags = 0) {
79 LINE(varray, flags, i - 1, i);
80 }
81 i = end;
82 fetch_init(varray, end);
83 varray_flush(varray);
84 }
85 break;
86
87 case PIPE_PRIM_TRIANGLES:
88 for (j = 0; j + first <= count; j += i) {
89 unsigned end = MIN2(FETCH_MAX, count - j);
90 end -= (end % incr);
91 for (i = 0; i+2 < end; i += 3) {
92 TRIANGLE(varray, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
93 i + 0, i + 1, i + 2);
94 }
95 i = end;
96 fetch_init(varray, end);
97 varray_flush(varray);
98 }
99 break;
100
101 case PIPE_PRIM_TRIANGLE_STRIP:
102 if (flatfirst) {
103 for (j = 0; j + first <= count; j += i) {
104 unsigned end = MIN2(FETCH_MAX, count - j);
105 end -= (end % incr);
106 for (i = 0; i+2 < end; i++) {
107 TRIANGLE(varray, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
108 i + 0, i + 1 + (i&1), i + 2 - (i&1));
109 }
110 i = end;
111 fetch_init(varray, end);
112 varray_flush(varray);
113 if (j + first + i <= count) {
114 varray->fetch_start -= 2;
115 i -= 2;
116 }
117 }
118 }
119 else {
120 for (j = 0; j + first <= count; j += i) {
121 unsigned end = MIN2(FETCH_MAX, count - j);
122 end -= (end % incr);
123 for (i = 0; i + 2 < end; i++) {
124 TRIANGLE(varray, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
125 i + 0 + (i&1), i + 1 - (i&1), i + 2);
126 }
127 i = end;
128 fetch_init(varray, end);
129 varray_flush(varray);
130 if (j + first + i <= count) {
131 varray->fetch_start -= 2;
132 i -= 2;
133 }
134 }
135 }
136 break;
137
138 case PIPE_PRIM_TRIANGLE_FAN:
139 if (count >= 3) {
140 if (flatfirst) {
141 flags = DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL;
142 for (j = 0; j + first <= count; j += i) {
143 unsigned end = MIN2(FETCH_MAX, count - j);
144 end -= (end % incr);
145 for (i = 0; i+2 < end; i++) {
146 TRIANGLE(varray, flags, i + 1, i + 2, 0);
147 }
148 i = end;
149 fetch_init(varray, end);
150 varray_flush(varray);
151 }
152 }
153 else {
154 flags = DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL;
155 for (j = 0; j + first <= count; j += i) {
156 unsigned end = MIN2(FETCH_MAX, count - j);
157 end -= (end % incr);
158 for (i = 0; i+2 < end; i++) {
159 TRIANGLE(varray, flags, 0, i + 1, i + 2);
160 }
161 i = end;
162 fetch_init(varray, end);
163 varray_flush(varray);
164 }
165 }
166 }
167 break;
168
169 case PIPE_PRIM_QUADS:
170 for (j = 0; j + first <= count; j += i) {
171 unsigned end = MIN2(FETCH_MAX, count - j);
172 end -= (end % incr);
173 for (i = 0; i+3 < end; i += 4) {
174 QUAD(varray, i + 0, i + 1, i + 2, i + 3);
175 }
176 i = end;
177 fetch_init(varray, end);
178 varray_flush(varray);
179 }
180 break;
181
182 case PIPE_PRIM_QUAD_STRIP:
183 for (j = 0; j + first <= count; j += i) {
184 unsigned end = MIN2(FETCH_MAX, count - j);
185 end -= (end % incr);
186 for (i = 0; i+3 < end; i += 2) {
187 QUAD(varray, i + 2, i + 0, i + 1, i + 3);
188 }
189 i = end;
190 fetch_init(varray, end);
191 varray_flush(varray);
192 if (j + first + i <= count) {
193 varray->fetch_start -= 2;
194 i -= 2;
195 }
196 }
197 break;
198
199 case PIPE_PRIM_POLYGON:
200 {
201 /* These bitflags look a little odd because we submit the
202 * vertices as (1,2,0) to satisfy flatshade requirements.
203 */
204 const ushort edge_first = DRAW_PIPE_EDGE_FLAG_2;
205 const ushort edge_middle = DRAW_PIPE_EDGE_FLAG_0;
206 const ushort edge_last = DRAW_PIPE_EDGE_FLAG_1;
207
208 flags = DRAW_PIPE_RESET_STIPPLE | edge_first | edge_middle;
209 for (j = 0; j + first <= count; j += i) {
210 unsigned end = MIN2(FETCH_MAX, count - j);
211 end -= (end % incr);
212 for (i = 0; i+2 < end; i++, flags = edge_middle) {
213
214 if (i + 3 == count)
215 flags |= edge_last;
216
217 TRIANGLE(varray, flags, i + 1, i + 2, 0);
218 }
219 i = end;
220 fetch_init(varray, end);
221 varray_flush(varray);
222 }
223 }
224 break;
225
226 default:
227 assert(0);
228 break;
229 }
230
231 varray_flush(varray);
232 }
233
234 #undef TRIANGLE
235 #undef QUAD
236 #undef POINT
237 #undef LINE
238 #undef FUNC