Changeset 3598 for trunk/src/opengl/mesa/3dfx/fxsetup.c
- Timestamp:
- May 23, 2000, 10:41:28 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/opengl/mesa/3dfx/fxsetup.c
r2938 r3598 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. … … 57 57 58 58 static GLuint fxGetTexSetConfiguration(GLcontext *ctx, 59 60 59 struct gl_texture_object *tObj0, 60 struct gl_texture_object *tObj1); 61 61 static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset); 62 static void fxSetupTextureSingleTMU(GLcontext *ctx, GLuint textureset); 63 static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa, 64 struct gl_texture_object *tObj0, 65 struct gl_texture_object *tObj1); 62 static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa, 63 struct gl_texture_object *tObj0, 64 struct gl_texture_object *tObj1); 65 static void fxSetupTexture_NoLock(GLcontext *ctx); 66 static void fxSetupTexture(GLcontext *ctx); 66 67 static void fxSetupBlend(GLcontext *ctx); 67 68 static void fxSetupDepthTest(GLcontext *ctx); 68 static void fxFogTableGenerate(GLcontext *ctx);69 static void fxSetupFog(GLcontext *ctx, GLboolean forceTableRebuild);70 69 static void fxSetupScissor(GLcontext *ctx); 71 70 static void fxSetupCull(GLcontext *ctx); … … 85 84 if(ti->validated) { 86 85 if (MESA_VERBOSE&VERBOSE_DRIVER) { 87 86 fprintf(stderr,"fxmesa: fxTexValidate(...) End (validated=GL_TRUE)\n"); 88 87 } 89 88 return; … … 95 94 96 95 fxTexGetInfo(tObj->Image[minl]->Width, tObj->Image[minl]->Height, 97 98 99 &(ti->int_sScale), &(ti->int_tScale), 100 96 &(FX_largeLodLog2(ti->info)), &(FX_aspectRatioLog2(ti->info)), 97 &(ti->sScale), &(ti->tScale), 98 &(ti->int_sScale), &(ti->int_tScale), 99 NULL, NULL); 101 100 102 101 if((tObj->MinFilter!=GL_NEAREST) && (tObj->MinFilter!=GL_LINEAR)) 103 102 fxTexGetInfo(tObj->Image[maxl]->Width,tObj->Image[maxl]->Height, 104 105 106 107 103 &(FX_smallLodLog2(ti->info)),NULL, 104 NULL,NULL, 105 NULL,NULL, 106 NULL,NULL); 108 107 else 109 108 FX_smallLodLog2(ti->info)=FX_largeLodLog2(ti->info); 110 109 111 fxTexGetFormat(tObj->Image[minl]-> Format,&(ti->info.format),&(ti->baseLevelInternalFormat));110 fxTexGetFormat(tObj->Image[minl]->IntFormat,&(ti->info.format),&(ti->baseLevelInternalFormat)); 112 111 113 112 switch (tObj->WrapS) { … … 147 146 static void fxPrintUnitsMode( const char *msg, GLuint mode ) 148 147 { 149 fprintf(stderr, 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 148 fprintf(stderr, 149 "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", 150 msg, 151 mode, 152 (mode & FX_UM_E0_REPLACE) ? "E0_REPLACE, " : "", 153 (mode & FX_UM_E0_MODULATE) ? "E0_MODULATE, " : "", 154 (mode & FX_UM_E0_DECAL) ? "E0_DECAL, " : "", 155 (mode & FX_UM_E0_BLEND) ? "E0_BLEND, " : "", 156 (mode & FX_UM_E1_REPLACE) ? "E1_REPLACE, " : "", 157 (mode & FX_UM_E1_MODULATE) ? "E1_MODULATE, " : "", 158 (mode & FX_UM_E1_DECAL) ? "E1_DECAL, " : "", 159 (mode & FX_UM_E1_BLEND) ? "E1_BLEND, " : "", 160 (mode & FX_UM_E0_ALPHA) ? "E0_ALPHA, " : "", 161 (mode & FX_UM_E0_LUMINANCE) ? "E0_LUMINANCE, " : "", 162 (mode & FX_UM_E0_LUMINANCE_ALPHA) ? "E0_LUMINANCE_ALPHA, " : "", 163 (mode & FX_UM_E0_INTENSITY) ? "E0_INTENSITY, " : "", 164 (mode & FX_UM_E0_RGB) ? "E0_RGB, " : "", 165 (mode & FX_UM_E0_RGBA) ? "E0_RGBA, " : "", 166 (mode & FX_UM_E1_ALPHA) ? "E1_ALPHA, " : "", 167 (mode & FX_UM_E1_LUMINANCE) ? "E1_LUMINANCE, " : "", 168 (mode & FX_UM_E1_LUMINANCE_ALPHA) ? "E1_LUMINANCE_ALPHA, " : "", 169 (mode & FX_UM_E1_INTENSITY) ? "E1_INTENSITY, " : "", 170 (mode & FX_UM_E1_RGB) ? "E1_RGB, " : "", 171 (mode & FX_UM_E1_RGBA) ? "E1_RGBA, " : "", 172 (mode & FX_UM_COLOR_ITERATED) ? "COLOR_ITERATED, " : "", 173 (mode & FX_UM_COLOR_CONSTANT) ? "COLOR_CONSTANT, " : "", 174 (mode & FX_UM_ALPHA_ITERATED) ? "ALPHA_ITERATED, " : "", 175 (mode & FX_UM_ALPHA_CONSTANT) ? "ALPHA_CONSTANT, " : ""); 177 176 } 178 177 179 178 static GLuint fxGetTexSetConfiguration(GLcontext *ctx, 180 181 179 struct gl_texture_object *tObj0, 180 struct gl_texture_object *tObj1) 182 181 { 183 182 GLuint unitsmode=0; … … 198 197 unitsmode|=FX_UM_COLOR_CONSTANT; 199 198 199 /* 200 OpenGL Feeds Texture 0 into Texture 1 201 Glide Feeds Texture 1 into Texture 0 202 */ 200 203 if(tObj0) { 201 204 tfxTexInfo *ti0=fxTMGetTexInfo(tObj0); … … 310 313 { 311 314 tfxTexInfo *ti=fxTMGetTexInfo(tObj); 312 315 int tmu; 316 317 /* Make sure we're not loaded incorrectly */ 318 if (ti->isInTM) { 319 if (ti->LODblend) { 320 if (ti->whichTMU!=FX_TMU_SPLIT) 321 fxTMMoveOutTM(fxMesa, tObj); 322 } else { 323 if (ti->whichTMU==FX_TMU_SPLIT) 324 fxTMMoveOutTM(fxMesa, tObj); 325 } 326 } 327 328 /* Make sure we're loaded correctly */ 313 329 if (!ti->isInTM) { 314 330 if (ti->LODblend) … … 316 332 else { 317 333 if (fxMesa->haveTwoTMUs) { 318 #if 0 319 /* This path is disabled because we're not correctly setting up 320 the second TMU as the only texture unit. It is arguable if this 321 fallback is ever really a win, because when we use the second 322 TMU we have to do setup for both TMU0 and TMU1 which is extra 323 work. We could just flush a texture from TMU0 instead. */ 324 if (fxMesa->freeTexMem[FX_TMU0] > 325 FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH, 326 &(ti->info))) { 327 fxTMMoveInTM_NoLock(fxMesa,tObj, FX_TMU0); 328 } else { 329 fxTMMoveInTM_NoLock(fxMesa,tObj, FX_TMU1); 330 } 331 #else 332 fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU0); 333 #endif 334 if (fxMesa->freeTexMem[FX_TMU0] > 335 FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH, 336 &(ti->info))) { 337 fxTMMoveInTM_NoLock(fxMesa,tObj, FX_TMU0); 338 } else { 339 fxTMMoveInTM_NoLock(fxMesa,tObj, FX_TMU1); 340 } 334 341 } else 335 342 fxTMMoveInTM_NoLock(fxMesa,tObj,FX_TMU0); 336 343 } 337 344 } … … 340 347 if ((ti->info.format==GR_TEXFMT_P_8) && (!fxMesa->haveGlobalPaletteTexture)) { 341 348 if (MESA_VERBOSE&VERBOSE_DRIVER) { 342 349 fprintf(stderr,"fxmesa: uploading texture palette\n"); 343 350 } 344 351 FX_grTexDownloadTable_NoLock(GR_TMU0,GR_TEXTABLE_PALETTE,&(ti->palette)); … … 354 361 355 362 FX_grTexSource_NoLock(GR_TMU0,ti->tm[FX_TMU0]->startAddr, 356 363 GR_MIPMAPLEVELMASK_ODD,&(ti->info)); 357 364 FX_grTexSource_NoLock(GR_TMU1,ti->tm[FX_TMU1]->startAddr, 358 365 GR_MIPMAPLEVELMASK_EVEN,&(ti->info)); 359 366 } else { 367 if (ti->whichTMU==FX_TMU_BOTH) tmu=FX_TMU0; 368 else tmu=ti->whichTMU; 369 360 370 if((ti->info.format==GR_TEXFMT_P_8) && (!fxMesa->haveGlobalPaletteTexture)) { 361 371 if (MESA_VERBOSE&VERBOSE_DRIVER) { 362 372 fprintf(stderr,"fxmesa: uploading texture palette\n"); 363 373 } 364 FX_grTexDownloadTable_NoLock(t i->whichTMU,GR_TEXTABLE_PALETTE,&(ti->palette));374 FX_grTexDownloadTable_NoLock(tmu, GR_TEXTABLE_PALETTE, &(ti->palette)); 365 375 } 366 376 367 377 /* KW: The alternative is to do the download to the other tmu. If 368 378 * we get to this point, I think it means we are thrashing the 369 * texture memory, so perhaps it's not a good idea. 379 * texture memory, so perhaps it's not a good idea. 370 380 */ 371 381 if (ti->LODblend && (MESA_VERBOSE&VERBOSE_DRIVER)) 372 382 fprintf(stderr, "fxmesa: not blending texture - only on one tmu\n"); 373 383 374 FX_grTexClampMode_NoLock(ti->whichTMU,ti->sClamp,ti->tClamp); 375 FX_grTexFilterMode_NoLock(ti->whichTMU,ti->minFilt,ti->maxFilt); 376 FX_grTexMipMapMode_NoLock(ti->whichTMU,ti->mmMode,FXFALSE); 377 378 FX_grTexSource_NoLock(ti->whichTMU, 379 ti->tm[ti->whichTMU]->startAddr, 380 GR_MIPMAPLEVELMASK_BOTH,&(ti->info)); 381 } 382 } 383 384 static void fxSetupSingleTMU(fxMesaContext fxMesa, struct gl_texture_object *tObj) { 385 BEGIN_BOARD_LOCK(); 386 fxSetupSingleTMU_NoLock(fxMesa, tObj); 387 END_BOARD_LOCK(); 388 } 389 390 static void fxSelectSingleTMUSrc_NoLock(fxMesaContext fxMesa, GLint tmu, 391 FxBool LODblend) 392 { 393 if (MESA_VERBOSE&VERBOSE_DRIVER) { 394 fprintf(stderr,"fxmesa: fxSelectSingleTMUSrc(%d,%d)\n",tmu,LODblend); 395 } 396 397 if(LODblend) { 384 FX_grTexClampMode_NoLock(tmu, ti->sClamp, ti->tClamp); 385 FX_grTexFilterMode_NoLock(tmu, ti->minFilt, ti->maxFilt); 386 FX_grTexMipMapMode_NoLock(tmu, ti->mmMode, FXFALSE); 387 388 FX_grTexSource_NoLock(tmu, ti->tm[tmu]->startAddr, 389 GR_MIPMAPLEVELMASK_BOTH, &(ti->info)); 390 } 391 } 392 393 static void fxSelectSingleTMUSrc_NoLock(fxMesaContext fxMesa, GLint tmu, 394 FxBool LODblend) 395 { 396 if (MESA_VERBOSE&VERBOSE_DRIVER) { 397 fprintf(stderr,"fxmesa: fxSelectSingleTMUSrc(%d,%d)\n",tmu,LODblend); 398 } 399 400 if (LODblend) { 398 401 FX_grTexCombine_NoLock(GR_TMU0, 399 GR_COMBINE_FUNCTION_BLEND, 400 GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION, 401 GR_COMBINE_FUNCTION_BLEND, 402 GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION, 403 FXFALSE,FXFALSE); 404 405 FX_grTexCombine_NoLock(GR_TMU1, 406 GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, 407 GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, 408 FXFALSE,FXFALSE); 402 GR_COMBINE_FUNCTION_BLEND, 403 GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION, 404 GR_COMBINE_FUNCTION_BLEND, 405 GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION, 406 FXFALSE,FXFALSE); 407 408 if (fxMesa->haveTwoTMUs) 409 FX_grTexCombine_NoLock(GR_TMU1, 410 GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, 411 GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, 412 FXFALSE,FXFALSE); 409 413 fxMesa->tmuSrc=FX_TMU_SPLIT; 410 } else { 411 if(tmu==FX_TMU0) { 414 } 415 else { 416 if (tmu!=FX_TMU1) { 412 417 FX_grTexCombine_NoLock(GR_TMU0, 413 GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, 414 GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, 415 FXFALSE,FXFALSE); 418 GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, 419 GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, 420 FXFALSE,FXFALSE); 421 if (fxMesa->haveTwoTMUs) { 422 FX_grTexCombine_NoLock(GR_TMU1, 423 GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE, 424 GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE, 425 FXFALSE,FXFALSE); 426 } 416 427 fxMesa->tmuSrc=FX_TMU0; 417 } else { 428 } 429 else { 418 430 FX_grTexCombine_NoLock(GR_TMU1, 419 420 421 422 431 GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, 432 GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, 433 FXFALSE,FXFALSE); 434 423 435 /* GR_COMBINE_FUNCTION_SCALE_OTHER doesn't work ?!? */ 424 436 425 437 FX_grTexCombine_NoLock(GR_TMU0, 426 427 428 429 430 431 438 GR_COMBINE_FUNCTION_BLEND, 439 GR_COMBINE_FACTOR_ONE, 440 GR_COMBINE_FUNCTION_BLEND, 441 GR_COMBINE_FACTOR_ONE, 442 FXFALSE,FXFALSE); 443 432 444 fxMesa->tmuSrc=FX_TMU1; 433 445 } … … 443 455 tfxTexInfo *ti; 444 456 struct gl_texture_object *tObj=ctx->Texture.Unit[textureset].CurrentD[2]; 457 int tmu; 445 458 446 459 if (MESA_VERBOSE&VERBOSE_DRIVER) { … … 454 467 fxSetupSingleTMU_NoLock(fxMesa,tObj); 455 468 456 if(fxMesa->tmuSrc!=ti->whichTMU) 457 fxSelectSingleTMUSrc_NoLock(fxMesa,ti->whichTMU,ti->LODblend); 469 if (ti->whichTMU==FX_TMU_BOTH) tmu=FX_TMU0; 470 else tmu=ti->whichTMU; 471 if (fxMesa->tmuSrc!=tmu) 472 fxSelectSingleTMUSrc_NoLock(fxMesa, tmu, ti->LODblend); 458 473 459 474 if(textureset==0 || !fxMesa->haveTwoTMUs) … … 484 499 if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE)) 485 500 fprintf(stderr, "fxMesa: fxSetupTextureSingleTMU, envmode is %s\n", 486 501 gl_lookup_enum_by_nr(ctx->Texture.Unit[textureset].EnvMode)); 487 502 488 503 switch(ctx->Texture.Unit[textureset].EnvMode) { 489 504 case GL_DECAL: 490 505 FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, 491 492 493 494 506 GR_COMBINE_FACTOR_NONE, 507 locala, 508 GR_COMBINE_OTHER_NONE, 509 FXFALSE); 495 510 496 511 FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_BLEND, 497 498 499 500 512 GR_COMBINE_FACTOR_TEXTURE_ALPHA, 513 localc, 514 GR_COMBINE_OTHER_TEXTURE, 515 FXFALSE); 501 516 break; 502 517 case GL_MODULATE: 503 518 FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, 504 505 506 507 519 GR_COMBINE_FACTOR_LOCAL, 520 locala, 521 GR_COMBINE_OTHER_TEXTURE, 522 FXFALSE); 508 523 509 524 if(ifmt==GL_ALPHA) 510 525 FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, 511 512 513 514 526 GR_COMBINE_FACTOR_NONE, 527 localc, 528 GR_COMBINE_OTHER_NONE, 529 FXFALSE); 515 530 else 516 531 FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, 517 518 519 520 532 GR_COMBINE_FACTOR_LOCAL, 533 localc, 534 GR_COMBINE_OTHER_TEXTURE, 535 FXFALSE); 521 536 break; 522 537 case GL_BLEND: 538 #if 0 523 539 FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, 524 525 526 527 540 GR_COMBINE_FACTOR_LOCAL, 541 locala, 542 GR_COMBINE_OTHER_TEXTURE, 543 FXFALSE); 528 544 if (ifmt==GL_ALPHA) 529 545 FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, 530 531 532 533 546 GR_COMBINE_FACTOR_NONE, 547 localc, 548 GR_COMBINE_OTHER_NONE, 549 FXFALSE); 534 550 else 535 551 FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, 536 GR_COMBINE_FACTOR_LOCAL, 537 localc, 538 GR_COMBINE_OTHER_TEXTURE, 539 FXTRUE); 540 /*ctx->Driver.MultipassFunc = fxMultipassBlend;*/ 552 GR_COMBINE_FACTOR_LOCAL, 553 localc, 554 GR_COMBINE_OTHER_TEXTURE, 555 FXTRUE); 556 ctx->Driver.MultipassFunc = fxMultipassBlend; 557 #else 558 #ifndef FX_SILENT 559 fprintf(stderr,"fx Driver: GL_BLEND not yet supported\n"); 560 #endif 561 #endif 541 562 break; 542 563 case GL_REPLACE: 543 564 if((ifmt==GL_RGB) || (ifmt==GL_LUMINANCE)) 544 565 FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, 545 546 547 548 566 GR_COMBINE_FACTOR_NONE, 567 locala, 568 GR_COMBINE_OTHER_NONE, 569 FXFALSE); 549 570 else 550 571 FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, 551 552 553 554 555 572 GR_COMBINE_FACTOR_ONE, 573 locala, 574 GR_COMBINE_OTHER_TEXTURE, 575 FXFALSE); 576 556 577 if(ifmt==GL_ALPHA) 557 578 FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, 558 559 560 561 579 GR_COMBINE_FACTOR_NONE, 580 localc, 581 GR_COMBINE_OTHER_NONE, 582 FXFALSE); 562 583 else 563 584 FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, 564 565 566 567 585 GR_COMBINE_FACTOR_ONE, 586 localc, 587 GR_COMBINE_OTHER_TEXTURE, 588 FXFALSE); 568 589 break; 569 590 default: … … 587 608 /************************* Double Texture Set ***************************/ 588 609 589 static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa, 590 591 610 static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa, 611 struct gl_texture_object *tObj0, 612 struct gl_texture_object *tObj1) 592 613 { 593 614 #define T0_NOT_IN_TMU 0x01 … … 601 622 tfxTexInfo *ti1=fxTMGetTexInfo(tObj1); 602 623 GLuint tstate=0; 624 int tmu0=0, tmu1=1; 603 625 604 626 if (MESA_VERBOSE&VERBOSE_DRIVER) { … … 606 628 } 607 629 608 if(ti0->isInTM) { 609 if(ti0->whichTMU==FX_TMU0) 630 /* We shouldn't need to do this. There is something wrong with 631 mutlitexturing when the TMUs are swapped. So, we're forcing 632 them to always be loaded correctly. !!! */ 633 if (ti0->whichTMU==FX_TMU1) 634 fxTMMoveOutTM_NoLock(fxMesa, tObj0); 635 if (ti1->whichTMU==FX_TMU0) 636 fxTMMoveOutTM_NoLock(fxMesa, tObj1); 637 638 if (ti0->isInTM) { 639 switch (ti0->whichTMU) { 640 case FX_TMU0: 610 641 tstate|=T0_IN_TMU0; 611 else if(ti0->whichTMU==FX_TMU1) 642 break; 643 case FX_TMU1: 612 644 tstate|=T0_IN_TMU1; 613 else { 614 fxTMMoveOutTM(fxMesa,tObj0); 645 break; 646 case FX_TMU_BOTH: 647 tstate|=T0_IN_TMU0|T0_IN_TMU1; 648 break; 649 case FX_TMU_SPLIT: 615 650 tstate|=T0_NOT_IN_TMU; 616 } 617 } else 618 tstate|=T0_NOT_IN_TMU; 619 620 if(ti1->isInTM) { 621 if(ti1->whichTMU==FX_TMU0) 651 break; 652 } 653 } else tstate|=T0_NOT_IN_TMU; 654 655 if (ti1->isInTM) { 656 switch (ti1->whichTMU) { 657 case FX_TMU0: 622 658 tstate|=T1_IN_TMU0; 623 else if(ti1->whichTMU==FX_TMU1) 659 break; 660 case FX_TMU1: 624 661 tstate|=T1_IN_TMU1; 625 else { 626 fxTMMoveOutTM(fxMesa,tObj1); 662 break; 663 case FX_TMU_BOTH: 664 tstate|=T1_IN_TMU0|T1_IN_TMU1; 665 break; 666 case FX_TMU_SPLIT: 627 667 tstate|=T1_NOT_IN_TMU; 628 }629 } else630 668 break; 669 } 670 } else tstate|=T1_NOT_IN_TMU; 631 671 632 672 ti0->lastTimeUsed=fxMesa->texBindNumber; 633 673 ti1->lastTimeUsed=fxMesa->texBindNumber; 634 674 635 /* Move texture maps in TMUs */ 636 637 switch(tstate) { 638 case (T0_IN_TMU0 | T1_IN_TMU0): 639 fxTMMoveOutTM(fxMesa,tObj1); 640 641 fxTMMoveInTM_NoLock(fxMesa,tObj1,FX_TMU1); 642 break; 643 644 case (T0_IN_TMU1 | T1_IN_TMU1): 645 fxTMMoveOutTM(fxMesa,tObj0); 646 647 fxTMMoveInTM_NoLock(fxMesa,tObj0,FX_TMU0); 648 break; 649 650 case (T0_NOT_IN_TMU | T1_NOT_IN_TMU): 651 fxTMMoveInTM_NoLock(fxMesa,tObj0,FX_TMU0); 652 fxTMMoveInTM_NoLock(fxMesa,tObj1,FX_TMU1); 653 break; 654 655 /*** T0/T1 ***/ 656 657 case (T0_NOT_IN_TMU | T1_IN_TMU0): 658 fxTMMoveInTM_NoLock(fxMesa,tObj0,FX_TMU1); 659 break; 660 661 case (T0_NOT_IN_TMU | T1_IN_TMU1): 662 fxTMMoveInTM_NoLock(fxMesa,tObj0,FX_TMU0); 663 break; 664 665 case (T0_IN_TMU0 | T1_NOT_IN_TMU): 666 fxTMMoveInTM_NoLock(fxMesa,tObj1,FX_TMU1); 667 break; 668 669 case (T0_IN_TMU1 | T1_NOT_IN_TMU): 670 fxTMMoveInTM_NoLock(fxMesa,tObj1,FX_TMU0); 671 break; 672 673 /*** Best Case ***/ 674 675 case (T0_IN_TMU1 | T1_IN_TMU0): 676 case (T0_IN_TMU0 | T1_IN_TMU1): 677 break; 678 679 default: 680 fprintf(stderr,"fx Driver: internal error in fxSetupDoubleTMU()\n"); 681 fxCloseHardware(); 682 exit(-1); 683 break; 675 /* Move texture maps into TMUs */ 676 677 if (!(((tstate&T0_IN_TMU0) && (tstate&T1_IN_TMU1)) || 678 ((tstate&T0_IN_TMU1) && (tstate&T1_IN_TMU0)))) { 679 if (tObj0==tObj1) fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU_BOTH); 680 else { 681 /* Find the minimal way to correct the situation */ 682 if ((tstate&T0_IN_TMU0) || (tstate&T1_IN_TMU1)) { 683 /* We have one in the standard order, setup the other */ 684 if (tstate&T0_IN_TMU0) { /* T0 is in TMU0, put T1 in TMU1 */ 685 fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1); 686 } else { 687 fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0); 688 } 689 /* tmu0 and tmu1 are setup */ 690 } else if ((tstate&T0_IN_TMU1) || (tstate&T1_IN_TMU0)) { 691 /* we have one in the reverse order, setup the other */ 692 if (tstate&T1_IN_TMU0) { /* T1 is in TMU0, put T0 in TMU1 */ 693 fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU1); 694 } else { 695 fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU0); 696 } 697 tmu0=1; 698 tmu1=0; 699 } else { /* Nothing is loaded */ 700 fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0); 701 fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1); 702 /* tmu0 and tmu1 are setup */ 703 } 704 } 684 705 } 685 706 … … 687 708 if (ti0->info.format==GR_TEXFMT_P_8) { 688 709 if (MESA_VERBOSE&VERBOSE_DRIVER) { 689 710 fprintf(stderr,"fxmesa: uploading texture palette TMU0\n"); 690 711 } 691 FX_grTexDownloadTable_NoLock(t i0->whichTMU,GR_TEXTABLE_PALETTE,&(ti0->palette));712 FX_grTexDownloadTable_NoLock(tmu0, GR_TEXTABLE_PALETTE, &(ti0->palette)); 692 713 } 693 714 694 715 if (ti1->info.format==GR_TEXFMT_P_8) { 695 716 if (MESA_VERBOSE&VERBOSE_DRIVER) { 696 717 fprintf(stderr,"fxmesa: uploading texture palette TMU1\n"); 697 718 } 698 FX_grTexDownloadTable_NoLock(ti1->whichTMU, GR_TEXTABLE_PALETTE,&(ti1->palette)); 699 } 700 } 701 702 FX_grTexSource_NoLock(ti0->whichTMU, 703 ti0->tm[ti0->whichTMU]->startAddr, 704 GR_MIPMAPLEVELMASK_BOTH,&(ti0->info)); 705 FX_grTexClampMode_NoLock(ti0->whichTMU,ti0->sClamp,ti0->tClamp); 706 FX_grTexFilterMode_NoLock(ti0->whichTMU,ti0->minFilt,ti0->maxFilt); 707 FX_grTexMipMapMode_NoLock(ti0->whichTMU,ti0->mmMode,FXFALSE); 708 709 FX_grTexSource_NoLock(ti1->whichTMU, 710 ti1->tm[ti1->whichTMU]->startAddr, 711 GR_MIPMAPLEVELMASK_BOTH,&(ti1->info)); 712 FX_grTexClampMode_NoLock(ti1->whichTMU,ti1->sClamp,ti1->tClamp); 713 FX_grTexFilterMode_NoLock(ti1->whichTMU,ti1->minFilt,ti1->maxFilt); 714 FX_grTexMipMapMode_NoLock(ti1->whichTMU,ti1->mmMode,FXFALSE); 719 FX_grTexDownloadTable_NoLock(tmu1, GR_TEXTABLE_PALETTE, &(ti1->palette)); 720 } 721 } 722 723 FX_grTexSource_NoLock(tmu0, ti0->tm[tmu0]->startAddr, 724 GR_MIPMAPLEVELMASK_BOTH, &(ti0->info)); 725 FX_grTexClampMode_NoLock(tmu0, ti0->sClamp, ti0->tClamp); 726 FX_grTexFilterMode_NoLock(tmu0, ti0->minFilt, ti0->maxFilt); 727 FX_grTexMipMapMode_NoLock(tmu0, ti0->mmMode, FXFALSE); 728 729 FX_grTexSource_NoLock(tmu1, ti1->tm[tmu1]->startAddr, 730 GR_MIPMAPLEVELMASK_BOTH, &(ti1->info)); 731 FX_grTexClampMode_NoLock(tmu1, ti1->sClamp, ti1->tClamp); 732 FX_grTexFilterMode_NoLock(tmu1, ti1->minFilt, ti1->maxFilt); 733 FX_grTexMipMapMode_NoLock(tmu1, ti1->mmMode, FXFALSE); 715 734 716 735 #undef T0_NOT_IN_TMU … … 730 749 struct gl_texture_object *tObj1=ctx->Texture.Unit[1].CurrentD[2]; 731 750 GLuint envmode,ifmt,unitsmode; 751 int tmu0=0, tmu1=1; 732 752 733 753 if (MESA_VERBOSE&VERBOSE_DRIVER) { … … 769 789 if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE)) 770 790 fprintf(stderr, "fxMesa: fxSetupTextureDoubleTMU, envmode is %s/%s\n", 771 gl_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode), 772 gl_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode)); 773 774 791 gl_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode), 792 gl_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode)); 793 794 795 if ((ti0->whichTMU==FX_TMU1) || (ti1->whichTMU==FX_TMU0)) { 796 tmu0=1; 797 tmu1=0; 798 } 775 799 fxMesa->tmuSrc=FX_TMU_BOTH; 776 800 switch(envmode) { … … 780 804 781 805 if(ti0->baseLevelInternalFormat==GL_ALPHA) 782 isalpha[ti0->whichTMU]=GL_TRUE;806 isalpha[tmu0]=GL_TRUE; 783 807 else 784 isalpha[ti0->whichTMU]=GL_FALSE;808 isalpha[tmu0]=GL_FALSE; 785 809 786 810 if(ti1->baseLevelInternalFormat==GL_ALPHA) 787 isalpha[ti1->whichTMU]=GL_TRUE;811 isalpha[tmu1]=GL_TRUE; 788 812 else 789 isalpha[ti1->whichTMU]=GL_FALSE;790 813 isalpha[tmu1]=GL_FALSE; 814 791 815 if(isalpha[FX_TMU1]) 792 793 794 795 796 797 816 FX_grTexCombine_NoLock(GR_TMU1, 817 GR_COMBINE_FUNCTION_ZERO, 818 GR_COMBINE_FACTOR_NONE, 819 GR_COMBINE_FUNCTION_LOCAL, 820 GR_COMBINE_FACTOR_NONE, 821 FXTRUE,FXFALSE); 798 822 else 799 800 801 802 803 804 823 FX_grTexCombine_NoLock(GR_TMU1, 824 GR_COMBINE_FUNCTION_LOCAL, 825 GR_COMBINE_FACTOR_NONE, 826 GR_COMBINE_FUNCTION_LOCAL, 827 GR_COMBINE_FACTOR_NONE, 828 FXFALSE,FXFALSE); 805 829 806 830 if(isalpha[FX_TMU0]) 807 808 809 810 811 812 831 FX_grTexCombine_NoLock(GR_TMU0, 832 GR_COMBINE_FUNCTION_BLEND_OTHER, 833 GR_COMBINE_FACTOR_ONE, 834 GR_COMBINE_FUNCTION_BLEND_OTHER, 835 GR_COMBINE_FACTOR_LOCAL, 836 FXFALSE,FXFALSE); 813 837 else 814 815 816 817 818 819 838 FX_grTexCombine_NoLock(GR_TMU0, 839 GR_COMBINE_FUNCTION_BLEND_OTHER, 840 GR_COMBINE_FACTOR_LOCAL, 841 GR_COMBINE_FUNCTION_BLEND_OTHER, 842 GR_COMBINE_FACTOR_LOCAL, 843 FXFALSE,FXFALSE); 820 844 821 845 FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, 822 823 824 825 846 GR_COMBINE_FACTOR_LOCAL, 847 localc, 848 GR_COMBINE_OTHER_TEXTURE, 849 FXFALSE); 826 850 827 851 FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, 828 829 830 831 852 GR_COMBINE_FACTOR_LOCAL, 853 locala, 854 GR_COMBINE_OTHER_TEXTURE, 855 FXFALSE); 832 856 break; 833 857 } 834 858 case (FX_UM_E0_REPLACE | FX_UM_E1_BLEND): /* Only for GLQuake */ 835 if (ti1->whichTMU==FX_TMU1) {859 if (tmu1==FX_TMU1) { 836 860 FX_grTexCombine_NoLock(GR_TMU1, 837 838 839 840 841 842 861 GR_COMBINE_FUNCTION_LOCAL, 862 GR_COMBINE_FACTOR_NONE, 863 GR_COMBINE_FUNCTION_LOCAL, 864 GR_COMBINE_FACTOR_NONE, 865 FXTRUE,FXFALSE); 866 843 867 FX_grTexCombine_NoLock(GR_TMU0, 844 845 846 847 848 868 GR_COMBINE_FUNCTION_BLEND_OTHER, 869 GR_COMBINE_FACTOR_LOCAL, 870 GR_COMBINE_FUNCTION_BLEND_OTHER, 871 GR_COMBINE_FACTOR_LOCAL, 872 FXFALSE,FXFALSE); 849 873 } else { 850 874 FX_grTexCombine_NoLock(GR_TMU1, 851 852 853 854 855 856 875 GR_COMBINE_FUNCTION_LOCAL, 876 GR_COMBINE_FACTOR_NONE, 877 GR_COMBINE_FUNCTION_LOCAL, 878 GR_COMBINE_FACTOR_NONE, 879 FXFALSE,FXFALSE); 880 857 881 FX_grTexCombine_NoLock(GR_TMU0, 858 859 860 861 862 863 } 864 882 GR_COMBINE_FUNCTION_BLEND_OTHER, 883 GR_COMBINE_FACTOR_ONE_MINUS_LOCAL, 884 GR_COMBINE_FUNCTION_BLEND_OTHER, 885 GR_COMBINE_FACTOR_ONE_MINUS_LOCAL, 886 FXFALSE,FXFALSE); 887 } 888 865 889 FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, 866 867 868 869 890 GR_COMBINE_FACTOR_NONE, 891 locala, 892 GR_COMBINE_OTHER_NONE, 893 FXFALSE); 870 894 871 895 FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, 872 873 874 875 896 GR_COMBINE_FACTOR_ONE, 897 localc, 898 GR_COMBINE_OTHER_TEXTURE, 899 FXFALSE); 876 900 break; 877 901 case (FX_UM_E0_REPLACE | FX_UM_E1_MODULATE): /* Quake 2 and 3 */ 878 if (ti1->whichTMU==FX_TMU1) {902 if (tmu1==FX_TMU1) { 879 903 FX_grTexCombine_NoLock(GR_TMU1, 880 881 882 883 884 885 904 GR_COMBINE_FUNCTION_LOCAL, 905 GR_COMBINE_FACTOR_NONE, 906 GR_COMBINE_FUNCTION_ZERO, 907 GR_COMBINE_FACTOR_NONE, 908 FXFALSE,FXTRUE); 909 886 910 FX_grTexCombine_NoLock(GR_TMU0, 887 888 889 890 891 911 GR_COMBINE_FUNCTION_BLEND_OTHER, 912 GR_COMBINE_FACTOR_LOCAL, 913 GR_COMBINE_FUNCTION_BLEND_OTHER, 914 GR_COMBINE_FACTOR_LOCAL, 915 FXFALSE,FXFALSE); 892 916 893 917 } else { 894 918 FX_grTexCombine_NoLock(GR_TMU1, 895 896 897 898 899 900 919 GR_COMBINE_FUNCTION_LOCAL, 920 GR_COMBINE_FACTOR_NONE, 921 GR_COMBINE_FUNCTION_LOCAL, 922 GR_COMBINE_FACTOR_NONE, 923 FXFALSE,FXFALSE); 924 901 925 FX_grTexCombine_NoLock(GR_TMU0, 902 903 904 905 906 907 } 908 926 GR_COMBINE_FUNCTION_BLEND_OTHER, 927 GR_COMBINE_FACTOR_LOCAL, 928 GR_COMBINE_FUNCTION_BLEND_OTHER, 929 GR_COMBINE_FACTOR_ONE, 930 FXFALSE,FXFALSE); 931 } 932 909 933 if(ti0->baseLevelInternalFormat==GL_RGB) 910 934 FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, 911 912 913 914 935 GR_COMBINE_FACTOR_NONE, 936 locala, 937 GR_COMBINE_OTHER_NONE, 938 FXFALSE); 915 939 else 916 940 FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, 917 918 919 920 941 GR_COMBINE_FACTOR_ONE, 942 locala, 943 GR_COMBINE_OTHER_NONE, 944 FXFALSE); 921 945 922 946 923 947 FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, 924 925 926 927 928 break; 929 948 GR_COMBINE_FACTOR_ONE, 949 localc, 950 GR_COMBINE_OTHER_TEXTURE, 951 FXFALSE); 952 break; 953 930 954 931 955 case (FX_UM_E0_MODULATE | FX_UM_E1_ADD): /* Quake 3 Sky */ … … 934 958 935 959 if(ti0->baseLevelInternalFormat==GL_ALPHA) 936 isalpha[ti0->whichTMU]=GL_TRUE;960 isalpha[tmu0]=GL_TRUE; 937 961 else 938 isalpha[ti0->whichTMU]=GL_FALSE;962 isalpha[tmu0]=GL_FALSE; 939 963 940 964 if(ti1->baseLevelInternalFormat==GL_ALPHA) 941 isalpha[ti1->whichTMU]=GL_TRUE;965 isalpha[tmu1]=GL_TRUE; 942 966 else 943 isalpha[ti1->whichTMU]=GL_FALSE;944 967 isalpha[tmu1]=GL_FALSE; 968 945 969 if(isalpha[FX_TMU1]) 946 947 948 949 950 951 970 FX_grTexCombine_NoLock(GR_TMU1, 971 GR_COMBINE_FUNCTION_ZERO, 972 GR_COMBINE_FACTOR_NONE, 973 GR_COMBINE_FUNCTION_LOCAL, 974 GR_COMBINE_FACTOR_NONE, 975 FXTRUE,FXFALSE); 952 976 else 953 954 955 956 957 958 977 FX_grTexCombine_NoLock(GR_TMU1, 978 GR_COMBINE_FUNCTION_LOCAL, 979 GR_COMBINE_FACTOR_NONE, 980 GR_COMBINE_FUNCTION_LOCAL, 981 GR_COMBINE_FACTOR_NONE, 982 FXFALSE,FXFALSE); 959 983 960 984 if(isalpha[FX_TMU0]) 961 962 963 964 965 966 985 FX_grTexCombine_NoLock(GR_TMU0, 986 GR_COMBINE_FUNCTION_SCALE_OTHER, 987 GR_COMBINE_FACTOR_ONE, 988 GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, 989 GR_COMBINE_FACTOR_ONE, 990 FXFALSE,FXFALSE); 967 991 else 968 969 970 971 972 973 992 FX_grTexCombine_NoLock(GR_TMU0, 993 GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, 994 GR_COMBINE_FACTOR_ONE, 995 GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, 996 GR_COMBINE_FACTOR_ONE, 997 FXFALSE,FXFALSE); 974 998 975 999 FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, 976 977 978 979 1000 GR_COMBINE_FACTOR_LOCAL, 1001 localc, 1002 GR_COMBINE_OTHER_TEXTURE, 1003 FXFALSE); 980 1004 981 1005 FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, 982 GR_COMBINE_FACTOR_LOCAL, 983 locala, 984 GR_COMBINE_OTHER_TEXTURE, 985 FXFALSE); 986 break; 987 } 988 1006 GR_COMBINE_FACTOR_LOCAL, 1007 locala, 1008 GR_COMBINE_OTHER_TEXTURE, 1009 FXFALSE); 1010 break; 1011 } 1012 default: 1013 fprintf(stderr, "Unexpected dual texture mode encountered\n"); 1014 break; 989 1015 } 990 1016 … … 1012 1038 else 1013 1039 locala=GR_COMBINE_LOCAL_CONSTANT; 1014 1040 1015 1041 if(ctx->Light.ShadeModel==GL_SMOOTH) 1016 1042 localc=GR_COMBINE_LOCAL_ITERATED; 1017 1043 else 1018 1044 localc=GR_COMBINE_LOCAL_CONSTANT; 1019 1045 1020 1046 FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, 1021 1022 1023 1024 1047 GR_COMBINE_FACTOR_NONE, 1048 locala, 1049 GR_COMBINE_OTHER_NONE, 1050 FXFALSE); 1025 1051 1026 1052 FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, 1027 1028 1029 1030 1053 GR_COMBINE_FACTOR_NONE, 1054 localc, 1055 GR_COMBINE_OTHER_NONE, 1056 FXFALSE); 1031 1057 1032 1058 fxMesa->lastUnitsMode=FX_UM_NONE; … … 1037 1063 /************************************************************************/ 1038 1064 1039 void fxSetupTexture_NoLock(GLcontext *ctx)1065 static void fxSetupTexture_NoLock(GLcontext *ctx) 1040 1066 { 1041 1067 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; … … 1051 1077 1052 1078 /* Texture Combine, Color Combine and Alpha Combine. 1053 */ 1079 */ 1054 1080 tex2Denabled = (ctx->Texture.ReallyEnabled & TEXTURE0_2D); 1055 1081 1056 1082 if (fxMesa->emulateTwoTMUs) 1057 1083 tex2Denabled |= (ctx->Texture.ReallyEnabled & TEXTURE1_2D); 1058 1084 1059 1085 switch(tex2Denabled) { 1060 1086 case TEXTURE0_2D: 1061 fxSetupTextureSingleTMU_NoLock(ctx,0); 1087 fxSetupTextureSingleTMU_NoLock(ctx,0); 1062 1088 break; 1063 1089 case TEXTURE1_2D: … … 1066 1092 case (TEXTURE0_2D|TEXTURE1_2D): 1067 1093 if (fxMesa->haveTwoTMUs) 1068 1094 fxSetupTextureDoubleTMU_NoLock(ctx); 1069 1095 else { 1070 1071 1072 1073 1074 1096 if (MESA_VERBOSE&VERBOSE_DRIVER) 1097 fprintf(stderr, "fxmesa: enabling fake multitexture\n"); 1098 1099 fxSetupTextureSingleTMU_NoLock(ctx,0); 1100 ctx->Driver.MultipassFunc = fxMultipassTexture; 1075 1101 } 1076 1102 break; … … 1081 1107 } 1082 1108 1083 void fxSetupTexture(GLcontext *ctx) {1109 static void fxSetupTexture(GLcontext *ctx) { 1084 1110 BEGIN_BOARD_LOCK(); 1085 1111 fxSetupTexture_NoLock(ctx); … … 1181 1207 break; 1182 1208 case GL_DST_ALPHA: 1183 dfact=GR_BLEND_DST_ALPHA; 1209 /* dfact=GR_BLEND_DST_ALPHA; */ 1210 /* We can't do DST_ALPHA */ 1211 dfact=GR_BLEND_ONE; 1184 1212 adfact=GR_BLEND_ZERO; 1185 1213 break; 1186 1214 case GL_ONE_MINUS_DST_ALPHA: 1187 dfact=GR_BLEND_ONE_MINUS_DST_ALPHA; 1215 /* dfact=GR_BLEND_ONE_MINUS_DST_ALPHA; */ 1216 /* We can't do DST_ALPHA */ 1217 dfact=GR_BLEND_ZERO; 1188 1218 adfact=GR_BLEND_ZERO; 1189 1219 break; … … 1215 1245 if(us->blendEnabled) 1216 1246 FX_grAlphaBlendFunction(us->blendSrcFuncRGB,us->blendDstFuncRGB, 1217 1247 us->blendSrcFuncAlpha,us->blendDstFuncAlpha); 1218 1248 else 1219 1249 FX_grAlphaBlendFunction(GR_BLEND_ONE,GR_BLEND_ZERO,GR_BLEND_ONE,GR_BLEND_ZERO); 1220 1250 } 1221 1251 1222 1252 /************************************************************************/ 1223 1253 /************************** Alpha Test SetUp ****************************/ … … 1258 1288 fprintf(stderr,"fx Driver: internal error in fxDDAlphaFunc()\n"); 1259 1289 fxCloseHardware(); 1260 exit(-1);1290 EXIT(-1); 1261 1291 break; 1262 1292 } … … 1325 1355 fprintf(stderr,"fx Driver: internal error in fxDDDepthFunc()\n"); 1326 1356 fxCloseHardware(); 1327 exit(-1);1357 EXIT(-1); 1328 1358 break; 1329 1359 } … … 1366 1396 /************************************************************************/ 1367 1397 1368 GLboolean fxDDColorMask(GLcontext *ctx, 1369 GLboolean r, GLboolean g, 1370 1398 GLboolean fxDDColorMask(GLcontext *ctx, 1399 GLboolean r, GLboolean g, 1400 GLboolean b, GLboolean a ) 1371 1401 { 1372 1402 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; … … 1374 1404 ctx->Driver.RenderStart = fxSetupFXUnits; 1375 1405 (void) r; (void) g; (void) b; (void) a; 1376 return 1;1406 return GL_FALSE; 1377 1407 } 1378 1408 … … 1382 1412 1383 1413 FX_grColorMask(ctx->Color.ColorMask[RCOMP] || 1384 1385 1386 1414 ctx->Color.ColorMask[GCOMP] || 1415 ctx->Color.ColorMask[BCOMP], 1416 ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); 1387 1417 } 1388 1418 … … 1393 1423 /************************************************************************/ 1394 1424 1395 static void fxFogTableGenerate(GLcontext *ctx) 1396 { 1397 int i; 1398 float f,eyez; 1399 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; 1400 1401 for(i=0;i<FX_grGetInteger(FX_FOG_TABLE_ENTRIES);i++) { 1402 eyez=guFogTableIndexToW(i); 1403 1404 switch(ctx->Fog.Mode) { 1405 case GL_LINEAR: 1406 f=(ctx->Fog.End-eyez)/(ctx->Fog.End-ctx->Fog.Start); 1407 break; 1408 case GL_EXP: 1409 f=exp(-ctx->Fog.Density*eyez); 1410 break; 1411 case GL_EXP2: 1412 f=exp(-ctx->Fog.Density*ctx->Fog.Density*eyez*eyez); 1413 break; 1414 default: /* That should never happen */ 1415 f=0.0f; 1416 break; 1417 } 1418 1419 fxMesa->fogTable[i]=(GrFog_t)((1.0f-CLAMP(f,0.0f,1.0f))*255.0f); 1420 } 1421 } 1422 1423 static void fxSetupFog(GLcontext *ctx, GLboolean forceTableRebuild) 1424 { 1425 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; 1426 1427 if(ctx->Fog.Enabled && ctx->FogMode==FOG_FRAGMENT) { 1425 /* 1426 * This is called during state update in order to update the Glide fog state. 1427 */ 1428 static void fxSetupFog(GLcontext *ctx) 1429 { 1430 if (ctx->Fog.Enabled && ctx->FogMode==FOG_FRAGMENT) { 1431 fxMesaContext fxMesa = FX_CONTEXT(ctx); 1432 1433 /* update fog color */ 1428 1434 GLubyte col[4]; 1429 FX_grFogMode(GR_FOG_WITH_TABLE);1430 1431 1435 col[0]=(unsigned int)(255*ctx->Fog.Color[0]); 1432 1436 col[1]=(unsigned int)(255*ctx->Fog.Color[1]); 1433 col[2]=(unsigned int)(255*ctx->Fog.Color[2]); 1437 col[2]=(unsigned int)(255*ctx->Fog.Color[2]); 1434 1438 col[3]=(unsigned int)(255*ctx->Fog.Color[3]); 1435 1436 1439 FX_grFogColorValue(FXCOLOR4(col)); 1437 1440 1438 if(forceTableRebuild || 1439 (fxMesa->fogTableMode!=ctx->Fog.Mode) || 1440 (fxMesa->fogDensity!=ctx->Fog.Density)) { 1441 fxFogTableGenerate(ctx); 1442 1443 fxMesa->fogTableMode=ctx->Fog.Mode; 1444 fxMesa->fogDensity=ctx->Fog.Density; 1445 } 1446 1441 if(fxMesa->fogTableMode != ctx->Fog.Mode || 1442 fxMesa->fogDensity != ctx->Fog.Density || 1443 fxMesa->fogStart != ctx->Fog.Start || 1444 fxMesa->fogEnd != ctx->Fog.End) { 1445 /* reload the fog table */ 1446 switch (ctx->Fog.Mode) { 1447 case GL_LINEAR: 1448 guFogGenerateLinear(fxMesa->fogTable, ctx->Fog.Start, ctx->Fog.End); 1449 break; 1450 case GL_EXP: 1451 guFogGenerateExp(fxMesa->fogTable, ctx->Fog.Density); 1452 break; 1453 case GL_EXP2: 1454 guFogGenerateExp2(fxMesa->fogTable, ctx->Fog.Density); 1455 break; 1456 default: 1457 ; 1458 } 1459 fxMesa->fogTableMode = ctx->Fog.Mode; 1460 fxMesa->fogDensity = ctx->Fog.Density; 1461 fxMesa->fogStart = ctx->Fog.Start; 1462 fxMesa->fogEnd = ctx->Fog.End; 1463 } 1464 1447 1465 FX_grFogTable(fxMesa->fogTable); 1448 } else 1466 FX_grFogMode(GR_FOG_WITH_TABLE); 1467 } 1468 else { 1449 1469 FX_grFogMode(GR_FOG_DISABLE); 1470 } 1450 1471 } 1451 1472 … … 1486 1507 if (xmin<fxMesa->clipMinX) xmin=fxMesa->clipMinX; 1487 1508 if (xmax>fxMesa->clipMaxX) xmax=fxMesa->clipMaxX; 1488 if (ymin<fxMesa->screen_height-fxMesa->clipMaxY) 1509 if (ymin<fxMesa->screen_height-fxMesa->clipMaxY) 1489 1510 ymin=fxMesa->screen_height-fxMesa->clipMaxY; 1490 1511 if (ymax>fxMesa->screen_height-fxMesa->clipMinY) … … 1518 1539 (void) mode; 1519 1540 FX_CONTEXT(ctx)->new_state |= FX_NEW_CULL; 1520 ctx->Driver.RenderStart = fxSetupFXUnits; 1541 ctx->Driver.RenderStart = fxSetupFXUnits; 1521 1542 } 1522 1543 … … 1525 1546 (void) mode; 1526 1547 FX_CONTEXT(ctx)->new_state |= FX_NEW_CULL; 1527 ctx->Driver.RenderStart = fxSetupFXUnits; 1548 ctx->Driver.RenderStart = fxSetupFXUnits; 1528 1549 } 1529 1550 … … 1531 1552 static void fxSetupCull(GLcontext *ctx) 1532 1553 { 1533 if(ctx->Polygon.CullFlag) {1534 switch(ctx->Polygon.CullFaceMode) {1535 1536 if(ctx->Polygon.FrontFace==GL_CCW)1537 FX_grCullMode(GR_CULL_NEGATIVE);1538 1539 FX_grCullMode(GR_CULL_POSITIVE);1540 1541 1542 1543 FX_grCullMode(GR_CULL_POSITIVE);1544 1545 FX_grCullMode(GR_CULL_NEGATIVE);1546 1547 1548 FX_grCullMode(GR_CULL_DISABLE);1549 1550 1551 1552 1553 } else1554 FX_grCullMode(GR_CULL_DISABLE);1554 if (ctx->Polygon.CullFlag) { 1555 switch (ctx->Polygon.CullFaceMode) { 1556 case GL_BACK: 1557 if (ctx->Polygon.FrontFace==GL_CCW) 1558 FX_CONTEXT(ctx)->cullMode=GR_CULL_NEGATIVE; 1559 else 1560 FX_CONTEXT(ctx)->cullMode=GR_CULL_POSITIVE; 1561 break; 1562 case GL_FRONT: 1563 if(ctx->Polygon.FrontFace==GL_CCW) 1564 FX_CONTEXT(ctx)->cullMode=GR_CULL_POSITIVE; 1565 else 1566 FX_CONTEXT(ctx)->cullMode=GR_CULL_NEGATIVE; 1567 break; 1568 case GL_FRONT_AND_BACK: 1569 FX_CONTEXT(ctx)->cullMode=GR_CULL_DISABLE; 1570 break; 1571 default: 1572 break; 1573 } 1574 } else FX_CONTEXT(ctx)->cullMode=GR_CULL_DISABLE; 1575 FX_grCullMode(FX_CONTEXT(ctx)->cullMode); 1555 1576 } 1556 1577 … … 1594 1615 fxMesa->new_state |= FX_NEW_SCISSOR; 1595 1616 ctx->Driver.RenderStart = fxSetupFXUnits; 1617 break; 1618 case GL_SHARED_TEXTURE_PALETTE_EXT: 1619 fxDDTexUseGlbPalette(ctx, state); 1596 1620 break; 1597 1621 case GL_FOG: … … 1604 1628 break; 1605 1629 case GL_LINE_SMOOTH: 1630 case GL_LINE_STIPPLE: 1606 1631 case GL_POINT_SMOOTH: 1607 1632 case GL_POLYGON_SMOOTH: … … 1612 1637 default: 1613 1638 ; /* XXX no-op? */ 1614 } 1639 } 1615 1640 } 1616 1641 … … 1636 1661 case GL_NEVER: 1637 1662 case GL_ALWAYS: 1638 1663 break; 1639 1664 default: 1640 1641 1665 fxDDDepthFunc(ctx, GL_EQUAL); 1666 break; 1642 1667 } 1643 1668 fxDDDepthMask(ctx, FALSE); … … 1646 1671 /* ? Set the Constant Color ? */ 1647 1672 fxDDEnable(ctx, GL_BLEND, GL_TRUE); 1648 fxDDBlendFunc(ctx, ?, ?);1649 fxSetupTextureSingleTMU(ctx, ?);1673 fxDDBlendFunc(ctx, XXX, XXX); 1674 fxSetupTextureSingleTMU(ctx, XXX); 1650 1675 fxSetupBlend(ctx); 1651 1676 fxSetupDepthTest(ctx); … … 1655 1680 /* Reset everything back to normal */ 1656 1681 fxMesa->unitsState = fxMesa->restoreUnitsState; 1657 fxMesa->setupdone &= ?;1658 fxSetupTextureSingleTMU(ctx, ?);1682 fxMesa->setupdone &= XXX; 1683 fxSetupTextureSingleTMU(ctx, XXX); 1659 1684 fxSetupBlend(ctx); 1660 1685 fxSetupDepthTest(ctx); … … 1676 1701 * support almost the same subset using multipass blending on the 1677 1702 * voodoo 1. In all other cases for both voodoo 1 and 2, we fall back 1678 * to software rendering, satisfying the spec if not the user. 1703 * to software rendering, satisfying the spec if not the user. 1679 1704 */ 1680 1705 static GLboolean fxMultipassTexture( struct vertex_buffer *VB, GLuint pass ) … … 1688 1713 case 1: 1689 1714 if (MESA_VERBOSE&(VERBOSE_DRIVER|VERBOSE_PIPELINE|VERBOSE_TEXTURE)) 1690 1715 fprintf(stderr, "fxmesa: Second texture pass\n"); 1691 1716 1692 1717 for ( ; v != last ; v++) { 1693 1694 1718 v->f[S0COORD] = v->f[S1COORD]; 1719 v->f[T0COORD] = v->f[T1COORD]; 1695 1720 } 1696 1721 1697 fxMesa->restoreUnitsState = fxMesa->unitsState; 1722 fxMesa->restoreUnitsState = fxMesa->unitsState; 1698 1723 fxMesa->tmu_source[0] = 1; 1699 1724 1700 1725 if (ctx->Depth.Mask) { 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 fxDDDepthMask( ctx, GL_FALSE ); 1726 switch (ctx->Depth.Func) { 1727 case GL_NEVER: 1728 case GL_ALWAYS: 1729 break; 1730 default: 1731 fxDDDepthFunc( ctx, GL_EQUAL ); 1732 break; 1733 } 1734 1735 fxDDDepthMask( ctx, GL_FALSE ); 1711 1736 } 1712 1737 1713 1738 if (ctx->Texture.Unit[1].EnvMode == GL_MODULATE) { 1714 1715 1739 fxDDEnable( ctx, GL_BLEND, GL_TRUE ); 1740 fxDDBlendFunc( ctx, GL_DST_COLOR, GL_ZERO ); 1716 1741 } 1717 1742 1718 fxSetupTextureSingleTMU( ctx, 1 ); 1743 fxSetupTextureSingleTMU( ctx, 1 ); 1719 1744 fxSetupBlend( ctx ); 1720 1745 fxSetupDepthTest( ctx ); … … 1722 1747 1723 1748 case 2: 1724 /* Restore original state. 1749 /* Restore original state. 1725 1750 */ 1726 1751 fxMesa->tmu_source[0] = 0; 1727 1752 fxMesa->unitsState = fxMesa->restoreUnitsState; 1728 1753 fxMesa->setupdone &= ~SETUP_TMU0; 1729 fxSetupTextureSingleTMU( ctx, 0 ); 1754 fxSetupTextureSingleTMU( ctx, 0 ); 1730 1755 fxSetupBlend( ctx ); 1731 1756 fxSetupDepthTest( ctx ); … … 1733 1758 } 1734 1759 1735 return pass == 1; 1760 return pass == 1; 1736 1761 } 1737 1762 … … 1757 1782 static void gl_print_fx_state_flags( const char *msg, GLuint flags ) 1758 1783 { 1759 fprintf(stderr, 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1784 fprintf(stderr, 1785 "%s: (0x%x) %s%s%s%s%s%s%s\n", 1786 msg, 1787 flags, 1788 (flags & FX_NEW_TEXTURING) ? "texture, " : "", 1789 (flags & FX_NEW_BLEND) ? "blend, " : "", 1790 (flags & FX_NEW_ALPHA) ? "alpha, " : "", 1791 (flags & FX_NEW_FOG) ? "fog, " : "", 1792 (flags & FX_NEW_SCISSOR) ? "scissor, " : "", 1793 (flags & FX_NEW_COLOR_MASK) ? "colormask, " : "", 1794 (flags & FX_NEW_CULL) ? "cull, " : ""); 1770 1795 } 1771 1796 … … 1780 1805 if (newstate) { 1781 1806 if (newstate & FX_NEW_TEXTURING) 1782 1807 fxSetupTexture(ctx); 1783 1808 1784 1809 if (newstate & FX_NEW_BLEND) 1785 1810 fxSetupBlend(ctx); 1786 1811 1787 1812 if (newstate & FX_NEW_ALPHA) 1788 1789 1813 fxSetupAlphaTest(ctx); 1814 1790 1815 if (newstate & FX_NEW_DEPTH) 1791 1816 fxSetupDepthTest(ctx); 1792 1817 1793 1818 if (newstate & FX_NEW_FOG) 1794 fxSetupFog(ctx,GL_FALSE);1819 fxSetupFog(ctx); 1795 1820 1796 1821 if (newstate & FX_NEW_SCISSOR) 1797 1822 fxSetupScissor(ctx); 1798 1823 1799 1824 if (newstate & FX_NEW_COLOR_MASK) 1800 1825 fxSetupColorMask(ctx); 1801 1826 1802 1827 if (newstate & FX_NEW_CULL) 1803 fxSetupCull(ctx); 1828 fxSetupCull(ctx); 1804 1829 1805 1830 fxMesa->new_state = 0;
Note:
See TracChangeset
for help on using the changeset viewer.