1 /**************************************************************************
3 * Copyright 2007 VMware, Inc.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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 VMWARE 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.
26 **************************************************************************/
29 * \brief Primitive rasterization/rendering (points, lines, triangles)
31 * \author Keith Whitwell <keithw@vmware.com>
35 #include "sp_context.h"
37 #include "sp_quad_pipe.h"
40 #include "draw/draw_context.h"
41 #include "draw/draw_vertex.h"
42 #include "pipe/p_shader_tokens.h"
43 #include "util/u_math.h"
44 #include "util/u_memory.h"
55 float dx
; /**< X(v1) - X(v0), used only during setup */
56 float dy
; /**< Y(v1) - Y(v0), used only during setup */
57 float dxdy
; /**< dx/dy */
58 float sx
, sy
; /**< first sample point coord */
59 int lines
; /**< number of lines on this edge */
64 * Max number of quads (2x2 pixel blocks) to process per batch.
65 * This can't be arbitrarily increased since we depend on some 32-bit
66 * bitmasks (two bits per quad).
72 * Triangle setup info.
73 * Also used for line drawing (taking some liberties).
75 struct setup_context
{
76 struct softpipe_context
*softpipe
;
78 /* Vertices are just an array of floats making up each attribute in
79 * turn. Currently fixed at 4 floats, but should change in time.
80 * Codegen will help cope with this.
82 const float (*vmax
)[4];
83 const float (*vmid
)[4];
84 const float (*vmin
)[4];
85 const float (*vprovoke
)[4];
97 struct quad_header quad
[MAX_QUADS
];
98 struct quad_header
*quad_ptrs
[MAX_QUADS
];
101 struct tgsi_interp_coef coef
[PIPE_MAX_SHADER_INPUTS
];
102 struct tgsi_interp_coef posCoef
; /* For Z, W */
105 int left
[2]; /**< [0] = row0, [1] = row1 */
111 uint numFragsEmitted
; /**< per primitive */
112 uint numFragsWritten
; /**< per primitive */
115 unsigned cull_face
; /* which faces cull */
116 unsigned nr_vertex_attrs
;
126 * Clip setup->quad against the scissor/surface bounds.
129 quad_clip(struct setup_context
*setup
, struct quad_header
*quad
)
131 unsigned viewport_index
= quad
[0].input
.viewport_index
;
132 const struct pipe_scissor_state
*cliprect
= &setup
->softpipe
->cliprect
[viewport_index
];
133 const int minx
= (int) cliprect
->minx
;
134 const int maxx
= (int) cliprect
->maxx
;
135 const int miny
= (int) cliprect
->miny
;
136 const int maxy
= (int) cliprect
->maxy
;
138 if (quad
->input
.x0
>= maxx
||
139 quad
->input
.y0
>= maxy
||
140 quad
->input
.x0
+ 1 < minx
||
141 quad
->input
.y0
+ 1 < miny
) {
142 /* totally clipped */
143 quad
->inout
.mask
= 0x0;
146 if (quad
->input
.x0
< minx
)
147 quad
->inout
.mask
&= (MASK_BOTTOM_RIGHT
| MASK_TOP_RIGHT
);
148 if (quad
->input
.y0
< miny
)
149 quad
->inout
.mask
&= (MASK_BOTTOM_LEFT
| MASK_BOTTOM_RIGHT
);
150 if (quad
->input
.x0
== maxx
- 1)
151 quad
->inout
.mask
&= (MASK_BOTTOM_LEFT
| MASK_TOP_LEFT
);
152 if (quad
->input
.y0
== maxy
- 1)
153 quad
->inout
.mask
&= (MASK_TOP_LEFT
| MASK_TOP_RIGHT
);
158 * Emit a quad (pass to next stage) with clipping.
161 clip_emit_quad(struct setup_context
*setup
, struct quad_header
*quad
)
163 quad_clip(setup
, quad
);
165 if (quad
->inout
.mask
) {
166 struct softpipe_context
*sp
= setup
->softpipe
;
169 setup
->numFragsEmitted
+= util_bitcount(quad
->inout
.mask
);
172 sp
->quad
.first
->run( sp
->quad
.first
, &quad
, 1 );
179 * Given an X or Y coordinate, return the block/quad coordinate that it
197 * Render a horizontal span of quads
200 flush_spans(struct setup_context
*setup
)
202 const int step
= MAX_QUADS
;
203 const int xleft0
= setup
->span
.left
[0];
204 const int xleft1
= setup
->span
.left
[1];
205 const int xright0
= setup
->span
.right
[0];
206 const int xright1
= setup
->span
.right
[1];
207 struct quad_stage
*pipe
= setup
->softpipe
->quad
.first
;
209 const int minleft
= block_x(MIN2(xleft0
, xleft1
));
210 const int maxright
= MAX2(xright0
, xright1
);
213 /* process quads in horizontal chunks of 16 */
214 for (x
= minleft
; x
< maxright
; x
+= step
) {
215 unsigned skip_left0
= CLAMP(xleft0
- x
, 0, step
);
216 unsigned skip_left1
= CLAMP(xleft1
- x
, 0, step
);
217 unsigned skip_right0
= CLAMP(x
+ step
- xright0
, 0, step
);
218 unsigned skip_right1
= CLAMP(x
+ step
- xright1
, 0, step
);
222 unsigned skipmask_left0
= (1U << skip_left0
) - 1U;
223 unsigned skipmask_left1
= (1U << skip_left1
) - 1U;
225 /* These calculations fail when step == 32 and skip_right == 0.
227 unsigned skipmask_right0
= ~0U << (unsigned)(step
- skip_right0
);
228 unsigned skipmask_right1
= ~0U << (unsigned)(step
- skip_right1
);
230 unsigned mask0
= ~skipmask_left0
& ~skipmask_right0
;
231 unsigned mask1
= ~skipmask_left1
& ~skipmask_right1
;
235 unsigned quadmask
= (mask0
& 3) | ((mask1
& 3) << 2);
237 setup
->quad
[q
].input
.x0
= lx
;
238 setup
->quad
[q
].input
.y0
= setup
->span
.y
;
239 setup
->quad
[q
].input
.facing
= setup
->facing
;
240 setup
->quad
[q
].inout
.mask
= quadmask
;
241 setup
->quad_ptrs
[q
] = &setup
->quad
[q
];
244 setup
->numFragsEmitted
+= util_bitcount(quadmask
);
250 } while (mask0
| mask1
);
252 pipe
->run( pipe
, setup
->quad_ptrs
, q
);
258 setup
->span
.right
[0] = 0;
259 setup
->span
.right
[1] = 0;
260 setup
->span
.left
[0] = 1000000; /* greater than right[0] */
261 setup
->span
.left
[1] = 1000000; /* greater than right[1] */
267 print_vertex(const struct setup_context
*setup
,
271 debug_printf(" Vertex: (%p)\n", (void *) v
);
272 for (i
= 0; i
< setup
->nr_vertex_attrs
; i
++) {
273 debug_printf(" %d: %f %f %f %f\n", i
,
274 v
[i
][0], v
[i
][1], v
[i
][2], v
[i
][3]);
275 if (util_is_inf_or_nan(v
[i
][0])) {
276 debug_printf(" NaN!\n");
284 * Sort the vertices from top to bottom order, setting up the triangle
285 * edge fields (ebot, emaj, etop).
286 * \return FALSE if coords are inf/nan (cull the tri), TRUE otherwise
289 setup_sort_vertices(struct setup_context
*setup
,
291 const float (*v0
)[4],
292 const float (*v1
)[4],
293 const float (*v2
)[4])
295 if (setup
->softpipe
->rasterizer
->flatshade_first
)
296 setup
->vprovoke
= v0
;
298 setup
->vprovoke
= v2
;
300 /* determine bottom to top order of vertices */
347 setup
->ebot
.dx
= setup
->vmid
[0][0] - setup
->vmin
[0][0];
348 setup
->ebot
.dy
= setup
->vmid
[0][1] - setup
->vmin
[0][1];
349 setup
->emaj
.dx
= setup
->vmax
[0][0] - setup
->vmin
[0][0];
350 setup
->emaj
.dy
= setup
->vmax
[0][1] - setup
->vmin
[0][1];
351 setup
->etop
.dx
= setup
->vmax
[0][0] - setup
->vmid
[0][0];
352 setup
->etop
.dy
= setup
->vmax
[0][1] - setup
->vmid
[0][1];
355 * Compute triangle's area. Use 1/area to compute partial
356 * derivatives of attributes later.
358 * The area will be the same as prim->det, but the sign may be
359 * different depending on how the vertices get sorted above.
361 * To determine whether the primitive is front or back facing we
362 * use the prim->det value because its sign is correct.
365 const float area
= (setup
->emaj
.dx
* setup
->ebot
.dy
-
366 setup
->ebot
.dx
* setup
->emaj
.dy
);
368 setup
->oneoverarea
= 1.0f
/ area
;
371 debug_printf("%s one-over-area %f area %f det %f\n",
372 __FUNCTION__, setup->oneoverarea, area, det );
374 if (util_is_inf_or_nan(setup
->oneoverarea
))
378 /* We need to know if this is a front or back-facing triangle for:
379 * - the GLSL gl_FrontFacing fragment attribute (bool)
380 * - two-sided stencil test
381 * 0 = front-facing, 1 = back-facing
385 (setup
->softpipe
->rasterizer
->front_ccw
));
388 unsigned face
= setup
->facing
== 0 ? PIPE_FACE_FRONT
: PIPE_FACE_BACK
;
390 if (face
& setup
->cull_face
)
395 /* Prepare pixel offset for rasterisation:
396 * - pixel center (0.5, 0.5) for GL, or
397 * - assume (0.0, 0.0) for other APIs.
399 if (setup
->softpipe
->rasterizer
->half_pixel_center
) {
400 setup
->pixel_offset
= 0.5f
;
402 setup
->pixel_offset
= 0.0f
;
409 /* Apply cylindrical wrapping to v0, v1, v2 coordinates, if enabled.
410 * Input coordinates must be in [0, 1] range, otherwise results are undefined.
411 * Some combinations of coordinates produce invalid results,
412 * but this behaviour is acceptable.
415 tri_apply_cylindrical_wrap(float v0
,
418 uint cylindrical_wrap
,
421 if (cylindrical_wrap
) {
428 else if (delta
< -0.5f
) {
436 else if (delta
< -0.5f
) {
444 else if (delta
< -0.5f
) {
456 * Compute a0 for a constant-valued coefficient (GL_FLAT shading).
457 * The value value comes from vertex[slot][i].
458 * The result will be put into setup->coef[slot].a0[i].
459 * \param slot which attribute slot
460 * \param i which component of the slot (0..3)
463 const_coeff(struct setup_context
*setup
,
464 struct tgsi_interp_coef
*coef
,
465 uint vertSlot
, uint i
)
472 /* need provoking vertex info!
474 coef
->a0
[i
] = setup
->vprovoke
[vertSlot
][i
];
479 * Compute a0, dadx and dady for a linearly interpolated coefficient,
481 * v[0], v[1] and v[2] are vmin, vmid and vmax, respectively.
484 tri_linear_coeff(struct setup_context
*setup
,
485 struct tgsi_interp_coef
*coef
,
489 float botda
= v
[1] - v
[0];
490 float majda
= v
[2] - v
[0];
491 float a
= setup
->ebot
.dy
* majda
- botda
* setup
->emaj
.dy
;
492 float b
= setup
->emaj
.dx
* botda
- majda
* setup
->ebot
.dx
;
493 float dadx
= a
* setup
->oneoverarea
;
494 float dady
= b
* setup
->oneoverarea
;
498 coef
->dadx
[i
] = dadx
;
499 coef
->dady
[i
] = dady
;
501 /* calculate a0 as the value which would be sampled for the
502 * fragment at (0,0), taking into account that we want to sample at
503 * pixel centers, in other words (pixel_offset, pixel_offset).
505 * this is neat but unfortunately not a good way to do things for
506 * triangles with very large values of dadx or dady as it will
507 * result in the subtraction and re-addition from a0 of a very
508 * large number, which means we'll end up loosing a lot of the
509 * fractional bits and precision from a0. the way to fix this is
510 * to define a0 as the sample at a pixel center somewhere near vmin
511 * instead - i'll switch to this later.
513 coef
->a0
[i
] = (v
[0] -
514 (dadx
* (setup
->vmin
[0][0] - setup
->pixel_offset
) +
515 dady
* (setup
->vmin
[0][1] - setup
->pixel_offset
)));
520 * Compute a0, dadx and dady for a perspective-corrected interpolant,
522 * We basically multiply the vertex value by 1/w before computing
523 * the plane coefficients (a0, dadx, dady).
524 * Later, when we compute the value at a particular fragment position we'll
525 * divide the interpolated value by the interpolated W at that fragment.
526 * v[0], v[1] and v[2] are vmin, vmid and vmax, respectively.
529 tri_persp_coeff(struct setup_context
*setup
,
530 struct tgsi_interp_coef
*coef
,
534 /* premultiply by 1/w (v[0][3] is always W):
536 float mina
= v
[0] * setup
->vmin
[0][3];
537 float mida
= v
[1] * setup
->vmid
[0][3];
538 float maxa
= v
[2] * setup
->vmax
[0][3];
539 float botda
= mida
- mina
;
540 float majda
= maxa
- mina
;
541 float a
= setup
->ebot
.dy
* majda
- botda
* setup
->emaj
.dy
;
542 float b
= setup
->emaj
.dx
* botda
- majda
* setup
->ebot
.dx
;
543 float dadx
= a
* setup
->oneoverarea
;
544 float dady
= b
* setup
->oneoverarea
;
548 coef
->dadx
[i
] = dadx
;
549 coef
->dady
[i
] = dady
;
550 coef
->a0
[i
] = (mina
-
551 (dadx
* (setup
->vmin
[0][0] - setup
->pixel_offset
) +
552 dady
* (setup
->vmin
[0][1] - setup
->pixel_offset
)));
557 * Special coefficient setup for gl_FragCoord.
558 * X and Y are trivial, though Y may have to be inverted for OpenGL.
559 * Z and W are copied from posCoef which should have already been computed.
560 * We could do a bit less work if we'd examine gl_FragCoord's swizzle mask.
563 setup_fragcoord_coeff(struct setup_context
*setup
, uint slot
)
565 const struct tgsi_shader_info
*fsInfo
= &setup
->softpipe
->fs_variant
->info
;
566 boolean origin_lower_left
=
567 fsInfo
->properties
[TGSI_PROPERTY_FS_COORD_ORIGIN
];
568 boolean pixel_center_integer
=
569 fsInfo
->properties
[TGSI_PROPERTY_FS_COORD_PIXEL_CENTER
];
572 setup
->coef
[slot
].a0
[0] = pixel_center_integer
? 0.0f
: 0.5f
;
573 setup
->coef
[slot
].dadx
[0] = 1.0f
;
574 setup
->coef
[slot
].dady
[0] = 0.0f
;
576 setup
->coef
[slot
].a0
[1] =
577 (origin_lower_left
? setup
->softpipe
->framebuffer
.height
-1 : 0)
578 + (pixel_center_integer
? 0.0f
: 0.5f
);
579 setup
->coef
[slot
].dadx
[1] = 0.0f
;
580 setup
->coef
[slot
].dady
[1] = origin_lower_left
? -1.0f
: 1.0f
;
582 setup
->coef
[slot
].a0
[2] = setup
->posCoef
.a0
[2];
583 setup
->coef
[slot
].dadx
[2] = setup
->posCoef
.dadx
[2];
584 setup
->coef
[slot
].dady
[2] = setup
->posCoef
.dady
[2];
586 setup
->coef
[slot
].a0
[3] = setup
->posCoef
.a0
[3];
587 setup
->coef
[slot
].dadx
[3] = setup
->posCoef
.dadx
[3];
588 setup
->coef
[slot
].dady
[3] = setup
->posCoef
.dady
[3];
594 * Compute the setup->coef[] array dadx, dady, a0 values.
595 * Must be called after setup->vmin,vmid,vmax,vprovoke are initialized.
598 setup_tri_coefficients(struct setup_context
*setup
)
600 struct softpipe_context
*softpipe
= setup
->softpipe
;
601 const struct tgsi_shader_info
*fsInfo
= &setup
->softpipe
->fs_variant
->info
;
602 const struct vertex_info
*vinfo
= softpipe_get_vertex_info(softpipe
);
606 /* z and w are done by linear interpolation:
608 v
[0] = setup
->vmin
[0][2];
609 v
[1] = setup
->vmid
[0][2];
610 v
[2] = setup
->vmax
[0][2];
611 tri_linear_coeff(setup
, &setup
->posCoef
, 2, v
);
613 v
[0] = setup
->vmin
[0][3];
614 v
[1] = setup
->vmid
[0][3];
615 v
[2] = setup
->vmax
[0][3];
616 tri_linear_coeff(setup
, &setup
->posCoef
, 3, v
);
618 /* setup interpolation for all the remaining attributes:
620 for (fragSlot
= 0; fragSlot
< fsInfo
->num_inputs
; fragSlot
++) {
621 const uint vertSlot
= vinfo
->attrib
[fragSlot
].src_index
;
624 switch (vinfo
->attrib
[fragSlot
].interp_mode
) {
625 case INTERP_CONSTANT
:
626 for (j
= 0; j
< TGSI_NUM_CHANNELS
; j
++)
627 const_coeff(setup
, &setup
->coef
[fragSlot
], vertSlot
, j
);
630 for (j
= 0; j
< TGSI_NUM_CHANNELS
; j
++) {
631 tri_apply_cylindrical_wrap(setup
->vmin
[vertSlot
][j
],
632 setup
->vmid
[vertSlot
][j
],
633 setup
->vmax
[vertSlot
][j
],
634 fsInfo
->input_cylindrical_wrap
[fragSlot
] & (1 << j
),
636 tri_linear_coeff(setup
, &setup
->coef
[fragSlot
], j
, v
);
639 case INTERP_PERSPECTIVE
:
640 for (j
= 0; j
< TGSI_NUM_CHANNELS
; j
++) {
641 tri_apply_cylindrical_wrap(setup
->vmin
[vertSlot
][j
],
642 setup
->vmid
[vertSlot
][j
],
643 setup
->vmax
[vertSlot
][j
],
644 fsInfo
->input_cylindrical_wrap
[fragSlot
] & (1 << j
),
646 tri_persp_coeff(setup
, &setup
->coef
[fragSlot
], j
, v
);
650 setup_fragcoord_coeff(setup
, fragSlot
);
656 if (fsInfo
->input_semantic_name
[fragSlot
] == TGSI_SEMANTIC_FACE
) {
657 /* convert 0 to 1.0 and 1 to -1.0 */
658 setup
->coef
[fragSlot
].a0
[0] = setup
->facing
* -2.0f
+ 1.0f
;
659 setup
->coef
[fragSlot
].dadx
[0] = 0.0;
660 setup
->coef
[fragSlot
].dady
[0] = 0.0;
664 for (j
= 0; j
< TGSI_NUM_CHANNELS
; j
++) {
665 debug_printf("attr[%d].%c: a0:%f dx:%f dy:%f\n",
667 setup
->coef
[fragSlot
].a0
[j
],
668 setup
->coef
[fragSlot
].dadx
[j
],
669 setup
->coef
[fragSlot
].dady
[j
]);
677 setup_tri_edges(struct setup_context
*setup
)
679 float vmin_x
= setup
->vmin
[0][0] + setup
->pixel_offset
;
680 float vmid_x
= setup
->vmid
[0][0] + setup
->pixel_offset
;
682 float vmin_y
= setup
->vmin
[0][1] - setup
->pixel_offset
;
683 float vmid_y
= setup
->vmid
[0][1] - setup
->pixel_offset
;
684 float vmax_y
= setup
->vmax
[0][1] - setup
->pixel_offset
;
686 setup
->emaj
.sy
= ceilf(vmin_y
);
687 setup
->emaj
.lines
= (int) ceilf(vmax_y
- setup
->emaj
.sy
);
688 setup
->emaj
.dxdy
= setup
->emaj
.dy
? setup
->emaj
.dx
/ setup
->emaj
.dy
: .0f
;
689 setup
->emaj
.sx
= vmin_x
+ (setup
->emaj
.sy
- vmin_y
) * setup
->emaj
.dxdy
;
691 setup
->etop
.sy
= ceilf(vmid_y
);
692 setup
->etop
.lines
= (int) ceilf(vmax_y
- setup
->etop
.sy
);
693 setup
->etop
.dxdy
= setup
->etop
.dy
? setup
->etop
.dx
/ setup
->etop
.dy
: .0f
;
694 setup
->etop
.sx
= vmid_x
+ (setup
->etop
.sy
- vmid_y
) * setup
->etop
.dxdy
;
696 setup
->ebot
.sy
= ceilf(vmin_y
);
697 setup
->ebot
.lines
= (int) ceilf(vmid_y
- setup
->ebot
.sy
);
698 setup
->ebot
.dxdy
= setup
->ebot
.dy
? setup
->ebot
.dx
/ setup
->ebot
.dy
: .0f
;
699 setup
->ebot
.sx
= vmin_x
+ (setup
->ebot
.sy
- vmin_y
) * setup
->ebot
.dxdy
;
704 * Render the upper or lower half of a triangle.
705 * Scissoring/cliprect is applied here too.
708 subtriangle(struct setup_context
*setup
,
712 unsigned viewport_index
)
714 const struct pipe_scissor_state
*cliprect
= &setup
->softpipe
->cliprect
[viewport_index
];
715 const int minx
= (int) cliprect
->minx
;
716 const int maxx
= (int) cliprect
->maxx
;
717 const int miny
= (int) cliprect
->miny
;
718 const int maxy
= (int) cliprect
->maxy
;
719 int y
, start_y
, finish_y
;
720 int sy
= (int)eleft
->sy
;
722 assert((int)eleft
->sy
== (int) eright
->sy
);
725 /* clip top/bottom */
730 finish_y
= sy
+ lines
;
738 debug_printf("%s %d %d\n", __FUNCTION__, start_y, finish_y);
741 for (y
= start_y
; y
< finish_y
; y
++) {
743 /* avoid accumulating adds as floats don't have the precision to
744 * accurately iterate large triangle edges that way. luckily we
745 * can just multiply these days.
747 * this is all drowned out by the attribute interpolation anyway.
749 int left
= (int)(eleft
->sx
+ y
* eleft
->dxdy
);
750 int right
= (int)(eright
->sx
+ y
* eright
->dxdy
);
752 /* clip left/right */
760 if (block(_y
) != setup
->span
.y
) {
762 setup
->span
.y
= block(_y
);
765 setup
->span
.left
[_y
&1] = left
;
766 setup
->span
.right
[_y
&1] = right
;
771 /* save the values so that emaj can be restarted:
773 eleft
->sx
+= lines
* eleft
->dxdy
;
774 eright
->sx
+= lines
* eright
->dxdy
;
781 * Recalculate prim's determinant. This is needed as we don't have
782 * get this information through the vbuf_render interface & we must
786 calc_det(const float (*v0
)[4],
787 const float (*v1
)[4],
788 const float (*v2
)[4])
790 /* edge vectors e = v0 - v2, f = v1 - v2 */
791 const float ex
= v0
[0][0] - v2
[0][0];
792 const float ey
= v0
[0][1] - v2
[0][1];
793 const float fx
= v1
[0][0] - v2
[0][0];
794 const float fy
= v1
[0][1] - v2
[0][1];
796 /* det = cross(e,f).z */
797 return ex
* fy
- ey
* fx
;
802 * Do setup for triangle rasterization, then render the triangle.
805 sp_setup_tri(struct setup_context
*setup
,
806 const float (*v0
)[4],
807 const float (*v1
)[4],
808 const float (*v2
)[4])
812 unsigned viewport_index
= 0;
814 debug_printf("Setup triangle:\n");
815 print_vertex(setup
, v0
);
816 print_vertex(setup
, v1
);
817 print_vertex(setup
, v2
);
820 if (setup
->softpipe
->no_rast
|| setup
->softpipe
->rasterizer
->rasterizer_discard
)
823 det
= calc_det(v0
, v1
, v2
);
825 debug_printf("%s\n", __FUNCTION__ );
829 setup
->numFragsEmitted
= 0;
830 setup
->numFragsWritten
= 0;
833 if (!setup_sort_vertices( setup
, det
, v0
, v1
, v2
))
836 setup_tri_coefficients( setup
);
837 setup_tri_edges( setup
);
839 assert(setup
->softpipe
->reduced_prim
== PIPE_PRIM_TRIANGLES
);
842 setup
->span
.right
[0] = 0;
843 setup
->span
.right
[1] = 0;
844 /* setup->span.z_mode = tri_z_mode( setup->ctx ); */
845 if (setup
->softpipe
->layer_slot
> 0) {
846 layer
= *(unsigned *)setup
->vprovoke
[setup
->softpipe
->layer_slot
];
847 layer
= MIN2(layer
, setup
->max_layer
);
849 setup
->quad
[0].input
.layer
= layer
;
851 if (setup
->softpipe
->viewport_index_slot
> 0) {
852 unsigned *udata
= (unsigned*)v0
[setup
->softpipe
->viewport_index_slot
];
853 viewport_index
= sp_clamp_viewport_idx(*udata
);
855 setup
->quad
[0].input
.viewport_index
= viewport_index
;
857 /* init_constant_attribs( setup ); */
859 if (setup
->oneoverarea
< 0.0) {
862 subtriangle(setup
, &setup
->emaj
, &setup
->ebot
, setup
->ebot
.lines
, viewport_index
);
863 subtriangle(setup
, &setup
->emaj
, &setup
->etop
, setup
->etop
.lines
, viewport_index
);
868 subtriangle(setup
, &setup
->ebot
, &setup
->emaj
, setup
->ebot
.lines
, viewport_index
);
869 subtriangle(setup
, &setup
->etop
, &setup
->emaj
, setup
->etop
.lines
, viewport_index
);
872 flush_spans( setup
);
874 if (setup
->softpipe
->active_statistics_queries
) {
875 setup
->softpipe
->pipeline_statistics
.c_primitives
++;
879 printf("Tri: %u frags emitted, %u written\n",
880 setup
->numFragsEmitted
,
881 setup
->numFragsWritten
);
886 /* Apply cylindrical wrapping to v0, v1 coordinates, if enabled.
887 * Input coordinates must be in [0, 1] range, otherwise results are undefined.
890 line_apply_cylindrical_wrap(float v0
,
892 uint cylindrical_wrap
,
895 if (cylindrical_wrap
) {
902 else if (delta
< -0.5f
) {
913 * Compute a0, dadx and dady for a linearly interpolated coefficient,
915 * v[0] and v[1] are vmin and vmax, respectively.
918 line_linear_coeff(const struct setup_context
*setup
,
919 struct tgsi_interp_coef
*coef
,
923 const float da
= v
[1] - v
[0];
924 const float dadx
= da
* setup
->emaj
.dx
* setup
->oneoverarea
;
925 const float dady
= da
* setup
->emaj
.dy
* setup
->oneoverarea
;
926 coef
->dadx
[i
] = dadx
;
927 coef
->dady
[i
] = dady
;
928 coef
->a0
[i
] = (v
[0] -
929 (dadx
* (setup
->vmin
[0][0] - setup
->pixel_offset
) +
930 dady
* (setup
->vmin
[0][1] - setup
->pixel_offset
)));
935 * Compute a0, dadx and dady for a perspective-corrected interpolant,
937 * v[0] and v[1] are vmin and vmax, respectively.
940 line_persp_coeff(const struct setup_context
*setup
,
941 struct tgsi_interp_coef
*coef
,
945 const float a0
= v
[0] * setup
->vmin
[0][3];
946 const float a1
= v
[1] * setup
->vmax
[0][3];
947 const float da
= a1
- a0
;
948 const float dadx
= da
* setup
->emaj
.dx
* setup
->oneoverarea
;
949 const float dady
= da
* setup
->emaj
.dy
* setup
->oneoverarea
;
950 coef
->dadx
[i
] = dadx
;
951 coef
->dady
[i
] = dady
;
953 (dadx
* (setup
->vmin
[0][0] - setup
->pixel_offset
) +
954 dady
* (setup
->vmin
[0][1] - setup
->pixel_offset
)));
959 * Compute the setup->coef[] array dadx, dady, a0 values.
960 * Must be called after setup->vmin,vmax are initialized.
963 setup_line_coefficients(struct setup_context
*setup
,
964 const float (*v0
)[4],
965 const float (*v1
)[4])
967 struct softpipe_context
*softpipe
= setup
->softpipe
;
968 const struct tgsi_shader_info
*fsInfo
= &setup
->softpipe
->fs_variant
->info
;
969 const struct vertex_info
*vinfo
= softpipe_get_vertex_info(softpipe
);
974 /* use setup->vmin, vmax to point to vertices */
975 if (softpipe
->rasterizer
->flatshade_first
)
976 setup
->vprovoke
= v0
;
978 setup
->vprovoke
= v1
;
982 setup
->emaj
.dx
= setup
->vmax
[0][0] - setup
->vmin
[0][0];
983 setup
->emaj
.dy
= setup
->vmax
[0][1] - setup
->vmin
[0][1];
985 /* NOTE: this is not really area but something proportional to it */
986 area
= setup
->emaj
.dx
* setup
->emaj
.dx
+ setup
->emaj
.dy
* setup
->emaj
.dy
;
987 if (area
== 0.0f
|| util_is_inf_or_nan(area
))
989 setup
->oneoverarea
= 1.0f
/ area
;
991 /* z and w are done by linear interpolation:
993 v
[0] = setup
->vmin
[0][2];
994 v
[1] = setup
->vmax
[0][2];
995 line_linear_coeff(setup
, &setup
->posCoef
, 2, v
);
997 v
[0] = setup
->vmin
[0][3];
998 v
[1] = setup
->vmax
[0][3];
999 line_linear_coeff(setup
, &setup
->posCoef
, 3, v
);
1001 /* setup interpolation for all the remaining attributes:
1003 for (fragSlot
= 0; fragSlot
< fsInfo
->num_inputs
; fragSlot
++) {
1004 const uint vertSlot
= vinfo
->attrib
[fragSlot
].src_index
;
1007 switch (vinfo
->attrib
[fragSlot
].interp_mode
) {
1008 case INTERP_CONSTANT
:
1009 for (j
= 0; j
< TGSI_NUM_CHANNELS
; j
++)
1010 const_coeff(setup
, &setup
->coef
[fragSlot
], vertSlot
, j
);
1013 for (j
= 0; j
< TGSI_NUM_CHANNELS
; j
++) {
1014 line_apply_cylindrical_wrap(setup
->vmin
[vertSlot
][j
],
1015 setup
->vmax
[vertSlot
][j
],
1016 fsInfo
->input_cylindrical_wrap
[fragSlot
] & (1 << j
),
1018 line_linear_coeff(setup
, &setup
->coef
[fragSlot
], j
, v
);
1021 case INTERP_PERSPECTIVE
:
1022 for (j
= 0; j
< TGSI_NUM_CHANNELS
; j
++) {
1023 line_apply_cylindrical_wrap(setup
->vmin
[vertSlot
][j
],
1024 setup
->vmax
[vertSlot
][j
],
1025 fsInfo
->input_cylindrical_wrap
[fragSlot
] & (1 << j
),
1027 line_persp_coeff(setup
, &setup
->coef
[fragSlot
], j
, v
);
1031 setup_fragcoord_coeff(setup
, fragSlot
);
1037 if (fsInfo
->input_semantic_name
[fragSlot
] == TGSI_SEMANTIC_FACE
) {
1038 /* convert 0 to 1.0 and 1 to -1.0 */
1039 setup
->coef
[fragSlot
].a0
[0] = setup
->facing
* -2.0f
+ 1.0f
;
1040 setup
->coef
[fragSlot
].dadx
[0] = 0.0;
1041 setup
->coef
[fragSlot
].dady
[0] = 0.0;
1049 * Plot a pixel in a line segment.
1052 plot(struct setup_context
*setup
, int x
, int y
)
1054 const int iy
= y
& 1;
1055 const int ix
= x
& 1;
1056 const int quadX
= x
- ix
;
1057 const int quadY
= y
- iy
;
1058 const int mask
= (1 << ix
) << (2 * iy
);
1060 if (quadX
!= setup
->quad
[0].input
.x0
||
1061 quadY
!= setup
->quad
[0].input
.y0
)
1063 /* flush prev quad, start new quad */
1065 if (setup
->quad
[0].input
.x0
!= -1)
1066 clip_emit_quad(setup
, &setup
->quad
[0]);
1068 setup
->quad
[0].input
.x0
= quadX
;
1069 setup
->quad
[0].input
.y0
= quadY
;
1070 setup
->quad
[0].inout
.mask
= 0x0;
1073 setup
->quad
[0].inout
.mask
|= mask
;
1078 * Do setup for line rasterization, then render the line.
1079 * Single-pixel width, no stipple, etc. We rely on the 'draw' module
1080 * to handle stippling and wide lines.
1083 sp_setup_line(struct setup_context
*setup
,
1084 const float (*v0
)[4],
1085 const float (*v1
)[4])
1087 int x0
= (int) v0
[0][0];
1088 int x1
= (int) v1
[0][0];
1089 int y0
= (int) v0
[0][1];
1090 int y1
= (int) v1
[0][1];
1095 unsigned viewport_index
= 0;
1098 debug_printf("Setup line:\n");
1099 print_vertex(setup
, v0
);
1100 print_vertex(setup
, v1
);
1103 if (setup
->softpipe
->no_rast
|| setup
->softpipe
->rasterizer
->rasterizer_discard
)
1106 if (dx
== 0 && dy
== 0)
1109 if (!setup_line_coefficients(setup
, v0
, v1
))
1112 assert(v0
[0][0] < 1.0e9
);
1113 assert(v0
[0][1] < 1.0e9
);
1114 assert(v1
[0][0] < 1.0e9
);
1115 assert(v1
[0][1] < 1.0e9
);
1118 dx
= -dx
; /* make positive */
1126 dy
= -dy
; /* make positive */
1135 assert(setup
->softpipe
->reduced_prim
== PIPE_PRIM_LINES
);
1137 setup
->quad
[0].input
.x0
= setup
->quad
[0].input
.y0
= -1;
1138 setup
->quad
[0].inout
.mask
= 0x0;
1139 if (setup
->softpipe
->layer_slot
> 0) {
1140 layer
= *(unsigned *)setup
->vprovoke
[setup
->softpipe
->layer_slot
];
1141 layer
= MIN2(layer
, setup
->max_layer
);
1143 setup
->quad
[0].input
.layer
= layer
;
1145 if (setup
->softpipe
->viewport_index_slot
> 0) {
1146 unsigned *udata
= (unsigned*)setup
->vprovoke
[setup
->softpipe
->viewport_index_slot
];
1147 viewport_index
= sp_clamp_viewport_idx(*udata
);
1149 setup
->quad
[0].input
.viewport_index
= viewport_index
;
1151 /* XXX temporary: set coverage to 1.0 so the line appears
1152 * if AA mode happens to be enabled.
1154 setup
->quad
[0].input
.coverage
[0] =
1155 setup
->quad
[0].input
.coverage
[1] =
1156 setup
->quad
[0].input
.coverage
[2] =
1157 setup
->quad
[0].input
.coverage
[3] = 1.0;
1160 /*** X-major line ***/
1162 const int errorInc
= dy
+ dy
;
1163 int error
= errorInc
- dx
;
1164 const int errorDec
= error
- dx
;
1166 for (i
= 0; i
< dx
; i
++) {
1167 plot(setup
, x0
, y0
);
1180 /*** Y-major line ***/
1182 const int errorInc
= dx
+ dx
;
1183 int error
= errorInc
- dy
;
1184 const int errorDec
= error
- dy
;
1186 for (i
= 0; i
< dy
; i
++) {
1187 plot(setup
, x0
, y0
);
1200 /* draw final quad */
1201 if (setup
->quad
[0].inout
.mask
) {
1202 clip_emit_quad(setup
, &setup
->quad
[0]);
1208 point_persp_coeff(const struct setup_context
*setup
,
1209 const float (*vert
)[4],
1210 struct tgsi_interp_coef
*coef
,
1211 uint vertSlot
, uint i
)
1214 coef
->dadx
[i
] = 0.0F
;
1215 coef
->dady
[i
] = 0.0F
;
1216 coef
->a0
[i
] = vert
[vertSlot
][i
] * vert
[0][3];
1221 * Do setup for point rasterization, then render the point.
1222 * Round or square points...
1223 * XXX could optimize a lot for 1-pixel points.
1226 sp_setup_point(struct setup_context
*setup
,
1227 const float (*v0
)[4])
1229 struct softpipe_context
*softpipe
= setup
->softpipe
;
1230 const struct tgsi_shader_info
*fsInfo
= &setup
->softpipe
->fs_variant
->info
;
1231 const int sizeAttr
= setup
->softpipe
->psize_slot
;
1233 = sizeAttr
> 0 ? v0
[sizeAttr
][0]
1234 : setup
->softpipe
->rasterizer
->point_size
;
1235 const float halfSize
= 0.5F
* size
;
1236 const boolean round
= (boolean
) setup
->softpipe
->rasterizer
->point_smooth
;
1237 const float x
= v0
[0][0]; /* Note: data[0] is always position */
1238 const float y
= v0
[0][1];
1239 const struct vertex_info
*vinfo
= softpipe_get_vertex_info(softpipe
);
1242 unsigned viewport_index
= 0;
1244 debug_printf("Setup point:\n");
1245 print_vertex(setup
, v0
);
1248 if (setup
->softpipe
->no_rast
|| setup
->softpipe
->rasterizer
->rasterizer_discard
)
1251 assert(setup
->softpipe
->reduced_prim
== PIPE_PRIM_POINTS
);
1253 if (setup
->softpipe
->layer_slot
> 0) {
1254 layer
= *(unsigned *)v0
[setup
->softpipe
->layer_slot
];
1255 layer
= MIN2(layer
, setup
->max_layer
);
1257 setup
->quad
[0].input
.layer
= layer
;
1259 if (setup
->softpipe
->viewport_index_slot
> 0) {
1260 unsigned *udata
= (unsigned*)v0
[setup
->softpipe
->viewport_index_slot
];
1261 viewport_index
= sp_clamp_viewport_idx(*udata
);
1263 setup
->quad
[0].input
.viewport_index
= viewport_index
;
1265 /* For points, all interpolants are constant-valued.
1266 * However, for point sprites, we'll need to setup texcoords appropriately.
1267 * XXX: which coefficients are the texcoords???
1268 * We may do point sprites as textured quads...
1270 * KW: We don't know which coefficients are texcoords - ultimately
1271 * the choice of what interpolation mode to use for each attribute
1272 * should be determined by the fragment program, using
1273 * per-attribute declaration statements that include interpolation
1274 * mode as a parameter. So either the fragment program will have
1275 * to be adjusted for pointsprite vs normal point behaviour, or
1276 * otherwise a special interpolation mode will have to be defined
1277 * which matches the required behaviour for point sprites. But -
1278 * the latter is not a feature of normal hardware, and as such
1279 * probably should be ruled out on that basis.
1281 setup
->vprovoke
= v0
;
1284 const_coeff(setup
, &setup
->posCoef
, 0, 2);
1285 const_coeff(setup
, &setup
->posCoef
, 0, 3);
1287 for (fragSlot
= 0; fragSlot
< fsInfo
->num_inputs
; fragSlot
++) {
1288 const uint vertSlot
= vinfo
->attrib
[fragSlot
].src_index
;
1291 switch (vinfo
->attrib
[fragSlot
].interp_mode
) {
1292 case INTERP_CONSTANT
:
1295 for (j
= 0; j
< TGSI_NUM_CHANNELS
; j
++)
1296 const_coeff(setup
, &setup
->coef
[fragSlot
], vertSlot
, j
);
1298 case INTERP_PERSPECTIVE
:
1299 for (j
= 0; j
< TGSI_NUM_CHANNELS
; j
++)
1300 point_persp_coeff(setup
, setup
->vprovoke
,
1301 &setup
->coef
[fragSlot
], vertSlot
, j
);
1304 setup_fragcoord_coeff(setup
, fragSlot
);
1310 if (fsInfo
->input_semantic_name
[fragSlot
] == TGSI_SEMANTIC_FACE
) {
1311 /* convert 0 to 1.0 and 1 to -1.0 */
1312 setup
->coef
[fragSlot
].a0
[0] = setup
->facing
* -2.0f
+ 1.0f
;
1313 setup
->coef
[fragSlot
].dadx
[0] = 0.0;
1314 setup
->coef
[fragSlot
].dady
[0] = 0.0;
1319 if (halfSize
<= 0.5 && !round
) {
1320 /* special case for 1-pixel points */
1321 const int ix
= ((int) x
) & 1;
1322 const int iy
= ((int) y
) & 1;
1323 setup
->quad
[0].input
.x0
= (int) x
- ix
;
1324 setup
->quad
[0].input
.y0
= (int) y
- iy
;
1325 setup
->quad
[0].inout
.mask
= (1 << ix
) << (2 * iy
);
1326 clip_emit_quad(setup
, &setup
->quad
[0]);
1330 /* rounded points */
1331 const int ixmin
= block((int) (x
- halfSize
));
1332 const int ixmax
= block((int) (x
+ halfSize
));
1333 const int iymin
= block((int) (y
- halfSize
));
1334 const int iymax
= block((int) (y
+ halfSize
));
1335 const float rmin
= halfSize
- 0.7071F
; /* 0.7071 = sqrt(2)/2 */
1336 const float rmax
= halfSize
+ 0.7071F
;
1337 const float rmin2
= MAX2(0.0F
, rmin
* rmin
);
1338 const float rmax2
= rmax
* rmax
;
1339 const float cscale
= 1.0F
/ (rmax2
- rmin2
);
1342 for (iy
= iymin
; iy
<= iymax
; iy
+= 2) {
1343 for (ix
= ixmin
; ix
<= ixmax
; ix
+= 2) {
1344 float dx
, dy
, dist2
, cover
;
1346 setup
->quad
[0].inout
.mask
= 0x0;
1348 dx
= (ix
+ 0.5f
) - x
;
1349 dy
= (iy
+ 0.5f
) - y
;
1350 dist2
= dx
* dx
+ dy
* dy
;
1351 if (dist2
<= rmax2
) {
1352 cover
= 1.0F
- (dist2
- rmin2
) * cscale
;
1353 setup
->quad
[0].input
.coverage
[QUAD_TOP_LEFT
] = MIN2(cover
, 1.0f
);
1354 setup
->quad
[0].inout
.mask
|= MASK_TOP_LEFT
;
1357 dx
= (ix
+ 1.5f
) - x
;
1358 dy
= (iy
+ 0.5f
) - y
;
1359 dist2
= dx
* dx
+ dy
* dy
;
1360 if (dist2
<= rmax2
) {
1361 cover
= 1.0F
- (dist2
- rmin2
) * cscale
;
1362 setup
->quad
[0].input
.coverage
[QUAD_TOP_RIGHT
] = MIN2(cover
, 1.0f
);
1363 setup
->quad
[0].inout
.mask
|= MASK_TOP_RIGHT
;
1366 dx
= (ix
+ 0.5f
) - x
;
1367 dy
= (iy
+ 1.5f
) - y
;
1368 dist2
= dx
* dx
+ dy
* dy
;
1369 if (dist2
<= rmax2
) {
1370 cover
= 1.0F
- (dist2
- rmin2
) * cscale
;
1371 setup
->quad
[0].input
.coverage
[QUAD_BOTTOM_LEFT
] = MIN2(cover
, 1.0f
);
1372 setup
->quad
[0].inout
.mask
|= MASK_BOTTOM_LEFT
;
1375 dx
= (ix
+ 1.5f
) - x
;
1376 dy
= (iy
+ 1.5f
) - y
;
1377 dist2
= dx
* dx
+ dy
* dy
;
1378 if (dist2
<= rmax2
) {
1379 cover
= 1.0F
- (dist2
- rmin2
) * cscale
;
1380 setup
->quad
[0].input
.coverage
[QUAD_BOTTOM_RIGHT
] = MIN2(cover
, 1.0f
);
1381 setup
->quad
[0].inout
.mask
|= MASK_BOTTOM_RIGHT
;
1384 if (setup
->quad
[0].inout
.mask
) {
1385 setup
->quad
[0].input
.x0
= ix
;
1386 setup
->quad
[0].input
.y0
= iy
;
1387 clip_emit_quad(setup
, &setup
->quad
[0]);
1394 const int xmin
= (int) (x
+ 0.75 - halfSize
);
1395 const int ymin
= (int) (y
+ 0.25 - halfSize
);
1396 const int xmax
= xmin
+ (int) size
;
1397 const int ymax
= ymin
+ (int) size
;
1398 /* XXX could apply scissor to xmin,ymin,xmax,ymax now */
1399 const int ixmin
= block(xmin
);
1400 const int ixmax
= block(xmax
- 1);
1401 const int iymin
= block(ymin
);
1402 const int iymax
= block(ymax
- 1);
1406 debug_printf("(%f, %f) -> X:%d..%d Y:%d..%d\n", x, y, xmin, xmax,ymin,ymax);
1408 for (iy
= iymin
; iy
<= iymax
; iy
+= 2) {
1411 /* above the top edge */
1412 rowMask
&= (MASK_BOTTOM_LEFT
| MASK_BOTTOM_RIGHT
);
1414 if (iy
+ 1 >= ymax
) {
1415 /* below the bottom edge */
1416 rowMask
&= (MASK_TOP_LEFT
| MASK_TOP_RIGHT
);
1419 for (ix
= ixmin
; ix
<= ixmax
; ix
+= 2) {
1420 uint mask
= rowMask
;
1423 /* fragment is past left edge of point, turn off left bits */
1424 mask
&= (MASK_BOTTOM_RIGHT
| MASK_TOP_RIGHT
);
1426 if (ix
+ 1 >= xmax
) {
1427 /* past the right edge */
1428 mask
&= (MASK_BOTTOM_LEFT
| MASK_TOP_LEFT
);
1431 setup
->quad
[0].inout
.mask
= mask
;
1432 setup
->quad
[0].input
.x0
= ix
;
1433 setup
->quad
[0].input
.y0
= iy
;
1434 clip_emit_quad(setup
, &setup
->quad
[0]);
1443 * Called by vbuf code just before we start buffering primitives.
1446 sp_setup_prepare(struct setup_context
*setup
)
1448 struct softpipe_context
*sp
= setup
->softpipe
;
1450 unsigned max_layer
= ~0;
1452 softpipe_update_derived(sp
, sp
->reduced_api_prim
);
1455 /* Note: nr_attrs is only used for debugging (vertex printing) */
1456 setup
->nr_vertex_attrs
= draw_num_shader_outputs(sp
->draw
);
1459 * Determine how many layers the fb has (used for clamping layer value).
1460 * OpenGL (but not d3d10) permits different amount of layers per rt, however
1461 * results are undefined if layer exceeds the amount of layers of ANY
1462 * attachment hence don't need separate per cbuf and zsbuf max.
1464 for (i
= 0; i
< setup
->softpipe
->framebuffer
.nr_cbufs
; i
++) {
1465 struct pipe_surface
*cbuf
= setup
->softpipe
->framebuffer
.cbufs
[i
];
1467 max_layer
= MIN2(max_layer
,
1468 cbuf
->u
.tex
.last_layer
- cbuf
->u
.tex
.first_layer
);
1473 setup
->max_layer
= max_layer
;
1475 sp
->quad
.first
->begin( sp
->quad
.first
);
1477 if (sp
->reduced_api_prim
== PIPE_PRIM_TRIANGLES
&&
1478 sp
->rasterizer
->fill_front
== PIPE_POLYGON_MODE_FILL
&&
1479 sp
->rasterizer
->fill_back
== PIPE_POLYGON_MODE_FILL
) {
1480 /* we'll do culling */
1481 setup
->cull_face
= sp
->rasterizer
->cull_face
;
1484 /* 'draw' will do culling */
1485 setup
->cull_face
= PIPE_FACE_NONE
;
1491 sp_setup_destroy_context(struct setup_context
*setup
)
1498 * Create a new primitive setup/render stage.
1500 struct setup_context
*
1501 sp_setup_create_context(struct softpipe_context
*softpipe
)
1503 struct setup_context
*setup
= CALLOC_STRUCT(setup_context
);
1506 setup
->softpipe
= softpipe
;
1508 for (i
= 0; i
< MAX_QUADS
; i
++) {
1509 setup
->quad
[i
].coef
= setup
->coef
;
1510 setup
->quad
[i
].posCoef
= &setup
->posCoef
;
1513 setup
->span
.left
[0] = 1000000; /* greater than right[0] */
1514 setup
->span
.left
[1] = 1000000; /* greater than right[1] */