Changeset 3598 for trunk/src/opengl/mesa/vbrender.c
- Timestamp:
- May 23, 2000, 10:41:28 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/opengl/mesa/vbrender.c
r2962 r3598 1 /* $Id: vbrender.c,v 1. 2 2000-03-01 18:49:39jeroen Exp $ */1 /* $Id: vbrender.c,v 1.3 2000-05-23 20:41:03 jeroen Exp $ */ 2 2 3 3 /* 4 4 * Mesa 3-D graphics library 5 * Version: 3. 15 * Version: 3.3 6 6 * 7 7 * Copyright (C) 1999 Brian Paul All Rights Reserved. … … 42 42 #include "all.h" 43 43 #else 44 #ifndef XFree86Server 45 #include <stdio.h> 46 #else 47 #include "GL/xf86glx.h" 48 #endif 44 #include "glheader.h" 49 45 #include "clip.h" 50 46 #include "types.h" … … 87 83 88 84 static INLINE void gl_render_clipped_line2( GLcontext *ctx, 89 85 GLuint v1, GLuint v2 ) 90 86 { 91 87 GLuint pv = v2; … … 128 124 } 129 125 130 #define FLUSH_PRIM(prim) 131 do { 132 if (ctx->PB->primitive != prim) { 133 gl_reduced_prim_change( ctx, prim ); 134 } 126 #define FLUSH_PRIM(prim) \ 127 do { \ 128 if (ctx->PB->primitive != prim) { \ 129 gl_reduced_prim_change( ctx, prim ); \ 130 } \ 135 131 } while(0) 136 132 … … 155 151 j = vlist[i]; 156 152 if (edge_ptr[j] & 0x3) { 157 153 edge_ptr[j] &= ~0x3; 158 154 (*ctx->Driver.PointsFunc)( ctx, j, j ); 159 155 } … … 162 158 else if (mode==GL_LINE) { 163 159 GLuint i, j0, j1; 160 ctx->StippleCounter = 0; 164 161 165 162 /* draw the edges */ 166 163 for (i=0;i<n-1;i++) { 167 168 169 170 171 edge_ptr[j0] &= ~1;172 173 164 j0 = vlist[i]; 165 j1 = vlist[i+1]; 166 167 if (edge_ptr[j0] & 0x1) { 168 edge_ptr[j0] &= ~0x1; 169 (*ctx->Driver.LineFunc)( ctx, j0, j1, pv ); 170 } 174 171 } 175 172 … … 179 176 180 177 if (edge_ptr[j0] & 0x2) { 181 edge_ptr[j0] &= ~2;182 178 edge_ptr[j0] &= ~0x2; 179 (*ctx->Driver.LineFunc)( ctx, j0, j1, pv ); 183 180 } 184 181 } … … 203 200 */ 204 201 void gl_render_clipped_triangle( GLcontext *ctx, GLuint n, GLuint vlist[], 205 202 GLuint pv ) 206 203 { 207 204 struct vertex_buffer *VB = ctx->VB; … … 220 217 221 218 static INLINE void gl_render_clipped_triangle2( GLcontext *ctx, 222 223 219 GLuint v1, GLuint v2, GLuint v3, 220 GLuint pv ) 224 221 { 225 222 struct vertex_buffer *VB = ctx->VB; 226 GLubyte mask = (GLubyte) (VB->ClipMask[v1] | VB->ClipMask[v2] | VB->ClipMask[v3]); 223 GLubyte mask = (GLubyte) (VB->ClipMask[v1] | 224 VB->ClipMask[v2] | 225 VB->ClipMask[v3]); 227 226 GLuint vlist[VB_MAX_CLIPPED_VERTS]; 228 227 GLuint i, n; … … 238 237 ASSIGN_3V(vlist, v1, v2, v3 ); 239 238 n = (ctx->poly_clip_tab[VB->ClipPtr->size])( VB, 3, vlist, mask ); 239 240 for (i=2;i<n;i++) 241 ctx->TriangleFunc( ctx, *vlist, vlist[i-1], vlist[i], pv ); 242 } 243 244 245 static INLINE void gl_render_clipped_quad2( GLcontext *ctx, 246 GLuint v1, GLuint v2, GLuint v3, 247 GLuint v4, 248 GLuint pv ) 249 { 250 struct vertex_buffer *VB = ctx->VB; 251 GLubyte mask = (GLubyte) (VB->ClipMask[v1] | 252 VB->ClipMask[v2] | 253 VB->ClipMask[v3] | 254 VB->ClipMask[v4]); 255 GLuint vlist[VB_MAX_CLIPPED_VERTS]; 256 GLuint i, n; 257 258 if (!mask) { 259 ctx->QuadFunc( ctx, v1, v2, v3, v4, pv ); 260 return; 261 } 262 263 if (CLIP_ALL_BITS & VB->ClipMask[v1] & 264 VB->ClipMask[v2] & VB->ClipMask[v3] & 265 VB->ClipMask[v4]) 266 return; 267 268 ASSIGN_4V(vlist, v1, v2, v3, v4 ); 269 n = (ctx->poly_clip_tab[VB->ClipPtr->size])( VB, 4, vlist, mask ); 240 270 241 271 for (i=2;i<n;i++) … … 294 324 295 325 326 static void null_triangle( GLcontext *ctx, 327 GLuint v0, GLuint v1, GLuint v2, GLuint pv ) 328 { 329 } 330 296 331 297 332 /* Implements triangle_rendering when (IndirectTriangles & DD_SW_SETUP) … … 309 344 GLfloat c = ex*fy-ey*fx; 310 345 GLuint facing; 311 GLuint tricaps ;346 GLuint tricaps = ctx->IndirectTriangles; 312 347 313 348 if (c * ctx->backface_sign > 0) … … 315 350 316 351 facing = (c<0.0F) ^ (ctx->Polygon.FrontFace==GL_CW); 317 tricaps = ctx->IndirectTriangles; 318 (void) tricaps; /* not needed? */ 319 320 if (ctx->IndirectTriangles & DD_TRI_OFFSET) { 352 353 if (tricaps & DD_TRI_OFFSET) { 321 354 GLfloat ez = win[v2][2] - win[v0][2]; 322 355 GLfloat fz = win[v3][2] - win[v1][2]; … … 327 360 328 361 329 if ( ctx->IndirectTriangles & DD_TRI_LIGHT_TWOSIDE) {362 if (tricaps & DD_TRI_LIGHT_TWOSIDE) { 330 363 VB->Specular = VB->Spec[facing]; 331 364 VB->ColorPtr = VB->Color[facing]; … … 335 368 336 369 /* Render the quad! */ 337 if ( ctx->IndirectTriangles & DD_TRI_UNFILLED) {370 if (tricaps & DD_TRI_UNFILLED) { 338 371 GLuint vlist[4]; 339 372 vlist[0] = v0; … … 349 382 350 383 351 384 #if 0 385 static void null_quad( GLcontext *ctx, GLuint v0, GLuint v1, 386 GLuint v2, GLuint v3, GLuint pv ) 387 { 388 } 389 #endif 352 390 353 391 … … 366 404 #define NEED_EDGEFLAG_SETUP (ctx->TriangleCaps & DD_TRI_UNFILLED) 367 405 368 #define EDGEFLAG_TRI( i2, i1, i, pv, parity) \ 369 do { \ 370 GLuint e1=i1, e0=i; \ 371 if (parity) { GLuint t=e1; e1=e0; e0=t; } \ 372 eflag[i2] = eflag[e1] = 1; eflag[e0] = 2; \ 373 } while (0) 374 375 #define EDGEFLAG_QUAD( i3, i2, i1, i, pv) \ 376 do { \ 377 eflag[i3] = eflag[i2] = eflag[i1] = 1; eflag[i] = 2; \ 378 } while (0) 406 #define EDGEFLAG_TRI( i2, i1, i, pv, parity) \ 407 do { \ 408 eflag[i2] = eflag[i1] = 1; eflag[i] = 2; \ 409 } while (0) 410 411 #define EDGEFLAG_QUAD( i3, i2, i1, i, pv) \ 412 do { \ 413 eflag[i3] = eflag[i2] = eflag[i1] = 1; eflag[i] = 2; \ 414 } while (0) 415 416 417 #define EDGEFLAG_POLY_TRI_PRE( i2, i1, i, pv) \ 418 do { \ 419 eflag[i1] |= (eflag[i1] >> 2) & 1; \ 420 eflag[i] |= (eflag[i] >> 2) & 2; \ 421 } while (0) 422 423 #define EDGEFLAG_POLY_TRI_POST( i2, i1, i, pv) \ 424 do { \ 425 eflag[i2] = 0; \ 426 eflag[i1] &= ~(4|1); \ 427 eflag[i] &= ~(8|2); \ 428 } while (0) 429 379 430 380 431 381 432 /* Culled and possibly clipped primitives. 382 433 */ 383 #define RENDER_POINTS( start, count ) 384 (void) cullmask; 434 #define RENDER_POINTS( start, count ) \ 435 (void) cullmask; \ 385 436 (*ctx->Driver.PointsFunc)( ctx, start, count-1 ); 386 437 387 438 388 #define RENDER_LINE( i1, i ) 389 do { 390 const GLubyte flags = cullmask[i]; 391 392 if (!(flags & PRIM_NOT_CULLED)) 393 continue; 394 395 if (flags & PRIM_ANY_CLIP) 396 gl_render_clipped_line( ctx, i1, i ); 397 else 398 ctx->Driver.LineFunc( ctx, i1, i, i ); 399 } while (0) 400 401 402 403 #define RENDER_TRI( i2, i1, i, pv, parity) 404 do { 405 const GLubyte flags = cullmask[i]; 406 407 if (!(flags & PRIM_NOT_CULLED)) 408 continue; 409 410 if (flags & PRIM_ANY_CLIP) { 411 if (parity) { 412 vlist[0] = i1;\413 vlist[1] = i2;\414 vlist[2] = i;\415 } else { 416 vlist[0] = i2;\417 vlist[1] = i1;\418 vlist[2] = i;\419 } 420 gl_render_clipped_triangle( ctx, 3, vlist, pv ); 421 } else if (parity) 422 ctx->TriangleFunc( ctx, i1, i2, i, pv ); 423 else 424 ctx->TriangleFunc( ctx, i2, i1, i, pv ); 425 426 } while (0) 427 428 429 #define RENDER_QUAD( i3, i2, i1, i, pv) 430 do { 431 const GLubyte flags = cullmask[i]; 432 433 if (!(flags & PRIM_NOT_CULLED)) 434 continue; 435 436 if (flags&PRIM_ANY_CLIP) { 437 vlist[0] = i3; 438 vlist[1] = i2; 439 vlist[2] = i1; 440 vlist[3] = i; 441 gl_render_clipped_triangle( ctx, 4, vlist, pv ); 442 } else 443 ctx->QuadFunc( ctx, i3, i2, i1, i, pv ); 444 } while (0) 445 446 447 #define LOCAL_VARS 448 GLcontext *ctx = VB->ctx; 449 const GLubyte *cullmask = VB->CullMask; 450 GLuint vlist[VB_SIZE]; 451 GLubyte *eflag = VB->EdgeFlagPtr->data; 439 #define RENDER_LINE( i1, i ) \ 440 do { \ 441 const GLubyte flags = cullmask[i]; \ 442 \ 443 if (!(flags & PRIM_NOT_CULLED)) \ 444 continue; \ 445 \ 446 if (flags & PRIM_ANY_CLIP) \ 447 gl_render_clipped_line( ctx, i1, i ); \ 448 else \ 449 ctx->Driver.LineFunc( ctx, i1, i, i ); \ 450 } while (0) 451 452 453 454 #define RENDER_TRI( i2, i1, i, pv, parity) \ 455 do { \ 456 const GLubyte flags = cullmask[i]; \ 457 \ 458 if (!(flags & PRIM_NOT_CULLED)) \ 459 continue; \ 460 \ 461 if (flags & PRIM_ANY_CLIP) { \ 462 if (parity) { \ 463 vlist[0] = i1; \ 464 vlist[1] = i2; \ 465 vlist[2] = i; \ 466 } else { \ 467 vlist[0] = i2; \ 468 vlist[1] = i1; \ 469 vlist[2] = i; \ 470 } \ 471 gl_render_clipped_triangle( ctx, 3, vlist, pv ); \ 472 } else if (parity) \ 473 ctx->TriangleFunc( ctx, i1, i2, i, pv ); \ 474 else \ 475 ctx->TriangleFunc( ctx, i2, i1, i, pv ); \ 476 \ 477 } while (0) 478 479 480 #define RENDER_QUAD( i3, i2, i1, i, pv) \ 481 do { \ 482 const GLubyte flags = cullmask[i]; \ 483 \ 484 if (!(flags & PRIM_NOT_CULLED)) \ 485 continue; \ 486 \ 487 if (flags&PRIM_ANY_CLIP) { \ 488 vlist[0] = i3; \ 489 vlist[1] = i2; \ 490 vlist[2] = i1; \ 491 vlist[3] = i; \ 492 gl_render_clipped_triangle( ctx, 4, vlist, pv ); \ 493 } else \ 494 ctx->QuadFunc( ctx, i3, i2, i1, i, pv ); \ 495 } while (0) 496 497 498 #define LOCAL_VARS \ 499 GLcontext *ctx = VB->ctx; \ 500 const GLubyte *cullmask = VB->CullMask; \ 501 GLuint vlist[VB_SIZE]; \ 502 GLubyte *eflag = VB->EdgeFlagPtr->data; \ 452 503 GLuint *stipplecounter = &VB->ctx->StippleCounter; \ 453 504 (void) vlist; (void) eflag; (void) stipplecounter; … … 472 523 (*ctx->Driver.LineFunc)( ctx, i1, i, i ) 473 524 474 #define RENDER_TRI( i2, i1, i, pv, parity ) 475 do { 476 if (parity) 477 ctx->TriangleFunc( ctx, i1, i2, i, pv ); 478 else 479 ctx->TriangleFunc( ctx, i2, i1, i, pv ); 480 } while (0) 481 482 483 #define RENDER_QUAD( i3, i2, i1, i, pv ) 525 #define RENDER_TRI( i2, i1, i, pv, parity ) \ 526 do { \ 527 if (parity) \ 528 ctx->TriangleFunc( ctx, i1, i2, i, pv ); \ 529 else \ 530 ctx->TriangleFunc( ctx, i2, i1, i, pv ); \ 531 } while (0) 532 533 534 #define RENDER_QUAD( i3, i2, i1, i, pv ) \ 484 535 ctx->QuadFunc( ctx, i3, i2, i1, i, i ); 485 536 486 537 #define TAG(x) x##_raw 487 538 488 #define LOCAL_VARS 489 GLcontext *ctx = VB->ctx; 490 GLubyte *eflag = VB->EdgeFlagPtr->data; 539 #define LOCAL_VARS \ 540 GLcontext *ctx = VB->ctx; \ 541 GLubyte *eflag = VB->EdgeFlagPtr->data; \ 491 542 GLuint *stipplecounter = &VB->ctx->StippleCounter; \ 492 543 (void) eflag; (void) stipplecounter; … … 501 552 /* Direct, with the possibility of clipping. 502 553 */ 503 #define RENDER_POINTS( start, count ) 554 #define RENDER_POINTS( start, count ) \ 504 555 (*ctx->Driver.PointsFunc)( ctx, start, count-1 ) 505 556 506 #define RENDER_LINE( i1, i ) 557 #define RENDER_LINE( i1, i ) \ 507 558 gl_render_clipped_line2( ctx, i1, i ) 508 559 509 #define RENDER_TRI( i2, i1, i, pv, parity) \ 510 do { \ 511 GLuint e1=i1, e0=i; \ 512 if (parity) { GLuint t=e1; e1=e0; e0=t; } \ 513 gl_render_clipped_triangle2(ctx,i2,e1,e0,pv); \ 514 } while (0) 515 516 #define RENDER_QUAD( i3, i2, i1, i, pv) \ 517 do { \ 518 gl_render_clipped_triangle2(ctx,i3,i2,i1,pv); \ 519 gl_render_clipped_triangle2(ctx,i3,i1,i,pv); \ 520 } while (0) 521 522 /* gl_render_clipped_triangle2(ctx,i3,i2,i,pv); */ 523 /* gl_render_clipped_triangle2(ctx,i2,i1,i,pv); */ 524 525 526 #define LOCAL_VARS \ 527 GLcontext *ctx = VB->ctx; \ 528 GLubyte *eflag = VB->EdgeFlagPtr->data; \ 560 #define RENDER_TRI( i2, i1, i, pv, parity) \ 561 do { \ 562 GLuint e2=i2, e1=i1; \ 563 if (parity) { GLuint t=e2; e2=e1; e1=t; } \ 564 gl_render_clipped_triangle2(ctx,e2,e1,i,pv); \ 565 } while (0) 566 567 #define RENDER_QUAD( i3, i2, i1, i, pv) \ 568 do { \ 569 gl_render_clipped_quad2(ctx,i3,i2,i1,i,pv); \ 570 } while (0) 571 572 573 #define LOCAL_VARS \ 574 GLcontext *ctx = VB->ctx; \ 575 GLubyte *eflag = VB->EdgeFlagPtr->data; \ 529 576 GLuint *stipplecounter = &VB->ctx->StippleCounter; \ 530 577 (void) eflag; (void) stipplecounter; … … 557 604 * Keith. 558 605 */ 559 void gl_setup_edgeflag( struct vertex_buffer *VB, 560 GLenum prim, 561 GLuint start, 562 GLuint count, 563 GLuint parity ) 606 static void 607 setup_edgeflag( struct vertex_buffer *VB, 608 GLenum prim, 609 GLuint start, 610 GLuint count, 611 GLuint parity ) 564 612 { 565 613 GLubyte *flag = VB->EdgeFlagPtr->data + start; … … 571 619 case GL_TRIANGLES: 572 620 for (i = 0 ; i < n-2 ; i+=3) { 573 if (flag[i]) flag[i] = 0x5;574 if (flag[i+1]) flag[i+1] = 0x5;575 if (flag[i+2]) flag[i+2] = 0x6;621 if (flag[i]) flag[i] = 0x1; 622 if (flag[i+1]) flag[i+1] = 0x1; 623 if (flag[i+2]) flag[i+2] = 0x3; 576 624 } 577 625 break; 578 626 case GL_QUADS: 579 627 for (i = 0 ; i < n-3 ; i+=4) { 580 if (flag[i]) flag[i] = 0x5;581 if (flag[i+1]) flag[i+1] = 0x5;582 if (flag[i+2]) flag[i+2] = 0x5;583 if (flag[i+3]) flag[i+3] = 0x6;628 if (flag[i]) flag[i] = 0x1; 629 if (flag[i+1]) flag[i+1] = 0x1; 630 if (flag[i+2]) flag[i+2] = 0x1; 631 if (flag[i+3]) flag[i+3] = 0x3; 584 632 } 585 633 break; 586 634 case GL_POLYGON: 587 for (i = 0 ; i < n-1 ; i++) { 588 if (flag[i]) flag[i] = 0x5; 589 } 590 if (flag[i]) flag[i] = 0x6; 635 if (flag[0]) flag[0] = 0x1; 636 for (i = 1 ; i < n-1 ; i++) { 637 if (flag[i]) flag[i] = 0x1<<2; 638 } 639 if (flag[i]) flag[i] = 0x3<<2; 591 640 break; 592 641 default: … … 628 677 629 678 gl_import_client_data( VB, ctx->RenderFlags, 630 631 632 679 (VB->ClipOrMask 680 ? VEC_WRITABLE|VEC_GOOD_STRIDE 681 : VEC_GOOD_STRIDE)); 633 682 634 683 if (/* ctx->Current.Primitive == GL_POLYGON+1 && */ … … 640 689 for ( i= VB->CopyStart ; i < count ; parity = 0, i = next ) 641 690 { 642 643 644 645 646 gl_setup_edgeflag(VB, (GLenum)prim, i, next, parity);647 648 649 650 651 652 653 654 691 prim = VB->Primitive[i]; 692 next = VB->NextPrimitive[i]; 693 694 if (ctx->TriangleCaps & DD_TRI_UNFILLED) 695 setup_edgeflag(VB, prim, i, next, parity); 696 697 tab[prim]( VB, i, next, parity ); 698 699 if (ctx->TriangleCaps & DD_TRI_LIGHT_TWOSIDE) { 700 VB->Specular = VB->Spec[0]; 701 VB->ColorPtr = VB->Color[0]; 702 VB->IndexPtr = VB->Index[0]; 703 } 655 704 } 656 705 657 706 } while (ctx->Driver.MultipassFunc && 658 707 ctx->Driver.MultipassFunc( VB, ++p )); 659 708 660 709 if (ctx->PB->count > 0) … … 670 719 { 671 720 if (ctx->PB->count > 0) 672 gl_flush_pb(ctx); 673 674 ctx->PB->count = 0; 675 ctx->PB->mono = GL_FALSE; 721 gl_flush_pb(ctx); 722 723 ctx->PB->count = 0; 724 ctx->PB->mono = GL_FALSE; 676 725 677 726 if (ctx->PB->primitive != prim) { 678 ctx->PB->primitive = prim; 727 ctx->PB->primitive = prim; 679 728 680 729 if (ctx->Driver.ReducedPrimitiveChange) 681 730 ctx->Driver.ReducedPrimitiveChange( ctx, prim ); 682 731 } 683 732 } … … 695 744 ctx->Driver.RenderVBRawTab = render_tab_raw; 696 745 697 /* Culling will be done earlier by gl_cull_vb(). 698 */ 699 if (ctx->IndirectTriangles & (DD_SW_SETUP & ~DD_TRI_CULL)) { 700 ctx->TriangleFunc = render_triangle; 701 ctx->QuadFunc = render_quad; 702 } else { 703 ctx->TriangleFunc = ctx->Driver.TriangleFunc; 704 ctx->QuadFunc = ctx->Driver.QuadFunc; 705 } 706 707 if (ctx->IndirectTriangles & (DD_SW_SETUP)) { 746 ctx->TriangleFunc = ctx->Driver.TriangleFunc; 747 ctx->QuadFunc = ctx->Driver.QuadFunc; 748 ctx->ClippedTriangleFunc = ctx->TriangleFunc; 749 750 if (ctx->IndirectTriangles & DD_SW_SETUP) { 751 708 752 ctx->ClippedTriangleFunc = render_triangle; 709 } else { 710 ctx->ClippedTriangleFunc = ctx->TriangleFunc; 711 } 712 753 754 if (ctx->IndirectTriangles & (DD_SW_SETUP & ~DD_TRI_CULL)) { 755 if (ctx->IndirectTriangles & DD_TRI_CULL_FRONT_BACK) { 756 ctx->TriangleFunc = null_triangle; 757 ctx->QuadFunc = render_quad; 758 ctx->ClippedTriangleFunc = null_triangle; 759 } else { 760 ctx->TriangleFunc = render_triangle; 761 ctx->QuadFunc = render_quad; 762 } 763 } 764 } 713 765 } 714 766
Note:
See TracChangeset
for help on using the changeset viewer.