llvmpipe: slightly shrink the size of a binned triangle
[mesa.git] / src / gallium / drivers / llvmpipe / lp_setup_line.c
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 /*
29 * Binning code for lines
30 */
31
32 #include "util/u_math.h"
33 #include "util/u_memory.h"
34 #include "lp_perf.h"
35 #include "lp_setup_context.h"
36 #include "lp_rast.h"
37 #include "lp_state_fs.h"
38
39 #define NUM_CHANNELS 4
40
41 struct lp_line_info {
42
43 float dx;
44 float dy;
45 float oneoverarea;
46
47 const float (*v1)[4];
48 const float (*v2)[4];
49
50 float (*a0)[4];
51 float (*dadx)[4];
52 float (*dady)[4];
53 };
54
55
56 /**
57 * Compute a0 for a constant-valued coefficient (GL_FLAT shading).
58 */
59 static void constant_coef( struct lp_setup_context *setup,
60 struct lp_line_info *info,
61 unsigned slot,
62 const float value,
63 unsigned i )
64 {
65 info->a0[slot][i] = value;
66 info->dadx[slot][i] = 0.0f;
67 info->dady[slot][i] = 0.0f;
68 }
69
70
71 /**
72 * Compute a0, dadx and dady for a linearly interpolated coefficient,
73 * for a triangle.
74 */
75 static void linear_coef( struct lp_setup_context *setup,
76 struct lp_line_info *info,
77 unsigned slot,
78 unsigned vert_attr,
79 unsigned i)
80 {
81 float a1 = info->v1[vert_attr][i];
82 float a2 = info->v2[vert_attr][i];
83
84 float da21 = a1 - a2;
85 float dadx = da21 * info->dx * info->oneoverarea;
86 float dady = da21 * info->dy * info->oneoverarea;
87
88 info->dadx[slot][i] = dadx;
89 info->dady[slot][i] = dady;
90
91 info->a0[slot][i] = (a1 -
92 (dadx * (info->v1[0][0] - setup->pixel_offset) +
93 dady * (info->v1[0][1] - setup->pixel_offset)));
94 }
95
96
97 /**
98 * Compute a0, dadx and dady for a perspective-corrected interpolant,
99 * for a triangle.
100 * We basically multiply the vertex value by 1/w before computing
101 * the plane coefficients (a0, dadx, dady).
102 * Later, when we compute the value at a particular fragment position we'll
103 * divide the interpolated value by the interpolated W at that fragment.
104 */
105 static void perspective_coef( struct lp_setup_context *setup,
106 struct lp_line_info *info,
107 unsigned slot,
108 unsigned vert_attr,
109 unsigned i)
110 {
111 /* premultiply by 1/w (v[0][3] is always 1/w):
112 */
113 float a1 = info->v1[vert_attr][i] * info->v1[0][3];
114 float a2 = info->v2[vert_attr][i] * info->v2[0][3];
115
116 float da21 = a1 - a2;
117 float dadx = da21 * info->dx * info->oneoverarea;
118 float dady = da21 * info->dy * info->oneoverarea;
119
120 info->dadx[slot][i] = dadx;
121 info->dady[slot][i] = dady;
122
123 info->a0[slot][i] = (a1 -
124 (dadx * (info->v1[0][0] - setup->pixel_offset) +
125 dady * (info->v1[0][1] - setup->pixel_offset)));
126 }
127
128 static void
129 setup_fragcoord_coef( struct lp_setup_context *setup,
130 struct lp_line_info *info,
131 unsigned slot,
132 unsigned usage_mask)
133 {
134 /*X*/
135 if (usage_mask & TGSI_WRITEMASK_X) {
136 info->a0[slot][0] = 0.0;
137 info->dadx[slot][0] = 1.0;
138 info->dady[slot][0] = 0.0;
139 }
140
141 /*Y*/
142 if (usage_mask & TGSI_WRITEMASK_Y) {
143 info->a0[slot][1] = 0.0;
144 info->dadx[slot][1] = 0.0;
145 info->dady[slot][1] = 1.0;
146 }
147
148 /*Z*/
149 if (usage_mask & TGSI_WRITEMASK_Z) {
150 linear_coef(setup, info, slot, 0, 2);
151 }
152
153 /*W*/
154 if (usage_mask & TGSI_WRITEMASK_W) {
155 linear_coef(setup, info, slot, 0, 3);
156 }
157 }
158
159 /**
160 * Compute the tri->coef[] array dadx, dady, a0 values.
161 */
162 static void setup_line_coefficients( struct lp_setup_context *setup,
163 struct lp_line_info *info)
164 {
165 unsigned fragcoord_usage_mask = TGSI_WRITEMASK_XYZ;
166 unsigned slot;
167
168 /* setup interpolation for all the remaining attributes:
169 */
170 for (slot = 0; slot < setup->fs.nr_inputs; slot++) {
171 unsigned vert_attr = setup->fs.input[slot].src_index;
172 unsigned usage_mask = setup->fs.input[slot].usage_mask;
173 unsigned i;
174
175 switch (setup->fs.input[slot].interp) {
176 case LP_INTERP_CONSTANT:
177 if (setup->flatshade_first) {
178 for (i = 0; i < NUM_CHANNELS; i++)
179 if (usage_mask & (1 << i))
180 constant_coef(setup, info, slot+1, info->v1[vert_attr][i], i);
181 }
182 else {
183 for (i = 0; i < NUM_CHANNELS; i++)
184 if (usage_mask & (1 << i))
185 constant_coef(setup, info, slot+1, info->v2[vert_attr][i], i);
186 }
187 break;
188
189 case LP_INTERP_LINEAR:
190 for (i = 0; i < NUM_CHANNELS; i++)
191 if (usage_mask & (1 << i))
192 linear_coef(setup, info, slot+1, vert_attr, i);
193 break;
194
195 case LP_INTERP_PERSPECTIVE:
196 for (i = 0; i < NUM_CHANNELS; i++)
197 if (usage_mask & (1 << i))
198 perspective_coef(setup, info, slot+1, vert_attr, i);
199 fragcoord_usage_mask |= TGSI_WRITEMASK_W;
200 break;
201
202 case LP_INTERP_POSITION:
203 /*
204 * The generated pixel interpolators will pick up the coeffs from
205 * slot 0, so all need to ensure that the usage mask is covers all
206 * usages.
207 */
208 fragcoord_usage_mask |= usage_mask;
209 break;
210
211 case LP_INTERP_FACING:
212 for (i = 0; i < NUM_CHANNELS; i++)
213 if (usage_mask & (1 << i))
214 constant_coef(setup, info, slot+1, 1.0, i);
215 break;
216
217 default:
218 assert(0);
219 }
220 }
221
222 /* The internal position input is in slot zero:
223 */
224 setup_fragcoord_coef(setup, info, 0,
225 fragcoord_usage_mask);
226 }
227
228
229
230 static INLINE int subpixel_snap( float a )
231 {
232 return util_iround(FIXED_ONE * a);
233 }
234
235
236 /**
237 * Print line vertex attribs (for debug).
238 */
239 static void
240 print_line(struct lp_setup_context *setup,
241 const float (*v1)[4],
242 const float (*v2)[4])
243 {
244 uint i;
245
246 debug_printf("llvmpipe line\n");
247 for (i = 0; i < 1 + setup->fs.nr_inputs; i++) {
248 debug_printf(" v1[%d]: %f %f %f %f\n", i,
249 v1[i][0], v1[i][1], v1[i][2], v1[i][3]);
250 }
251 for (i = 0; i < 1 + setup->fs.nr_inputs; i++) {
252 debug_printf(" v2[%d]: %f %f %f %f\n", i,
253 v2[i][0], v2[i][1], v2[i][2], v2[i][3]);
254 }
255 }
256
257
258 static INLINE boolean sign(float x){
259 return x >= 0;
260 }
261
262
263 /* Used on positive floats only:
264 */
265 static INLINE float fracf(float f)
266 {
267 return f - floorf(f);
268 }
269
270
271
272 static boolean
273 try_setup_line( struct lp_setup_context *setup,
274 const float (*v1)[4],
275 const float (*v2)[4])
276 {
277 struct lp_scene *scene = setup->scene;
278 struct lp_rast_triangle *line;
279 struct lp_rast_plane *plane;
280 struct lp_line_info info;
281 float width = MAX2(1.0, setup->line_width);
282 struct u_rect bbox;
283 unsigned tri_bytes;
284 int x[4];
285 int y[4];
286 int i;
287 int nr_planes = 4;
288
289 /* linewidth should be interpreted as integer */
290 int fixed_width = util_iround(width) * FIXED_ONE;
291
292 float x_offset=0;
293 float y_offset=0;
294 float x_offset_end=0;
295 float y_offset_end=0;
296
297 float x1diff;
298 float y1diff;
299 float x2diff;
300 float y2diff;
301 float dx, dy;
302 float area;
303
304 boolean draw_start;
305 boolean draw_end;
306 boolean will_draw_start;
307 boolean will_draw_end;
308
309 if (0)
310 print_line(setup, v1, v2);
311
312 if (setup->scissor_test) {
313 nr_planes = 8;
314 }
315 else {
316 nr_planes = 4;
317 }
318
319
320 dx = v1[0][0] - v2[0][0];
321 dy = v1[0][1] - v2[0][1];
322 area = (dx * dx + dy * dy);
323 if (area == 0) {
324 LP_COUNT(nr_culled_tris);
325 return TRUE;
326 }
327
328 info.oneoverarea = 1.0f / area;
329 info.dx = dx;
330 info.dy = dy;
331 info.v1 = v1;
332 info.v2 = v2;
333
334
335 /* X-MAJOR LINE */
336 if (fabsf(dx) >= fabsf(dy)) {
337 float dydx = dy / dx;
338
339 x1diff = v1[0][0] - (float) floor(v1[0][0]) - 0.5;
340 y1diff = v1[0][1] - (float) floor(v1[0][1]) - 0.5;
341 x2diff = v2[0][0] - (float) floor(v2[0][0]) - 0.5;
342 y2diff = v2[0][1] - (float) floor(v2[0][1]) - 0.5;
343
344 if (y2diff==-0.5 && dy<0){
345 y2diff = 0.5;
346 }
347
348 /*
349 * Diamond exit rule test for starting point
350 */
351 if (fabsf(x1diff) + fabsf(y1diff) < 0.5) {
352 draw_start = TRUE;
353 }
354 else if (sign(x1diff) == sign(-dx)) {
355 draw_start = FALSE;
356 }
357 else if (sign(-y1diff) != sign(dy)) {
358 draw_start = TRUE;
359 }
360 else {
361 /* do intersection test */
362 float yintersect = fracf(v1[0][1]) + x1diff * dydx;
363 draw_start = (yintersect < 1.0 && yintersect > 0.0);
364 }
365
366
367 /*
368 * Diamond exit rule test for ending point
369 */
370 if (fabsf(x2diff) + fabsf(y2diff) < 0.5) {
371 draw_end = FALSE;
372 }
373 else if (sign(x2diff) != sign(-dx)) {
374 draw_end = FALSE;
375 }
376 else if (sign(-y2diff) == sign(dy)) {
377 draw_end = TRUE;
378 }
379 else {
380 /* do intersection test */
381 float yintersect = fracf(v2[0][1]) + x2diff * dydx;
382 draw_end = (yintersect < 1.0 && yintersect > 0.0);
383 }
384
385 /* Are we already drawing start/end?
386 */
387 will_draw_start = sign(-x1diff) != sign(dx);
388 will_draw_end = (sign(x2diff) == sign(-dx)) || x2diff==0;
389
390 if (dx < 0) {
391 /* if v2 is to the right of v1, swap pointers */
392 const float (*temp)[4] = v1;
393 v1 = v2;
394 v2 = temp;
395 dx = -dx;
396 dy = -dy;
397 /* Otherwise shift planes appropriately */
398 if (will_draw_start != draw_start) {
399 x_offset_end = - x1diff - 0.5;
400 y_offset_end = x_offset_end * dydx;
401
402 }
403 if (will_draw_end != draw_end) {
404 x_offset = - x2diff - 0.5;
405 y_offset = x_offset * dydx;
406 }
407
408 }
409 else{
410 /* Otherwise shift planes appropriately */
411 if (will_draw_start != draw_start) {
412 x_offset = - x1diff + 0.5;
413 y_offset = x_offset * dydx;
414 }
415 if (will_draw_end != draw_end) {
416 x_offset_end = - x2diff + 0.5;
417 y_offset_end = x_offset_end * dydx;
418 }
419 }
420
421 /* x/y positions in fixed point */
422 x[0] = subpixel_snap(v1[0][0] + x_offset - setup->pixel_offset);
423 x[1] = subpixel_snap(v2[0][0] + x_offset_end - setup->pixel_offset);
424 x[2] = subpixel_snap(v2[0][0] + x_offset_end - setup->pixel_offset);
425 x[3] = subpixel_snap(v1[0][0] + x_offset - setup->pixel_offset);
426
427 y[0] = subpixel_snap(v1[0][1] + y_offset - setup->pixel_offset) - fixed_width/2;
428 y[1] = subpixel_snap(v2[0][1] + y_offset_end - setup->pixel_offset) - fixed_width/2;
429 y[2] = subpixel_snap(v2[0][1] + y_offset_end - setup->pixel_offset) + fixed_width/2;
430 y[3] = subpixel_snap(v1[0][1] + y_offset - setup->pixel_offset) + fixed_width/2;
431
432 }
433 else {
434 const float dxdy = dx / dy;
435
436 /* Y-MAJOR LINE */
437 x1diff = v1[0][0] - (float) floor(v1[0][0]) - 0.5;
438 y1diff = v1[0][1] - (float) floor(v1[0][1]) - 0.5;
439 x2diff = v2[0][0] - (float) floor(v2[0][0]) - 0.5;
440 y2diff = v2[0][1] - (float) floor(v2[0][1]) - 0.5;
441
442 if (x2diff==-0.5 && dx<0) {
443 x2diff = 0.5;
444 }
445
446 /*
447 * Diamond exit rule test for starting point
448 */
449 if (fabsf(x1diff) + fabsf(y1diff) < 0.5) {
450 draw_start = TRUE;
451 }
452 else if (sign(-y1diff) == sign(dy)) {
453 draw_start = FALSE;
454 }
455 else if (sign(x1diff) != sign(-dx)) {
456 draw_start = TRUE;
457 }
458 else {
459 /* do intersection test */
460 float xintersect = fracf(v1[0][0]) + y1diff * dxdy;
461 draw_start = (xintersect < 1.0 && xintersect > 0.0);
462 }
463
464 /*
465 * Diamond exit rule test for ending point
466 */
467 if (fabsf(x2diff) + fabsf(y2diff) < 0.5) {
468 draw_end = FALSE;
469 }
470 else if (sign(-y2diff) != sign(dy) ) {
471 draw_end = FALSE;
472 }
473 else if (sign(x2diff) == sign(-dx) ) {
474 draw_end = TRUE;
475 }
476 else {
477 /* do intersection test */
478 float xintersect = fracf(v2[0][0]) + y2diff * dxdy;
479 draw_end = (xintersect < 1.0 && xintersect >= 0.0);
480 }
481
482 /* Are we already drawing start/end?
483 */
484 will_draw_start = sign(y1diff) == sign(dy);
485 will_draw_end = (sign(-y2diff) == sign(dy)) || y2diff==0;
486
487 if (dy > 0) {
488 /* if v2 is on top of v1, swap pointers */
489 const float (*temp)[4] = v1;
490 v1 = v2;
491 v2 = temp;
492 dx = -dx;
493 dy = -dy;
494
495 /* Otherwise shift planes appropriately */
496 if (will_draw_start != draw_start) {
497 y_offset_end = - y1diff + 0.5;
498 x_offset_end = y_offset_end * dxdy;
499 }
500 if (will_draw_end != draw_end) {
501 y_offset = - y2diff + 0.5;
502 x_offset = y_offset * dxdy;
503 }
504 }
505 else {
506 /* Otherwise shift planes appropriately */
507 if (will_draw_start != draw_start) {
508 y_offset = - y1diff - 0.5;
509 x_offset = y_offset * dxdy;
510
511 }
512 if (will_draw_end != draw_end) {
513 y_offset_end = - y2diff - 0.5;
514 x_offset_end = y_offset_end * dxdy;
515 }
516 }
517
518 /* x/y positions in fixed point */
519 x[0] = subpixel_snap(v1[0][0] + x_offset - setup->pixel_offset) - fixed_width/2;
520 x[1] = subpixel_snap(v2[0][0] + x_offset_end - setup->pixel_offset) - fixed_width/2;
521 x[2] = subpixel_snap(v2[0][0] + x_offset_end - setup->pixel_offset) + fixed_width/2;
522 x[3] = subpixel_snap(v1[0][0] + x_offset - setup->pixel_offset) + fixed_width/2;
523
524 y[0] = subpixel_snap(v1[0][1] + y_offset - setup->pixel_offset);
525 y[1] = subpixel_snap(v2[0][1] + y_offset_end - setup->pixel_offset);
526 y[2] = subpixel_snap(v2[0][1] + y_offset_end - setup->pixel_offset);
527 y[3] = subpixel_snap(v1[0][1] + y_offset - setup->pixel_offset);
528 }
529
530
531
532 LP_COUNT(nr_tris);
533
534
535 /* Bounding rectangle (in pixels) */
536 {
537 /* Yes this is necessary to accurately calculate bounding boxes
538 * with the two fill-conventions we support. GL (normally) ends
539 * up needing a bottom-left fill convention, which requires
540 * slightly different rounding.
541 */
542 int adj = (setup->pixel_offset != 0) ? 1 : 0;
543
544 bbox.x0 = (MIN4(x[0], x[1], x[2], x[3]) + (FIXED_ONE-1)) >> FIXED_ORDER;
545 bbox.x1 = (MAX4(x[0], x[1], x[2], x[3]) + (FIXED_ONE-1)) >> FIXED_ORDER;
546 bbox.y0 = (MIN4(y[0], y[1], y[2], y[3]) + (FIXED_ONE-1) + adj) >> FIXED_ORDER;
547 bbox.y1 = (MAX4(y[0], y[1], y[2], y[3]) + (FIXED_ONE-1) + adj) >> FIXED_ORDER;
548
549 /* Inclusive coordinates:
550 */
551 bbox.x1--;
552 bbox.y1--;
553 }
554
555 if (bbox.x1 < bbox.x0 ||
556 bbox.y1 < bbox.y0) {
557 if (0) debug_printf("empty bounding box\n");
558 LP_COUNT(nr_culled_tris);
559 return TRUE;
560 }
561
562 if (!u_rect_test_intersection(&setup->draw_region, &bbox)) {
563 if (0) debug_printf("offscreen\n");
564 LP_COUNT(nr_culled_tris);
565 return TRUE;
566 }
567
568 u_rect_find_intersection(&setup->draw_region, &bbox);
569
570 line = lp_setup_alloc_triangle(scene,
571 setup->fs.nr_inputs,
572 nr_planes,
573 &tri_bytes);
574 if (!line)
575 return FALSE;
576
577 #ifdef DEBUG
578 line->v[0][0] = v1[0][0];
579 line->v[1][0] = v2[0][0];
580 line->v[0][1] = v1[0][1];
581 line->v[1][1] = v2[0][1];
582 #endif
583
584 /* calculate the deltas */
585 plane = GET_PLANES(line);
586 plane[0].dcdy = x[0] - x[1];
587 plane[1].dcdy = x[1] - x[2];
588 plane[2].dcdy = x[2] - x[3];
589 plane[3].dcdy = x[3] - x[0];
590
591 plane[0].dcdx = y[0] - y[1];
592 plane[1].dcdx = y[1] - y[2];
593 plane[2].dcdx = y[2] - y[3];
594 plane[3].dcdx = y[3] - y[0];
595
596
597 /* Setup parameter interpolants:
598 */
599 info.a0 = GET_A0(&line->inputs);
600 info.dadx = GET_DADX(&line->inputs);
601 info.dady = GET_DADY(&line->inputs);
602 setup_line_coefficients(setup, &info);
603
604 line->inputs.frontfacing = TRUE;
605 line->inputs.disable = FALSE;
606 line->inputs.opaque = FALSE;
607
608 for (i = 0; i < 4; i++) {
609
610 /* half-edge constants, will be interated over the whole render
611 * target.
612 */
613 plane[i].c = plane[i].dcdx * x[i] - plane[i].dcdy * y[i];
614
615
616 /* correct for top-left vs. bottom-left fill convention.
617 *
618 * note that we're overloading gl_rasterization_rules to mean
619 * both (0.5,0.5) pixel centers *and* bottom-left filling
620 * convention.
621 *
622 * GL actually has a top-left filling convention, but GL's
623 * notion of "top" differs from gallium's...
624 *
625 * Also, sometimes (in FBO cases) GL will render upside down
626 * to its usual method, in which case it will probably want
627 * to use the opposite, top-left convention.
628 */
629 if (plane[i].dcdx < 0) {
630 /* both fill conventions want this - adjust for left edges */
631 plane[i].c++;
632 }
633 else if (plane[i].dcdx == 0) {
634 if (setup->pixel_offset == 0) {
635 /* correct for top-left fill convention:
636 */
637 if (plane[i].dcdy > 0) plane[i].c++;
638 }
639 else {
640 /* correct for bottom-left fill convention:
641 */
642 if (plane[i].dcdy < 0) plane[i].c++;
643 }
644 }
645
646 plane[i].dcdx *= FIXED_ONE;
647 plane[i].dcdy *= FIXED_ONE;
648
649 /* find trivial reject offsets for each edge for a single-pixel
650 * sized block. These will be scaled up at each recursive level to
651 * match the active blocksize. Scaling in this way works best if
652 * the blocks are square.
653 */
654 plane[i].eo = 0;
655 if (plane[i].dcdx < 0) plane[i].eo -= plane[i].dcdx;
656 if (plane[i].dcdy > 0) plane[i].eo += plane[i].dcdy;
657
658 /* Calculate trivial accept offsets from the above.
659 */
660 plane[i].ei = plane[i].dcdy - plane[i].dcdx - plane[i].eo;
661 }
662
663
664 /*
665 * When rasterizing scissored tris, use the intersection of the
666 * triangle bounding box and the scissor rect to generate the
667 * scissor planes.
668 *
669 * This permits us to cut off the triangle "tails" that are present
670 * in the intermediate recursive levels caused when two of the
671 * triangles edges don't diverge quickly enough to trivially reject
672 * exterior blocks from the triangle.
673 *
674 * It's not really clear if it's worth worrying about these tails,
675 * but since we generate the planes for each scissored tri, it's
676 * free to trim them in this case.
677 *
678 * Note that otherwise, the scissor planes only vary in 'C' value,
679 * and even then only on state-changes. Could alternatively store
680 * these planes elsewhere.
681 */
682 if (nr_planes == 8) {
683 plane[4].dcdx = -1;
684 plane[4].dcdy = 0;
685 plane[4].c = 1-bbox.x0;
686 plane[4].ei = 0;
687 plane[4].eo = 1;
688
689 plane[5].dcdx = 1;
690 plane[5].dcdy = 0;
691 plane[5].c = bbox.x1+1;
692 plane[5].ei = -1;
693 plane[5].eo = 0;
694
695 plane[6].dcdx = 0;
696 plane[6].dcdy = 1;
697 plane[6].c = 1-bbox.y0;
698 plane[6].ei = 0;
699 plane[6].eo = 1;
700
701 plane[7].dcdx = 0;
702 plane[7].dcdy = -1;
703 plane[7].c = bbox.y1+1;
704 plane[7].ei = -1;
705 plane[7].eo = 0;
706 }
707
708 return lp_setup_bin_triangle(setup, line, &bbox, nr_planes);
709 }
710
711
712 static void lp_setup_line( struct lp_setup_context *setup,
713 const float (*v0)[4],
714 const float (*v1)[4] )
715 {
716 if (!try_setup_line( setup, v0, v1 ))
717 {
718 if (!lp_setup_flush_and_restart(setup))
719 return;
720
721 if (!try_setup_line( setup, v0, v1 ))
722 return;
723 }
724 }
725
726
727 void lp_setup_choose_line( struct lp_setup_context *setup )
728 {
729 setup->line = lp_setup_line;
730 }
731
732