Ignore:
Timestamp:
May 23, 2000, 10:41:28 PM (25 years ago)
Author:
jeroen
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/opengl/mesa/3dfx/fxapi.c

    r2938 r3598  
    33/*
    44 * Mesa 3-D graphics library
    5  * Version:  3.1
     5 * Version:  3.3
    66 *
    77 * Copyright (C) 1999  Brian Paul   All Rights Reserved.
     
    7070 *         - fixed few problems in my and Keith's fxDDClear code
    7171 *         - merged my code with the Keith's one
    72  *         - used the new BlendFunc Mesa device driver function 
    73  *         - used the new AlphaFunc Mesa device driver function 
    74  *         - used the new Enable Mesa device driver function 
     72 *         - used the new BlendFunc Mesa device driver function
     73 *         - used the new AlphaFunc Mesa device driver function
     74 *         - used the new Enable Mesa device driver function
    7575 *         - fixed a bug related to fog in the Mesa core. Fog
    7676 *           were applied two times: at vertex level and at fragment
     
    126126 *           OpenGL Optimizer 1.1 (thanks to Erwin Coumans for
    127127 *           the bug report)
    128  *         - fixed some bug in the fxwgl.c code (thanks to 
     128 *         - fixed some bug in the fxwgl.c code (thanks to
    129129 *           Peter Pettersson for a patch and a bug report)
    130130 *
     
    249249 *         - written the first partial support for the Multitexture extension.
    250250 *           This task is quite hard because the color combine units work after
    251  *           the two texture combine units and not before as required by the 
     251 *           the two texture combine units and not before as required by the
    252252 *           Multitexture extension
    253253 *         - written a workaround in fxBestResolution() in order to solve a
     
    256256 *           screen resolution supported by the hardware (instead of 640x480)
    257257 *           when it is unable to find an appropriate resolution that is large
    258  *           enough for the requested size 
     258 *           enough for the requested size
    259259 *         - the driver is now able to use also the texture memory attached to
    260260 *           second TMU
     
    349349 *         - fixed a bug in fxmesa6.h for GL_LINE_LOOP
    350350 *         - fixed a NearFarStack bug in the Mesa when applications
    351  *           directly call glLoadMatrix to load a projection matrix 
     351 *           directly call glLoadMatrix to load a projection matrix
    352352 *         - done some cleanup in the fxmesa2.c file
    353353 *         - the driver no longer translates the texture maps
     
    484484 *         - optimized the SETUP macro (added one argument)
    485485 *         - the Mesa/Voodoo is now 20/30% for points, lines and small triangles !
    486  *         - performance improvement setting VBSIZE to 72 
     486 *         - performance improvement setting VBSIZE to 72
    487487 *         - the GrVertex texture code is now written in asm
    488488 *         - the GrVertex zbuffer code is now written in asm
     
    582582 * V0.13 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
    583583 *         - now glBlendFunc() works for all glBlendFunc without DST_ALPHA
    584  *           (because the alpha buffer is not yet implemented) 
     584 *           (because the alpha buffer is not yet implemented)
    585585 *         - now fxMesaCreateContext() accept resolution and refresh rate
    586586 *         - fixed a bug for texture mapping: the w (alias z) must be set
     
    607607 *         - introduced texture mapping support (not yet finished !)
    608608 *         - tested with Mesa2.2b6
    609  *         - the driver is faster 
     609 *         - the driver is faster
    610610 *         - written glFlush/glFinish
    611611 *         - the driver print a lot of info about the Glide lib
     
    665665
    666666  cleangraphics();
    667 /*    abort(); */
    668   exit(1);
     667/*    ABORT(); */
     668  EXIT(1);
    669669}
    670670#endif
     
    702702
    703703/*
    704  * The extension GL_FXMESA_global_texture_lod_bias
    705  */
    706 void GLAPIENTRY glGlobalTextureLODBiasFXMESA(GLfloat biasVal)
    707 {
    708   grTexLodBiasValue(GR_TMU0,biasVal);
    709 
    710   if(fxMesaCurrentCtx->haveTwoTMUs)
    711     grTexLodBiasValue(GR_TMU1,biasVal);
    712 }
    713 
    714 
    715 /*
    716704 * The 3Dfx Global Palette extension for GLQuake.
    717705 * More a trick than a real extesion, use the shared global
    718  * palette extension. 
     706 * palette extension.
    719707 */
     708extern void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint *pal); /* silence warning */
    720709void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint *pal)
    721710{
    722711  fxMesaContext fxMesa =fxMesaCurrentCtx;
    723  
     712
    724713  if (MESA_VERBOSE&VERBOSE_DRIVER) {
    725714    int i;
     
    730719      fprintf(stderr,"%x\n",pal[i]);
    731720  }
    732  
     721
    733722  if(fxMesa) {
    734723    fxMesa->haveGlobalPaletteTexture=1;
    735    
     724
    736725    FX_grTexDownloadTable(GR_TMU0,GR_TEXTABLE_PALETTE,(GuTexPalette *)pal);
    737726    if (fxMesa->haveTwoTMUs)
    738         FX_grTexDownloadTable(GR_TMU1,GR_TEXTABLE_PALETTE,(GuTexPalette *)pal);
     727        FX_grTexDownloadTable(GR_TMU1,GR_TEXTABLE_PALETTE,(GuTexPalette *)pal);
    739728  }
    740729}
     
    743732static GrScreenResolution_t fxBestResolution(int width, int height, int aux)
    744733{
    745   static int resolutions[][5]={ 
     734  static int resolutions[][5]={
    746735    { 512, 384, GR_RESOLUTION_512x384, 2, 2 },
    747736    { 640, 400, GR_RESOLUTION_640x400, 2, 2 },
     
    795784
    796785fxMesaContext GLAPIENTRY fxMesaCreateBestContext(GLuint win,GLint width, GLint height,
    797                                                const GLint attribList[])
     786                                               const GLint attribList[])
    798787{
    799788  GrScreenRefresh_t refresh;
     
    887876      switch (attribList[i]) {
    888877      case FXMESA_DOUBLEBUFFER:
    889         doubleBuffer=GL_TRUE;
    890         break;
     878        doubleBuffer=GL_TRUE;
     879        break;
    891880      case FXMESA_ALPHA_SIZE:
    892         i++;
    893         alphaBuffer=attribList[i]>0;
    894         if(alphaBuffer)
    895             aux=1;
    896         break;
     881        i++;
     882        alphaBuffer=attribList[i]>0;
     883        if(alphaBuffer)
     884            aux=1;
     885        break;
    897886      case FXMESA_DEPTH_SIZE:
    898          i++;
    899          depthSize=attribList[i];
    900          if(depthSize)
    901             aux=1;
    902          break;
     887         i++;
     888         depthSize=attribList[i];
     889         if(depthSize) {
     890            aux=1;
     891            depthSize = 16;
     892         }
     893         break;
    903894      case FXMESA_STENCIL_SIZE:
    904         i++;
    905         stencilSize=attribList[i];
    906         break;
     895        i++;
     896        stencilSize=attribList[i];
     897        break;
    907898      case FXMESA_ACCUM_SIZE:
    908         i++;
    909         accumSize=attribList[i];
    910         break;
    911         /* XXX ugly hack here for sharing display lists */
     899        i++;
     900        accumSize=attribList[i];
     901        break;
     902        /* XXX ugly hack here for sharing display lists */
    912903#define FXMESA_SHARE_CONTEXT 990099  /* keep in sync with xmesa1.c! */
    913904      case FXMESA_SHARE_CONTEXT:
    914         i++;
    915         {
    916             const void *vPtr = &attribList[i];
    917             GLcontext **ctx = (GLcontext **) vPtr;
    918             shareCtx = *ctx;
    919         }
    920         break;
     905        i++;
     906        {
     907            const void *vPtr = &attribList[i];
     908            GLcontext **ctx = (GLcontext **) vPtr;
     909            shareCtx = *ctx;
     910        }
     911        break;
    921912      default:
    922         if (MESA_VERBOSE&VERBOSE_DRIVER) {
    923             fprintf(stderr,"fxmesa: fxMesaCreateContext() End (defualt)\n");
    924         }
    925         return NULL;
     913        if (MESA_VERBOSE&VERBOSE_DRIVER) {
     914            fprintf(stderr,"fxmesa: fxMesaCreateContext() End (defualt)\n");
     915        }
     916        return NULL;
    926917      }
    927918      i++;
     
    965956   fxMesa->board=glbCurrentBoard;
    966957
     958
     959   fxMesa->glideContext = FX_grSstWinOpen((FxU32)win,res,ref,
    967960#if  FXMESA_USE_ARGB
    968    fxMesa->glideContext = FX_grSstWinOpen((FxU32)win,res,ref,
    969                                         GR_COLORFORMAT_ARGB,
    970                                         GR_ORIGIN_LOWER_LEFT,
    971                                         2,aux);
     961                                          GR_COLORFORMAT_ARGB,
    972962#else
    973    fxMesa->glideContext = FX_grSstWinOpen((FxU32)win,res,ref,
    974                                         GR_COLORFORMAT_ABGR,
    975                                         GR_ORIGIN_LOWER_LEFT,
    976                                         2,aux);
     963                                          GR_COLORFORMAT_ABGR,
    977964#endif
     965                                          GR_ORIGIN_LOWER_LEFT,
     966                                          2,aux);
    978967   if (!fxMesa->glideContext){
    979       errorstr = "grSstWinOpen"; 
     968      errorstr = "grSstWinOpen";
    980969      goto errorhandler;
    981970   }
    982    
     971
    983972   /* Pixel tables are use during pixel read-back */
    984 #if FXMESA_USE_ARGB 
    985    fxInitPixelTables(GL_FALSE); /* Force RGB pixel order */     
     973#if FXMESA_USE_ARGB
     974   fxInitPixelTables(fxMesa, GL_FALSE); /* Force RGB pixel order */
    986975#else
    987976   if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_VOODOO) {
     
    992981       * Thanks to Joseph Kain for that one
    993982       */
    994       if (glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.nTexelfx == 2) {
    995          fxInitPixelTables(GL_FALSE); /* use RGB pixel order (Voodoo3) */
     983      GrVoodooConfig_t *voodoo;
     984      voodoo = &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig;
     985
     986      if (voodoo->nTexelfx == 2 && voodoo->fbiRev != 260) {
     987         /* RGB pixel order (Voodoo3, but some Quantum3D models) */
     988         fxInitPixelTables(fxMesa, GL_FALSE);
    996989      }
    997990      else {
    998          fxInitPixelTables(GL_TRUE); /* use BGR pixel order on Voodoo1/2 */
     991         /* BGR pixel order on Voodoo1/2, or certain Quantum3D models  */
     992         fxInitPixelTables(fxMesa, GL_TRUE);
    999993      }
    1000994   }
    1001995   else {
    1002       fxInitPixelTables(GL_FALSE); /* use RGB pixel order otherwise */
     996      fxInitPixelTables(fxMesa, GL_FALSE); /* use RGB pixel order otherwise */
    1003997   }
    1004998#endif
     
    10171011   fxMesa->y_offset = 0;
    10181012   fxMesa->y_delta = 0;
    1019    
     1013
    10201014   fxMesa->needClip = 0;
    10211015
     
    10251019
    10261020   fxMesa->glVis=gl_create_visual(GL_TRUE,     /* RGB mode */
    1027                                   alphaBuffer,
    1028                                   doubleBuffer,
    1029                                   GL_FALSE,    /* stereo */
    1030                                   depthSize,   /* depth_size */
    1031                                   stencilSize, /* stencil_size */
    1032                                   accumSize,   /* accum_size */
    1033                                   0,           /* index bits */
    1034                                   5,6,5,0);    /* RGBA bits */
     1021                                  alphaBuffer,
     1022                                  doubleBuffer,
     1023                                  GL_FALSE,    /* stereo */
     1024                                  depthSize,   /* depth_size */
     1025                                  stencilSize, /* stencil_size */
     1026                                  accumSize,   /* accum_size */
     1027                                  0,           /* index bits */
     1028                                  5,6,5,0);    /* RGBA bits */
    10351029   if (!fxMesa->glVis) {
    10361030      errorstr = "gl_create_visual";
     
    10391033
    10401034   ctx = fxMesa->glCtx=gl_create_context(fxMesa->glVis,
    1041                                         shareCtx,  /* share list context */
    1042                                         (void *) fxMesa, GL_TRUE);
     1035                                        shareCtx,  /* share list context */
     1036                                        (void *) fxMesa, GL_TRUE);
    10431037   if (!ctx) {
    10441038      errorstr = "gl_create_context";
     
    10481042
    10491043   if (!fxDDInitFxMesaContext( fxMesa )) {
    1050       errorstr = "fxDDInitFxMesaContext failed"; 
     1044      errorstr = "fxDDInitFxMesaContext failed";
    10511045      goto errorhandler;
    10521046   }
    10531047
    10541048
    1055    fxMesa->glBuffer=gl_create_framebuffer(fxMesa->glVis);
     1049   fxMesa->glBuffer=gl_create_framebuffer(fxMesa->glVis,
     1050                                          GL_FALSE,  /* no software depth */
     1051                                          fxMesa->glVis->StencilBits > 0,
     1052                                          fxMesa->glVis->AccumBits > 0,
     1053                                          fxMesa->glVis->AlphaBits > 0 );
    10561054   if (!fxMesa->glBuffer) {
    10571055      errorstr = "gl_create_framebuffer";
    10581056      goto errorhandler;
    10591057   }
    1060  
     1058
    10611059   glbTotNumCtx++;
    10621060
    10631061   /* install signal handlers */
    10641062#if defined(__linux__)
    1065    if (fxMesa->glCtx->CatchSignals) {
     1063   /* Only install if environment var. is not set. */
     1064   if (fxMesa->glCtx->CatchSignals && !getenv("MESA_FX_NO_SIGNALS")) {
    10661065      signal(SIGINT,cleangraphics_handler);
    10671066      signal(SIGHUP,cleangraphics_handler);
     
    10841083   if (fxMesa) {
    10851084      if (fxMesa->glideContext)
    1086         FX_grSstWinClose(fxMesa->glideContext);
     1085        FX_grSstWinClose(fxMesa->glideContext);
    10871086      fxMesa->glideContext = 0;
    1088      
    1089       if (fxMesa->state) 
    1090         free(fxMesa->state);
     1087
     1088      if (fxMesa->state)
     1089        free(fxMesa->state);
    10911090      if (fxMesa->fogTable)
    1092         free(fxMesa->fogTable);
     1091        free(fxMesa->fogTable);
    10931092      if (fxMesa->glBuffer)
    1094         gl_destroy_framebuffer(fxMesa->glBuffer);
     1093        gl_destroy_framebuffer(fxMesa->glBuffer);
    10951094      if (fxMesa->glVis)
    1096         gl_destroy_visual(fxMesa->glVis);
     1095        gl_destroy_visual(fxMesa->glVis);
    10971096      if (fxMesa->glCtx)
    1098         gl_destroy_context(fxMesa->glCtx);
     1097        gl_destroy_context(fxMesa->glCtx);
    10991098      free(fxMesa);
    11001099   }
    1101    
     1100
    11021101   if (MESA_VERBOSE&VERBOSE_DRIVER) {
    11031102      fprintf(stderr,"fxmesa: fxMesaCreateContext() End (%s)\n",errorstr);
     
    11601159              (fxMesa->stats.memTexUpload/(float)fxMesa->stats.swapBuffer)/(float)(1<<20));
    11611160    }
    1162     if (fxMesa->state) 
     1161    if (fxMesa->state)
    11631162       free(fxMesa->state);
    11641163    if (fxMesa->fogTable)
    11651164       free(fxMesa->fogTable);
    11661165    fxTMClose(fxMesa);
    1167    
     1166
    11681167    free(fxMesa);
    11691168  }
     
    12761275      if(getenv("MESA_FX_INFO")) {
    12771276        char buf[80];
    1278                        
     1277
    12791278        FX_grGlideGetVersion(buf);
    12801279        fprintf(stderr,"Using Glide V%s\n","");
     
    13061305    onexit((_onexit_t)cleangraphics);
    13071306#elif defined(__linux__)
    1308     atexit(cleangraphics);
     1307    /* Only register handler if environment variable is not defined. */
     1308    if (!getenv("MESA_FX_NO_SIGNALS")) {
     1309        atexit(cleangraphics);
     1310    }
    13091311#endif
    13101312  }
Note: See TracChangeset for help on using the changeset viewer.