lp_setup_tri.c revision c40858fa0dac28dc5096973ac267630ba5725003
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 triangles 30 */ 31 32#include "util/u_math.h" 33#include "util/u_memory.h" 34#include "util/u_rect.h" 35#include "lp_perf.h" 36#include "lp_setup_context.h" 37#include "lp_setup_coef.h" 38#include "lp_rast.h" 39#include "lp_state_fs.h" 40 41#define NUM_CHANNELS 4 42 43 44 45static INLINE int 46subpixel_snap(float a) 47{ 48 return util_iround(FIXED_ONE * a); 49} 50 51static INLINE float 52fixed_to_float(int a) 53{ 54 return a * (1.0 / FIXED_ONE); 55} 56 57 58 59 60 61 62 63/** 64 * Alloc space for a new triangle plus the input.a0/dadx/dady arrays 65 * immediately after it. 66 * The memory is allocated from the per-scene pool, not per-tile. 67 * \param tri_size returns number of bytes allocated 68 * \param nr_inputs number of fragment shader inputs 69 * \return pointer to triangle space 70 */ 71struct lp_rast_triangle * 72lp_setup_alloc_triangle(struct lp_scene *scene, 73 unsigned nr_inputs, 74 unsigned nr_planes, 75 unsigned *tri_size) 76{ 77 unsigned input_array_sz = NUM_CHANNELS * (nr_inputs + 1) * sizeof(float); 78 struct lp_rast_triangle *tri; 79 unsigned tri_bytes, bytes; 80 char *inputs; 81 82 tri_bytes = align(Offset(struct lp_rast_triangle, plane[nr_planes]), 16); 83 bytes = tri_bytes + (3 * input_array_sz); 84 85 tri = lp_scene_alloc_aligned( scene, bytes, 16 ); 86 87 if (tri) { 88 inputs = ((char *)tri) + tri_bytes; 89 tri->inputs.a0 = (float (*)[4]) inputs; 90 tri->inputs.dadx = (float (*)[4]) (inputs + input_array_sz); 91 tri->inputs.dady = (float (*)[4]) (inputs + 2 * input_array_sz); 92 93 *tri_size = bytes; 94 } 95 96 return tri; 97} 98 99void 100lp_setup_print_vertex(struct lp_setup_context *setup, 101 const char *name, 102 const float (*v)[4]) 103{ 104 int i, j; 105 106 debug_printf(" wpos (%s[0]) xyzw %f %f %f %f\n", 107 name, 108 v[0][0], v[0][1], v[0][2], v[0][3]); 109 110 for (i = 0; i < setup->fs.nr_inputs; i++) { 111 const float *in = v[setup->fs.input[i].src_index]; 112 113 debug_printf(" in[%d] (%s[%d]) %s%s%s%s ", 114 i, 115 name, setup->fs.input[i].src_index, 116 (setup->fs.input[i].usage_mask & 0x1) ? "x" : " ", 117 (setup->fs.input[i].usage_mask & 0x2) ? "y" : " ", 118 (setup->fs.input[i].usage_mask & 0x4) ? "z" : " ", 119 (setup->fs.input[i].usage_mask & 0x8) ? "w" : " "); 120 121 for (j = 0; j < 4; j++) 122 if (setup->fs.input[i].usage_mask & (1<<j)) 123 debug_printf("%.5f ", in[j]); 124 125 debug_printf("\n"); 126 } 127} 128 129 130/** 131 * Print triangle vertex attribs (for debug). 132 */ 133void 134lp_setup_print_triangle(struct lp_setup_context *setup, 135 const float (*v0)[4], 136 const float (*v1)[4], 137 const float (*v2)[4]) 138{ 139 debug_printf("triangle\n"); 140 141 { 142 const float ex = v0[0][0] - v2[0][0]; 143 const float ey = v0[0][1] - v2[0][1]; 144 const float fx = v1[0][0] - v2[0][0]; 145 const float fy = v1[0][1] - v2[0][1]; 146 147 /* det = cross(e,f).z */ 148 const float det = ex * fy - ey * fx; 149 if (det < 0.0f) 150 debug_printf(" - ccw\n"); 151 else if (det > 0.0f) 152 debug_printf(" - cw\n"); 153 else 154 debug_printf(" - zero area\n"); 155 } 156 157 lp_setup_print_vertex(setup, "v0", v0); 158 lp_setup_print_vertex(setup, "v1", v1); 159 lp_setup_print_vertex(setup, "v2", v2); 160} 161 162 163static unsigned 164lp_rast_tri_tab[9] = { 165 0, /* should be impossible */ 166 LP_RAST_OP_TRIANGLE_1, 167 LP_RAST_OP_TRIANGLE_2, 168 LP_RAST_OP_TRIANGLE_3, 169 LP_RAST_OP_TRIANGLE_4, 170 LP_RAST_OP_TRIANGLE_5, 171 LP_RAST_OP_TRIANGLE_6, 172 LP_RAST_OP_TRIANGLE_7, 173 LP_RAST_OP_TRIANGLE_8 174}; 175 176 177 178/** 179 * The primitive covers the whole tile- shade whole tile. 180 * 181 * \param tx, ty the tile position in tiles, not pixels 182 */ 183static boolean 184lp_setup_whole_tile(struct lp_setup_context *setup, 185 const struct lp_rast_shader_inputs *inputs, 186 int tx, int ty) 187{ 188 struct lp_scene *scene = setup->scene; 189 190 LP_COUNT(nr_fully_covered_64); 191 192 /* if variant is opaque and scissor doesn't effect the tile */ 193 if (inputs->opaque) { 194 if (!scene->fb.zsbuf) { 195 /* 196 * All previous rendering will be overwritten so reset the bin. 197 */ 198 lp_scene_bin_reset( scene, tx, ty ); 199 } 200 201 LP_COUNT(nr_shade_opaque_64); 202 return lp_scene_bin_command( scene, tx, ty, 203 LP_RAST_OP_SHADE_TILE_OPAQUE, 204 lp_rast_arg_inputs(inputs) ); 205 } else { 206 LP_COUNT(nr_shade_64); 207 return lp_scene_bin_command( scene, tx, ty, 208 LP_RAST_OP_SHADE_TILE, 209 lp_rast_arg_inputs(inputs) ); 210 } 211} 212 213 214/** 215 * Do basic setup for triangle rasterization and determine which 216 * framebuffer tiles are touched. Put the triangle in the scene's 217 * bins for the tiles which we overlap. 218 */ 219static boolean 220do_triangle_ccw(struct lp_setup_context *setup, 221 const float (*v0)[4], 222 const float (*v1)[4], 223 const float (*v2)[4], 224 boolean frontfacing ) 225{ 226 struct lp_scene *scene = setup->scene; 227 struct lp_rast_triangle *tri; 228 int x[3]; 229 int y[3]; 230 int area; 231 struct u_rect bbox; 232 unsigned tri_bytes; 233 int i; 234 int nr_planes = 3; 235 236 if (0) 237 lp_setup_print_triangle(setup, v0, v1, v2); 238 239 if (setup->scissor_test) { 240 nr_planes = 7; 241 } 242 else { 243 nr_planes = 3; 244 } 245 246 /* x/y positions in fixed point */ 247 x[0] = subpixel_snap(v0[0][0] - setup->pixel_offset); 248 x[1] = subpixel_snap(v1[0][0] - setup->pixel_offset); 249 x[2] = subpixel_snap(v2[0][0] - setup->pixel_offset); 250 y[0] = subpixel_snap(v0[0][1] - setup->pixel_offset); 251 y[1] = subpixel_snap(v1[0][1] - setup->pixel_offset); 252 y[2] = subpixel_snap(v2[0][1] - setup->pixel_offset); 253 254 255 /* Bounding rectangle (in pixels) */ 256 { 257 /* Yes this is necessary to accurately calculate bounding boxes 258 * with the two fill-conventions we support. GL (normally) ends 259 * up needing a bottom-left fill convention, which requires 260 * slightly different rounding. 261 */ 262 int adj = (setup->pixel_offset != 0) ? 1 : 0; 263 264 bbox.x0 = (MIN3(x[0], x[1], x[2]) + (FIXED_ONE-1)) >> FIXED_ORDER; 265 bbox.x1 = (MAX3(x[0], x[1], x[2]) + (FIXED_ONE-1)) >> FIXED_ORDER; 266 bbox.y0 = (MIN3(y[0], y[1], y[2]) + (FIXED_ONE-1) + adj) >> FIXED_ORDER; 267 bbox.y1 = (MAX3(y[0], y[1], y[2]) + (FIXED_ONE-1) + adj) >> FIXED_ORDER; 268 269 /* Inclusive coordinates: 270 */ 271 bbox.x1--; 272 bbox.y1--; 273 } 274 275 if (bbox.x1 < bbox.x0 || 276 bbox.y1 < bbox.y0) { 277 if (0) debug_printf("empty bounding box\n"); 278 LP_COUNT(nr_culled_tris); 279 return TRUE; 280 } 281 282 if (!u_rect_test_intersection(&setup->draw_region, &bbox)) { 283 if (0) debug_printf("offscreen\n"); 284 LP_COUNT(nr_culled_tris); 285 return TRUE; 286 } 287 288 u_rect_find_intersection(&setup->draw_region, &bbox); 289 290 tri = lp_setup_alloc_triangle(scene, 291 setup->fs.nr_inputs, 292 nr_planes, 293 &tri_bytes); 294 if (!tri) 295 return FALSE; 296 297#ifdef DEBUG 298 tri->v[0][0] = v0[0][0]; 299 tri->v[1][0] = v1[0][0]; 300 tri->v[2][0] = v2[0][0]; 301 tri->v[0][1] = v0[0][1]; 302 tri->v[1][1] = v1[0][1]; 303 tri->v[2][1] = v2[0][1]; 304#endif 305 306 tri->plane[0].dcdy = x[0] - x[1]; 307 tri->plane[1].dcdy = x[1] - x[2]; 308 tri->plane[2].dcdy = x[2] - x[0]; 309 310 tri->plane[0].dcdx = y[0] - y[1]; 311 tri->plane[1].dcdx = y[1] - y[2]; 312 tri->plane[2].dcdx = y[2] - y[0]; 313 314 area = (tri->plane[0].dcdy * tri->plane[2].dcdx - 315 tri->plane[2].dcdy * tri->plane[0].dcdx); 316 317 LP_COUNT(nr_tris); 318 319 /* Cull non-ccw and zero-sized triangles. 320 * 321 * XXX: subject to overflow?? 322 */ 323 if (area <= 0) { 324 lp_scene_putback_data( scene, tri_bytes ); 325 LP_COUNT(nr_culled_tris); 326 return TRUE; 327 } 328 329 /* Setup parameter interpolants: 330 */ 331 lp_setup_tri_coef( setup, &tri->inputs, v0, v1, v2, frontfacing ); 332 333 tri->inputs.facing = frontfacing ? 1.0F : -1.0F; 334 tri->inputs.disable = FALSE; 335 tri->inputs.opaque = setup->fs.current.variant->opaque; 336 tri->inputs.state = setup->fs.stored; 337 338 339 for (i = 0; i < 3; i++) { 340 struct lp_rast_plane *plane = &tri->plane[i]; 341 342 /* half-edge constants, will be interated over the whole render 343 * target. 344 */ 345 plane->c = plane->dcdx * x[i] - plane->dcdy * y[i]; 346 347 /* correct for top-left vs. bottom-left fill convention. 348 * 349 * note that we're overloading gl_rasterization_rules to mean 350 * both (0.5,0.5) pixel centers *and* bottom-left filling 351 * convention. 352 * 353 * GL actually has a top-left filling convention, but GL's 354 * notion of "top" differs from gallium's... 355 * 356 * Also, sometimes (in FBO cases) GL will render upside down 357 * to its usual method, in which case it will probably want 358 * to use the opposite, top-left convention. 359 */ 360 if (plane->dcdx < 0) { 361 /* both fill conventions want this - adjust for left edges */ 362 plane->c++; 363 } 364 else if (plane->dcdx == 0) { 365 if (setup->pixel_offset == 0) { 366 /* correct for top-left fill convention: 367 */ 368 if (plane->dcdy > 0) plane->c++; 369 } 370 else { 371 /* correct for bottom-left fill convention: 372 */ 373 if (plane->dcdy < 0) plane->c++; 374 } 375 } 376 377 plane->dcdx *= FIXED_ONE; 378 plane->dcdy *= FIXED_ONE; 379 380 /* find trivial reject offsets for each edge for a single-pixel 381 * sized block. These will be scaled up at each recursive level to 382 * match the active blocksize. Scaling in this way works best if 383 * the blocks are square. 384 */ 385 plane->eo = 0; 386 if (plane->dcdx < 0) plane->eo -= plane->dcdx; 387 if (plane->dcdy > 0) plane->eo += plane->dcdy; 388 389 /* Calculate trivial accept offsets from the above. 390 */ 391 plane->ei = plane->dcdy - plane->dcdx - plane->eo; 392 } 393 394 395 /* 396 * When rasterizing scissored tris, use the intersection of the 397 * triangle bounding box and the scissor rect to generate the 398 * scissor planes. 399 * 400 * This permits us to cut off the triangle "tails" that are present 401 * in the intermediate recursive levels caused when two of the 402 * triangles edges don't diverge quickly enough to trivially reject 403 * exterior blocks from the triangle. 404 * 405 * It's not really clear if it's worth worrying about these tails, 406 * but since we generate the planes for each scissored tri, it's 407 * free to trim them in this case. 408 * 409 * Note that otherwise, the scissor planes only vary in 'C' value, 410 * and even then only on state-changes. Could alternatively store 411 * these planes elsewhere. 412 */ 413 if (nr_planes == 7) { 414 tri->plane[3].dcdx = -1; 415 tri->plane[3].dcdy = 0; 416 tri->plane[3].c = 1-bbox.x0; 417 tri->plane[3].ei = 0; 418 tri->plane[3].eo = 1; 419 420 tri->plane[4].dcdx = 1; 421 tri->plane[4].dcdy = 0; 422 tri->plane[4].c = bbox.x1+1; 423 tri->plane[4].ei = -1; 424 tri->plane[4].eo = 0; 425 426 tri->plane[5].dcdx = 0; 427 tri->plane[5].dcdy = 1; 428 tri->plane[5].c = 1-bbox.y0; 429 tri->plane[5].ei = 0; 430 tri->plane[5].eo = 1; 431 432 tri->plane[6].dcdx = 0; 433 tri->plane[6].dcdy = -1; 434 tri->plane[6].c = bbox.y1+1; 435 tri->plane[6].ei = -1; 436 tri->plane[6].eo = 0; 437 } 438 439 return lp_setup_bin_triangle( setup, tri, &bbox, nr_planes ); 440} 441 442/* 443 * Round to nearest less or equal power of two of the input. 444 * 445 * Undefined if no bit set exists, so code should check against 0 first. 446 */ 447static INLINE uint32_t 448floor_pot(uint32_t n) 449{ 450 assert(n); 451#if defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86) 452 __asm__("bsr %1,%0" 453 : "=r" (n) 454 : "rm" (n)); 455 return 1 << n; 456#else 457 n |= (n >> 1); 458 n |= (n >> 2); 459 n |= (n >> 4); 460 n |= (n >> 8); 461 n |= (n >> 16); 462 return n - (n >> 1); 463#endif 464} 465 466 467boolean 468lp_setup_bin_triangle( struct lp_setup_context *setup, 469 struct lp_rast_triangle *tri, 470 const struct u_rect *bbox, 471 int nr_planes ) 472{ 473 struct lp_scene *scene = setup->scene; 474 int i; 475 476 /* What is the largest power-of-two boundary this triangle crosses: 477 */ 478 int dx = floor_pot((bbox->x0 ^ bbox->x1) | 479 (bbox->y0 ^ bbox->y1)); 480 481 /* The largest dimension of the rasterized area of the triangle 482 * (aligned to a 4x4 grid), rounded down to the nearest power of two: 483 */ 484 int sz = floor_pot((bbox->x1 - (bbox->x0 & ~3)) | 485 (bbox->y1 - (bbox->y0 & ~3))); 486 487 if (nr_planes == 3) { 488 if (sz < 4 && dx < 64) 489 { 490 /* Triangle is contained in a single 4x4 stamp: 491 */ 492 int mask = (bbox->x0 & 63 & ~3) | ((bbox->y0 & 63 & ~3) << 8); 493 494 return lp_scene_bin_command( scene, 495 bbox->x0/64, bbox->y0/64, 496 LP_RAST_OP_TRIANGLE_3_4, 497 lp_rast_arg_triangle(tri, mask) ); 498 } 499 500 if (sz < 16 && dx < 64) 501 { 502 int mask = (bbox->x0 & 63 & ~3) | ((bbox->y0 & 63 & ~3) << 8); 503 504 /* Triangle is contained in a single 16x16 block: 505 */ 506 return lp_scene_bin_command( scene, 507 bbox->x0/64, bbox->y0/64, 508 LP_RAST_OP_TRIANGLE_3_16, 509 lp_rast_arg_triangle(tri, mask) ); 510 } 511 } 512 513 514 /* Determine which tile(s) intersect the triangle's bounding box 515 */ 516 if (dx < TILE_SIZE) 517 { 518 int ix0 = bbox->x0 / TILE_SIZE; 519 int iy0 = bbox->y0 / TILE_SIZE; 520 521 assert(iy0 == bbox->y1 / TILE_SIZE && 522 ix0 == bbox->x1 / TILE_SIZE); 523 524 /* Triangle is contained in a single tile: 525 */ 526 return lp_scene_bin_command( scene, ix0, iy0, 527 lp_rast_tri_tab[nr_planes], 528 lp_rast_arg_triangle(tri, (1<<nr_planes)-1) ); 529 } 530 else 531 { 532 int c[7]; 533 int ei[7]; 534 int eo[7]; 535 int xstep[7]; 536 int ystep[7]; 537 int x, y; 538 539 int ix0 = bbox->x0 / TILE_SIZE; 540 int iy0 = bbox->y0 / TILE_SIZE; 541 int ix1 = bbox->x1 / TILE_SIZE; 542 int iy1 = bbox->y1 / TILE_SIZE; 543 544 for (i = 0; i < nr_planes; i++) { 545 c[i] = (tri->plane[i].c + 546 tri->plane[i].dcdy * iy0 * TILE_SIZE - 547 tri->plane[i].dcdx * ix0 * TILE_SIZE); 548 549 ei[i] = tri->plane[i].ei << TILE_ORDER; 550 eo[i] = tri->plane[i].eo << TILE_ORDER; 551 xstep[i] = -(tri->plane[i].dcdx << TILE_ORDER); 552 ystep[i] = tri->plane[i].dcdy << TILE_ORDER; 553 } 554 555 556 557 /* Test tile-sized blocks against the triangle. 558 * Discard blocks fully outside the tri. If the block is fully 559 * contained inside the tri, bin an lp_rast_shade_tile command. 560 * Else, bin a lp_rast_triangle command. 561 */ 562 for (y = iy0; y <= iy1; y++) 563 { 564 boolean in = FALSE; /* are we inside the triangle? */ 565 int cx[7]; 566 567 for (i = 0; i < nr_planes; i++) 568 cx[i] = c[i]; 569 570 for (x = ix0; x <= ix1; x++) 571 { 572 int out = 0; 573 int partial = 0; 574 575 for (i = 0; i < nr_planes; i++) { 576 int planeout = cx[i] + eo[i]; 577 int planepartial = cx[i] + ei[i] - 1; 578 out |= (planeout >> 31); 579 partial |= (planepartial >> 31) & (1<<i); 580 } 581 582 if (out) { 583 /* do nothing */ 584 if (in) 585 break; /* exiting triangle, all done with this row */ 586 LP_COUNT(nr_empty_64); 587 } 588 else if (partial) { 589 /* Not trivially accepted by at least one plane - 590 * rasterize/shade partial tile 591 */ 592 int count = util_bitcount(partial); 593 in = TRUE; 594 if (!lp_scene_bin_command( scene, x, y, 595 lp_rast_tri_tab[count], 596 lp_rast_arg_triangle(tri, partial) )) 597 goto fail; 598 599 LP_COUNT(nr_partially_covered_64); 600 } 601 else { 602 /* triangle covers the whole tile- shade whole tile */ 603 LP_COUNT(nr_fully_covered_64); 604 in = TRUE; 605 if (!lp_setup_whole_tile(setup, &tri->inputs, x, y)) 606 goto fail; 607 } 608 609 /* Iterate cx values across the region: 610 */ 611 for (i = 0; i < nr_planes; i++) 612 cx[i] += xstep[i]; 613 } 614 615 /* Iterate c values down the region: 616 */ 617 for (i = 0; i < nr_planes; i++) 618 c[i] += ystep[i]; 619 } 620 } 621 622 return TRUE; 623 624fail: 625 /* Need to disable any partially binned triangle. This is easier 626 * than trying to locate all the triangle, shade-tile, etc, 627 * commands which may have been binned. 628 */ 629 tri->inputs.disable = TRUE; 630 return FALSE; 631} 632 633 634/** 635 * Draw triangle if it's CW, cull otherwise. 636 */ 637static void triangle_cw( struct lp_setup_context *setup, 638 const float (*v0)[4], 639 const float (*v1)[4], 640 const float (*v2)[4] ) 641{ 642 if (!do_triangle_ccw( setup, v1, v0, v2, !setup->ccw_is_frontface )) 643 { 644 lp_setup_flush_and_restart(setup); 645 646 if (!do_triangle_ccw( setup, v1, v0, v2, !setup->ccw_is_frontface )) 647 assert(0); 648 } 649} 650 651 652/** 653 * Draw triangle if it's CCW, cull otherwise. 654 */ 655static void triangle_ccw( struct lp_setup_context *setup, 656 const float (*v0)[4], 657 const float (*v1)[4], 658 const float (*v2)[4] ) 659{ 660 if (!do_triangle_ccw( setup, v0, v1, v2, setup->ccw_is_frontface )) 661 { 662 lp_setup_flush_and_restart(setup); 663 if (!do_triangle_ccw( setup, v0, v1, v2, setup->ccw_is_frontface )) 664 assert(0); 665 } 666} 667 668 669 670/** 671 * Draw triangle whether it's CW or CCW. 672 */ 673static void triangle_both( struct lp_setup_context *setup, 674 const float (*v0)[4], 675 const float (*v1)[4], 676 const float (*v2)[4] ) 677{ 678 /* edge vectors e = v0 - v2, f = v1 - v2 */ 679 const float ex = v0[0][0] - v2[0][0]; 680 const float ey = v0[0][1] - v2[0][1]; 681 const float fx = v1[0][0] - v2[0][0]; 682 const float fy = v1[0][1] - v2[0][1]; 683 684 /* det = cross(e,f).z */ 685 const float det = ex * fy - ey * fx; 686 if (det < 0.0f) 687 triangle_ccw( setup, v0, v1, v2 ); 688 else if (det > 0.0f) 689 triangle_cw( setup, v0, v1, v2 ); 690} 691 692 693static void triangle_nop( struct lp_setup_context *setup, 694 const float (*v0)[4], 695 const float (*v1)[4], 696 const float (*v2)[4] ) 697{ 698} 699 700 701void 702lp_setup_choose_triangle( struct lp_setup_context *setup ) 703{ 704 switch (setup->cullmode) { 705 case PIPE_FACE_NONE: 706 setup->triangle = triangle_both; 707 break; 708 case PIPE_FACE_BACK: 709 setup->triangle = setup->ccw_is_frontface ? triangle_ccw : triangle_cw; 710 break; 711 case PIPE_FACE_FRONT: 712 setup->triangle = setup->ccw_is_frontface ? triangle_cw : triangle_ccw; 713 break; 714 default: 715 setup->triangle = triangle_nop; 716 break; 717 } 718} 719