2 static void FUNC(struct draw_pt_front_end
*frontend
,
7 struct varray_frontend
*varray
= (struct varray_frontend
*)frontend
;
8 struct draw_context
*draw
= varray
->draw
;
9 unsigned start
= (unsigned)elts
;
11 boolean flatfirst
= (draw
->rasterizer
->flatshade
&&
12 draw
->rasterizer
->flatshade_first
);
16 varray
->fetch_start
= start
;
18 draw_pt_split_prim(varray
->input_prim
, &first
, &incr
);
21 debug_printf("%s (%d) %d/%d\n", __FUNCTION__
,
26 switch (varray
->input_prim
) {
27 case PIPE_PRIM_POINTS
:
28 for (j
= 0; j
+ first
<= count
; j
+= i
) {
29 unsigned end
= MIN2(FETCH_MAX
, count
- j
);
31 for (i
= 0; i
< end
; i
++) {
35 fetch_init(varray
, end
);
41 for (j
= 0; j
+ first
<= count
; j
+= i
) {
42 unsigned end
= MIN2(FETCH_MAX
, count
- j
);
44 for (i
= 0; i
+1 < end
; i
+= 2) {
45 LINE(varray
, DRAW_PIPE_RESET_STIPPLE
,
49 fetch_init(varray
, end
);
54 case PIPE_PRIM_LINE_LOOP
:
56 flags
= DRAW_PIPE_RESET_STIPPLE
;
58 for (j
= 0; j
+ first
<= count
; j
+= i
) {
59 unsigned end
= MIN2(FETCH_MAX
, count
- j
);
61 for (i
= 1; i
< end
; i
++, flags
= 0) {
62 LINE(varray
, flags
, i
- 1, i
);
64 LINE(varray
, flags
, i
- 1, 0);
66 fetch_init(varray
, end
);
72 case PIPE_PRIM_LINE_STRIP
:
73 flags
= DRAW_PIPE_RESET_STIPPLE
;
74 for (j
= 0; j
+ first
<= count
; j
+= i
) {
75 unsigned end
= MIN2(FETCH_MAX
, count
- j
);
77 for (i
= 1; i
< end
; i
++, flags
= 0) {
78 LINE(varray
, flags
, i
- 1, i
);
81 fetch_init(varray
, end
);
86 case PIPE_PRIM_TRIANGLES
:
87 for (j
= 0; j
+ first
<= count
; j
+= i
) {
88 unsigned end
= MIN2(FETCH_MAX
, count
- j
);
90 for (i
= 0; i
+2 < end
; i
+= 3) {
91 TRIANGLE(varray
, DRAW_PIPE_RESET_STIPPLE
| DRAW_PIPE_EDGE_FLAG_ALL
,
95 fetch_init(varray
, end
);
100 case PIPE_PRIM_TRIANGLE_STRIP
:
102 for (j
= 0; j
+ first
<= count
; j
+= i
) {
103 unsigned end
= MIN2(FETCH_MAX
, count
- j
);
105 for (i
= 0; i
+2 < end
; i
++) {
106 TRIANGLE(varray
, DRAW_PIPE_RESET_STIPPLE
| DRAW_PIPE_EDGE_FLAG_ALL
,
107 i
+ 0, i
+ 1 + (i
&1), i
+ 2 - (i
&1));
110 fetch_init(varray
, end
);
111 varray_flush(varray
);
112 if (j
+ first
+ i
<= count
) {
113 varray
->fetch_start
-= 2;
119 for (j
= 0; j
+ first
<= count
; j
+= i
) {
120 unsigned end
= MIN2(FETCH_MAX
, count
- j
);
122 for (i
= 0; i
+ 2 < end
; i
++) {
123 TRIANGLE(varray
, DRAW_PIPE_RESET_STIPPLE
| DRAW_PIPE_EDGE_FLAG_ALL
,
124 i
+ 0 + (i
&1), i
+ 1 - (i
&1), i
+ 2);
127 fetch_init(varray
, end
);
128 varray_flush(varray
);
129 if (j
+ first
+ i
<= count
) {
130 varray
->fetch_start
-= 2;
137 case PIPE_PRIM_TRIANGLE_FAN
:
140 flags
= DRAW_PIPE_RESET_STIPPLE
| DRAW_PIPE_EDGE_FLAG_ALL
;
141 for (j
= 0; j
+ first
<= count
; j
+= i
) {
142 unsigned end
= MIN2(FETCH_MAX
, count
- j
);
144 for (i
= 0; i
+2 < end
; i
++) {
145 TRIANGLE(varray
, flags
, i
+ 1, i
+ 2, 0);
148 fetch_init(varray
, end
);
149 varray_flush(varray
);
153 flags
= DRAW_PIPE_RESET_STIPPLE
| DRAW_PIPE_EDGE_FLAG_ALL
;
154 for (j
= 0; j
+ first
<= count
; j
+= i
) {
155 unsigned end
= MIN2(FETCH_MAX
, count
- j
);
157 for (i
= 0; i
+2 < end
; i
++) {
158 TRIANGLE(varray
, flags
, 0, i
+ 1, i
+ 2);
161 fetch_init(varray
, end
);
162 varray_flush(varray
);
168 case PIPE_PRIM_QUADS
:
169 for (j
= 0; j
+ first
<= count
; j
+= i
) {
170 unsigned end
= MIN2(FETCH_MAX
, count
- j
);
172 for (i
= 0; i
+3 < end
; i
+= 4) {
173 QUAD(varray
, i
+ 0, i
+ 1, i
+ 2, i
+ 3);
176 fetch_init(varray
, end
);
177 varray_flush(varray
);
181 case PIPE_PRIM_QUAD_STRIP
:
182 for (j
= 0; j
+ first
<= count
; j
+= i
) {
183 unsigned end
= MIN2(FETCH_MAX
, count
- j
);
185 for (i
= 0; i
+3 < end
; i
+= 2) {
186 QUAD(varray
, i
+ 2, i
+ 0, i
+ 1, i
+ 3);
189 fetch_init(varray
, end
);
190 varray_flush(varray
);
191 if (j
+ first
+ i
<= count
) {
192 varray
->fetch_start
-= 2;
198 case PIPE_PRIM_POLYGON
:
200 /* These bitflags look a little odd because we submit the
201 * vertices as (1,2,0) to satisfy flatshade requirements.
203 const unsigned edge_first
= DRAW_PIPE_EDGE_FLAG_2
;
204 const unsigned edge_middle
= DRAW_PIPE_EDGE_FLAG_0
;
205 const unsigned edge_last
= DRAW_PIPE_EDGE_FLAG_1
;
207 flags
= DRAW_PIPE_RESET_STIPPLE
| edge_first
| edge_middle
;
208 for (j
= 0; j
+ first
<= count
; j
+= i
) {
209 unsigned end
= MIN2(FETCH_MAX
, count
- j
);
211 for (i
= 0; i
+2 < end
; i
++, flags
= edge_middle
) {
216 TRIANGLE(varray
, flags
, i
+ 1, i
+ 2, 0);
219 fetch_init(varray
, end
);
220 varray_flush(varray
);
230 varray_flush(varray
);