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 sp_setup_info
*sinfo
= &softpipe
->setup_info
;
606 assert(sinfo
->valid
);
608 /* z and w are done by linear interpolation:
610 v
[0] = setup
->vmin
[0][2];
611 v
[1] = setup
->vmid
[0][2];
612 v
[2] = setup
->vmax
[0][2];
613 tri_linear_coeff(setup
, &setup
->posCoef
, 2, v
);
615 v
[0] = setup
->vmin
[0][3];
616 v
[1] = setup
->vmid
[0][3];
617 v
[2] = setup
->vmax
[0][3];
618 tri_linear_coeff(setup
, &setup
->posCoef
, 3, v
);
620 /* setup interpolation for all the remaining attributes:
622 for (fragSlot
= 0; fragSlot
< fsInfo
->num_inputs
; fragSlot
++) {
623 const uint vertSlot
= sinfo
->attrib
[fragSlot
].src_index
;
626 switch (sinfo
->attrib
[fragSlot
].interp
) {
627 case INTERP_CONSTANT
:
628 for (j
= 0; j
< TGSI_NUM_CHANNELS
; j
++) {
629 const_coeff(setup
, &setup
->coef
[fragSlot
], vertSlot
, j
);
633 for (j
= 0; j
< TGSI_NUM_CHANNELS
; j
++) {
634 tri_apply_cylindrical_wrap(setup
->vmin
[vertSlot
][j
],
635 setup
->vmid
[vertSlot
][j
],
636 setup
->vmax
[vertSlot
][j
],
637 fsInfo
->input_cylindrical_wrap
[fragSlot
] & (1 << j
),
639 tri_linear_coeff(setup
, &setup
->coef
[fragSlot
], j
, v
);
642 case INTERP_PERSPECTIVE
:
643 for (j
= 0; j
< TGSI_NUM_CHANNELS
; j
++) {
644 tri_apply_cylindrical_wrap(setup
->vmin
[vertSlot
][j
],
645 setup
->vmid
[vertSlot
][j
],
646 setup
->vmax
[vertSlot
][j
],
647 fsInfo
->input_cylindrical_wrap
[fragSlot
] & (1 << j
),
649 tri_persp_coeff(setup
, &setup
->coef
[fragSlot
], j
, v
);
653 setup_fragcoord_coeff(setup
, fragSlot
);
659 if (fsInfo
->input_semantic_name
[fragSlot
] == TGSI_SEMANTIC_FACE
) {
660 /* convert 0 to 1.0 and 1 to -1.0 */
661 setup
->coef
[fragSlot
].a0
[0] = setup
->facing
* -2.0f
+ 1.0f
;
662 setup
->coef
[fragSlot
].dadx
[0] = 0.0;
663 setup
->coef
[fragSlot
].dady
[0] = 0.0;
667 for (j
= 0; j
< TGSI_NUM_CHANNELS
; j
++) {
668 debug_printf("attr[%d].%c: a0:%f dx:%f dy:%f\n",
670 setup
->coef
[fragSlot
].a0
[j
],
671 setup
->coef
[fragSlot
].dadx
[j
],
672 setup
->coef
[fragSlot
].dady
[j
]);
680 setup_tri_edges(struct setup_context
*setup
)
682 float vmin_x
= setup
->vmin
[0][0] + setup
->pixel_offset
;
683 float vmid_x
= setup
->vmid
[0][0] + setup
->pixel_offset
;
685 float vmin_y
= setup
->vmin
[0][1] - setup
->pixel_offset
;
686 float vmid_y
= setup
->vmid
[0][1] - setup
->pixel_offset
;
687 float vmax_y
= setup
->vmax
[0][1] - setup
->pixel_offset
;
689 setup
->emaj
.sy
= ceilf(vmin_y
);
690 setup
->emaj
.lines
= (int) ceilf(vmax_y
- setup
->emaj
.sy
);
691 setup
->emaj
.dxdy
= setup
->emaj
.dy
? setup
->emaj
.dx
/ setup
->emaj
.dy
: .0f
;
692 setup
->emaj
.sx
= vmin_x
+ (setup
->emaj
.sy
- vmin_y
) * setup
->emaj
.dxdy
;
694 setup
->etop
.sy
= ceilf(vmid_y
);
695 setup
->etop
.lines
= (int) ceilf(vmax_y
- setup
->etop
.sy
);
696 setup
->etop
.dxdy
= setup
->etop
.dy
? setup
->etop
.dx
/ setup
->etop
.dy
: .0f
;
697 setup
->etop
.sx
= vmid_x
+ (setup
->etop
.sy
- vmid_y
) * setup
->etop
.dxdy
;
699 setup
->ebot
.sy
= ceilf(vmin_y
);
700 setup
->ebot
.lines
= (int) ceilf(vmid_y
- setup
->ebot
.sy
);
701 setup
->ebot
.dxdy
= setup
->ebot
.dy
? setup
->ebot
.dx
/ setup
->ebot
.dy
: .0f
;
702 setup
->ebot
.sx
= vmin_x
+ (setup
->ebot
.sy
- vmin_y
) * setup
->ebot
.dxdy
;
707 * Render the upper or lower half of a triangle.
708 * Scissoring/cliprect is applied here too.
711 subtriangle(struct setup_context
*setup
,
715 unsigned viewport_index
)
717 const struct pipe_scissor_state
*cliprect
= &setup
->softpipe
->cliprect
[viewport_index
];
718 const int minx
= (int) cliprect
->minx
;
719 const int maxx
= (int) cliprect
->maxx
;
720 const int miny
= (int) cliprect
->miny
;
721 const int maxy
= (int) cliprect
->maxy
;
722 int y
, start_y
, finish_y
;
723 int sy
= (int)eleft
->sy
;
725 assert((int)eleft
->sy
== (int) eright
->sy
);
728 /* clip top/bottom */
733 finish_y
= sy
+ lines
;
741 debug_printf("%s %d %d\n", __FUNCTION__, start_y, finish_y);
744 for (y
= start_y
; y
< finish_y
; y
++) {
746 /* avoid accumulating adds as floats don't have the precision to
747 * accurately iterate large triangle edges that way. luckily we
748 * can just multiply these days.
750 * this is all drowned out by the attribute interpolation anyway.
752 int left
= (int)(eleft
->sx
+ y
* eleft
->dxdy
);
753 int right
= (int)(eright
->sx
+ y
* eright
->dxdy
);
755 /* clip left/right */
763 if (block(_y
) != setup
->span
.y
) {
765 setup
->span
.y
= block(_y
);
768 setup
->span
.left
[_y
&1] = left
;
769 setup
->span
.right
[_y
&1] = right
;
774 /* save the values so that emaj can be restarted:
776 eleft
->sx
+= lines
* eleft
->dxdy
;
777 eright
->sx
+= lines
* eright
->dxdy
;
784 * Recalculate prim's determinant. This is needed as we don't have
785 * get this information through the vbuf_render interface & we must
789 calc_det(const float (*v0
)[4],
790 const float (*v1
)[4],
791 const float (*v2
)[4])
793 /* edge vectors e = v0 - v2, f = v1 - v2 */
794 const float ex
= v0
[0][0] - v2
[0][0];
795 const float ey
= v0
[0][1] - v2
[0][1];
796 const float fx
= v1
[0][0] - v2
[0][0];
797 const float fy
= v1
[0][1] - v2
[0][1];
799 /* det = cross(e,f).z */
800 return ex
* fy
- ey
* fx
;
805 * Do setup for triangle rasterization, then render the triangle.
808 sp_setup_tri(struct setup_context
*setup
,
809 const float (*v0
)[4],
810 const float (*v1
)[4],
811 const float (*v2
)[4])
815 unsigned viewport_index
= 0;
817 debug_printf("Setup triangle:\n");
818 print_vertex(setup
, v0
);
819 print_vertex(setup
, v1
);
820 print_vertex(setup
, v2
);
823 if (setup
->softpipe
->no_rast
|| setup
->softpipe
->rasterizer
->rasterizer_discard
)
826 det
= calc_det(v0
, v1
, v2
);
828 debug_printf("%s\n", __FUNCTION__ );
832 setup
->numFragsEmitted
= 0;
833 setup
->numFragsWritten
= 0;
836 if (!setup_sort_vertices( setup
, det
, v0
, v1
, v2
))
839 setup_tri_coefficients( setup
);
840 setup_tri_edges( setup
);
842 assert(setup
->softpipe
->reduced_prim
== PIPE_PRIM_TRIANGLES
);
845 setup
->span
.right
[0] = 0;
846 setup
->span
.right
[1] = 0;
847 /* setup->span.z_mode = tri_z_mode( setup->ctx ); */
848 if (setup
->softpipe
->layer_slot
> 0) {
849 layer
= *(unsigned *)setup
->vprovoke
[setup
->softpipe
->layer_slot
];
850 layer
= MIN2(layer
, setup
->max_layer
);
852 setup
->quad
[0].input
.layer
= layer
;
854 if (setup
->softpipe
->viewport_index_slot
> 0) {
855 unsigned *udata
= (unsigned*)v0
[setup
->softpipe
->viewport_index_slot
];
856 viewport_index
= sp_clamp_viewport_idx(*udata
);
858 setup
->quad
[0].input
.viewport_index
= viewport_index
;
860 /* init_constant_attribs( setup ); */
862 if (setup
->oneoverarea
< 0.0) {
865 subtriangle(setup
, &setup
->emaj
, &setup
->ebot
, setup
->ebot
.lines
, viewport_index
);
866 subtriangle(setup
, &setup
->emaj
, &setup
->etop
, setup
->etop
.lines
, viewport_index
);
871 subtriangle(setup
, &setup
->ebot
, &setup
->emaj
, setup
->ebot
.lines
, viewport_index
);
872 subtriangle(setup
, &setup
->etop
, &setup
->emaj
, setup
->etop
.lines
, viewport_index
);
875 flush_spans( setup
);
877 if (setup
->softpipe
->active_statistics_queries
) {
878 setup
->softpipe
->pipeline_statistics
.c_primitives
++;
882 printf("Tri: %u frags emitted, %u written\n",
883 setup
->numFragsEmitted
,
884 setup
->numFragsWritten
);
889 /* Apply cylindrical wrapping to v0, v1 coordinates, if enabled.
890 * Input coordinates must be in [0, 1] range, otherwise results are undefined.
893 line_apply_cylindrical_wrap(float v0
,
895 uint cylindrical_wrap
,
898 if (cylindrical_wrap
) {
905 else if (delta
< -0.5f
) {
916 * Compute a0, dadx and dady for a linearly interpolated coefficient,
918 * v[0] and v[1] are vmin and vmax, respectively.
921 line_linear_coeff(const struct setup_context
*setup
,
922 struct tgsi_interp_coef
*coef
,
926 const float da
= v
[1] - v
[0];
927 const float dadx
= da
* setup
->emaj
.dx
* setup
->oneoverarea
;
928 const float dady
= da
* setup
->emaj
.dy
* setup
->oneoverarea
;
929 coef
->dadx
[i
] = dadx
;
930 coef
->dady
[i
] = dady
;
931 coef
->a0
[i
] = (v
[0] -
932 (dadx
* (setup
->vmin
[0][0] - setup
->pixel_offset
) +
933 dady
* (setup
->vmin
[0][1] - setup
->pixel_offset
)));
938 * Compute a0, dadx and dady for a perspective-corrected interpolant,
940 * v[0] and v[1] are vmin and vmax, respectively.
943 line_persp_coeff(const struct setup_context
*setup
,
944 struct tgsi_interp_coef
*coef
,
948 const float a0
= v
[0] * setup
->vmin
[0][3];
949 const float a1
= v
[1] * setup
->vmax
[0][3];
950 const float da
= a1
- a0
;
951 const float dadx
= da
* setup
->emaj
.dx
* setup
->oneoverarea
;
952 const float dady
= da
* setup
->emaj
.dy
* setup
->oneoverarea
;
953 coef
->dadx
[i
] = dadx
;
954 coef
->dady
[i
] = dady
;
956 (dadx
* (setup
->vmin
[0][0] - setup
->pixel_offset
) +
957 dady
* (setup
->vmin
[0][1] - setup
->pixel_offset
)));
962 * Compute the setup->coef[] array dadx, dady, a0 values.
963 * Must be called after setup->vmin,vmax are initialized.
966 setup_line_coefficients(struct setup_context
*setup
,
967 const float (*v0
)[4],
968 const float (*v1
)[4])
970 struct softpipe_context
*softpipe
= setup
->softpipe
;
971 const struct tgsi_shader_info
*fsInfo
= &setup
->softpipe
->fs_variant
->info
;
972 const struct sp_setup_info
*sinfo
= &softpipe
->setup_info
;
977 assert(sinfo
->valid
);
979 /* use setup->vmin, vmax to point to vertices */
980 if (softpipe
->rasterizer
->flatshade_first
)
981 setup
->vprovoke
= v0
;
983 setup
->vprovoke
= v1
;
987 setup
->emaj
.dx
= setup
->vmax
[0][0] - setup
->vmin
[0][0];
988 setup
->emaj
.dy
= setup
->vmax
[0][1] - setup
->vmin
[0][1];
990 /* NOTE: this is not really area but something proportional to it */
991 area
= setup
->emaj
.dx
* setup
->emaj
.dx
+ setup
->emaj
.dy
* setup
->emaj
.dy
;
992 if (area
== 0.0f
|| util_is_inf_or_nan(area
))
994 setup
->oneoverarea
= 1.0f
/ area
;
996 /* z and w are done by linear interpolation:
998 v
[0] = setup
->vmin
[0][2];
999 v
[1] = setup
->vmax
[0][2];
1000 line_linear_coeff(setup
, &setup
->posCoef
, 2, v
);
1002 v
[0] = setup
->vmin
[0][3];
1003 v
[1] = setup
->vmax
[0][3];
1004 line_linear_coeff(setup
, &setup
->posCoef
, 3, v
);
1006 /* setup interpolation for all the remaining attributes:
1008 for (fragSlot
= 0; fragSlot
< fsInfo
->num_inputs
; fragSlot
++) {
1009 const uint vertSlot
= sinfo
->attrib
[fragSlot
].src_index
;
1012 switch (sinfo
->attrib
[fragSlot
].interp
) {
1013 case INTERP_CONSTANT
:
1014 for (j
= 0; j
< TGSI_NUM_CHANNELS
; j
++)
1015 const_coeff(setup
, &setup
->coef
[fragSlot
], vertSlot
, j
);
1018 for (j
= 0; j
< TGSI_NUM_CHANNELS
; j
++) {
1019 line_apply_cylindrical_wrap(setup
->vmin
[vertSlot
][j
],
1020 setup
->vmax
[vertSlot
][j
],
1021 fsInfo
->input_cylindrical_wrap
[fragSlot
] & (1 << j
),
1023 line_linear_coeff(setup
, &setup
->coef
[fragSlot
], j
, v
);
1026 case INTERP_PERSPECTIVE
:
1027 for (j
= 0; j
< TGSI_NUM_CHANNELS
; j
++) {
1028 line_apply_cylindrical_wrap(setup
->vmin
[vertSlot
][j
],
1029 setup
->vmax
[vertSlot
][j
],
1030 fsInfo
->input_cylindrical_wrap
[fragSlot
] & (1 << j
),
1032 line_persp_coeff(setup
, &setup
->coef
[fragSlot
], j
, v
);
1036 setup_fragcoord_coeff(setup
, fragSlot
);
1042 if (fsInfo
->input_semantic_name
[fragSlot
] == TGSI_SEMANTIC_FACE
) {
1043 /* convert 0 to 1.0 and 1 to -1.0 */
1044 setup
->coef
[fragSlot
].a0
[0] = setup
->facing
* -2.0f
+ 1.0f
;
1045 setup
->coef
[fragSlot
].dadx
[0] = 0.0;
1046 setup
->coef
[fragSlot
].dady
[0] = 0.0;
1054 * Plot a pixel in a line segment.
1057 plot(struct setup_context
*setup
, int x
, int y
)
1059 const int iy
= y
& 1;
1060 const int ix
= x
& 1;
1061 const int quadX
= x
- ix
;
1062 const int quadY
= y
- iy
;
1063 const int mask
= (1 << ix
) << (2 * iy
);
1065 if (quadX
!= setup
->quad
[0].input
.x0
||
1066 quadY
!= setup
->quad
[0].input
.y0
)
1068 /* flush prev quad, start new quad */
1070 if (setup
->quad
[0].input
.x0
!= -1)
1071 clip_emit_quad(setup
, &setup
->quad
[0]);
1073 setup
->quad
[0].input
.x0
= quadX
;
1074 setup
->quad
[0].input
.y0
= quadY
;
1075 setup
->quad
[0].inout
.mask
= 0x0;
1078 setup
->quad
[0].inout
.mask
|= mask
;
1083 * Do setup for line rasterization, then render the line.
1084 * Single-pixel width, no stipple, etc. We rely on the 'draw' module
1085 * to handle stippling and wide lines.
1088 sp_setup_line(struct setup_context
*setup
,
1089 const float (*v0
)[4],
1090 const float (*v1
)[4])
1092 int x0
= (int) v0
[0][0];
1093 int x1
= (int) v1
[0][0];
1094 int y0
= (int) v0
[0][1];
1095 int y1
= (int) v1
[0][1];
1100 unsigned viewport_index
= 0;
1103 debug_printf("Setup line:\n");
1104 print_vertex(setup
, v0
);
1105 print_vertex(setup
, v1
);
1108 if (setup
->softpipe
->no_rast
|| setup
->softpipe
->rasterizer
->rasterizer_discard
)
1111 if (dx
== 0 && dy
== 0)
1114 if (!setup_line_coefficients(setup
, v0
, v1
))
1117 assert(v0
[0][0] < 1.0e9
);
1118 assert(v0
[0][1] < 1.0e9
);
1119 assert(v1
[0][0] < 1.0e9
);
1120 assert(v1
[0][1] < 1.0e9
);
1123 dx
= -dx
; /* make positive */
1131 dy
= -dy
; /* make positive */
1140 assert(setup
->softpipe
->reduced_prim
== PIPE_PRIM_LINES
);
1142 setup
->quad
[0].input
.x0
= setup
->quad
[0].input
.y0
= -1;
1143 setup
->quad
[0].inout
.mask
= 0x0;
1144 if (setup
->softpipe
->layer_slot
> 0) {
1145 layer
= *(unsigned *)setup
->vprovoke
[setup
->softpipe
->layer_slot
];
1146 layer
= MIN2(layer
, setup
->max_layer
);
1148 setup
->quad
[0].input
.layer
= layer
;
1150 if (setup
->softpipe
->viewport_index_slot
> 0) {
1151 unsigned *udata
= (unsigned*)setup
->vprovoke
[setup
->softpipe
->viewport_index_slot
];
1152 viewport_index
= sp_clamp_viewport_idx(*udata
);
1154 setup
->quad
[0].input
.viewport_index
= viewport_index
;
1156 /* XXX temporary: set coverage to 1.0 so the line appears
1157 * if AA mode happens to be enabled.
1159 setup
->quad
[0].input
.coverage
[0] =
1160 setup
->quad
[0].input
.coverage
[1] =
1161 setup
->quad
[0].input
.coverage
[2] =
1162 setup
->quad
[0].input
.coverage
[3] = 1.0;
1165 /*** X-major line ***/
1167 const int errorInc
= dy
+ dy
;
1168 int error
= errorInc
- dx
;
1169 const int errorDec
= error
- dx
;
1171 for (i
= 0; i
< dx
; i
++) {
1172 plot(setup
, x0
, y0
);
1185 /*** Y-major line ***/
1187 const int errorInc
= dx
+ dx
;
1188 int error
= errorInc
- dy
;
1189 const int errorDec
= error
- dy
;
1191 for (i
= 0; i
< dy
; i
++) {
1192 plot(setup
, x0
, y0
);
1205 /* draw final quad */
1206 if (setup
->quad
[0].inout
.mask
) {
1207 clip_emit_quad(setup
, &setup
->quad
[0]);
1213 point_persp_coeff(const struct setup_context
*setup
,
1214 const float (*vert
)[4],
1215 struct tgsi_interp_coef
*coef
,
1216 uint vertSlot
, uint i
)
1219 coef
->dadx
[i
] = 0.0F
;
1220 coef
->dady
[i
] = 0.0F
;
1221 coef
->a0
[i
] = vert
[vertSlot
][i
] * vert
[0][3];
1226 * Do setup for point rasterization, then render the point.
1227 * Round or square points...
1228 * XXX could optimize a lot for 1-pixel points.
1231 sp_setup_point(struct setup_context
*setup
,
1232 const float (*v0
)[4])
1234 struct softpipe_context
*softpipe
= setup
->softpipe
;
1235 const struct tgsi_shader_info
*fsInfo
= &setup
->softpipe
->fs_variant
->info
;
1236 const int sizeAttr
= setup
->softpipe
->psize_slot
;
1238 = sizeAttr
> 0 ? v0
[sizeAttr
][0]
1239 : setup
->softpipe
->rasterizer
->point_size
;
1240 const float halfSize
= 0.5F
* size
;
1241 const boolean round
= (boolean
) setup
->softpipe
->rasterizer
->point_smooth
;
1242 const float x
= v0
[0][0]; /* Note: data[0] is always position */
1243 const float y
= v0
[0][1];
1244 const struct sp_setup_info
*sinfo
= &softpipe
->setup_info
;
1247 unsigned viewport_index
= 0;
1249 debug_printf("Setup point:\n");
1250 print_vertex(setup
, v0
);
1253 assert(sinfo
->valid
);
1255 if (setup
->softpipe
->no_rast
|| setup
->softpipe
->rasterizer
->rasterizer_discard
)
1258 assert(setup
->softpipe
->reduced_prim
== PIPE_PRIM_POINTS
);
1260 if (setup
->softpipe
->layer_slot
> 0) {
1261 layer
= *(unsigned *)v0
[setup
->softpipe
->layer_slot
];
1262 layer
= MIN2(layer
, setup
->max_layer
);
1264 setup
->quad
[0].input
.layer
= layer
;
1266 if (setup
->softpipe
->viewport_index_slot
> 0) {
1267 unsigned *udata
= (unsigned*)v0
[setup
->softpipe
->viewport_index_slot
];
1268 viewport_index
= sp_clamp_viewport_idx(*udata
);
1270 setup
->quad
[0].input
.viewport_index
= viewport_index
;
1272 /* For points, all interpolants are constant-valued.
1273 * However, for point sprites, we'll need to setup texcoords appropriately.
1274 * XXX: which coefficients are the texcoords???
1275 * We may do point sprites as textured quads...
1277 * KW: We don't know which coefficients are texcoords - ultimately
1278 * the choice of what interpolation mode to use for each attribute
1279 * should be determined by the fragment program, using
1280 * per-attribute declaration statements that include interpolation
1281 * mode as a parameter. So either the fragment program will have
1282 * to be adjusted for pointsprite vs normal point behaviour, or
1283 * otherwise a special interpolation mode will have to be defined
1284 * which matches the required behaviour for point sprites. But -
1285 * the latter is not a feature of normal hardware, and as such
1286 * probably should be ruled out on that basis.
1288 setup
->vprovoke
= v0
;
1291 const_coeff(setup
, &setup
->posCoef
, 0, 2);
1292 const_coeff(setup
, &setup
->posCoef
, 0, 3);
1294 for (fragSlot
= 0; fragSlot
< fsInfo
->num_inputs
; fragSlot
++) {
1295 const uint vertSlot
= sinfo
->attrib
[fragSlot
].src_index
;
1298 switch (sinfo
->attrib
[fragSlot
].interp
) {
1299 case INTERP_CONSTANT
:
1302 for (j
= 0; j
< TGSI_NUM_CHANNELS
; j
++)
1303 const_coeff(setup
, &setup
->coef
[fragSlot
], vertSlot
, j
);
1305 case INTERP_PERSPECTIVE
:
1306 for (j
= 0; j
< TGSI_NUM_CHANNELS
; j
++)
1307 point_persp_coeff(setup
, setup
->vprovoke
,
1308 &setup
->coef
[fragSlot
], vertSlot
, j
);
1311 setup_fragcoord_coeff(setup
, fragSlot
);
1317 if (fsInfo
->input_semantic_name
[fragSlot
] == TGSI_SEMANTIC_FACE
) {
1318 /* convert 0 to 1.0 and 1 to -1.0 */
1319 setup
->coef
[fragSlot
].a0
[0] = setup
->facing
* -2.0f
+ 1.0f
;
1320 setup
->coef
[fragSlot
].dadx
[0] = 0.0;
1321 setup
->coef
[fragSlot
].dady
[0] = 0.0;
1326 if (halfSize
<= 0.5 && !round
) {
1327 /* special case for 1-pixel points */
1328 const int ix
= ((int) x
) & 1;
1329 const int iy
= ((int) y
) & 1;
1330 setup
->quad
[0].input
.x0
= (int) x
- ix
;
1331 setup
->quad
[0].input
.y0
= (int) y
- iy
;
1332 setup
->quad
[0].inout
.mask
= (1 << ix
) << (2 * iy
);
1333 clip_emit_quad(setup
, &setup
->quad
[0]);
1337 /* rounded points */
1338 const int ixmin
= block((int) (x
- halfSize
));
1339 const int ixmax
= block((int) (x
+ halfSize
));
1340 const int iymin
= block((int) (y
- halfSize
));
1341 const int iymax
= block((int) (y
+ halfSize
));
1342 const float rmin
= halfSize
- 0.7071F
; /* 0.7071 = sqrt(2)/2 */
1343 const float rmax
= halfSize
+ 0.7071F
;
1344 const float rmin2
= MAX2(0.0F
, rmin
* rmin
);
1345 const float rmax2
= rmax
* rmax
;
1346 const float cscale
= 1.0F
/ (rmax2
- rmin2
);
1349 for (iy
= iymin
; iy
<= iymax
; iy
+= 2) {
1350 for (ix
= ixmin
; ix
<= ixmax
; ix
+= 2) {
1351 float dx
, dy
, dist2
, cover
;
1353 setup
->quad
[0].inout
.mask
= 0x0;
1355 dx
= (ix
+ 0.5f
) - x
;
1356 dy
= (iy
+ 0.5f
) - y
;
1357 dist2
= dx
* dx
+ dy
* dy
;
1358 if (dist2
<= rmax2
) {
1359 cover
= 1.0F
- (dist2
- rmin2
) * cscale
;
1360 setup
->quad
[0].input
.coverage
[QUAD_TOP_LEFT
] = MIN2(cover
, 1.0f
);
1361 setup
->quad
[0].inout
.mask
|= MASK_TOP_LEFT
;
1364 dx
= (ix
+ 1.5f
) - x
;
1365 dy
= (iy
+ 0.5f
) - y
;
1366 dist2
= dx
* dx
+ dy
* dy
;
1367 if (dist2
<= rmax2
) {
1368 cover
= 1.0F
- (dist2
- rmin2
) * cscale
;
1369 setup
->quad
[0].input
.coverage
[QUAD_TOP_RIGHT
] = MIN2(cover
, 1.0f
);
1370 setup
->quad
[0].inout
.mask
|= MASK_TOP_RIGHT
;
1373 dx
= (ix
+ 0.5f
) - x
;
1374 dy
= (iy
+ 1.5f
) - y
;
1375 dist2
= dx
* dx
+ dy
* dy
;
1376 if (dist2
<= rmax2
) {
1377 cover
= 1.0F
- (dist2
- rmin2
) * cscale
;
1378 setup
->quad
[0].input
.coverage
[QUAD_BOTTOM_LEFT
] = MIN2(cover
, 1.0f
);
1379 setup
->quad
[0].inout
.mask
|= MASK_BOTTOM_LEFT
;
1382 dx
= (ix
+ 1.5f
) - x
;
1383 dy
= (iy
+ 1.5f
) - y
;
1384 dist2
= dx
* dx
+ dy
* dy
;
1385 if (dist2
<= rmax2
) {
1386 cover
= 1.0F
- (dist2
- rmin2
) * cscale
;
1387 setup
->quad
[0].input
.coverage
[QUAD_BOTTOM_RIGHT
] = MIN2(cover
, 1.0f
);
1388 setup
->quad
[0].inout
.mask
|= MASK_BOTTOM_RIGHT
;
1391 if (setup
->quad
[0].inout
.mask
) {
1392 setup
->quad
[0].input
.x0
= ix
;
1393 setup
->quad
[0].input
.y0
= iy
;
1394 clip_emit_quad(setup
, &setup
->quad
[0]);
1401 const int xmin
= (int) (x
+ 0.75 - halfSize
);
1402 const int ymin
= (int) (y
+ 0.25 - halfSize
);
1403 const int xmax
= xmin
+ (int) size
;
1404 const int ymax
= ymin
+ (int) size
;
1405 /* XXX could apply scissor to xmin,ymin,xmax,ymax now */
1406 const int ixmin
= block(xmin
);
1407 const int ixmax
= block(xmax
- 1);
1408 const int iymin
= block(ymin
);
1409 const int iymax
= block(ymax
- 1);
1413 debug_printf("(%f, %f) -> X:%d..%d Y:%d..%d\n", x, y, xmin, xmax,ymin,ymax);
1415 for (iy
= iymin
; iy
<= iymax
; iy
+= 2) {
1418 /* above the top edge */
1419 rowMask
&= (MASK_BOTTOM_LEFT
| MASK_BOTTOM_RIGHT
);
1421 if (iy
+ 1 >= ymax
) {
1422 /* below the bottom edge */
1423 rowMask
&= (MASK_TOP_LEFT
| MASK_TOP_RIGHT
);
1426 for (ix
= ixmin
; ix
<= ixmax
; ix
+= 2) {
1427 uint mask
= rowMask
;
1430 /* fragment is past left edge of point, turn off left bits */
1431 mask
&= (MASK_BOTTOM_RIGHT
| MASK_TOP_RIGHT
);
1433 if (ix
+ 1 >= xmax
) {
1434 /* past the right edge */
1435 mask
&= (MASK_BOTTOM_LEFT
| MASK_TOP_LEFT
);
1438 setup
->quad
[0].inout
.mask
= mask
;
1439 setup
->quad
[0].input
.x0
= ix
;
1440 setup
->quad
[0].input
.y0
= iy
;
1441 clip_emit_quad(setup
, &setup
->quad
[0]);
1450 * Called by vbuf code just before we start buffering primitives.
1453 sp_setup_prepare(struct setup_context
*setup
)
1455 struct softpipe_context
*sp
= setup
->softpipe
;
1457 unsigned max_layer
= ~0;
1459 softpipe_update_derived(sp
, sp
->reduced_api_prim
);
1462 /* Note: nr_attrs is only used for debugging (vertex printing) */
1463 setup
->nr_vertex_attrs
= draw_num_shader_outputs(sp
->draw
);
1466 * Determine how many layers the fb has (used for clamping layer value).
1467 * OpenGL (but not d3d10) permits different amount of layers per rt, however
1468 * results are undefined if layer exceeds the amount of layers of ANY
1469 * attachment hence don't need separate per cbuf and zsbuf max.
1471 for (i
= 0; i
< setup
->softpipe
->framebuffer
.nr_cbufs
; i
++) {
1472 struct pipe_surface
*cbuf
= setup
->softpipe
->framebuffer
.cbufs
[i
];
1474 max_layer
= MIN2(max_layer
,
1475 cbuf
->u
.tex
.last_layer
- cbuf
->u
.tex
.first_layer
);
1480 setup
->max_layer
= max_layer
;
1482 sp
->quad
.first
->begin( sp
->quad
.first
);
1484 if (sp
->reduced_api_prim
== PIPE_PRIM_TRIANGLES
&&
1485 sp
->rasterizer
->fill_front
== PIPE_POLYGON_MODE_FILL
&&
1486 sp
->rasterizer
->fill_back
== PIPE_POLYGON_MODE_FILL
) {
1487 /* we'll do culling */
1488 setup
->cull_face
= sp
->rasterizer
->cull_face
;
1491 /* 'draw' will do culling */
1492 setup
->cull_face
= PIPE_FACE_NONE
;
1498 sp_setup_destroy_context(struct setup_context
*setup
)
1505 * Create a new primitive setup/render stage.
1507 struct setup_context
*
1508 sp_setup_create_context(struct softpipe_context
*softpipe
)
1510 struct setup_context
*setup
= CALLOC_STRUCT(setup_context
);
1513 setup
->softpipe
= softpipe
;
1515 for (i
= 0; i
< MAX_QUADS
; i
++) {
1516 setup
->quad
[i
].coef
= setup
->coef
;
1517 setup
->quad
[i
].posCoef
= &setup
->posCoef
;
1520 setup
->span
.left
[0] = 1000000; /* greater than right[0] */
1521 setup
->span
.left
[1] = 1000000; /* greater than right[1] */