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

* empty log message *

Location:
trunk/src/opengl/mesa/3dfx
Files:
28 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  }
  • trunk/src/opengl/mesa/3dfx/fxclip.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.
     
    6868
    6969
    70 #define CLIP(sgn,v)                                             \
    71 do {                                                            \
    72    GLuint out = in ^ 1;                                         \
    73    GLfloat **indata = inlist[in];                               \
    74    GrVertex **inverts = vertlist[in];                           \
    75    GrVertex **outverts = vertlist[out];                         \
    76    GLfloat **outdata = inlist[in = out];                        \
    77    GLfloat *J = indata[n-1];                                    \
    78    GLfloat dpJ = (sgn J[v]) + J[3];                             \
    79    GLuint nr = n;                                               \
    80                                                                 \
    81    for (i = n = 0 ; i < nr ; i++) {                             \
    82       GLfloat *I = indata[i];                                   \
    83       GLfloat dpI = (sgn I[v]) + I[3];                          \
    84                                                                 \
    85       if (DIFFERENT_SIGNS(dpI, dpJ)) {                          \
    86          GLuint j;                                              \
     70#define CLIP(sgn,v)                                             \
     71do {                                                            \
     72   GLuint out = in ^ 1;                                         \
     73   GLfloat **indata = inlist[in];                               \
     74   GrVertex **inverts = vertlist[in];                           \
     75   GrVertex **outverts = vertlist[out];                         \
     76   GLfloat **outdata = inlist[in = out];                        \
     77   GLfloat *J = indata[n-1];                                    \
     78   GLfloat dpJ = (sgn J[v]) + J[3];                             \
     79   GLuint nr = n;                                               \
     80                                                                \
     81   for (i = n = 0 ; i < nr ; i++) {                             \
     82      GLfloat *I = indata[i];                                   \
     83      GLfloat dpI = (sgn I[v]) + I[3];                          \
     84                                                                \
     85      if (DIFFERENT_SIGNS(dpI, dpJ)) {                          \
     86         GLuint j;                                              \
    8787         GLfloat t = dpI / (dpI - dpJ);                         \
    88          outverts[n] = 0;                                       \
    89          outdata[n++] = store;                                  \
    90          store[3] = LINTERP(t, I[3], J[3]);                     \
    91          store[v] = - sgn store[3];                             \
    92          if (v != 0) store[0] = LINTERP(t, I[0], J[0]);         \
    93          if (v != 1) store[1] = LINTERP(t, I[1], J[1]);         \
    94          if (v != 2) store[2] = LINTERP(t, I[2], J[2]);         \
    95          store += 4;                                            \
    96          for (j = 4 ; j < sz ; j+=4,store+=4) {                 \
    97             store[0] = LINTERP(t, I[j],   J[j] );               \
    98             store[1] = LINTERP(t, I[j+1], J[j+1] );             \
    99             store[2] = LINTERP(t, I[j+2], J[j+2] );             \
    100             store[3] = LINTERP(t, I[j+3], J[j+3] );             \
    101          }                                                      \
    102       }                                                         \
    103                                                                 \
    104       if (!NEGATIVE(dpI)) {                                     \
    105          outverts[n] = inverts[i];                              \
    106          outdata[n++] = I;                                      \
    107       }                                                         \
    108                                                                 \
    109                                                                 \
    110       J = I;                                                    \
    111       dpJ = dpI;                                                \
    112    }                                                            \
    113                                                                 \
    114    if (n < 3) return 0;                                         \
     88         outverts[n] = 0;                                       \
     89         outdata[n++] = store;                                  \
     90         store[3] = LINTERP(t, I[3], J[3]);                     \
     91         store[v] = - sgn store[3];                             \
     92         if (v != 0) store[0] = LINTERP(t, I[0], J[0]);         \
     93         if (v != 1) store[1] = LINTERP(t, I[1], J[1]);         \
     94         if (v != 2) store[2] = LINTERP(t, I[2], J[2]);         \
     95         store += 4;                                            \
     96         for (j = 4 ; j < sz ; j+=4,store+=4) {                 \
     97            store[0] = LINTERP(t, I[j],   J[j] );               \
     98            store[1] = LINTERP(t, I[j+1], J[j+1] );             \
     99            store[2] = LINTERP(t, I[j+2], J[j+2] );             \
     100            store[3] = LINTERP(t, I[j+3], J[j+3] );             \
     101         }                                                      \
     102      }                                                         \
     103                                                                \
     104      if (!NEGATIVE(dpI)) {                                     \
     105         outverts[n] = inverts[i];                              \
     106         outdata[n++] = I;                                      \
     107      }                                                         \
     108                                                                \
     109                                                                \
     110      J = I;                                                    \
     111      dpJ = dpI;                                                \
     112   }                                                            \
     113                                                                \
     114   if (n < 3) return 0;                                         \
    115115} while (0)
    116116
     
    121121 * code only really differs in the way it sets store[v] to +- w.
    122122 */
    123 #define UCLIP(a,b,c,d)                                  \
    124 do {                                                    \
    125    GLuint out = in ^ 1;                                 \
    126    GLfloat **indata = inlist[in];                       \
    127    GrVertex **inverts = vertlist[in];                   \
    128    GrVertex **outverts = vertlist[out];                 \
    129    GLfloat **outdata = inlist[in = out];                \
    130    GLfloat *J = indata[n-1];                            \
    131    GLfloat dpJ = DOT4V(J,a,b,c,d);                      \
    132    GLuint nr = n;                                       \
    133                                                         \
    134    for (i = n = 0 ; i < nr ; i++) {                     \
    135       GLfloat *I = indata[i];                           \
    136       GLfloat dpI = DOT4V(I,a,b,c,d);                   \
    137                                                         \
    138       if (DIFFERENT_SIGNS(dpI, dpJ)) {                  \
    139          GLuint j;                                      \
    140          GLfloat t = dpI / (dpI - dpJ);                 \
    141          outverts[n] = 0;                               \
    142          outdata[n++] = store;                          \
    143          for (j = 0 ; j < sz ; j+=4,store+=4) {         \
    144             store[0] = LINTERP(t, I[j],   J[j] );       \
    145             store[1] = LINTERP(t, I[j+1], J[j+1] );     \
    146             store[2] = LINTERP(t, I[j+2], J[j+2] );     \
    147             store[3] = LINTERP(t, I[j+3], J[j+3] );     \
    148          }                                              \
    149       }                                                 \
    150                                                         \
    151       if (!NEGATIVE(dpI)) {                             \
    152          outverts[n] = inverts[i];                      \
    153          outdata[n++] = I;                              \
    154       }                                                 \
    155                                                         \
    156                                                         \
    157       J = I;                                            \
    158       dpJ = dpI;                                        \
    159    }                                                    \
    160                                                         \
    161    if (n < 3) return 0;                                 \
     123#define UCLIP(a,b,c,d)                                  \
     124do {                                                    \
     125   GLuint out = in ^ 1;                                 \
     126   GLfloat **indata = inlist[in];                       \
     127   GrVertex **inverts = vertlist[in];                   \
     128   GrVertex **outverts = vertlist[out];                 \
     129   GLfloat **outdata = inlist[in = out];                \
     130   GLfloat *J = indata[n-1];                            \
     131   GLfloat dpJ = DOT4V(J,a,b,c,d);                      \
     132   GLuint nr = n;                                       \
     133                                                        \
     134   for (i = n = 0 ; i < nr ; i++) {                     \
     135      GLfloat *I = indata[i];                           \
     136      GLfloat dpI = DOT4V(I,a,b,c,d);                   \
     137                                                        \
     138      if (DIFFERENT_SIGNS(dpI, dpJ)) {                  \
     139         GLuint j;                                      \
     140         GLfloat t = dpI / (dpI - dpJ);                 \
     141         outverts[n] = 0;                               \
     142         outdata[n++] = store;                          \
     143         for (j = 0 ; j < sz ; j+=4,store+=4) {         \
     144            store[0] = LINTERP(t, I[j],   J[j] );       \
     145            store[1] = LINTERP(t, I[j+1], J[j+1] );     \
     146            store[2] = LINTERP(t, I[j+2], J[j+2] );     \
     147            store[3] = LINTERP(t, I[j+3], J[j+3] );     \
     148         }                                              \
     149      }                                                 \
     150                                                        \
     151      if (!NEGATIVE(dpI)) {                             \
     152         outverts[n] = inverts[i];                      \
     153         outdata[n++] = I;                              \
     154      }                                                 \
     155                                                        \
     156                                                        \
     157      J = I;                                            \
     158      dpJ = dpI;                                        \
     159   }                                                    \
     160                                                        \
     161   if (n < 3) return 0;                                 \
    162162} while (0)
    163163
     
    172172 */
    173173static INLINE GLuint fx_clip_triangle( GLcontext *ctx,
    174                                        GLfloat *inoutlist[],
    175                                        GrVertex **verts,
    176                                        GLuint sz,
    177                                        GLuint mask )
     174                                       GLfloat *inoutlist[],
     175                                       GrVertex **verts,
     176                                       GLuint sz,
     177                                       GLuint mask )
    178178{
    179179   GLuint n = 3;
     
    195195   {
    196196      if (mask & CLIP_RIGHT_BIT)
    197         CLIP(-,0);
     197        CLIP(-,0);
    198198
    199199      if (mask & CLIP_LEFT_BIT)
    200         CLIP(+,0);
     200        CLIP(+,0);
    201201
    202202      if (mask & CLIP_TOP_BIT)
    203         CLIP(-,1);
     203        CLIP(-,1);
    204204
    205205      if (mask & CLIP_BOTTOM_BIT)
    206         CLIP(+,1);
     206        CLIP(+,1);
    207207
    208208      if (mask & CLIP_FAR_BIT)
    209         CLIP(-,2);
     209        CLIP(-,2);
    210210
    211211      if (mask & CLIP_NEAR_BIT)
    212         CLIP(+,2);
     212        CLIP(+,2);
    213213   }
    214214
     
    217217      GLfloat (*plane)[4] = &ctx->Transform.ClipUserPlane[0];
    218218      for (bit = 0x100 ; bit < mask ; plane++, bit *= 2) {
    219         if (mask & bit) {
    220             GLfloat a = plane[0][0];
    221             GLfloat b = plane[0][1];
    222             GLfloat c = plane[0][2];
    223             GLfloat d = plane[0][3];
    224             UCLIP(a,b,c,d);
    225         }
     219        if (mask & bit) {
     220            GLfloat a = plane[0][0];
     221            GLfloat b = plane[0][1];
     222            GLfloat c = plane[0][2];
     223            GLfloat d = plane[0][3];
     224            UCLIP(a,b,c,d);
     225        }
    226226      }
    227227   }
     
    229229   if (inlist[in] != inoutlist)
    230230      for (i = 0 ; i < n ; i++) {
    231         inoutlist[i] = inlist[in][i];
    232         verts[i] = verts2[i];
     231        inoutlist[i] = inlist[in][i];
     232        verts[i] = verts2[i];
    233233      }
    234234
     
    239239
    240240static INLINE GLuint fx_view_clip_triangle( GLcontext *ctx,
    241                                             GLfloat *inoutlist[],
    242                                             GrVertex **verts,
    243                                             GLuint sz,
    244                                             GLubyte mask )
     241                                            GLfloat *inoutlist[],
     242                                            GrVertex **verts,
     243                                            GLuint sz,
     244                                            GLubyte mask )
    245245{
    246246   GLuint n = 3;
     
    279279   if (inlist[in] != inoutlist)
    280280      for (i = 0 ; i < n ; i++) {
    281         inoutlist[i] = inlist[in][i];
    282         verts[i] = verts2[i];
     281        inoutlist[i] = inlist[in][i];
     282        verts[i] = verts2[i];
    283283      }
    284284
     
    290290#undef CLIP
    291291
    292 #define CLIP(x,y,z,w)                                   \
    293 do {                                                    \
    294    GLfloat dpI = DOT4V(I,x,y,z,w);                      \
    295    GLfloat dpJ = DOT4V(J,x,y,z,w);                      \
    296                                                         \
    297    if (DIFFERENT_SIGNS(dpI, dpJ)) {                     \
    298       GLuint j;                                         \
    299       GLfloat t = dpI / (dpI - dpJ);                    \
    300       GLfloat *tmp = store;                             \
    301                                                         \
    302       for (j = 0 ; j < sz ; j+=2) {                     \
    303          *store++ = LINTERP(t, I[j],   J[j] );          \
    304          *store++ = LINTERP(t, I[j+1], J[j+1] );        \
    305       }                                                 \
    306                                                         \
    307       if (NEGATIVE(dpI))                                \
    308          I = tmp;                                       \
    309       else                                              \
    310          J = tmp;                                       \
    311                                                         \
    312    }                                                    \
    313    else if (NEGATIVE(dpI))                              \
    314       return 0;                                         \
    315                                                         \
     292#define CLIP(x,y,z,w)                                   \
     293do {                                                    \
     294   GLfloat dpI = DOT4V(I,x,y,z,w);                      \
     295   GLfloat dpJ = DOT4V(J,x,y,z,w);                      \
     296                                                        \
     297   if (DIFFERENT_SIGNS(dpI, dpJ)) {                     \
     298      GLuint j;                                         \
     299      GLfloat t = dpI / (dpI - dpJ);                    \
     300      GLfloat *tmp = store;                             \
     301                                                        \
     302      for (j = 0 ; j < sz ; j+=2) {                     \
     303         *store++ = LINTERP(t, I[j],   J[j] );          \
     304         *store++ = LINTERP(t, I[j+1], J[j+1] );        \
     305      }                                                 \
     306                                                        \
     307      if (NEGATIVE(dpI))                                \
     308         I = tmp;                                       \
     309      else                                              \
     310         J = tmp;                                       \
     311                                                        \
     312   }                                                    \
     313   else if (NEGATIVE(dpI))                              \
     314      return 0;                                         \
     315                                                        \
    316316} while (0)
    317317
    318318
    319319static GLuint fx_clip_line( GLcontext *ctx,
    320                             GLfloat *inoutlist[],
    321                             GLuint sz,
    322                             GLubyte clipor )
     320                            GLfloat *inoutlist[],
     321                            GLuint sz,
     322                            GLubyte clipor )
    323323{
    324324   GLfloat *I = inoutlist[0];
     
    329329   {
    330330      if (clipor & CLIP_LEFT_BIT)
    331         CLIP(1,0,0,1);
    332  
     331        CLIP(1,0,0,1);
     332
    333333      if (clipor & CLIP_RIGHT_BIT)
    334         CLIP(-1,0,0,1);
    335  
     334        CLIP(-1,0,0,1);
     335
    336336      if (clipor & CLIP_TOP_BIT)
    337         CLIP(0,-1,0,1);
    338  
     337        CLIP(0,-1,0,1);
     338
    339339      if (clipor & CLIP_BOTTOM_BIT)
    340         CLIP(0,1,0,1);
    341  
     340        CLIP(0,1,0,1);
     341
    342342      if (clipor & CLIP_FAR_BIT)
    343         CLIP(0,0,-1,1);
    344  
     343        CLIP(0,0,-1,1);
     344
    345345      if (clipor & CLIP_NEAR_BIT)
    346         CLIP(0,0,1,1);
     346        CLIP(0,0,1,1);
    347347   }
    348348
     
    350350      GLuint i;
    351351      for (i = 0 ; i < MAX_CLIP_PLANES ; i++) {
    352         if (ctx->Transform.ClipEnabled[i]) {
    353             GLfloat a = ctx->Transform.ClipUserPlane[i][0];
    354             GLfloat b = ctx->Transform.ClipUserPlane[i][1];
    355             GLfloat c = ctx->Transform.ClipUserPlane[i][2];
    356             GLfloat d = ctx->Transform.ClipUserPlane[i][3];
    357             CLIP(a,b,c,d);
    358         }
     352        if (ctx->Transform.ClipEnabled[i]) {
     353            GLfloat a = ctx->Transform.ClipUserPlane[i][0];
     354            GLfloat b = ctx->Transform.ClipUserPlane[i][1];
     355            GLfloat c = ctx->Transform.ClipUserPlane[i][2];
     356            GLfloat d = ctx->Transform.ClipUserPlane[i][3];
     357            CLIP(a,b,c,d);
     358        }
    359359      }
    360360   }
     
    373373#if defined(FX_V2)
    374374
    375 #define VARS_XYZW                               \
    376   GLfloat vsx = mat[MAT_SX];                    \
    377   GLfloat vsy = mat[MAT_SY];                    \
    378   GLfloat vsz = mat[MAT_SZ];                    \
    379   GLfloat vtx = mat[MAT_TX];                    \
    380   GLfloat vty = mat[MAT_TY];                    \
    381   GLfloat vtz = mat[MAT_TZ];                   
    382 
    383 #define DO_SETUP_XYZW                           \
    384 {                                               \
    385   GLfloat oow = 1.0 / data[3];                  \
    386   v->x   = data[0]*oow*vsx + vtx;               \
    387   v->y   = data[1]*oow*vsy + vty;               \
    388   v->ooz = data[2]*oow*vsz + vtz;               \
    389   v->oow = oow;                                 \
     375#define VARS_XYZW                               \
     376  GLfloat vsx = mat[MAT_SX];                    \
     377  GLfloat vsy = mat[MAT_SY];                    \
     378  GLfloat vsz = mat[MAT_SZ];                    \
     379  GLfloat vtx = mat[MAT_TX];                    \
     380  GLfloat vty = mat[MAT_TY];                    \
     381  GLfloat vtz = mat[MAT_TZ];
     382
     383#define DO_SETUP_XYZW                           \
     384{                                               \
     385  GLfloat oow = 1.0 / data[3];                  \
     386  v->x   = data[0]*oow*vsx + vtx;               \
     387  v->y   = data[1]*oow*vsy + vty;               \
     388  v->ooz = data[2]*oow*vsz + vtz;               \
     389  v->oow = oow;                                 \
    390390}
    391391#else
     
    393393#if defined(DRIVERTS)
    394394
    395 #define VARS_XYZW                               \
    396   GLfloat vsx = mat[MAT_SX];                    \
    397   GLfloat vsy = mat[MAT_SY];                    \
    398   GLfloat vsz = mat[MAT_SZ];                    \
    399   GLfloat vtx = mat[MAT_TX]+fxMesa->x_offset;   \
    400   GLfloat vty = mat[MAT_TY]+fxMesa->y_delta;    \
     395#define VARS_XYZW                               \
     396  GLfloat vsx = mat[MAT_SX];                    \
     397  GLfloat vsy = mat[MAT_SY];                    \
     398  GLfloat vsz = mat[MAT_SZ];                    \
     399  GLfloat vtx = mat[MAT_TX]+fxMesa->x_offset;   \
     400  GLfloat vty = mat[MAT_TY]+fxMesa->y_delta;    \
    401401  GLfloat vtz = mat[MAT_TZ];
    402402
    403 #define DO_SETUP_XYZW                           \
    404 {                                               \
    405   GLfloat oow = 1.0 / data[3];                  \
    406   v->x   = data[0]*oow*vsx + vtx;               \
    407   v->y   = data[1]*oow*vsy + vty;               \
    408   v->ooz = data[2]*oow*vsz + vtz;               \
    409   v->oow = oow;                                 \
     403#define DO_SETUP_XYZW                           \
     404{                                               \
     405  GLfloat oow = 1.0 / data[3];                  \
     406  v->x   = data[0]*oow*vsx + vtx;               \
     407  v->y   = data[1]*oow*vsy + vty;               \
     408  v->ooz = data[2]*oow*vsz + vtz;               \
     409  v->oow = oow;                                 \
    410410}
    411411
    412412#else
    413 #define VARS_XYZW                               \
    414   GLfloat vsx = mat[MAT_SX];                    \
    415   GLfloat vsy = mat[MAT_SY];                    \
    416   GLfloat vsz = mat[MAT_SZ];                    \
    417   const GLfloat snapper = (3L << 18);           \
    418   GLfloat snap_tx = mat[MAT_TX] + snapper;      \
    419   GLfloat snap_ty = mat[MAT_TY] + snapper;      \
     413#define VARS_XYZW                               \
     414  GLfloat vsx = mat[MAT_SX];                    \
     415  GLfloat vsy = mat[MAT_SY];                    \
     416  GLfloat vsz = mat[MAT_SZ];                    \
     417  const GLfloat snapper = (3L << 18);           \
     418  GLfloat snap_tx = mat[MAT_TX] + snapper;      \
     419  GLfloat snap_ty = mat[MAT_TY] + snapper;      \
    420420  GLfloat vtz = mat[MAT_TZ];
    421421
    422 #define DO_SETUP_XYZW                           \
    423 {                                               \
    424   GLfloat oow = 1.0 / data[3];                  \
    425   v->x = data[0]*oow*vsx + snap_tx;             \
    426   v->y = data[1]*oow*vsy + snap_ty;             \
    427   v->ooz = data[2]*oow*vsz + vtz;               \
    428   v->oow = oow;                                 \
    429   v->x -= snapper;                              \
    430   v->y -= snapper;                              \
     422#define DO_SETUP_XYZW                           \
     423{                                               \
     424  GLfloat oow = 1.0 / data[3];                  \
     425  v->x = data[0]*oow*vsx + snap_tx;             \
     426  v->y = data[1]*oow*vsy + snap_ty;             \
     427  v->ooz = data[2]*oow*vsz + vtz;               \
     428  v->oow = oow;                                 \
     429  v->x -= snapper;                              \
     430  v->y -= snapper;                              \
    431431}
    432432
     
    434434#endif
    435435
    436 #define COPY_XYZW_STRIDE                                \
    437   { GLfloat *clip = VEC_ELT(VB->ClipPtr, GLfloat, e);   \
     436#define COPY_XYZW_STRIDE                                \
     437  { GLfloat *clip = VEC_ELT(VB->ClipPtr, GLfloat, e);   \
    438438    COPY_4FV(out, clip); }
    439439
    440440#define VARS_RGBA
    441441
    442 #define COPY_RGBA_STRIDE                                        \
    443   { GLubyte *color = VEC_ELT(VB->ColorPtr, GLubyte, e);         \
     442#define COPY_RGBA_STRIDE                                        \
     443  { GLubyte *color = VEC_ELT(VB->ColorPtr, GLubyte, e);         \
    444444    UBYTE_RGBA_TO_FLOAT_255_RGBA((out+4), color); }
    445445
    446446#if FX_USE_PARGB
    447 #define DO_SETUP_RGBA                           \
    448   GET_PARGB(v) = (((int)data[4+3]) << 24) |     \
    449                  (((int)data[4+0]) << 16) |     \
    450                  (((int)data[4+1]) << 8)  |     \
    451                  (((int)data[4+2]) << 0);       
     447#define DO_SETUP_RGBA                           \
     448  GET_PARGB(v) = (((int)data[4+3]) << 24) |     \
     449                 (((int)data[4+0]) << 16) |     \
     450                 (((int)data[4+1]) << 8)  |     \
     451                 (((int)data[4+2]) << 0);
    452452#else
    453 #define DO_SETUP_RGBA                           \
    454   v->r = data[4+0];                             \
    455   v->g = data[4+1];                             \
    456   v->b = data[4+2];                             \
     453#define DO_SETUP_RGBA                           \
     454  v->r = data[4+0];                             \
     455  v->g = data[4+1];                             \
     456  v->b = data[4+2];                             \
    457457  v->a = data[4+3];
    458458#endif /* FX_USE_PARGB */
    459459
    460 #define VARS_TMU0                                                       \
    461   struct gl_texture_unit *t0 = &ctx->Texture.Unit[tmu0_source];         \
    462   GLfloat sScale0 = fxTMGetTexInfo(t0->Current)->sScale;        \
    463   GLfloat tScale0 = fxTMGetTexInfo(t0->Current)->tScale;        \
    464 
    465 
    466 #define COPY_TMU0_STRIDE(offset)                                        \
    467   { GLfloat *tc0 = VEC_ELT(tc0_vec, GLfloat, e);        \
     460#define VARS_TMU0                                                       \
     461  struct gl_texture_unit *t0 = &ctx->Texture.Unit[tmu0_source];         \
     462  GLfloat sScale0 = fxTMGetTexInfo(t0->Current)->sScale;        \
     463  GLfloat tScale0 = fxTMGetTexInfo(t0->Current)->tScale;        \
     464
     465
     466#define COPY_TMU0_STRIDE(offset)                                        \
     467  { GLfloat *tc0 = VEC_ELT(tc0_vec, GLfloat, e);        \
    468468    COPY_2V((out+offset), tc0); }
    469469
    470470
    471 #define DO_SETUP_TMU0(offset)                           \
    472   v->tmuvtx[0].sow = data[offset+0]*sScale0*v->oow;     \
     471#define DO_SETUP_TMU0(offset)                           \
     472  v->tmuvtx[0].sow = data[offset+0]*sScale0*v->oow;     \
    473473  v->tmuvtx[0].tow = data[offset+1]*tScale0*v->oow;
    474474
    475 #define VARS_TMU1                                                       \
    476   struct gl_texture_unit *t1 = &ctx->Texture.Unit[tmu1_source];         \
    477   GLfloat sScale1 = fxTMGetTexInfo(t1->Current)->sScale;        \
     475#define VARS_TMU1                                                       \
     476  struct gl_texture_unit *t1 = &ctx->Texture.Unit[tmu1_source];         \
     477  GLfloat sScale1 = fxTMGetTexInfo(t1->Current)->sScale;        \
    478478  GLfloat tScale1 = fxTMGetTexInfo(t1->Current)->tScale;
    479479
    480 #define COPY_TMU1_STRIDE(offset)                                        \
    481   { GLfloat *tc1 = VEC_ELT(tc1_vec, GLfloat, e);        \
     480#define COPY_TMU1_STRIDE(offset)                                        \
     481  { GLfloat *tc1 = VEC_ELT(tc1_vec, GLfloat, e);        \
    482482    COPY_2V((out+offset), tc1); }
    483483
    484484
    485 #define DO_SETUP_TMU1(offset)                           \
    486   v->tmuvtx[1].sow = data[offset+0]*sScale1*v->oow;     \
     485#define DO_SETUP_TMU1(offset)                           \
     486  v->tmuvtx[1].sow = data[offset+0]*sScale1*v->oow;     \
    487487  v->tmuvtx[1].tow = data[offset+1]*tScale1*v->oow;
    488488
  • trunk/src/opengl/mesa/3dfx/fxcliptmp.h

    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.
     
    9696#define SETUP S4
    9797
    98 
    99 static void TAG(fx_tri_view_clip)( struct vertex_buffer *VB,
    100                                    GLuint v[],
    101                                    GLubyte mask )
     98#define DRAW_LINE(tmp0, tmp1, width)    \
     99  do {                                  \
     100    GrVertex verts[4];                  \
     101    float dx, dy, ix, iy;               \
     102                                        \
     103    dx = tmp0->x - tmp1->x;             \
     104    dy = tmp0->y - tmp1->y;             \
     105                                        \
     106    if (dx * dx > dy * dy) {            \
     107      iy = width * .5;                  \
     108      ix = 0;                           \
     109    } else {                            \
     110      iy = 0;                           \
     111      ix = width * .5;                  \
     112    }                                   \
     113                                        \
     114   verts[0] = *tmp0;                    \
     115   verts[1] = *tmp0;                    \
     116   verts[2] = *tmp1;                    \
     117   verts[3] = *tmp1;                    \
     118                                        \
     119   verts[0].x = tmp0->x - ix;           \
     120   verts[0].y = tmp0->y - iy;           \
     121                                        \
     122   verts[1].x = tmp0->x + ix;           \
     123   verts[1].y = tmp0->y + iy;           \
     124                                        \
     125   verts[2].x = tmp1->x + ix;           \
     126   verts[2].y = tmp1->y + iy;           \
     127                                        \
     128   verts[3].x = tmp1->x - ix;           \
     129   verts[3].y = tmp1->y - iy;           \
     130                                        \
     131   FX_grDrawPolygonVertexList(4, verts); \
     132  } while (0)
     133
     134static void TAG(fx_tri_view_clip)( struct vertex_buffer *VB,
     135                                   GLuint v[],
     136                                   GLubyte mask )
    102137{
    103138   GLcontext *ctx = VB->ctx;
     
    112147   GLubyte *clipmask = VB->ClipMask;
    113148
    114    GLuint tmu0_source = fxMesa->tmu_source[0];                         
    115    GLuint tmu1_source = fxMesa->tmu_source[1];                         
     149   GLuint tmu0_source = fxMesa->tmu_source[0];
     150   GLuint tmu1_source = fxMesa->tmu_source[1];
    116151   GLvector4f *tc0_vec = VB->TexCoordPtr[tmu0_source];
    117152   GLvector4f *tc1_vec = VB->TexCoordPtr[tmu1_source];
     
    124159      GLuint e = v[i];
    125160      verts[i] = 0;
    126       if (!clipmask[e]) verts[i] = (GrVertex *)gWin[e].f;       
    127       vlist[i] = out; 
     161      if (!clipmask[e]) verts[i] = (GrVertex *)gWin[e].f;
     162      vlist[i] = out;
    128163      COPY_STRIDE;
    129164      out += SIZE;
     
    135170      GrVertex *v = tmp, *v2, *v3;
    136171      VARS;
    137    
     172
    138173      for (i = 0 ; i < n ; i++)
    139         if (!verts[i]) {
    140             GLfloat *data = vlist[i];
    141             SETUP;
    142             verts[i] = v++;
    143         }
    144          
     174        if (!verts[i]) {
     175            GLfloat *data = vlist[i];
     176            SETUP;
     177            verts[i] = v++;
     178        }
     179
    145180      v = verts[0];
    146181      v2 = verts[1];
     
    148183
    149184      for (i = 2 ; i < n ; v2 = v3, v3=verts[++i])
    150         FX_grDrawTriangle(v, v2, v3);
     185        FX_grDrawTriangle(v, v2, v3);
    151186   }
    152187}
     
    156191
    157192
    158 static void TAG(fx_tri_clip_stride)( struct vertex_buffer *VB, 
    159                                      GLuint v[],
    160                                      GLuint mask )
     193static void TAG(fx_tri_clip_stride)( struct vertex_buffer *VB,
     194                                     GLuint v[],
     195                                     GLuint mask )
    161196{
    162197   GLcontext *ctx = VB->ctx;
     
    171206   GLubyte *clipmask = VB->ClipMask;
    172207
    173    GLuint tmu0_source = fxMesa->tmu_source[0];                         
    174    GLuint tmu1_source = fxMesa->tmu_source[1];                         
     208   GLuint tmu0_source = fxMesa->tmu_source[0];
     209   GLuint tmu1_source = fxMesa->tmu_source[1];
    175210   GLvector4f *tc0_vec = VB->TexCoordPtr[tmu0_source];
    176211   GLvector4f *tc1_vec = VB->TexCoordPtr[tmu1_source];
     
    183218      GLuint e = v[i];
    184219      verts[i] = 0;
    185       if (!clipmask[e]) verts[i] = (GrVertex *)gWin[e].f;       
    186       vlist[i] = out; 
     220      if (!clipmask[e]) verts[i] = (GrVertex *)gWin[e].f;
     221      vlist[i] = out;
    187222      COPY_STRIDE;
    188223      out += SIZE;
     
    191226   if (VB->ClipPtr->size < 4) {
    192227      vlist[0][3] = vlist[1][3] = vlist[2][3] = 1.0;
    193       if (VB->ClipPtr->size == 2) 
    194         vlist[0][2] = vlist[1][2] = vlist[2][2] = 0.0;
    195    }
    196      
     228      if (VB->ClipPtr->size == 2)
     229        vlist[0][2] = vlist[1][2] = vlist[2][2] = 0.0;
     230   }
     231
    197232   if ((n = fx_clip_triangle( ctx, vlist, verts, SIZE, mask )) >= 3)
    198233   {
     
    200235      GrVertex *v = tmp, *v2, *v3;
    201236      VARS;
    202    
     237
    203238      for (i = 0 ; i < n ; i++)
    204         if (!verts[i]) {
    205             GLfloat *data = vlist[i];
    206             SETUP;
    207             verts[i] = v++;
    208         }
    209          
     239        if (!verts[i]) {
     240            GLfloat *data = vlist[i];
     241            SETUP;
     242            verts[i] = v++;
     243        }
     244
    210245      v = verts[0];
    211246      v2 = verts[1];
     
    213248
    214249      for (i = 2 ; i < n ; v2 = v3, v3=verts[++i])
    215         FX_grDrawTriangle(v, v2, v3);
     250        FX_grDrawTriangle(v, v2, v3);
    216251   }
    217252}
     
    219254
    220255
    221 static void TAG(fx_line_clip)( struct vertex_buffer *VB, 
    222                                GLuint v1, GLuint v2,
    223                                GLubyte mask )
     256static void TAG(fx_line_clip)( struct vertex_buffer *VB,
     257                               GLuint v1, GLuint v2,
     258                               GLubyte mask )
    224259{
    225260   GLcontext *ctx = VB->ctx;
     
    229264   GLfloat *out = data;
    230265   GLfloat *mat = ctx->Viewport.WindowMap.m;
     266   GLfloat w = ctx->Line.Width*.5;
    231267   GLuint  e, n;
    232268
    233    GLuint tmu0_source = fxMesa->tmu_source[0];                         
    234    GLuint tmu1_source = fxMesa->tmu_source[1];                         
     269   GLuint tmu0_source = fxMesa->tmu_source[0];
     270   GLuint tmu1_source = fxMesa->tmu_source[1];
    235271   GLvector4f *tc0_vec = VB->TexCoordPtr[tmu0_source];
    236272   GLvector4f *tc1_vec = VB->TexCoordPtr[tmu1_source];
     
    242278   (void) tmu1_source; (void) tc1_vec;
    243279
    244    vlist[0] = out; 
     280   vlist[0] = out;
    245281   e = v1;
    246282   COPY_STRIDE;
    247283   out += SIZE;
    248284
    249    vlist[1] = out; 
     285   vlist[1] = out;
    250286   e = v2;
    251287   COPY_STRIDE;
     
    254290   if (VB->ClipPtr->size < 4) {
    255291      vlist[0][3] = vlist[1][3] = 1.0;
    256       if (VB->ClipPtr->size == 2) 
    257         vlist[0][2] = vlist[1][2] = 0.0;
    258    }
    259      
     292      if (VB->ClipPtr->size == 2)
     293        vlist[0][2] = vlist[1][2] = 0.0;
     294   }
     295
    260296   if ((n = fx_clip_line( ctx, vlist, SIZE, mask )) != 0)
    261297   {
     
    272308      SETUP;
    273309
    274       FX_grDrawLine(gWin, v);     
     310      DRAW_LINE(gWin, v, w);
    275311   }
    276312}
     
    278314
    279315
    280 #undef V1 
    281 #undef S1 
    282 #undef C1 
    283 #undef Z1 
     316#undef V1
     317#undef S1
     318#undef C1
     319#undef Z1
    284320#undef T1
    285321
    286 #undef V2 
    287 #undef S2 
    288 #undef C2 
    289 #undef Z2 
     322#undef V2
     323#undef S2
     324#undef C2
     325#undef Z2
    290326#undef T2
    291327
    292 #undef V3 
    293 #undef S3 
    294 #undef C3 
    295 #undef Z3 
     328#undef V3
     329#undef S3
     330#undef C3
     331#undef Z3
    296332#undef T3
    297333
    298 #undef V4 
    299 #undef S4 
    300 #undef C4 
    301 #undef Z4 
     334#undef V4
     335#undef S4
     336#undef C4
     337#undef Z4
    302338#undef T4
    303339
    304 #undef VARS 
    305 #undef SETUP 
    306 #undef COPY 
     340#undef VARS
     341#undef SETUP
     342#undef COPY
    307343#undef COPY_STRIDE
    308344#undef SIZE
  • trunk/src/opengl/mesa/3dfx/fxcva.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.
     
    8282
    8383typedef void (*mergefunc)( struct vertex_buffer *cvaVB,
    84                            struct vertex_buffer *VB,
    85                            const struct gl_prim_state *state,
    86                            GLuint start,
    87                            GLuint count );
     84                           struct vertex_buffer *VB,
     85                           const struct gl_prim_state *state,
     86                           GLuint start,
     87                           GLuint count );
    8888
    8989static void fxCvaRenderNoop( struct vertex_buffer *cvaVB,
    90                              struct vertex_buffer *VB,
    91                              const struct gl_prim_state *state,
    92                              GLuint start,
    93                              GLuint count )
     90                             struct vertex_buffer *VB,
     91                             const struct gl_prim_state *state,
     92                             GLuint start,
     93                             GLuint count )
    9494{
    9595}
    9696
    9797static INLINE void fxRenderClippedTriangle2( struct vertex_buffer *VB,
    98                                              GLuint v1, GLuint v2, GLuint v3 )
     98                                             GLuint v1, GLuint v2, GLuint v3 )
    9999{
    100100  fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
     
    103103
    104104  if (!mask) {
    105      FX_grDrawTriangle((GrVertex *)gWin[v1].f, 
    106                     (GrVertex *)gWin[v2].f,
    107                     (GrVertex *)gWin[v3].f);
    108   } else if (!(clipmask[v1]&clipmask[v2]&clipmask[v3]&CLIP_ALL_BITS)) {   
     105     FX_grDrawTriangle((GrVertex *)gWin[v1].f,
     106                    (GrVertex *)gWin[v2].f,
     107                    (GrVertex *)gWin[v3].f);
     108  } else if (!(clipmask[v1]&clipmask[v2]&clipmask[v3]&CLIP_ALL_BITS)) {
    109109    GLuint n;
    110110    GLuint vlist[VB_MAX_CLIPPED_VERTS];
     
    115115      GLuint i, j0 = vlist[0];
    116116      for (i=2;i<n;i++) {
    117         FX_grDrawTriangle((GrVertex *)gWin[j0].f,
    118                        (GrVertex *)gWin[vlist[i-1]].f,
    119                        (GrVertex *)gWin[vlist[i]].f);
     117        FX_grDrawTriangle((GrVertex *)gWin[j0].f,
     118                       (GrVertex *)gWin[vlist[i-1]].f,
     119                       (GrVertex *)gWin[vlist[i]].f);
    120120      }
    121121    }
     
    128128
    129129/*
    130 #define CVA_VARS_RGBA                                                   \
    131    GLubyte (*color)[4] = VB->ColorPtr->data;                    \
     130#define CVA_VARS_RGBA                                                   \
     131   GLubyte (*color)[4] = VB->ColorPtr->data;                    \
    132132   GLubyte (*cva_color)[4] = (cvaVB->ColorPtr = cvaVB->LitColor[0])->data;
    133133*/
    134134
    135 #define CVA_VARS_RGBA                                                   \
    136    GLubyte (*color)[4] = VB->ColorPtr->data;                    \
     135#define CVA_VARS_RGBA                                                   \
     136   GLubyte (*color)[4] = VB->ColorPtr->data;                    \
    137137   GLubyte (*cva_color)[4] = cvaVB->ColorPtr->data;
    138138
     
    141141#undef DO_SETUP_RGBA
    142142#if FX_USE_PARGB
    143 #define DO_SETUP_RGBA                           \
    144 {                                                                       \
    145   GLubyte *col = color[i];                      \
    146   GET_PARGB(v)= ((col[3] << 24) |       \
    147                             (col[0] << 16)  |   \
    148                             (col[1] << 8)   |   \
    149                             (col[2]));                  \
     143#define DO_SETUP_RGBA                           \
     144{                                                                       \
     145  GLubyte *col = color[i];                      \
     146  GET_PARGB(v)= ((col[3] << 24) |       \
     147                            (col[0] << 16)  |   \
     148                            (col[1] << 8)   |   \
     149                            (col[2]));                  \
    150150}
    151151#else
    152 #define DO_SETUP_RGBA                           \
    153 {                                                       \
    154   GLubyte *col = color[i];                                      \
    155   v[GR_VERTEX_R_OFFSET]=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[0]); \
    156   v[GR_VERTEX_G_OFFSET]=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[1]); \
    157   v[GR_VERTEX_B_OFFSET]=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[2]); \
    158   v[GR_VERTEX_A_OFFSET]=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[3]); \
     152#define DO_SETUP_RGBA                           \
     153{                                                       \
     154  GLubyte *col = color[i];                                      \
     155  v[GR_VERTEX_R_OFFSET]=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[0]); \
     156  v[GR_VERTEX_G_OFFSET]=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[1]); \
     157  v[GR_VERTEX_B_OFFSET]=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[2]); \
     158  v[GR_VERTEX_A_OFFSET]=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[3]); \
    159159}
    160160#endif /* FX_USE_PARGB */
    161161
    162162
    163 #define CVA_VARS_TMU0                                                   \
    164    VARS_TMU0                                                            \
     163#define CVA_VARS_TMU0                                                   \
     164   VARS_TMU0                                                            \
    165165   GLfloat (*cva_tex0)[4] = (cvaVB->TexCoordPtr[tmu0_source] = cvaVB->store.TexCoord[tmu0_source])->data;
    166166
    167 #define CVA_VARS_TMU1                                                   \
    168    VARS_TMU1                                                            \
     167#define CVA_VARS_TMU1                                                   \
     168   VARS_TMU1                                                            \
    169169   GLfloat (*cva_tex1)[4] = (cvaVB->TexCoordPtr[tmu1_source] = cvaVB->store.TexCoord[tmu1_source])->data;
    170170
     
    221221#define TAG(x) x##T0T1
    222222#define IDX SETUP_TMU0|SETUP_TMU1
    223 #define VARS CVA_VARS_TMU0 CVA_VARS_TMU1 
    224 #define INIT INIT_TMU0 INIT_TMU1 
     223#define VARS CVA_VARS_TMU0 CVA_VARS_TMU1
     224#define INIT INIT_TMU0 INIT_TMU1
    225225#define INCR , tmu0_data+=4 , tmu1_data+=4
    226226#define MERGE_RAST DO_SETUP_TMU0 DO_SETUP_TMU1
     
    231231#define TAG(x) x##RGBAT0
    232232#define IDX SETUP_RGBA|SETUP_TMU0
    233 #define VARS CVA_VARS_RGBA CVA_VARS_TMU0 
    234 #define INIT INIT_RGBA INIT_TMU0 
    235 #define INCR , tmu0_data+=4 
     233#define VARS CVA_VARS_RGBA CVA_VARS_TMU0
     234#define INIT INIT_RGBA INIT_TMU0
     235#define INCR , tmu0_data+=4
    236236#define MERGE_RAST DO_SETUP_RGBA; DO_SETUP_TMU0
    237237#define MERGE_VB COPY_2FV(cva_tex0[e], tmu0_data); \
     
    262262
    263263
    264 #undef DRAW_POINT 
    265 #undef DRAW_LINE 
    266 #undef DRAW_TRI 
    267 #undef CLIP_LINE 
    268 #undef CLIP_OR_DRAW_TRI 
     264#undef DRAW_POINT
     265#undef DRAW_LINE
     266#undef DRAW_TRI
     267#undef CLIP_LINE
     268#undef CLIP_OR_DRAW_TRI
    269269#undef DIRECT
    270270
    271271#define DRAW_POINT ctx->Driver.PointsFunc( ctx, e, e )
    272 #define DRAW_LINE ctx->Driver.LineFunc( ctx, e, prev, e ) 
     272#define DRAW_LINE ctx->Driver.LineFunc( ctx, e, prev, e )
    273273#define DRAW_TRI ctx->TriangleFunc( ctx, l[0], l[1], e, e )
    274274#define CLIP_LINE gl_render_clipped_line( ctx, e, prev )
    275 #define CLIP_OR_DRAW_TRI                                                \
    276 do {                                                                    \
    277    if (clip[l[0]] | clip[l[1]] | clip[e]) {                             \
    278       if (!(clip[l[0]] & clip[l[1]] & clip[e] & CLIP_ALL_BITS)) {       \
    279          COPY_3V(vlist, l);                                             \
    280          gl_render_clipped_triangle( ctx, 3, vlist, e );                \
    281       }                                                                 \
    282    }                                                                    \
    283    else ctx->TriangleFunc( ctx, l[0], l[1], e, e );                     \
     275#define CLIP_OR_DRAW_TRI                                                \
     276do {                                                                    \
     277   if (clip[l[0]] | clip[l[1]] | clip[e]) {                             \
     278      if (!(clip[l[0]] & clip[l[1]] & clip[e] & CLIP_ALL_BITS)) {       \
     279         COPY_3V(vlist, l);                                             \
     280         gl_render_clipped_triangle( ctx, 3, vlist, e );                \
     281      }                                                                 \
     282   }                                                                    \
     283   else ctx->TriangleFunc( ctx, l[0], l[1], e, e );                     \
    284284} while (0)
    285285
    286            
     286
    287287#define DIRECT 0
    288288
     
    325325#define TAG(x) x##T0T1_indirect
    326326#define IDX SETUP_TMU0|SETUP_TMU1
    327 #define VARS CVA_VARS_TMU0 CVA_VARS_TMU1 
    328 #define INIT INIT_TMU0 INIT_TMU1 
     327#define VARS CVA_VARS_TMU0 CVA_VARS_TMU1
     328#define INIT INIT_TMU0 INIT_TMU1
    329329#define INCR , tmu0_data+=4 , tmu1_data+=4
    330330#define MERGE_RAST DO_SETUP_TMU0 DO_SETUP_TMU1
     
    335335#define TAG(x) x##RGBAT0_indirect
    336336#define IDX SETUP_RGBA|SETUP_TMU0
    337 #define VARS CVA_VARS_RGBA CVA_VARS_TMU0 
    338 #define INIT INIT_RGBA INIT_TMU0 
     337#define VARS CVA_VARS_RGBA CVA_VARS_TMU0
     338#define INIT INIT_RGBA INIT_TMU0
    339339#define INCR , tmu0_data+=4
    340340#define MERGE_RAST DO_SETUP_RGBA; DO_SETUP_TMU0
     
    398398       (ctx->Array.Summary & VERT_OBJ_ANY))
    399399   {
    400       d->inputs = (VERT_SETUP_PART | VERT_ELT | inputs);   
     400      d->inputs = (VERT_SETUP_PART | VERT_ELT | inputs);
    401401      d->outputs = 0;
    402402      d->type = PIPE_IMMEDIATE;
     
    409409extern void fxPointSmooth(GLcontext *ctx, GLuint first, GLuint last);
    410410extern void fxLineSmooth(GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv);
    411 extern void fxTriangleSmooth(GLcontext *ctx, GLuint v1, GLuint v2, GLuint v3, 
    412                              GLuint pv);
     411extern void fxTriangleSmooth(GLcontext *ctx, GLuint v1, GLuint v2, GLuint v3,
     412                             GLuint pv);
    413413extern const char *gl_prim_name[];
    414414
     
    433433   GLuint p = 0;
    434434
    435    if (fxMesa->new_state) 
     435   if (fxMesa->new_state)
    436436      fxSetupFXUnits(ctx);
    437437
     
    441441    * VB so that funcs like fxTriangleFlat will be able to reach them.
    442442    *
    443     * This leads to some duplication of effort in the merge funcs. 
     443    * This leads to some duplication of effort in the merge funcs.
    444444    */
    445445   if (inputs & VERT_RGBA) {
     
    464464   if (cvaVB->ClipOrMask)
    465465      gl_import_client_data( cvaVB, ctx->RenderFlags,
    466                              VEC_WRITABLE|VEC_GOOD_STRIDE );
     466                             VEC_WRITABLE|VEC_GOOD_STRIDE );
    467467
    468468   ctx->VB = cvaVB;
    469469
    470470   do {
    471       for ( i= VB->CopyStart ; i < count ; parity = 0, i = next ) 
     471      for ( i= VB->CopyStart ; i < count ; parity = 0, i = next )
    472472      {
    473         prim = VB->Primitive[i];
    474         next = VB->NextPrimitive[i];
    475 
    476         state = gl_prim_state_machine[prim][parity];
    477         func = tab[flags][reduce_prim[prim]];
    478         func( cvaVB, VB, state, i, next );
    479      
    480          if ( ctx->TriangleCaps & DD_TRI_LIGHT_TWOSIDE )
    481         {
    482             cvaVB->Specular = cvaVB->Spec[0];
    483             cvaVB->ColorPtr = cvaVB->Color[0];
    484             cvaVB->IndexPtr = cvaVB->Index[0];
    485         }
     473        prim = VB->Primitive[i];
     474        next = VB->NextPrimitive[i];
     475
     476        state = gl_prim_state_machine[prim][parity];
     477        func = tab[flags][reduce_prim[prim]];
     478        func( cvaVB, VB, state, i, next );
     479
     480         if ( ctx->TriangleCaps & DD_TRI_LIGHT_TWOSIDE )
     481        {
     482            cvaVB->Specular = cvaVB->Spec[0];
     483            cvaVB->ColorPtr = cvaVB->Color[0];
     484            cvaVB->IndexPtr = cvaVB->Index[0];
     485        }
    486486      }
    487487   } while (ctx->Driver.MultipassFunc &&
    488             ctx->Driver.MultipassFunc( VB, ++p ));
    489 
    490 
    491 
    492    if (ctx->PB->count > 0) 
     488            ctx->Driver.MultipassFunc( VB, ++p ));
     489
     490
     491
     492   if (ctx->PB->count > 0)
    493493      gl_flush_pb(ctx);
    494494
  • trunk/src/opengl/mesa/3dfx/fxcva.h

    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.
     
    5050
    5151extern GLboolean fxMergeAndRenderCVA( struct vertex_buffer *VB,
    52                                       struct vertex_buffer *cvaVB );
     52                                      struct vertex_buffer *cvaVB );
    5353
    5454
    5555
    5656extern void fxRenderCVAElements( struct vertex_buffer *VB,
    57                                 GLenum mode,
    58                                 GLuint *elts,
    59                                 GLuint n );
     57                                GLenum mode,
     58                                GLuint *elts,
     59                                GLuint n );
    6060
    6161
  • trunk/src/opengl/mesa/3dfx/fxcvatmp.h

    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.
     
    4545
    4646static void TAG(cva_render_points)( struct vertex_buffer *cvaVB,
    47                                     struct vertex_buffer *VB,
    48                                     const struct gl_prim_state *state,
    49                                     GLuint start,
    50                                     GLuint count )
     47                                    struct vertex_buffer *VB,
     48                                    const struct gl_prim_state *state,
     49                                    GLuint start,
     50                                    GLuint count )
    5151{
    5252   GLcontext *ctx = VB->ctx;
     
    6363      const GLubyte *clip = cvaVB->ClipMask;
    6464      for (i = start ; i < count ; i++ INCR) {
    65         GLuint e = elt[i];
    66         if (!clip[e]) {
    67             GLfloat *v = gWin[e].f; (void) v;
    68             if (!DIRECT) { MERGE_VB; }
    69             MERGE_RAST;
    70             DRAW_POINT;
    71         }
     65        GLuint e = elt[i];
     66        if (!clip[e]) {
     67            GLfloat *v = gWin[e].f; (void) v;
     68            if (!DIRECT) { MERGE_VB; }
     69            MERGE_RAST;
     70            DRAW_POINT;
     71        }
    7272      }
    7373   } else {
    7474      for (i = start ; i < count ; i++ INCR) {
    75         GLuint e = elt[i];
    76         GLfloat *v = gWin[e].f; (void) v;
    77         if (!DIRECT) { MERGE_VB; }
    78         MERGE_RAST;
    79         DRAW_POINT;
     75        GLuint e = elt[i];
     76        GLfloat *v = gWin[e].f; (void) v;
     77        if (!DIRECT) { MERGE_VB; }
     78        MERGE_RAST;
     79        DRAW_POINT;
    8080      }
    8181   }
     
    8383
    8484static void TAG(cva_render_lines)( struct vertex_buffer *cvaVB,
    85                                    struct vertex_buffer *VB,
    86                                    const struct gl_prim_state *state,
    87                                    GLuint start,
    88                                    GLuint count )
     85                                   struct vertex_buffer *VB,
     86                                   const struct gl_prim_state *state,
     87                                   GLuint start,
     88                                   GLuint count )
    8989{
    9090   GLcontext *ctx = VB->ctx;
     
    104104
    105105      (void) ctx;
    106    
    107       for (i = start ; i < count ; i++ INCR) {
    108         GLuint e = elt[i];
    109         GLfloat *v = gWin[e].f;
    110 
    111         MERGE_VB;
    112 
    113         if (!clip[e])
    114             MERGE_RAST;
    115 
    116         if (state->draw) {
    117             if (clip[e] | clip[prev])
    118                CLIP_LINE;
    119             else
    120                DRAW_LINE;
    121         }
    122 
    123          prev = e;       
    124         prev_v = v;
    125         state = state->next;
     106
     107      for (i = start ; i < count ; i++ INCR) {
     108        GLuint e = elt[i];
     109        GLfloat *v = gWin[e].f;
     110
     111        MERGE_VB;
     112
     113        if (!clip[e])
     114            MERGE_RAST;
     115
     116        if (state->draw) {
     117            if (clip[e] | clip[prev])
     118               CLIP_LINE;
     119            else
     120               DRAW_LINE;
     121        }
     122
     123         prev = e;
     124        prev_v = v;
     125        state = state->next;
    126126      }
    127127      if (state->finish_loop) {
    128         GLuint e = elt[start];
    129         GLfloat *v = gWin[e].f; (void) v;
    130 
    131         if (!DIRECT) { MERGE_VB; }
    132         MERGE_RAST;
    133 
    134          if (clip[e] | clip[prev])
    135             CLIP_LINE;
    136         else
    137             DRAW_LINE;
     128        GLuint e = elt[start];
     129        GLfloat *v = gWin[e].f; (void) v;
     130
     131        if (!DIRECT) { MERGE_VB; }
     132        MERGE_RAST;
     133
     134         if (clip[e] | clip[prev])
     135            CLIP_LINE;
     136        else
     137            DRAW_LINE;
    138138      }
    139139   } else {
    140140      GLuint prev = 0;
    141141      GLfloat *prev_v = 0;
    142      
    143       for (i = start ; i < count ; i++ INCR) {
    144         GLuint e = elt[i];
    145         GLfloat *v = gWin[e].f;
    146 
    147         if (!DIRECT) { MERGE_VB; }
    148         MERGE_RAST;
    149         if (state->draw) DRAW_LINE;
    150         prev = e;
    151         prev_v = v;
    152         state = state->next;
     142
     143      for (i = start ; i < count ; i++ INCR) {
     144        GLuint e = elt[i];
     145        GLfloat *v = gWin[e].f;
     146
     147        if (!DIRECT) { MERGE_VB; }
     148        MERGE_RAST;
     149        if (state->draw) DRAW_LINE;
     150        prev = e;
     151        prev_v = v;
     152        state = state->next;
    153153      }
    154154      if (state->finish_loop) {
    155         GLuint e = elt[start];
    156         GLfloat *v = gWin[e].f; (void) v;
    157 
    158         if (!DIRECT) { MERGE_VB; }
    159         MERGE_RAST;
    160         DRAW_LINE;
    161       }
    162    }     
     155        GLuint e = elt[start];
     156        GLfloat *v = gWin[e].f; (void) v;
     157
     158        if (!DIRECT) { MERGE_VB; }
     159        MERGE_RAST;
     160        DRAW_LINE;
     161      }
     162   }
    163163}
    164164
    165165
    166166static void TAG(cva_render_tris)( struct vertex_buffer *cvaVB,
    167                                   struct vertex_buffer *VB,
    168                                   const struct gl_prim_state *state,
    169                                   GLuint start,
    170                                   GLuint count )
     167                                  struct vertex_buffer *VB,
     168                                  const struct gl_prim_state *state,
     169                                  GLuint start,
     170                                  GLuint count )
    171171{
    172172   GLcontext *ctx = VB->ctx;
     
    179179   (void) fxMesa;
    180180
    181    if (cvaVB->ClipOrMask) {     
     181   if (cvaVB->ClipOrMask) {
    182182      GLuint vlist[VB_MAX_CLIPPED_VERTS];
    183183      GLuint l[3];
    184       const GLubyte *clip = cvaVB->ClipMask; 
    185      
     184      const GLubyte *clip = cvaVB->ClipMask;
     185
    186186      (void) vlist;
    187187
    188188      for (i = start ; i < count ; i++ INCR) {
    189         GLuint e = l[2] = elt[i];
    190         GLfloat *v = gWin[e].f; (void) v;
    191 
    192          MERGE_VB;              /* needed for clip-interp */
    193 
    194         if (!clip[e]) {
    195             MERGE_RAST;
    196         }
    197 
    198          if (state->draw)
    199             CLIP_OR_DRAW_TRI;
    200 
    201 
    202         l[0] = l[state->v0];
    203         l[1] = l[state->v1];
    204         state = state->next;
     189        GLuint e = l[2] = elt[i];
     190        GLfloat *v = gWin[e].f; (void) v;
     191
     192         MERGE_VB;              /* needed for clip-interp */
     193
     194        if (!clip[e]) {
     195            MERGE_RAST;
     196        }
     197
     198         if (state->draw)
     199            CLIP_OR_DRAW_TRI;
     200
     201
     202        l[0] = l[state->v0];
     203        l[1] = l[state->v1];
     204        state = state->next;
    205205      }
    206206   } else if (DIRECT) {
    207207      GrVertex *vl[3];
    208208      for (i = start ; i < count ; i++ INCR) {
    209         GLuint e = elt[i];
    210         GLfloat *v = gWin[elt[i]].f;
    211 
    212         vl[2] = (GrVertex *)v;
    213 
    214          (void) v;
    215         (void) e;
    216 
    217         MERGE_RAST;
    218 
    219          if (state->draw)
    220             DRAW_TRI2;
    221 
    222         vl[0] = vl[state->v0];
    223         vl[1] = vl[state->v1];
    224         state = state->next;
     209        GLuint e = elt[i];
     210        GLfloat *v = gWin[elt[i]].f;
     211
     212        vl[2] = (GrVertex *)v;
     213
     214         (void) v;
     215        (void) e;
     216
     217        MERGE_RAST;
     218
     219         if (state->draw)
     220            DRAW_TRI2;
     221
     222        vl[0] = vl[state->v0];
     223        vl[1] = vl[state->v1];
     224        state = state->next;
    225225      }
    226226   } else {
    227227      GLuint l[3];
    228228      for (i = start ; i < count ; i++ INCR) {
    229         GLuint e = l[2] = elt[i];
    230         GLfloat *v = gWin[e].f; (void) v;
    231 
    232          MERGE_VB;              /* needed for ctx->trianglefunc? */
    233         MERGE_RAST;
    234          
    235          if (state->draw)
    236             DRAW_TRI;
    237 
    238         l[0] = l[state->v0];
    239         l[1] = l[state->v1];
    240         state = state->next;
     229        GLuint e = l[2] = elt[i];
     230        GLfloat *v = gWin[e].f; (void) v;
     231
     232         MERGE_VB;              /* needed for ctx->trianglefunc? */
     233        MERGE_RAST;
     234
     235         if (state->draw)
     236            DRAW_TRI;
     237
     238        l[0] = l[state->v0];
     239        l[1] = l[state->v1];
     240        state = state->next;
    241241      }
    242242   }
  • trunk/src/opengl/mesa/3dfx/fxdd.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.
     
    5353#if defined(FX)
    5454
     55#include "image.h"
    5556#include "types.h"
    5657#include "fxdrv.h"
    5758#include "enums.h"
    5859#include "extensions.h"
    59 
     60#include "pb.h"
    6061
    6162/* These lookup table are used to extract RGB values in [0,255] from
     
    7172 * Input: bgrOrder - if TRUE, pixels are in BGR order, else RGB order.
    7273 */
    73 void fxInitPixelTables(GLboolean bgrOrder)
     74void fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder)
    7475{
    7576  GLuint pixel;
     77
     78  fxMesa->bgrOrder=bgrOrder;
    7679  for (pixel = 0; pixel <= 0xffff; pixel++) {
    7780    GLuint r, g, b;
     
    101104
    102105/* Enalbe/Disable dithering */
    103 void fxDDDither(GLcontext *ctx, GLboolean enable)
     106static void fxDDDither(GLcontext *ctx, GLboolean enable)
    104107{
    105108  if (MESA_VERBOSE&VERBOSE_DRIVER) {
     
    116119
    117120/* Return buffer size information */
    118 void fxDDBufferSize(GLcontext *ctx, GLuint *width, GLuint *height)
     121static void fxDDBufferSize(GLcontext *ctx, GLuint *width, GLuint *height)
    119122{
    120123  fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
     
    140143  GLubyte col[4];
    141144  ASSIGN_4V( col, red, green, blue, alpha );
    142  
     145
    143146  if (MESA_VERBOSE&VERBOSE_DRIVER) {
    144147    fprintf(stderr,"fxmesa: fxDDSetColor(%d,%d,%d,%d)\n",red,green,blue,alpha);
     
    163166    fprintf(stderr,"fxmesa: fxDDClearColor(%d,%d,%d,%d)\n",red,green,blue,alpha);
    164167  }
    165  
     168
    166169  fxMesa->clearC=FXCOLOR4( col );
    167170  fxMesa->clearA=alpha;
     
    173176{
    174177  fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
    175   GLbitfield newmask;
     178  const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
     179  const FxU16 clearD = (FxU16) (ctx->Depth.Clear * 0xffff);
     180  GLbitfield softwareMask = mask & (DD_STENCIL_BIT | DD_ACCUM_BIT);
    176181
    177182  if (MESA_VERBOSE&VERBOSE_DRIVER) {
     
    179184  }
    180185
    181   switch(mask & (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)) {
    182   case (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT):
    183     /* clear color and depth buffer */
    184 
    185     if (ctx->Color.DrawDestMask & BACK_LEFT_BIT) {
     186  if (colorMask != 0xffffffff) {
     187    /* do color buffer clears in software */
     188    softwareMask |= (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT));
     189    mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT);
     190  }
     191
     192  /*
     193   * This could probably be done fancier but doing each possible case
     194   * explicitly is less error prone.
     195   */
     196  switch (mask) {
     197    case DD_BACK_LEFT_BIT | DD_DEPTH_BIT:
     198      /* back buffer & depth */
     199      FX_grDepthMask(FXTRUE);
    186200      FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
    187       FX_grBufferClear(fxMesa->clearC, fxMesa->clearA,
    188                        (FxU16)(ctx->Depth.Clear*0xffff));
    189     }
    190     if (ctx->Color.DrawDestMask & FRONT_LEFT_BIT) {
     201      FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
     202      if (!ctx->Depth.Mask) {
     203        FX_grDepthMask(FXFALSE);
     204      }
     205      break;
     206    case DD_FRONT_LEFT_BIT | DD_DEPTH_BIT:
     207      /* XXX it appears that the depth buffer isn't cleared when
     208       * glRenderBuffer(GR_BUFFER_FRONTBUFFER) is set.
     209       * This is a work-around/
     210       */
     211      /* clear depth */
     212      FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
     213      FX_grColorMask(FXFALSE,FXFALSE);
     214      FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
     215      /* clear front */
     216      FX_grColorMask(FXTRUE, ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
    191217      FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
    192       FX_grBufferClear(fxMesa->clearC, fxMesa->clearA,
    193                        (FxU16)(ctx->Depth.Clear*0xffff));
    194     }
    195 
    196     newmask=mask & (~(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT));
    197     break;
    198   case (GL_COLOR_BUFFER_BIT):
    199     /* clear color buffer */
    200 
    201     if(ctx->Color.ColorMask) {
     218      FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
     219      break;
     220    case DD_BACK_LEFT_BIT:
     221      /* back buffer only */
    202222      FX_grDepthMask(FXFALSE);
    203 
    204       if (ctx->Color.DrawDestMask & BACK_LEFT_BIT) {
    205         FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
    206         FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, 0);
     223      FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
     224      FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
     225      if (!ctx->Depth.Mask) {
     226        FX_grDepthMask(FXFALSE);
    207227      }
    208       if (ctx->Color.DrawDestMask & FRONT_LEFT_BIT) {
    209         FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
    210         FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, 0);
     228      break;
     229    case DD_FRONT_LEFT_BIT:
     230      /* front buffer only */
     231      FX_grDepthMask(FXFALSE);
     232      FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
     233      FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
     234      if (!ctx->Depth.Mask) {
     235        FX_grDepthMask(FXFALSE);
    211236      }
    212 
    213       if(ctx->Depth.Mask) {
    214         FX_grDepthMask(FXTRUE);
     237      break;
     238    case DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT:
     239      /* front and back */
     240      FX_grDepthMask(FXFALSE);
     241      FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
     242      FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
     243      FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
     244      FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
     245      if (!ctx->Depth.Mask) {
     246        FX_grDepthMask(FXFALSE);
    215247      }
    216     }
    217 
    218     newmask=mask & (~(GL_COLOR_BUFFER_BIT));
    219     break;
    220   case (GL_DEPTH_BUFFER_BIT):
    221     /* clear depth buffer */
    222 
    223     if(ctx->Depth.Mask) {
     248      break;
     249    case DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT | DD_DEPTH_BIT:
     250      /* clear front */
     251      FX_grDepthMask(FXFALSE);
     252      FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
     253      FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
     254      /* clear back and depth */
     255      FX_grDepthMask(FXTRUE);
     256      FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
     257      FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
     258      if (!ctx->Depth.Mask) {
     259        FX_grDepthMask(FXFALSE);
     260      }
     261      break;
     262    case DD_DEPTH_BIT:
     263      /* just the depth buffer */
    224264      FX_grColorMask(FXFALSE,FXFALSE);
    225265      FX_grBufferClear(fxMesa->clearC, fxMesa->clearA,
    226                        (FxU16)(ctx->Depth.Clear*0xffff));
    227 
    228       FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
    229                      ctx->Color.ColorMask[GCOMP] ||
    230                      ctx->Color.ColorMask[BCOMP],
    231                      ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
    232     }
    233 
    234     newmask=mask & (~(GL_DEPTH_BUFFER_BIT));
    235     break;
    236   default:
    237     newmask=mask;
    238     break;
    239   }
    240    
    241   return newmask;
    242 }
    243 
    244 
    245 /*  Set the buffer used in double buffering */
    246 static GLboolean fxDDSetBuffer(GLcontext *ctx, GLenum mode )
     266                       (FxU16)(ctx->Depth.Clear*0xffff));
     267      FX_grColorMask(FXTRUE, ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
     268      break;
     269    default:
     270      /* error */
     271      ;
     272  }
     273
     274  return softwareMask;
     275}
     276
     277
     278/*  Set the buffer used for reading */
     279static GLboolean fxDDSetDrawBuffer(GLcontext *ctx, GLenum mode )
    247280{
    248281  fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
     
    267300}
    268301
     302/* Set the buffer used for reading */
     303static void fxDDSetReadBuffer(GLcontext *ctx, GLframebuffer *buffer,
     304                              GLenum mode )
     305{
     306  fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
     307  (void) buffer;
     308
     309  if (MESA_VERBOSE&VERBOSE_DRIVER) {
     310    fprintf(stderr,"fxmesa: fxDDSetBuffer(%x)\n", (int) mode);
     311  }
     312
     313  if (mode == GL_FRONT_LEFT) {
     314    fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
     315    FX_grRenderBuffer(fxMesa->currentFB);
     316  }
     317  else if (mode == GL_BACK_LEFT) {
     318    fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
     319    FX_grRenderBuffer(fxMesa->currentFB);
     320  }
     321}
     322
     323
    269324
    270325#ifdef XF86DRI
     326/* test if window coord (px,py) is visible */
    271327static GLboolean inClipRects(fxMesaContext fxMesa, int px, int py)
    272328{
    273329  int i;
    274 
    275   py=fxMesa->height+fxMesa->y_offset-py;
    276330  for (i=0; i<fxMesa->numClipRects; i++) {
    277     if ((px>=fxMesa->pClipRects[i].x1) && 
    278         (px<fxMesa->pClipRects[i].x2) &&
    279         (py>=fxMesa->pClipRects[i].y1) &&
    280         (py<fxMesa->pClipRects[i].y2)) return GL_TRUE;
     331    if ((px>=fxMesa->pClipRects[i].x1) &&
     332        (px<fxMesa->pClipRects[i].x2) &&
     333        (py>=fxMesa->pClipRects[i].y1) &&
     334        (py<fxMesa->pClipRects[i].y2)) return GL_TRUE;
    281335  }
    282336  return GL_FALSE;
     
    291345{
    292346  fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
    293   FxU16 *p;
    294347  GrLfbInfo_t info;
    295   const GLubyte *pb;
    296   int x,y,xmin,xmax,ymin,ymax;
    297   GLint r,g,b,a,scrwidth,scrheight,stride;
    298348  FxU16 color;
    299 
    300   /* TODO: with a little work, these bitmap unpacking parameter restrictions
    301    * could be removed.
    302    */
    303   if((unpack->Alignment!=1) ||
    304      (unpack->RowLength!=0) ||
    305      (unpack->SkipPixels!=0) ||
    306      (unpack->SkipRows!=0) ||
    307      (unpack->SwapBytes) ||
    308      (unpack->LsbFirst))
     349  const struct gl_pixelstore_attrib *finalUnpack;
     350  struct gl_pixelstore_attrib scissoredUnpack;
     351
     352  /* check if there's any raster operations enabled which we can't handle */
     353  if (ctx->RasterMask & (ALPHATEST_BIT |
     354                         BLEND_BIT |
     355                         DEPTH_BIT |
     356                         FOG_BIT |
     357                         LOGIC_OP_BIT |
     358                         SCISSOR_BIT |
     359                         STENCIL_BIT |
     360                         MASKING_BIT |
     361                         ALPHABUF_BIT |
     362                         MULTI_DRAW_BIT))
    309363    return GL_FALSE;
    310364
    311365  if (ctx->Scissor.Enabled) {
    312         xmin=ctx->Scissor.X;
    313         xmax=ctx->Scissor.X+ctx->Scissor.Width;
    314         ymin=ctx->Scissor.Y;
    315         ymax=ctx->Scissor.Y+ctx->Scissor.Height;
    316   } else {
    317         xmin=0;
    318         xmax=fxMesa->width;
    319         ymin=0;
    320         ymax=fxMesa->height;
    321   }
    322 
    323   xmin+=fxMesa->x_offset;
    324   xmax+=fxMesa->x_offset;
    325 
    326 #ifdef XF86DRI
    327 #define ISCLIPPED(rx, ry) ( ((rx)<xmin) || ((rx)>=xmax) || !inClipRects(fxMesa, rx, ry))
    328 #else
    329 #define ISCLIPPED(rx, ry) ( ((rx)<xmin) || ((rx)>=xmax) )
    330 #endif
    331 #define DRAWBIT(i) {       \
    332   if(!ISCLIPPED(x+px, y))  \
    333     if( (*pb) & (1<<(i)) ) \
    334       (*p)=color;          \
    335   p++;                     \
    336   x++;                     \
    337   if(x>=width) {           \
    338     pb++;                  \
    339     break;                 \
    340   }                        \
    341 }
    342 
    343   scrwidth=fxMesa->width;
    344   scrheight=fxMesa->height;
    345 
    346   if ((px>=scrwidth) || (px+width<=0) || (py>=scrheight) || (py+height<=0))
    347     return GL_TRUE;
    348 
    349   pb=bitmap;
    350 
    351   if(py<0) {
    352     pb+=(height*(-py)) >> (3+1);
    353     height+=py;
    354     py=0;
    355   }
    356 
    357   if (py+height>=scrheight)
    358     height-=(py+height)-scrheight;
    359 
    360   info.size=sizeof(info);
    361   if(!FX_grLfbLock(GR_LFB_WRITE_ONLY,
    362                    fxMesa->currentFB,
    363                    GR_LFBWRITEMODE_565,
    364                    GR_ORIGIN_UPPER_LEFT,
    365                    FXFALSE,
    366                    &info)) {
     366    /* This is a bit tricky, but by carefully adjusting the px, py,
     367     * width, height, skipPixels and skipRows values we can do
     368     * scissoring without special code in the rendering loop.
     369     */
     370
     371    /* we'll construct a new pixelstore struct */
     372    finalUnpack = &scissoredUnpack;
     373    scissoredUnpack = *unpack;
     374    if (scissoredUnpack.RowLength == 0)
     375      scissoredUnpack.RowLength = width;
     376
     377    /* clip left */
     378    if (px < ctx->Scissor.X) {
     379      scissoredUnpack.SkipPixels += (ctx->Scissor.X - px);
     380      width -= (ctx->Scissor.X - px);
     381      px = ctx->Scissor.X;
     382    }
     383    /* clip right */
     384    if (px + width >= ctx->Scissor.X + ctx->Scissor.Width) {
     385      width -= (px + width - (ctx->Scissor.X + ctx->Scissor.Width));
     386    }
     387    /* clip bottom */
     388    if (py < ctx->Scissor.Y) {
     389      scissoredUnpack.SkipRows += (ctx->Scissor.Y - py);
     390      height -= (ctx->Scissor.Y - py);
     391      py = ctx->Scissor.Y;
     392    }
     393    /* clip top */
     394    if (py + height >= ctx->Scissor.Y + ctx->Scissor.Height) {
     395      height -= (py + height - (ctx->Scissor.Y + ctx->Scissor.Height));
     396    }
     397
     398    if (width <= 0 || height <= 0)
     399      return GL_TRUE;  /* totally scissored away */
     400  }
     401  else {
     402    finalUnpack = unpack;
     403  }
     404
     405  /* compute pixel value */
     406  {
     407    GLint r = (GLint) (ctx->Current.RasterColor[0] * 255.0f);
     408    GLint g = (GLint) (ctx->Current.RasterColor[1] * 255.0f);
     409    GLint b = (GLint) (ctx->Current.RasterColor[2] * 255.0f);
     410    /*GLint a = (GLint)(ctx->Current.RasterColor[3]*255.0f);*/
     411    if (fxMesa->bgrOrder)
     412      color = (FxU16)
     413        ( ((FxU16)0xf8 & b) << (11-3))  |
     414        ( ((FxU16)0xfc & g) << (5-3+1)) |
     415        ( ((FxU16)0xf8 & r) >> 3);
     416    else
     417      color = (FxU16)
     418        ( ((FxU16)0xf8 & r) << (11-3))  |
     419        ( ((FxU16)0xfc & g) << (5-3+1)) |
     420        ( ((FxU16)0xf8 & b) >> 3);
     421  }
     422
     423  info.size = sizeof(info);
     424  if (!FX_grLfbLock(GR_LFB_WRITE_ONLY,
     425                    fxMesa->currentFB,
     426                    GR_LFBWRITEMODE_565,
     427                    GR_ORIGIN_UPPER_LEFT,
     428                    FXFALSE,
     429                    &info)) {
    367430#ifndef FX_SILENT
    368431    fprintf(stderr,"fx Driver: error locking the linear frame buffer\n");
     
    371434  }
    372435
    373   r=(GLint)(ctx->Current.RasterColor[0]*255.0f);
    374   g=(GLint)(ctx->Current.RasterColor[1]*255.0f);
    375   b=(GLint)(ctx->Current.RasterColor[2]*255.0f);
    376   a=(GLint)(ctx->Current.RasterColor[3]*255.0f);
    377   color=(FxU16)
    378     ( ((FxU16)0xf8 & b) <<(11-3))  |
    379     ( ((FxU16)0xfc & g) <<(5-3+1)) |
    380     ( ((FxU16)0xf8 & r) >> 3);
    381 
    382   stride=info.strideInBytes>>1;
    383 
    384   /* This code is a bit slow... */
    385 
    386   if (py>ymin) ymin=py;
    387   if (py+height<ymax) ymax=py+height;
    388 
    389   px+=fxMesa->x_offset;
    390   scrheight=fxMesa->height+fxMesa->y_offset;
    391 
    392   for(y=ymin; y<ymax; y++) {
    393 
    394     p=((FxU16 *)info.lfbPtr)+px+((scrheight-y)*stride);
    395 
    396     for(x=0;;) {
    397       DRAWBIT(7);       DRAWBIT(6);     DRAWBIT(5);     DRAWBIT(4);
    398       DRAWBIT(3);       DRAWBIT(2);     DRAWBIT(1);     DRAWBIT(0);
    399       pb++;
    400     }
    401   }
     436#ifdef XF86DRI
     437#define INSIDE(c, x, y) inClipRects((c), (x), (y))
     438#else
     439#define INSIDE(c, x, y) (1)
     440#endif
     441
     442  {
     443    const GLint winX = fxMesa->x_offset;
     444    const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
     445    /* The dest stride depends on the hardware and whether we're drawing
     446     * to the front or back buffer.  This compile-time test seems to do
     447     * the job for now.
     448     */
     449#ifdef XF86DRI
     450    const GLint dstStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
     451                          ? (fxMesa->screen_width) : (info.strideInBytes / 2);
     452#else
     453    const GLint dstStride = info.strideInBytes / 2; /* stride in GLushorts */
     454#endif
     455    GLint row;
     456    /* compute dest address of bottom-left pixel in bitmap */
     457    GLushort *dst = (GLushort *) info.lfbPtr
     458                  + (winY - py) * dstStride
     459                  + (winX + px);
     460
     461    for (row = 0; row < height; row++) {
     462      const GLubyte *src = (const GLubyte *) _mesa_image_address( finalUnpack,
     463                 bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 );
     464      if (finalUnpack->LsbFirst) {
     465        /* least significan bit first */
     466        GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7);
     467        GLint col;
     468        for (col=0; col<width; col++) {
     469          if (*src & mask) {
     470            if (INSIDE(fxMesa, winX + px + col, winY - py - row))
     471              dst[col] = color;
     472          }
     473          if (mask == 128U) {
     474            src++;
     475            mask = 1U;
     476          }
     477          else {
     478            mask = mask << 1;
     479          }
     480        }
     481        if (mask != 1)
     482          src++;
     483      }
     484      else {
     485        /* most significan bit first */
     486        GLubyte mask = 128U >> (finalUnpack->SkipPixels & 0x7);
     487        GLint col;
     488        for (col=0; col<width; col++) {
     489          if (*src & mask) {
     490            if (INSIDE(fxMesa, winX + px + col, winY - py - row))
     491              dst[col] = color;
     492          }
     493          if (mask == 1U) {
     494            src++;
     495            mask = 128U;
     496          }
     497          else {
     498            mask = mask >> 1;
     499          }
     500        }
     501        if (mask != 128)
     502          src++;
     503      }
     504      dst -= dstStride;
     505    }
     506  }
     507
     508#undef INSIDE
    402509
    403510  FX_grLfbUnlock(GR_LFB_WRITE_ONLY,fxMesa->currentFB);
    404 
    405 #undef ISCLIPPED
    406 #undef DRAWBIT
    407 
    408511  return GL_TRUE;
    409512}
     
    423526    fprintf(stderr,"fx Driver: internal error in fxDDGetParameteri(): %x\n",param);
    424527    fxCloseHardware();
    425     exit(-1);
     528    EXIT(-1);
    426529    return 0;
    427530  }
     
    441544static const GLubyte *fxDDGetString(GLcontext *ctx, GLenum name)
    442545{
    443    switch (name) {
    444    case GL_RENDERER:
    445546#if defined(GLX_DIRECT_RENDERING)
    446       return "Mesa Glide - DRI VB/V3";
     547  /* Building for DRI driver */
     548  switch (name) {
     549    case GL_RENDERER:
     550      {
     551        static char buffer[100];
     552        char hardware[100];
     553        strcpy(hardware, grGetString(GR_HARDWARE));
     554        if (strcmp(hardware, "Voodoo3 (tm)") == 0)
     555          strcpy(hardware, "Voodoo3");
     556        else if (strcmp(hardware, "Voodoo Banshee (tm)") == 0)
     557          strcpy(hardware, "VoodooBanshee");
     558        else {
     559          /* unexpected result: replace spaces with hyphens */
     560          int i;
     561          for (i = 0; hardware[i]; i++) {
     562            if (hardware[i] == ' ' || hardware[i] == '\t')
     563              hardware[i] = '-';
     564          }
     565        }
     566        /* now make the GL_RENDERER string */
     567        sprintf(buffer, "Mesa DRI %s 20000322", hardware);
     568        return buffer;
     569      }
     570    case GL_VENDOR:
     571      return "Precision Insight, Inc.";
     572    default:
     573      return NULL;
     574  }
     575
    447576#else
     577
     578  /* Building for Voodoo1/2 stand-alone Mesa */
     579  switch (name) {
     580    case GL_RENDERER:
    448581      {
    449          static char buf[80];
    450 
    451          if (glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO)
    452          {
    453             GrVoodooConfig_t *vc =
    454                &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig;
    455 
    456             sprintf(buf,
    457                     "Mesa Glide v0.30 Voodoo_Graphics %d "
    458                     "CARD/%d FB/%d TM/%d TMU/%s",
    459                     glbCurrentBoard,
    460                     (vc->sliDetect ? (vc->fbRam*2) : vc->fbRam),
    461                     (vc->tmuConfig[GR_TMU0].tmuRam +
    462                      ((vc->nTexelfx>1) ? vc->tmuConfig[GR_TMU1].tmuRam : 0)),
    463                     vc->nTexelfx,
    464                     (vc->sliDetect ? "SLI" : "NOSLI"));
    465          }
    466          else if (glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_SST96)
    467          {
    468             GrSst96Config_t *sc =
    469                &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config;
    470 
    471             sprintf(buf,
    472                     "Glide v0.30 Voodoo_Rush %d "
    473                     "CARD/%d FB/%d TM/%d TMU/NOSLI",
    474                     glbCurrentBoard,
    475                     sc->fbRam,
    476                     sc->tmuConfig.tmuRam,
    477                     sc->nTexelfx);
    478          }
    479          else
    480          {
    481             strcpy(buf, "Glide v0.30 UNKNOWN");
    482          }
    483 
    484          return (GLubyte *) buf;
     582        static char buf[80];
     583
     584        if (glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO) {
     585          GrVoodooConfig_t *vc =
     586            &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig;
     587
     588          sprintf(buf,
     589                  "Mesa Glide v0.30 Voodoo_Graphics %d "
     590                  "CARD/%d FB/%d TM/%d TMU/%s",
     591                  glbCurrentBoard,
     592                  (vc->sliDetect ? (vc->fbRam*2) : vc->fbRam),
     593                  (vc->tmuConfig[GR_TMU0].tmuRam +
     594                   ((vc->nTexelfx>1) ? vc->tmuConfig[GR_TMU1].tmuRam : 0)),
     595                  vc->nTexelfx,
     596                  (vc->sliDetect ? "SLI" : "NOSLI"));
     597        }
     598        else if (glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_SST96) {
     599          GrSst96Config_t *sc =
     600            &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config;
     601
     602          sprintf(buf,
     603                  "Glide v0.30 Voodoo_Rush %d "
     604                  "CARD/%d FB/%d TM/%d TMU/NOSLI",
     605                  glbCurrentBoard,
     606                  sc->fbRam,
     607                  sc->tmuConfig.tmuRam,
     608                  sc->nTexelfx);
     609        }
     610        else {
     611          strcpy(buf, "Glide v0.30 UNKNOWN");
     612        }
     613        return (GLubyte *) buf;
    485614      }
     615    default:
     616      return NULL;
     617  }
    486618#endif
    487    default:
    488       return NULL;
    489    }
    490619}
    491620
     
    493622int fxDDInitFxMesaContext( fxMesaContext fxMesa )
    494623{
    495  
     624
    496625   FX_setupGrVertexLayout();
    497    
    498    if (getenv("FX_EMULATE_SINGLE_TMU")) 
     626
     627   if (getenv("FX_EMULATE_SINGLE_TMU"))
    499628      fxMesa->haveTwoTMUs = GL_FALSE;
    500      
     629
    501630   fxMesa->emulateTwoTMUs = fxMesa->haveTwoTMUs;
    502    
    503    if (!getenv("FX_DONT_FAKE_MULTITEX")) 
     631
     632   if (!getenv("FX_DONT_FAKE_MULTITEX"))
    504633      fxMesa->emulateTwoTMUs = GL_TRUE;
    505      
     634
    506635   if(getenv("FX_GLIDE_SWAPINTERVAL"))
    507636      fxMesa->swapInterval=atoi(getenv("FX_GLIDE_SWAPINTERVAL"));
     
    513642   else
    514643      fxMesa->maxPendingSwapBuffers=2;
    515    
     644
     645   if(getenv("MESA_FX_INFO"))
     646      fxMesa->verbose=GL_TRUE;
     647   else
     648      fxMesa->verbose=GL_FALSE;
     649
    516650   fxMesa->color=0xffffffff;
    517651   fxMesa->clearC=0;
     
    539673   fxMesa->unitsState.blendDstFuncAlpha=GR_BLEND_ZERO;
    540674
    541    fxMesa->unitsState.depthTestEnabled  =GL_FALSE;
    542    fxMesa->unitsState.depthMask         =GL_TRUE;
    543    fxMesa->unitsState.depthTestFunc     =GR_CMP_LESS;
     675   fxMesa->unitsState.depthTestEnabled  =GL_FALSE;
     676   fxMesa->unitsState.depthMask         =GL_TRUE;
     677   fxMesa->unitsState.depthTestFunc     =GR_CMP_LESS;
    544678
    545679   FX_grColorMask(FXTRUE, fxMesa->haveAlphaBuffer ? FXTRUE : FXFALSE);
     
    551685      FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
    552686   }
    553  
    554    fxMesa->state        = NULL;
    555    fxMesa->fogTable     = NULL;
    556  
    557    fxMesa->state        = malloc(FX_grGetInteger(FX_GLIDE_STATE_SIZE));
    558    fxMesa->fogTable     = (GrFog_t*)malloc(FX_grGetInteger(FX_FOG_TABLE_ENTRIES)*sizeof(GrFog_t));
    559  
     687
     688   fxMesa->state        = NULL;
     689   fxMesa->fogTable     = NULL;
     690
     691   fxMesa->state        = malloc(FX_grGetInteger(FX_GLIDE_STATE_SIZE));
     692   fxMesa->fogTable     = (GrFog_t*)malloc(FX_grGetInteger(FX_FOG_TABLE_ENTRIES)*sizeof(GrFog_t));
     693
    560694   if (!fxMesa->state || !fxMesa->fogTable) {
    561695      if (fxMesa->state) free(fxMesa->state);
     
    566700   if(fxMesa->haveZBuffer)
    567701      FX_grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER);
    568    
     702
    569703#if (!FXMESA_USE_ARGB)
    570704   FX_grLfbWriteColorFormat(GR_COLORFORMAT_ABGR); /* Not every Glide has this */
    571705#endif
    572706
     707   fxMesa->textureAlign=FX_grGetInteger(FX_TEXTURE_ALIGN);
    573708   fxMesa->glCtx->Const.MaxTextureLevels=9;
    574709   fxMesa->glCtx->Const.MaxTextureSize=256;
     
    576711   fxMesa->glCtx->NewState|=NEW_DRVSTATE1;
    577712   fxMesa->new_state = NEW_ALL;
    578  
     713
    579714   fxDDSetupInit();
    580715   fxDDCvaInit();
     
    585720   fxSetupDDPointers(fxMesa->glCtx);
    586721   fxDDRenderInit(fxMesa->glCtx);
    587    fxDDInitExtensions(fxMesa->glCtx); 
     722   fxDDInitExtensions(fxMesa->glCtx);
    588723
    589724   fxDDSetNearFar(fxMesa->glCtx,1.0,100.0);
    590  
     725
    591726   FX_grGlideGetState((GrState*)fxMesa->state);
    592727
    593728   /* XXX Fix me: callback not registered when main VB is created.
    594729    */
    595    if (fxMesa->glCtx->VB) 
     730   if (fxMesa->glCtx->VB)
    596731      fxDDRegisterVB( fxMesa->glCtx->VB );
    597  
     732
    598733   /* XXX Fix me too: need to have the 'struct dd' prepared prior to
    599734    * creating the context... The below is broken if you try to insert
    600     * new stages. 
     735    * new stages.
    601736    */
    602737   if (fxMesa->glCtx->NrPipelineStages)
    603       fxMesa->glCtx->NrPipelineStages = fxDDRegisterPipelineStages( 
    604         fxMesa->glCtx->PipelineStage,
    605         fxMesa->glCtx->PipelineStage,
    606         fxMesa->glCtx->NrPipelineStages);
     738      fxMesa->glCtx->NrPipelineStages = fxDDRegisterPipelineStages(
     739        fxMesa->glCtx->PipelineStage,
     740        fxMesa->glCtx->PipelineStage,
     741        fxMesa->glCtx->NrPipelineStages);
    607742
    608743   /* Run the config file */
     
    620755   fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
    621756
    622    gl_extensions_add( ctx, DEFAULT_ON, "3DFX_set_global_palette", 0 );
    623    gl_extensions_add( ctx, DEFAULT_ON, "GL_FXMESA_global_texture_lod_bias", 0);
    624    
    625    if(fxMesa->haveTwoTMUs)
    626       gl_extensions_add( ctx, DEFAULT_ON, "GL_EXT_texture_env_add", 0);
    627    
    628    if (!fxMesa->emulateTwoTMUs)
    629       gl_extensions_disable( ctx, "GL_ARB_multitexture" );
     757   gl_extensions_disable(ctx, "GL_EXT_blend_logic_op");
     758   gl_extensions_disable(ctx, "GL_EXT_blend_minmax");
     759   gl_extensions_disable(ctx, "GL_EXT_blend_subtract");
     760   gl_extensions_disable(ctx, "GL_EXT_blend_color");
     761   gl_extensions_disable(ctx, "GL_EXT_paletted_texture");
     762
     763   gl_extensions_add(ctx, DEFAULT_ON, "3DFX_set_global_palette", 0);
     764
     765   if (!fxMesa->haveTwoTMUs)
     766      gl_extensions_disable(ctx, "GL_EXT_texture_env_add");
     767
     768   if (!fxMesa->emulateTwoTMUs)
     769      gl_extensions_disable(ctx, "GL_ARB_multitexture");
     770
     771
     772   /* Example of hooking in an extension function.
     773    * For DRI-based drivers, also see __driRegisterExtensions in the
     774    * tdfx_xmesa.c file.
     775    */
     776#if 0
     777   {
     778     void **dispatchTable = (void **) ctx->Exec;
     779     const int _gloffset_FooBarEXT = 555;  /* just an example number! */
     780     const int tabSize = _glapi_get_dispatch_table_size();
     781     assert(_gloffset_FooBarEXT < tabSize);
     782     dispatchTable[_gloffset_FooBarEXT] = (void *) fxFooBarEXT;
     783     /* XXX You would also need to hook into the display list dispatch
     784      * table.  Really, the implementation of extensions might as well
     785      * be in the core of Mesa since core Mesa and the device driver
     786      * is one big shared lib.
     787      */
     788  }
     789#endif
    630790}
    631791
     
    640800/************************************************************************/
    641801
    642 /* This is a no-op, since the z-buffer is in hardware */
    643 static void fxAllocDepthBuffer(GLcontext *ctx)
    644 {
    645    if (MESA_VERBOSE&VERBOSE_DRIVER) {
    646      fprintf(stderr,"fxmesa: fxAllocDepthBuffer()\n");
    647    }
    648 }
    649 
    650 /************************************************************************/
    651 /************************************************************************/
    652 /************************************************************************/
    653 
    654 /* Check if the hardware supports the current context
     802/* Check if the hardware supports the current context
    655803 *
    656804 * Performs similar work to fxDDChooseRenderState() - should be merged.
     
    661809
    662810  if (!ctx->Hint.AllowDrawMem)
    663      return GL_TRUE;            /* you'll take it and like it */
     811     return GL_TRUE;            /* you'll take it and like it */
    664812
    665813  if((ctx->RasterMask & STENCIL_BIT) ||
     
    679827    if((ctx->Enabled & (TEXTURE0_3D | TEXTURE1_3D)) ||
    680828       /* Not very well written ... */
    681        ((ctx->Enabled & (TEXTURE0_1D | TEXTURE1_1D)) && 
     829       ((ctx->Enabled & (TEXTURE0_1D | TEXTURE1_1D)) &&
    682830        ((ctx->Enabled & (TEXTURE0_2D | TEXTURE1_2D))!=(TEXTURE0_2D | TEXTURE1_2D)))
    683831       ) {
     
    698846    if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE))
    699847       fprintf(stderr, "fxMesa: fxIsInHardware, envmode is %s/%s\n",
    700                gl_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode),
    701                gl_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode));
     848               gl_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode),
     849               gl_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode));
    702850
    703851    /* KW: This was wrong (I think) and I changed it... which doesn't mean
     
    708856    {
    709857       /* Can't use multipass to blend a multitextured triangle - fall
    710         * back to software.
    711         */
     858        * back to software.
     859        */
    712860      if (!fxMesa->haveTwoTMUs && ctx->Color.BlendEnabled) {
    713           return GL_FALSE;
     861          return GL_FALSE;
    714862      }
    715          
     863
    716864       if ((ctx->Texture.Unit[0].EnvMode!=ctx->Texture.Unit[1].EnvMode) &&
    717            (ctx->Texture.Unit[0].EnvMode!=GL_MODULATE) &&
    718            (ctx->Texture.Unit[0].EnvMode!=GL_REPLACE)) /* q2, seems ok... */
     865           (ctx->Texture.Unit[0].EnvMode!=GL_MODULATE) &&
     866           (ctx->Texture.Unit[0].EnvMode!=GL_REPLACE)) /* q2, seems ok... */
    719867       {
    720           if (MESA_VERBOSE&VERBOSE_DRIVER)
    721             fprintf(stderr, "fxMesa: unsupported multitex env mode\n");
    722           return GL_FALSE;
     868          if (MESA_VERBOSE&VERBOSE_DRIVER)
     869            fprintf(stderr, "fxMesa: unsupported multitex env mode\n");
     870          return GL_FALSE;
    723871       }
    724872    }
     
    726874    if((ctx->Enabled & (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D)) ||
    727875       /* Not very well written ... */
    728        ((ctx->Enabled & TEXTURE0_1D) && 
     876       ((ctx->Enabled & TEXTURE0_1D) &&
    729877        (!(ctx->Enabled & TEXTURE0_2D)))
    730878       ) {
     
    732880    }
    733881
    734    
     882
    735883    if((ctx->Texture.ReallyEnabled & TEXTURE0_2D) &&
    736884       (ctx->Texture.Unit[0].EnvMode==GL_BLEND)) {
     
    751899  GLuint new_state = ctx->NewState;
    752900
    753   if (MESA_VERBOSE&(VERBOSE_DRIVER|VERBOSE_STATE)) 
     901  if (MESA_VERBOSE&(VERBOSE_DRIVER|VERBOSE_STATE))
    754902    fprintf(stderr,"fxmesa: fxDDUpdateDDPointers(...)\n");
    755903
    756   if (new_state & (NEW_RASTER_OPS|NEW_TEXTURING)) 
     904  if (new_state & (NEW_RASTER_OPS|NEW_TEXTURING))
    757905     fxMesa->is_in_hardware = fxIsInHardware(ctx);
    758906
     
    770918      ctx->Driver.RasterSetup=fxDDChooseSetupFunction(ctx);
    771919    }
    772      
     920
    773921    ctx->Driver.PointsFunc=fxMesa->PointsFunc;
    774922    ctx->Driver.LineFunc=fxMesa->LineFunc;
     
    780928}
    781929
     930static void fxDDReducedPrimitiveChange(GLcontext *ctx, GLenum prim)
     931{
     932  if (ctx->Polygon.CullFlag) {
     933    if (ctx->PB->primitive != GL_POLYGON) { /* Lines or Points */
     934      FX_grCullMode(GR_CULL_DISABLE);
     935      FX_CONTEXT(ctx)->cullMode=GR_CULL_DISABLE;
     936    }
     937  }
     938}
     939
    782940void fxSetupDDPointers(GLcontext *ctx)
    783941{
     
    788946  ctx->Driver.UpdateState=fxDDUpdateDDPointers;
    789947
    790   ctx->Driver.AllocDepthBuffer=fxAllocDepthBuffer;
    791   ctx->Driver.DepthTestSpan=fxDDDepthTestSpanGeneric;
    792   ctx->Driver.DepthTestPixels=fxDDDepthTestPixelsGeneric;
    793   ctx->Driver.ReadDepthSpanFloat=fxDDReadDepthSpanFloat;
    794   ctx->Driver.ReadDepthSpanInt=fxDDReadDepthSpanInt;
    795          
     948  ctx->Driver.WriteDepthSpan=fxDDWriteDepthSpan;
     949  ctx->Driver.WriteDepthPixels=fxDDWriteDepthPixels;
     950  ctx->Driver.ReadDepthSpan=fxDDReadDepthSpan;
     951  ctx->Driver.ReadDepthPixels=fxDDReadDepthPixels;
     952
    796953  ctx->Driver.GetString=fxDDGetString;
    797954
     
    809966  ctx->Driver.Color=fxDDSetColor;
    810967
    811   ctx->Driver.SetBuffer=fxDDSetBuffer;
     968  ctx->Driver.SetDrawBuffer=fxDDSetDrawBuffer;
     969  ctx->Driver.SetReadBuffer=fxDDSetReadBuffer;
    812970  ctx->Driver.GetBufferSize=fxDDBufferSize;
    813971
     
    828986  ctx->Driver.DeleteTexture=fxDDTexDel;
    829987  ctx->Driver.UpdateTexturePalette=fxDDTexPalette;
    830   ctx->Driver.UseGlobalTexturePalette=fxDDTexUseGlbPalette;
    831988
    832989  ctx->Driver.RectFunc=NULL;
     
    8431000  ctx->Driver.ShadeModel=fxDDShadeModel;
    8441001  ctx->Driver.Enable=fxDDEnable;
     1002  ctx->Driver.ReducedPrimitiveChange=fxDDReducedPrimitiveChange;
    8451003
    8461004  ctx->Driver.RegisterVB=fxDDRegisterVB;
     
    8551013/*       ctx->Driver.OptimizePrecalcPipeline = fxDDOptimizePrecalcPipeline; */
    8561014
    857   if (!getenv("FX_NO_FAST")) 
    858       ctx->Driver.BuildPrecalcPipeline = fxDDBuildPrecalcPipeline; 
     1015  if (!getenv("FX_NO_FAST"))
     1016      ctx->Driver.BuildPrecalcPipeline = fxDDBuildPrecalcPipeline;
    8591017
    8601018  ctx->Driver.TriangleCaps = DD_TRI_CULL|DD_TRI_OFFSET|DD_TRI_LIGHT_TWOSIDE;
  • trunk/src/opengl/mesa/3dfx/fxddspan.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.
     
    6565
    6666
    67 #if !defined(FXMESA_USE_ARGB) 
     67#if !defined(FXMESA_USE_ARGB)
    6868
    6969
     
    7171
    7272static FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer,
    73                           FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format,
    74                           FxU32 src_width, FxU32 src_height, FxI32 src_stride,
    75                           void *src_data);
    76 
    77 FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer,
    78                           FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format,
    79                           FxU32 src_width, FxU32 src_height, FxI32 src_stride,
    80                           void *src_data)
    81 {
    82   int i, x, w;
     73                          FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format,
     74                          FxU32 src_width, FxU32 src_height, FxI32 src_stride,
     75                          void *src_data)
     76{
     77  int i, x, w, srcElt;
    8378  void *data;
    8479
    8580  if (src_width==1 && src_height==1) { /* Easy case writing a point */
    8681    for (i=0; i<fxMesa->numClipRects; i++) {
    87       if ((dst_x>=fxMesa->pClipRects[i].x1) && 
    88           (dst_x<fxMesa->pClipRects[i].x2) &&
    89           (dst_y>=fxMesa->pClipRects[i].y1) &&
    90           (dst_y<fxMesa->pClipRects[i].y2)) {
    91         FX_grLfbWriteRegion(dst_buffer, dst_x, dst_y, src_format,
    92                             src_width, src_height, src_stride, src_data);
    93         return GL_TRUE;
     82      if ((dst_x>=fxMesa->pClipRects[i].x1) &&
     83          (dst_x<fxMesa->pClipRects[i].x2) &&
     84          (dst_y>=fxMesa->pClipRects[i].y1) &&
     85          (dst_y<fxMesa->pClipRects[i].y2)) {
     86        FX_grLfbWriteRegion(dst_buffer, dst_x, dst_y, src_format,
     87                            1, 1, src_stride, src_data);
     88        return GL_TRUE;
    9489      }
    9590    }
    9691  } else if (src_height==1) { /* Writing a span */
     92    if (src_format==GR_LFB_SRC_FMT_8888) srcElt=4;
     93    else if (src_format==GR_LFB_SRC_FMT_ZA16) srcElt=2;
     94    else {
     95      fprintf(stderr, "Unknown src_format passed to writeRegionClipped\n");
     96      return GL_FALSE;
     97    }
    9798    for (i=0; i<fxMesa->numClipRects; i++) {
    9899      if (dst_y>=fxMesa->pClipRects[i].y1 && dst_y<fxMesa->pClipRects[i].y2) {
    99         if (dst_x<fxMesa->pClipRects[i].x1) {
    100           x=fxMesa->pClipRects[i].x1;
    101           data=((char*)src_data)+2*(dst_x-x);
    102           w=src_width-(x-dst_x);
    103         } else {
    104           x=dst_x;
    105           data=src_data;
    106           w=src_width;
    107         }
    108         if (x+w>fxMesa->pClipRects[i].x2) {
    109           w=fxMesa->pClipRects[i].x2-x;
    110         }
    111         FX_grLfbWriteRegion(dst_buffer, x, dst_y, src_format, w, src_height,
    112                             src_stride, data);
     100        if (dst_x<fxMesa->pClipRects[i].x1) {
     101          x=fxMesa->pClipRects[i].x1;
     102          data=((char*)src_data)+srcElt*(dst_x-x);
     103          w=src_width-(x-dst_x);
     104        } else {
     105          x=dst_x;
     106          data=src_data;
     107          w=src_width;
     108        }
     109        if (x+w>fxMesa->pClipRects[i].x2) {
     110          w=fxMesa->pClipRects[i].x2-x;
     111        }
     112        FX_grLfbWriteRegion(dst_buffer, x, dst_y, src_format, w, 1,
     113                            src_stride, data);
    113114      }
    114115    }
     
    121122#else
    122123
    123 #define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)              \
     124#define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)              \
    124125  FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)
    125126
     
    129130/* KW: Rearranged the args in the call to grLfbWriteRegion().
    130131 */
    131 #define LFB_WRITE_SPAN_MESA(dst_buffer,         \
    132                             dst_x,              \
    133                             dst_y,              \
    134                             src_width,          \
    135                             src_stride,         \
    136                             src_data)           \
    137   writeRegionClipped(fxMesa, dst_buffer,        \
    138                    dst_x,                       \
    139                    dst_y,                       \
    140                    GR_LFB_SRC_FMT_8888,         \
    141                    src_width,                   \
    142                    1,                           \
    143                    src_stride,                  \
    144                    src_data)                    \
     132#define LFB_WRITE_SPAN_MESA(dst_buffer,         \
     133                            dst_x,              \
     134                            dst_y,              \
     135                            src_width,          \
     136                            src_stride,         \
     137                            src_data)           \
     138  writeRegionClipped(fxMesa, dst_buffer,        \
     139                   dst_x,                       \
     140                   dst_y,                       \
     141                   GR_LFB_SRC_FMT_8888,         \
     142                   src_width,                   \
     143                   1,                           \
     144                   src_stride,                  \
     145                   src_data)                    \
    145146
    146147
    147148#else /* !defined(FXMESA_USE_RGBA) */
    148149
    149 #define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)              \
     150#define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)              \
    150151  FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)
    151152
    152153
    153 #define MESACOLOR_TO_ARGB(c) (                          \
    154              ( ((unsigned int)(c[ACOMP]))<<24 ) |       \
    155              ( ((unsigned int)(c[RCOMP]))<<16 ) |       \
    156              ( ((unsigned int)(c[GCOMP]))<<8 )  |       \
     154#define MESACOLOR_TO_ARGB(c) (                          \
     155             ( ((unsigned int)(c[ACOMP]))<<24 ) |       \
     156             ( ((unsigned int)(c[RCOMP]))<<16 ) |       \
     157             ( ((unsigned int)(c[GCOMP]))<<8 )  |       \
    157158             (  (unsigned int)(c[BCOMP])) )
    158  
    159 inline void LFB_WRITE_SPAN_MESA(GrBuffer_t dst_buffer, 
    160                          FxU32 dst_x,
    161                          FxU32 dst_y,
    162                         FxU32 src_width,
    163                          FxI32 src_stride,
    164                         void *src_data )
     159
     160inline void LFB_WRITE_SPAN_MESA(GrBuffer_t dst_buffer,
     161                         FxU32 dst_x,
     162                         FxU32 dst_y,
     163                        FxU32 src_width,
     164                         FxI32 src_stride,
     165                        void *src_data )
    165166{
    166167   /* Covert to ARGB */
     
    168169   GLuint argb[MAX_WIDTH];
    169170   int i;
    170    
     171
    171172   for (i = 0; i < src_width; i++)
    172173   {
     
    174175   }
    175176   writeRegionClipped( /*fxMesa,*/ NULL, dst_buffer,
    176                        dst_x,
    177                        dst_y,
    178                        GR_LFB_SRC_FMT_8888,
    179                        src_width,
    180                        1,
    181                        src_stride,
    182                        (void*)argb);
    183 }
    184  
     177                       dst_x,
     178                       dst_y,
     179                       GR_LFB_SRC_FMT_8888,
     180                       src_width,
     181                       1,
     182                       src_stride,
     183                       (void*)argb);
     184}
     185
    185186#endif /* !defined(FXMESA_USE_RGBA) */
    186187
     
    191192
    192193
    193 static void fxDDWriteRGBASpan(const GLcontext *ctx, 
     194static void fxDDWriteRGBASpan(const GLcontext *ctx,
    194195                              GLuint n, GLint x, GLint y,
    195196                              const GLubyte rgba[][4], const GLubyte mask[])
     
    197198  fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
    198199  GLuint i;
    199   GLint bottom=fxMesa->height+fxMesa->y_offset-1; 
     200  GLint bottom=fxMesa->height+fxMesa->y_offset-1;
    200201
    201202  if (MESA_VERBOSE&VERBOSE_DRIVER) {
     
    209210    for (i=0;i<n;i++) {
    210211      if (mask[i]) {
    211         ++span; 
     212        ++span;
    212213      } else {
    213214        if (span > 0) {
     
    228229
    229230
    230 static void fxDDWriteRGBSpan(const GLcontext *ctx, 
     231static void fxDDWriteRGBSpan(const GLcontext *ctx,
    231232                             GLuint n, GLint x, GLint y,
    232233                             const GLubyte rgb[][3], const GLubyte mask[])
     
    278279
    279280
    280 static void fxDDWriteMonoRGBASpan(const GLcontext *ctx, 
     281static void fxDDWriteMonoRGBASpan(const GLcontext *ctx,
    281282                                  GLuint n, GLint x, GLint y,
    282283                                  const GLubyte mask[])
     
    324325
    325326
    326 static void fxDDReadRGBASpan(const GLcontext *ctx, 
     327static void fxDDReadRGBASpan(const GLcontext *ctx,
    327328                             GLuint n, GLint x, GLint y, GLubyte rgba[][4])
    328329{
     
    419420/************************************************************************/
    420421
    421 void fxDDReadDepthSpanFloat(GLcontext *ctx,
    422                             GLuint n, GLint x, GLint y, GLfloat depth[])
    423 {
    424   fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
    425   GLuint i;
    426   GLint bottom=fxMesa->height+fxMesa->y_offset-1;
    427   GLushort data[MAX_WIDTH];
    428 
    429   if (MESA_VERBOSE&VERBOSE_DRIVER) {
    430      fprintf(stderr,"fxmesa: fxDDReadDepthSpanFloat(...)\n");
    431   }
    432 
    433   x+=fxMesa->x_offset;
    434   FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,data);
    435 
    436   /*
    437     convert the read values to float values [0.0 .. 1.0].
    438   */
    439   for(i=0;i<n;i++)
    440     depth[i]=data[i]/65535.0f;
    441 }
    442 
    443 void fxDDReadDepthSpanInt(GLcontext *ctx,
    444                           GLuint n, GLint x, GLint y, GLdepth depth[])
    445 {
    446   fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
    447   GLint bottom=fxMesa->height+fxMesa->y_offset-1;
    448 
    449   if (MESA_VERBOSE&VERBOSE_DRIVER) {
    450      fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n");
    451   }
    452 
    453   x+=fxMesa->x_offset;
    454   FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depth);
    455 }
    456 
    457 GLuint fxDDDepthTestSpanGeneric(GLcontext *ctx,
    458                                        GLuint n, GLint x, GLint y, const GLdepth z[],
    459                                        GLubyte mask[])
    460 {
    461   fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
    462   GLushort depthdata[MAX_WIDTH];
    463   GLdepth *zptr=depthdata;
    464   GLubyte *m=mask;
    465   GLuint i;
    466   GLuint passed=0;
    467   GLint bottom=fxMesa->height+fxMesa->y_offset-1;
    468 
    469   if (MESA_VERBOSE&VERBOSE_DRIVER) {
    470      fprintf(stderr,"fxmesa: fxDDDepthTestSpanGeneric(...)\n");
    471   }
    472 
    473   x+=fxMesa->x_offset;
    474   FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depthdata);
    475 
    476   /* switch cases ordered from most frequent to less frequent */
    477   switch (ctx->Depth.Func) {
    478   case GL_LESS:
    479     if (ctx->Depth.Mask) {
    480       /* Update Z buffer */
    481       for (i=0; i<n; i++,zptr++,m++) {
    482         if (*m) {
    483           if (z[i] < *zptr) {
    484             /* pass */
    485             *zptr = z[i];
    486             passed++;
    487           } else {
    488             /* fail */
    489             *m = 0;
    490           }
    491         }
     422void fxDDWriteDepthSpan(GLcontext *ctx,
     423                        GLuint n, GLint x, GLint y, const GLdepth depth[],
     424                        const GLubyte mask[])
     425{
     426  fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
     427  GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
     428
     429  if (MESA_VERBOSE & VERBOSE_DRIVER) {
     430     fprintf(stderr, "fxmesa: fxDDWriteDepthSpan(...)\n");
     431  }
     432
     433  x += fxMesa->x_offset;
     434
     435  if (mask) {
     436    GLint i;
     437    for (i = 0; i < n; i++) {
     438      if (mask[i]) {
     439        GLshort d = depth[i];
     440        writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x + i, bottom - y,
     441                           GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &d);
    492442      }
    493     } else {
    494       /* Don't update Z buffer */
    495       for (i=0; i<n; i++,zptr++,m++) {
    496         if (*m) {
    497           if (z[i] < *zptr) {
    498             /* pass */
    499             passed++;
    500           } else {
    501             *m = 0;
    502           }
    503         }
    504       }
    505     }
    506     break;
    507   case GL_LEQUAL:
    508     if (ctx->Depth.Mask) {
    509       /* Update Z buffer */
    510       for (i=0;i<n;i++,zptr++,m++) {
    511         if (*m) {
    512           if (z[i] <= *zptr) {
    513             *zptr = z[i];
    514             passed++;
    515           } else {
    516             *m = 0;
    517           }
    518         }
    519       }
    520     } else {
    521       /* Don't update Z buffer */
    522       for (i=0;i<n;i++,zptr++,m++) {
    523         if (*m) {
    524           if (z[i] <= *zptr) {
    525             /* pass */
    526             passed++;
    527           } else {
    528             *m = 0;
    529           }
    530         }
    531       }
    532     }
    533     break;
    534   case GL_GEQUAL:
    535     if (ctx->Depth.Mask) {
    536       /* Update Z buffer */
    537       for (i=0;i<n;i++,zptr++,m++) {
    538         if (*m) {
    539           if (z[i] >= *zptr) {
    540             *zptr = z[i];
    541             passed++;
    542           } else {
    543             *m = 0;
    544           }
    545         }
    546       }
    547     } else {
    548       /* Don't update Z buffer */
    549       for (i=0;i<n;i++,zptr++,m++) {
    550         if (*m) {
    551           if (z[i] >= *zptr) {
    552             /* pass */
    553             passed++;
    554           } else {
    555             *m = 0;
    556           }
    557         }
    558       }
    559     }
    560     break;
    561   case GL_GREATER:
    562     if (ctx->Depth.Mask) {
    563       /* Update Z buffer */
    564       for (i=0;i<n;i++,zptr++,m++) {
    565         if (*m) {
    566           if (z[i] > *zptr) {
    567             *zptr = z[i];
    568             passed++;
    569           } else {
    570             *m = 0;
    571           }
    572         }
    573       }
    574     } else {
    575       /* Don't update Z buffer */
    576       for (i=0;i<n;i++,zptr++,m++) {
    577         if (*m) {
    578           if (z[i] > *zptr) {
    579             /* pass */
    580             passed++;
    581           } else {
    582             *m = 0;
    583           }
    584         }
    585       }
    586     }
    587     break;
    588   case GL_NOTEQUAL:
    589     if (ctx->Depth.Mask) {
    590       /* Update Z buffer */
    591       for (i=0;i<n;i++,zptr++,m++) {
    592         if (*m) {
    593           if (z[i] != *zptr) {
    594             *zptr = z[i];
    595             passed++;
    596           } else {
    597             *m = 0;
    598           }
    599         }
    600       }
    601     } else {
    602       /* Don't update Z buffer */
    603       for (i=0;i<n;i++,zptr++,m++) {
    604         if (*m) {
    605           if (z[i] != *zptr) {
    606             /* pass */
    607             passed++;
    608           } else {
    609             *m = 0;
    610           }
    611         }
    612       }
    613     }
    614     break;
    615   case GL_EQUAL:
    616     if (ctx->Depth.Mask) {
    617       /* Update Z buffer */
    618       for (i=0;i<n;i++,zptr++,m++) {
    619         if (*m) {
    620           if (z[i] == *zptr) {
    621             *zptr = z[i];
    622             passed++;
    623           } else {
    624             *m =0;
    625           }
    626         }
    627       }
    628     } else {
    629       /* Don't update Z buffer */
    630       for (i=0;i<n;i++,zptr++,m++) {
    631         if (*m) {
    632           if (z[i] == *zptr) {
    633             /* pass */
    634             passed++;
    635           } else {
    636             *m =0;
    637           }
    638         }
    639       }
    640     }
    641     break;
    642   case GL_ALWAYS:
    643     if (ctx->Depth.Mask) {
    644       /* Update Z buffer */
    645       for (i=0;i<n;i++,zptr++,m++) {
    646         if (*m) {
    647           *zptr = z[i];
    648           passed++;
    649         }
    650       }
    651     } else {
    652       /* Don't update Z buffer or mask */
    653       passed = n;
    654     }
    655     break;
    656   case GL_NEVER:
    657     for (i=0;i<n;i++) {
    658       mask[i] = 0;
    659     }
    660     break;
    661   default:
    662     ;
    663   } /*switch*/
    664 
    665   if(passed)
    666     writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x,bottom-y,GR_LFB_SRC_FMT_ZA16,n,1,0,depthdata);
    667 
    668   return passed;
    669 }
    670 
    671 void fxDDDepthTestPixelsGeneric(GLcontext* ctx,
    672                                        GLuint n, const GLint x[], const GLint y[],
    673                                        const GLdepth z[], GLubyte mask[])
    674 {
    675   fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
    676   GLdepth zval;
    677   GLuint i;
    678   GLint bottom=fxMesa->height+fxMesa->y_offset-1;
    679 
    680   if (MESA_VERBOSE&VERBOSE_DRIVER) {
    681      fprintf(stderr,"fxmesa: fxDDDepthTestPixelsGeneric(...)\n");
    682   }
    683 
    684   /* switch cases ordered from most frequent to less frequent */
    685   switch (ctx->Depth.Func) {
    686   case GL_LESS:
    687     if (ctx->Depth.Mask) {
    688       /* Update Z buffer */
    689       for (i=0; i<n; i++) {
    690         if (mask[i]) {
    691           FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval);
    692           if (z[i] < zval) {
    693             /* pass */
    694             writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]);
    695           } else {
    696             /* fail */
    697             mask[i] = 0;
    698           }
    699         }
    700       }
    701     } else {
    702       /* Don't update Z buffer */
    703       for (i=0; i<n; i++) {
    704         if (mask[i]) {
    705           FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval);
    706           if (z[i] < zval) {
    707             /* pass */
    708           }
    709           else {
    710             /* fail */
    711             mask[i] = 0;
    712           }
    713         }
    714       }
    715     }
    716     break;
    717   case GL_LEQUAL:
    718     if (ctx->Depth.Mask) {
    719       /* Update Z buffer */
    720       for (i=0; i<n; i++) {
    721         if (mask[i]) {
    722           FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval);
    723           if (z[i] <= zval) {
    724             /* pass */
    725             writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]);
    726           } else {
    727             /* fail */
    728             mask[i] = 0;
    729           }
    730         }
    731       }
    732     } else {
    733       /* Don't update Z buffer */
    734       for (i=0; i<n; i++) {
    735         if (mask[i]) {
    736           FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval);
    737           if (z[i] <= zval) {
    738             /* pass */
    739           } else {
    740             /* fail */
    741             mask[i] = 0;
    742           }
    743         }
    744       }
    745     }
    746     break;
    747   case GL_GEQUAL:
    748     if (ctx->Depth.Mask) {
    749       /* Update Z buffer */
    750       for (i=0; i<n; i++) {
    751         if (mask[i]) {
    752           FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval);
    753           if (z[i] >= zval) {
    754             /* pass */
    755             writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]);
    756           } else {
    757             /* fail */
    758             mask[i] = 0;
    759           }
    760         }
    761       }
    762     } else {
    763       /* Don't update Z buffer */
    764       for (i=0; i<n; i++) {
    765         if (mask[i]) {
    766           FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval);
    767           if (z[i] >= zval) {
    768             /* pass */
    769           } else {
    770             /* fail */
    771             mask[i] = 0;
    772           }
    773         }
    774       }
    775     }
    776     break;
    777   case GL_GREATER:
    778     if (ctx->Depth.Mask) {
    779       /* Update Z buffer */
    780       for (i=0; i<n; i++) {
    781         if (mask[i]) {
    782           FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval);
    783           if (z[i] > zval) {
    784             /* pass */
    785             writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]);
    786           } else {
    787             /* fail */
    788             mask[i] = 0;
    789           }
    790         }
    791       }
    792     } else {
    793       /* Don't update Z buffer */
    794       for (i=0; i<n; i++) {
    795         if (mask[i]) {
    796           FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval);
    797           if (z[i] > zval) {
    798             /* pass */
    799           } else {
    800             /* fail */
    801             mask[i] = 0;
    802           }
    803         }
    804       }
    805     }
    806     break;
    807   case GL_NOTEQUAL:
    808     if (ctx->Depth.Mask) {
    809       /* Update Z buffer */
    810       for (i=0; i<n; i++) {
    811         if (mask[i]) {
    812           FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval);
    813           if (z[i] != zval) {
    814             /* pass */
    815             writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]);
    816           } else {
    817             /* fail */
    818             mask[i] = 0;
    819           }
    820         }
    821       }
    822     } else {
    823       /* Don't update Z buffer */
    824       for (i=0; i<n; i++) {
    825         if (mask[i]) {
    826           FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval);
    827           if (z[i] != zval) {
    828             /* pass */
    829           }
    830           else {
    831             /* fail */
    832             mask[i] = 0;
    833           }
    834         }
    835       }
    836     }
    837     break;
    838   case GL_EQUAL:
    839     if (ctx->Depth.Mask) {
    840       /* Update Z buffer */
    841       for (i=0; i<n; i++) {
    842         if (mask[i]) {
    843           FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval);
    844           if (z[i] == zval) {
    845             /* pass */
    846             writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]);
    847           } else {
    848             /* fail */
    849             mask[i] = 0;
    850           }
    851         }
    852       }
    853     } else {
    854       /* Don't update Z buffer */
    855       for (i=0; i<n; i++) {
    856         if (mask[i]) {
    857           FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval);
    858           if (z[i] == zval) {
    859             /* pass */
    860           } else {
    861             /* fail */
    862             mask[i] = 0;
    863           }
    864         }
    865       }
    866     }
    867     break;
    868   case GL_ALWAYS:
    869     if (ctx->Depth.Mask) {
    870       /* Update Z buffer */
    871       for (i=0; i<n; i++) {
    872         if (mask[i]) {
    873           writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]);
    874         }
    875       }
    876     } else {
    877       /* Don't update Z buffer or mask */
    878     }
    879     break;
    880   case GL_NEVER:
    881     /* depth test never passes */
    882     for (i=0;i<n;i++) {
    883       mask[i] = 0;
    884     }
    885     break;
    886   default:
    887     ;
    888   } /*switch*/
    889 }
     443    }
     444  }
     445  else {
     446    GLushort depth16[MAX_WIDTH];
     447    GLint i;
     448    for (i = 0; i < n; i++) {
     449      depth16[i] = depth[i];
     450    }
     451    writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x, bottom - y,
     452                       GR_LFB_SRC_FMT_ZA16, n, 1, 0, (void *) depth16);
     453  }
     454}
     455
     456
     457void fxDDReadDepthSpan(GLcontext *ctx,
     458                       GLuint n, GLint x, GLint y, GLdepth depth[])
     459{
     460  fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
     461  GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
     462  GLushort depth16[MAX_WIDTH];
     463  GLuint i;
     464
     465  if (MESA_VERBOSE & VERBOSE_DRIVER) {
     466     fprintf(stderr, "fxmesa: fxDDReadDepthSpan(...)\n");
     467  }
     468
     469  x += fxMesa->x_offset;
     470  FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth16);
     471  for (i = 0; i < n; i++) {
     472    depth[i] = depth16[i];
     473  }
     474}
     475
     476
     477
     478void fxDDWriteDepthPixels(GLcontext *ctx,
     479                          GLuint n, const GLint x[], const GLint y[],
     480                          const GLdepth depth[], const GLubyte mask[])
     481{
     482  fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
     483  GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
     484  GLuint i;
     485
     486  if (MESA_VERBOSE & VERBOSE_DRIVER) {
     487    fprintf(stderr, "fxmesa: fxDDWriteDepthPixels(...)\n");
     488  }
     489
     490  for (i = 0; i < n; i++) {
     491    if (mask[i]) {
     492      int xpos = x[i] + fxMesa->x_offset;
     493      int ypos = bottom - y[i];
     494      GLushort d = depth[i];
     495      writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, xpos, ypos,
     496                         GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &d);
     497    }
     498  }
     499}
     500
     501
     502void fxDDReadDepthPixels(GLcontext *ctx, GLuint n,
     503                         const GLint x[], const GLint y[], GLdepth depth[])
     504{
     505  fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
     506  GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
     507  GLuint i;
     508
     509  if (MESA_VERBOSE & VERBOSE_DRIVER) {
     510    fprintf(stderr, "fxmesa: fxDDReadDepthPixels(...)\n");
     511  }
     512
     513  for (i = 0; i < n; i++) {
     514    int xpos = x[i] + fxMesa->x_offset;
     515    int ypos = bottom - y[i];
     516    GLushort d;
     517    FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, xpos, ypos, 1, 1, 0, &d);
     518    depth[i] = d;
     519  }
     520}
     521
     522
     523
    890524
    891525/************************************************************************/
  • trunk/src/opengl/mesa/3dfx/fxddtex.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.
     
    5858    fprintf(stderr, "\tName: %d\n", ti->tObj->Name);
    5959    fprintf(stderr, "\tBaseLevel: %d\n", ti->tObj->BaseLevel);
    60     fprintf(stderr, "\tSize: %d x %d\n", 
    61             ti->tObj->Image[ti->tObj->BaseLevel]->Width,
    62             ti->tObj->Image[ti->tObj->BaseLevel]->Height);
     60    fprintf(stderr, "\tSize: %d x %d\n",
     61            ti->tObj->Image[ti->tObj->BaseLevel]->Width,
     62            ti->tObj->Image[ti->tObj->BaseLevel]->Height);
    6363  } else
    6464    fprintf(stderr, "\tName: UNNAMED\n");
    6565  fprintf(stderr, "\tLast used: %d\n", ti->lastTimeUsed);
    66   fprintf(stderr, "\tTMU: %d\n", ti->whichTMU);
     66  fprintf(stderr, "\tTMU: %ld\n", ti->whichTMU);
    6767  fprintf(stderr, "\t%s\n", (ti->isInTM)?"In TMU":"Not in TMU");
    68   if (ti->tm[0]) 
    69     fprintf(stderr, "\tMem0: %x-%x\n", ti->tm[0]->startAddr, 
    70             ti->tm[0]->endAddr);
    71   if (ti->tm[1]) 
    72     fprintf(stderr, "\tMem1: %x-%x\n", ti->tm[1]->startAddr, 
    73             ti->tm[1]->endAddr);
     68  if (ti->tm[0])
     69    fprintf(stderr, "\tMem0: %x-%x\n", ti->tm[0]->startAddr,
     70            ti->tm[0]->endAddr);
     71  if (ti->tm[1])
     72    fprintf(stderr, "\tMem1: %x-%x\n", ti->tm[1]->startAddr,
     73            ti->tm[1]->endAddr);
    7474  fprintf(stderr, "\tMipmaps: %d-%d\n", ti->minLevel, ti->maxLevel);
    7575  fprintf(stderr, "\tFilters: min %d min %d\n", ti->minFilt, ti->maxFilt);
    7676  fprintf(stderr, "\tClamps: s %d t %d\n", ti->sClamp, ti->tClamp);
    7777  fprintf(stderr, "\tScales: s %f t %f\n", ti->sScale, ti->tScale);
    78   fprintf(stderr, "\tInt Scales: s %d t %d\n", 
    79           ti->int_sScale/0x800000, ti->int_tScale/0x800000);
     78  fprintf(stderr, "\tInt Scales: s %d t %d\n",
     79          ti->int_sScale/0x800000, ti->int_tScale/0x800000);
    8080  fprintf(stderr, "\t%s\n", (ti->fixedPalette)?"Fixed palette":"Non fixed palette");
    8181  fprintf(stderr, "\t%s\n", (ti->validated)?"Validated":"Not validated");
     
    8787/************************************************************************/
    8888
    89 void fxTexInvalidate(GLcontext *ctx, struct gl_texture_object *tObj)
     89static void fxTexInvalidate(GLcontext *ctx, struct gl_texture_object *tObj)
    9090{
    9191  fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
     
    108108    fprintf(stderr,"fx Driver: out of memory !\n");
    109109    fxCloseHardware();
    110     exit(-1);
     110    EXIT(-1);
    111111  }
    112112
     
    161161}
    162162
    163 void fxDDTexEnv(GLcontext *ctx, GLenum pname, const GLfloat *param)
     163void fxDDTexEnv(GLcontext *ctx, GLenum target, GLenum pname, const GLfloat *param)
    164164{
    165165  fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
     
    167167   if (MESA_VERBOSE&VERBOSE_DRIVER) {
    168168      if(param)
    169         fprintf(stderr,"fxmesa: texenv(%x,%x)\n",pname,(GLint)(*param));
     169        fprintf(stderr,"fxmesa: texenv(%x,%x)\n",pname,(GLint)(*param));
    170170      else
    171          fprintf(stderr,"fxmesa: texenv(%x)\n",pname);
     171         fprintf(stderr,"fxmesa: texenv(%x)\n",pname);
     172   }
     173
     174   /* apply any lod biasing right now */
     175   if (pname==GL_TEXTURE_LOD_BIAS_EXT) {
     176     grTexLodBiasValue(GR_TMU0,*param);
     177
     178     if(fxMesa->haveTwoTMUs) {
     179       grTexLodBiasValue(GR_TMU1,*param);
     180     }
     181
    172182   }
    173183
     
    338348  tfxTexInfo *ti;
    339349
    340   if(tObj) { 
     350  if(tObj) {
    341351     if (MESA_VERBOSE&VERBOSE_DRIVER) {
    342         fprintf(stderr,"fxmesa: fxDDTexPalette(%d,%x)\n",tObj->Name,(GLuint)tObj->DriverData);
     352        fprintf(stderr,"fxmesa: fxDDTexPalette(%d,%x)\n",tObj->Name,(GLuint)tObj->DriverData);
    343353     }
    344354
    345     if(tObj->PaletteFormat!=GL_RGBA) {
     355    if(tObj->Palette.Format!=GL_RGBA) {
    346356#ifndef FX_SILENT
    347357      fprintf(stderr,"fx Driver: unsupported palette format in texpalette()\n");
     
    350360    }
    351361
    352     if(tObj->PaletteSize>256) {
     362    if(tObj->Palette.Size>256) {
    353363#ifndef FX_SILENT
    354364      fprintf(stderr,"fx Driver: unsupported palette size in texpalette()\n");
     
    359369    if (!tObj->DriverData)
    360370      tObj->DriverData=fxAllocTexObjData(fxMesa);
    361  
     371
    362372    ti=fxTMGetTexInfo(tObj);
    363373
    364     for(i=0;i<tObj->PaletteSize;i++) {
    365       r=tObj->Palette[i*4];
    366       g=tObj->Palette[i*4+1];
    367       b=tObj->Palette[i*4+2];
    368       a=tObj->Palette[i*4+3];
     374    for(i=0;i<tObj->Palette.Size;i++) {
     375      r=tObj->Palette.Table[i*4];
     376      g=tObj->Palette.Table[i*4+1];
     377      b=tObj->Palette.Table[i*4+2];
     378      a=tObj->Palette.Table[i*4+3];
    369379      ti->palette.data[i]=(a<<24)|(r<<16)|(g<<8)|b;
    370380    }
     
    373383  } else {
    374384     if (MESA_VERBOSE&VERBOSE_DRIVER) {
    375         fprintf(stderr,"fxmesa: fxDDTexPalette(global)\n");
     385        fprintf(stderr,"fxmesa: fxDDTexPalette(global)\n");
    376386     }
    377     if(ctx->Texture.PaletteFormat!=GL_RGBA) {
     387    if(ctx->Texture.Palette.Format!=GL_RGBA) {
    378388#ifndef FX_SILENT
    379389      fprintf(stderr,"fx Driver: unsupported palette format in texpalette()\n");
     
    382392    }
    383393
    384     if(ctx->Texture.PaletteSize>256) {
     394    if(ctx->Texture.Palette.Size>256) {
    385395#ifndef FX_SILENT
    386396      fprintf(stderr,"fx Driver: unsupported palette size in texpalette()\n");
     
    389399    }
    390400
    391     for(i=0;i<ctx->Texture.PaletteSize;i++) {
    392       r=ctx->Texture.Palette[i*4];
    393       g=ctx->Texture.Palette[i*4+1];
    394       b=ctx->Texture.Palette[i*4+2];
    395       a=ctx->Texture.Palette[i*4+3];
     401    for(i=0;i<ctx->Texture.Palette.Size;i++) {
     402      r=ctx->Texture.Palette.Table[i*4];
     403      g=ctx->Texture.Palette.Table[i*4+1];
     404      b=ctx->Texture.Palette.Table[i*4+2];
     405      a=ctx->Texture.Palette.Table[i*4+3];
    396406      fxMesa->glbPalette.data[i]=(a<<24)|(r<<16)|(g<<8)|b;
    397407    }
     
    425435      if (!tObj->DriverData)
    426436        tObj->DriverData=fxAllocTexObjData(fxMesa);
    427  
     437
    428438      fxTexInvalidate(ctx,tObj);
    429439    }
     
    660670}
    661671
     672/*
     673 * Given an OpenGL internal texture format, return the corresponding
     674 * Glide internal texture format and base texture format.
     675 */
    662676void fxTexGetFormat(GLenum glformat, GrTextureFormat_t *tfmt, GLint *ifmt)
    663677{
    664678  switch(glformat) {
    665   case 1:
    666   case GL_LUMINANCE:
    667   case GL_LUMINANCE4:
    668   case GL_LUMINANCE8:
    669   case GL_LUMINANCE12:
    670   case GL_LUMINANCE16:
    671     if(tfmt)
    672       (*tfmt)=GR_TEXFMT_INTENSITY_8;
    673     if(ifmt)
    674       (*ifmt)=GL_LUMINANCE;
    675     break;
    676   case 2:
    677   case GL_LUMINANCE_ALPHA:
    678   case GL_LUMINANCE4_ALPHA4:
    679   case GL_LUMINANCE6_ALPHA2:
    680   case GL_LUMINANCE8_ALPHA8:
    681   case GL_LUMINANCE12_ALPHA4:
    682   case GL_LUMINANCE12_ALPHA12:
    683   case GL_LUMINANCE16_ALPHA16:
    684     if(tfmt)
    685       (*tfmt)=GR_TEXFMT_ALPHA_INTENSITY_88;
    686     if(ifmt)
    687       (*ifmt)=GL_LUMINANCE_ALPHA;
    688     break;
    689   case GL_INTENSITY:
    690   case GL_INTENSITY4:
    691   case GL_INTENSITY8:
    692   case GL_INTENSITY12:
    693   case GL_INTENSITY16:
    694     if(tfmt)
    695       (*tfmt)=GR_TEXFMT_ALPHA_8;
    696     if(ifmt)
    697       (*ifmt)=GL_INTENSITY;
    698     break;
    699   case GL_ALPHA:
    700   case GL_ALPHA4:
    701   case GL_ALPHA8:
    702   case GL_ALPHA12:
    703   case GL_ALPHA16:
    704     if(tfmt)
    705       (*tfmt)=GR_TEXFMT_ALPHA_8;
    706     if(ifmt)
    707       (*ifmt)=GL_ALPHA;
    708     break;
    709   case 3:
    710   case GL_RGB:
    711   case GL_R3_G3_B2:
    712   case GL_RGB4:
    713   case GL_RGB5:
    714   case GL_RGB8:
    715   case GL_RGB10:
    716   case GL_RGB12:
    717   case GL_RGB16:
    718     if(tfmt)
    719       (*tfmt)=GR_TEXFMT_RGB_565;
    720     if(ifmt)
    721       (*ifmt)=GL_RGB;
    722     break;
    723   case 4:
    724   case GL_RGBA:
    725   case GL_RGBA2:
    726   case GL_RGBA4:
    727   case GL_RGB5_A1:
    728   case GL_RGBA8:
    729   case GL_RGB10_A2:
    730   case GL_RGBA12:
    731   case GL_RGBA16:
    732     if(tfmt)
    733       (*tfmt)=GR_TEXFMT_ARGB_4444;
    734     if(ifmt)
    735       (*ifmt)=GL_RGBA;
    736     break;
    737   case GL_COLOR_INDEX:
    738   case GL_COLOR_INDEX1_EXT:
    739   case GL_COLOR_INDEX2_EXT:
    740   case GL_COLOR_INDEX4_EXT:
    741   case GL_COLOR_INDEX8_EXT:
    742   case GL_COLOR_INDEX12_EXT:
    743   case GL_COLOR_INDEX16_EXT:
    744     if(tfmt)
    745       (*tfmt)=GR_TEXFMT_P_8;
    746     if(ifmt)
    747       (*ifmt)=GL_RGBA;
    748     break;
    749   default:
    750     fprintf(stderr,"fx Driver: unsupported internalFormat in fxTexGetFormat()\n");
    751     fxCloseHardware();
    752     exit(-1);
    753     break;
     679    case 1:
     680    case GL_LUMINANCE:
     681    case GL_LUMINANCE4:
     682    case GL_LUMINANCE8:
     683    case GL_LUMINANCE12:
     684    case GL_LUMINANCE16:
     685      if(tfmt)
     686        (*tfmt)=GR_TEXFMT_INTENSITY_8;
     687      if(ifmt)
     688        (*ifmt)=GL_LUMINANCE;
     689      break;
     690    case 2:
     691    case GL_LUMINANCE_ALPHA:
     692    case GL_LUMINANCE4_ALPHA4:
     693    case GL_LUMINANCE6_ALPHA2:
     694    case GL_LUMINANCE8_ALPHA8:
     695    case GL_LUMINANCE12_ALPHA4:
     696    case GL_LUMINANCE12_ALPHA12:
     697    case GL_LUMINANCE16_ALPHA16:
     698      if(tfmt)
     699        (*tfmt)=GR_TEXFMT_ALPHA_INTENSITY_88;
     700      if(ifmt)
     701        (*ifmt)=GL_LUMINANCE_ALPHA;
     702      break;
     703    case GL_INTENSITY:
     704    case GL_INTENSITY4:
     705    case GL_INTENSITY8:
     706    case GL_INTENSITY12:
     707    case GL_INTENSITY16:
     708      if(tfmt)
     709        (*tfmt)=GR_TEXFMT_ALPHA_8;
     710      if(ifmt)
     711        (*ifmt)=GL_INTENSITY;
     712      break;
     713    case GL_ALPHA:
     714    case GL_ALPHA4:
     715    case GL_ALPHA8:
     716    case GL_ALPHA12:
     717    case GL_ALPHA16:
     718      if(tfmt)
     719        (*tfmt)=GR_TEXFMT_ALPHA_8;
     720      if(ifmt)
     721        (*ifmt)=GL_ALPHA;
     722      break;
     723    case 3:
     724    case GL_RGB:
     725    case GL_R3_G3_B2:
     726    case GL_RGB4:
     727    case GL_RGB5:
     728    case GL_RGB8:
     729    case GL_RGB10:
     730    case GL_RGB12:
     731    case GL_RGB16:
     732      if(tfmt)
     733        (*tfmt)=GR_TEXFMT_RGB_565;
     734      if(ifmt)
     735        (*ifmt)=GL_RGB;
     736      break;
     737    case 4:
     738    case GL_RGBA:
     739    case GL_RGBA2:
     740    case GL_RGBA4:
     741    case GL_RGBA8:
     742    case GL_RGB10_A2:
     743    case GL_RGBA12:
     744    case GL_RGBA16:
     745      if(tfmt)
     746        (*tfmt)=GR_TEXFMT_ARGB_4444;
     747      if(ifmt)
     748        (*ifmt)=GL_RGBA;
     749      break;
     750    case GL_RGB5_A1:
     751       if(tfmt)
     752         (*tfmt)=GR_TEXFMT_ARGB_1555;
     753       if(ifmt)
     754         (*ifmt)=GL_RGBA;
     755       break;
     756    case GL_COLOR_INDEX:
     757    case GL_COLOR_INDEX1_EXT:
     758    case GL_COLOR_INDEX2_EXT:
     759    case GL_COLOR_INDEX4_EXT:
     760    case GL_COLOR_INDEX8_EXT:
     761    case GL_COLOR_INDEX12_EXT:
     762    case GL_COLOR_INDEX16_EXT:
     763      if(tfmt)
     764        (*tfmt)=GR_TEXFMT_P_8;
     765      if(ifmt)
     766        (*ifmt)=GL_RGBA;
     767      break;
     768    default:
     769      fprintf(stderr,"fx Driver: unsupported internalFormat in fxTexGetFormat()\n");
     770      fxCloseHardware();
     771      EXIT(-1);
     772      break;
    754773  }
    755774}
     
    762781
    763782  switch(internalFormat) {
    764   case GL_INTENSITY:
    765   case GL_INTENSITY4:
    766   case GL_INTENSITY8:
    767   case GL_INTENSITY12:
    768   case GL_INTENSITY16:
    769   case 1:
    770   case GL_LUMINANCE:
    771   case GL_LUMINANCE4:
    772   case GL_LUMINANCE8:
    773   case GL_LUMINANCE12:
    774   case GL_LUMINANCE16:
    775   case 2:
    776   case GL_LUMINANCE_ALPHA:
    777   case GL_LUMINANCE4_ALPHA4:
    778   case GL_LUMINANCE6_ALPHA2:
    779   case GL_LUMINANCE8_ALPHA8:
    780   case GL_LUMINANCE12_ALPHA4:
    781   case GL_LUMINANCE12_ALPHA12:
    782   case GL_LUMINANCE16_ALPHA16:
    783   case GL_ALPHA:
    784   case GL_ALPHA4:
    785   case GL_ALPHA8:
    786   case GL_ALPHA12:
    787   case GL_ALPHA16:
    788   case 3:
    789   case GL_RGB:
    790   case GL_R3_G3_B2:
    791   case GL_RGB4:
    792   case GL_RGB5:
    793   case GL_RGB8:
    794   case GL_RGB10:
    795   case GL_RGB12:
    796   case GL_RGB16:
    797   case 4:
    798   case GL_RGBA:
    799   case GL_RGBA2:
    800   case GL_RGBA4:
    801   case GL_RGB5_A1:
    802   case GL_RGBA8:
    803   case GL_RGB10_A2:
    804   case GL_RGBA12:
    805   case GL_RGBA16:
    806   case GL_COLOR_INDEX:
    807   case GL_COLOR_INDEX1_EXT:
    808   case GL_COLOR_INDEX2_EXT:
    809   case GL_COLOR_INDEX4_EXT:
    810   case GL_COLOR_INDEX8_EXT:
    811   case GL_COLOR_INDEX12_EXT:
    812   case GL_COLOR_INDEX16_EXT:
    813     break;
    814   default:
    815     return GL_FALSE;
     783    case GL_INTENSITY:
     784    case GL_INTENSITY4:
     785    case GL_INTENSITY8:
     786    case GL_INTENSITY12:
     787    case GL_INTENSITY16:
     788    case 1:
     789    case GL_LUMINANCE:
     790    case GL_LUMINANCE4:
     791    case GL_LUMINANCE8:
     792    case GL_LUMINANCE12:
     793    case GL_LUMINANCE16:
     794    case 2:
     795    case GL_LUMINANCE_ALPHA:
     796    case GL_LUMINANCE4_ALPHA4:
     797    case GL_LUMINANCE6_ALPHA2:
     798    case GL_LUMINANCE8_ALPHA8:
     799    case GL_LUMINANCE12_ALPHA4:
     800    case GL_LUMINANCE12_ALPHA12:
     801    case GL_LUMINANCE16_ALPHA16:
     802    case GL_ALPHA:
     803    case GL_ALPHA4:
     804    case GL_ALPHA8:
     805    case GL_ALPHA12:
     806    case GL_ALPHA16:
     807    case 3:
     808    case GL_RGB:
     809    case GL_R3_G3_B2:
     810    case GL_RGB4:
     811    case GL_RGB5:
     812    case GL_RGB8:
     813    case GL_RGB10:
     814    case GL_RGB12:
     815    case GL_RGB16:
     816    case 4:
     817    case GL_RGBA:
     818    case GL_RGBA2:
     819    case GL_RGBA4:
     820    case GL_RGB5_A1:
     821    case GL_RGBA8:
     822    case GL_RGB10_A2:
     823    case GL_RGBA12:
     824    case GL_RGBA16:
     825    case GL_COLOR_INDEX:
     826    case GL_COLOR_INDEX1_EXT:
     827    case GL_COLOR_INDEX2_EXT:
     828    case GL_COLOR_INDEX4_EXT:
     829    case GL_COLOR_INDEX8_EXT:
     830    case GL_COLOR_INDEX12_EXT:
     831    case GL_COLOR_INDEX16_EXT:
     832      break;
     833    default:
     834      return GL_FALSE;
    816835  }
    817836
     
    823842
    824843  if(!fxTexGetInfo(image->Width,image->Height,NULL,NULL,NULL,NULL,NULL,NULL,
    825                    NULL,NULL))
     844                   NULL,NULL))
    826845    return GL_FALSE;
    827846
     
    838857
    839858  fxTexGetInfo(image->Width,image->Height,NULL,NULL,NULL,NULL,NULL,NULL,
    840                &wscale,&hscale);
     859               &wscale,&hscale);
    841860  w=image->Width*wscale;
    842861  h=image->Height*hscale;
     
    882901          fprintf(stderr,"fx Driver: out of memory !\n");
    883902          fxCloseHardware();
    884           exit(-1);
     903          EXIT(-1);
    885904        }
    886905      } else
     
    910929        fprintf(stderr,"fx Driver: out of memory !\n");
    911930        fxCloseHardware();
    912         exit(-1);
     931        EXIT(-1);
    913932      }
    914933    } else
     
    954973        fprintf(stderr,"fx Driver: out of memory !\n");
    955974        fxCloseHardware();
    956         exit(-1);
     975        EXIT(-1);
    957976      }
    958977    } else
     
    962981      int i=0;
    963982      int length=h*w;
    964       unsigned short r,g,b;
     983      unsigned int r,g,b;
    965984
    966985      while(i++<length) {
     
    971990        *src++=((0xf8 & r) << (11-3))  |
    972991          ((0xfc & g) << (5-3+1))      |
    973           ((0xf8 & b) >> 3); 
     992          ((0xf8 & b) >> 3);
    974993      }
    975994    } else {
    976       unsigned short r,g,b;
     995      unsigned int r,g,b;
    977996
    978997      for(y=0;y<h;y++)
     
    9851004          src[x+y*w]=((0xf8 & r) << (11-3))  |
    9861005            ((0xfc & g) << (5-3+1))      |
    987             ((0xf8 & b) >> 3); 
     1006            ((0xf8 & b) >> 3);
    9881007        }
    9891008    }
     
    9931012  case GL_RGBA2:
    9941013  case GL_RGBA4:
    995   case GL_RGB5_A1:
    9961014  case GL_RGBA8:
    9971015  case GL_RGB10_A2:
     
    10041022        fprintf(stderr,"fx Driver: out of memory !\n");
    10051023        fxCloseHardware();
    1006         exit(-1);
     1024        EXIT(-1);
    10071025      }
    10081026    } else
     
    10121030      int i=0;
    10131031      int length=h*w;
    1014       unsigned short r,g,b,a;
     1032      unsigned int r,g,b,a;
    10151033
    10161034      while(i++<length) {
     
    10261044      }
    10271045    } else {
    1028       unsigned short r,g,b,a;
     1046      unsigned int r,g,b,a;
    10291047
    10301048      for(y=0;y<h;y++)
     
    10431061    }
    10441062    break;
     1063  case GL_RGB5_A1:
     1064    (*istranslate)=GL_TRUE;
     1065
     1066    if(!(*dest)) {
     1067      if(!((*dest)=src=(unsigned short *)malloc(sizeof(unsigned short)*w*h))) {
     1068        fprintf(stderr,"fx Driver: out of memory !\n");
     1069        fxCloseHardware();
     1070        exit(-1);
     1071      }
     1072    } else
     1073      src=(*dest);
     1074
     1075    if(wscale==hscale==1) {
     1076      int i=0;
     1077      int lenght=h*w;
     1078      unsigned  r,g,b,a;
     1079
     1080      while(i++<lenght) {
     1081        r=*data++;
     1082        g=*data++;
     1083        b=*data++;
     1084        a=*data++;
     1085        *src++=((0x80 & a) << 8) |
     1086          ((0xf8 & r) << 7)      |
     1087          ((0xf8 & g) << 2)      |
     1088          ((0xf8 & b) >> 3);
     1089      }
     1090    } else {
     1091      unsigned r,g,b,a;
     1092
     1093      for(y=0;y<h;y++)
     1094        for(x=0;x<w;x++) {
     1095          idx=(x/wscale+(y/hscale)*(w/wscale))*4;
     1096          r=data[idx];
     1097          g=data[idx+1];
     1098          b=data[idx+2];
     1099          a=data[idx+3];
     1100
     1101          src[x+y*w]=((0x80 & a) << 8) |
     1102          ((0xf8 & r) << 7)      |
     1103          ((0xf8 & g) << 2)      |
     1104          ((0xf8 & b) >> 3);
     1105        }
     1106    }
     1107    break;
    10451108  default:
    10461109    fprintf(stderr,"fx Driver: wrong internalFormat in texbuildimagemap()\n");
    10471110    fxCloseHardware();
    1048     exit(-1);
     1111    EXIT(-1);
    10491112    break;
    10501113  }
     
    10601123  if (MESA_VERBOSE&VERBOSE_DRIVER) {
    10611124     fprintf(stderr,
    1062              "fxmesa: (%d) fxDDTexImg(...,level=%d,target=%d,format=%x,width=%d,height=%d...)\n",
    1063              tObj->Name, level, target, internalFormat, image->Width,
    1064              image->Height);
     1125             "fxmesa: (%d) fxDDTexImg(...,level=%d,target=%d,format=%x,width=%d,height=%d...)\n",
     1126             tObj->Name, level, target, internalFormat, image->Width,
     1127             image->Height);
    10651128  }
    10661129
     
    10781141
    10791142    fxTexGetFormat((GLenum)internalFormat,&gldformat,NULL);
    1080    
     1143
    10811144    if(mml->used) {
    10821145      if((mml->glideFormat==gldformat) &&
     
    11211184{
    11221185  fxTexGetInfo(image->Width,image->Height,NULL,NULL,NULL,NULL,NULL,NULL,
    1123                NULL,NULL);
     1186               NULL,NULL);
    11241187
    11251188  switch(internalFormat) {
     
    11541217      bsrc=(unsigned char *)(image->Data+(yoffset*image->Width+xoffset));
    11551218      bdst=((unsigned char *)destimg)+(yoffset*image->Width+xoffset);
    1156    
     1219
    11571220      for(y=0;y<height;y++) {
    11581221        MEMCPY(bdst,bsrc,width);
     
    11781241      src=(unsigned char *)(image->Data+(yoffset*image->Width+xoffset)*2);
    11791242      dst=destimg+(yoffset*image->Width+xoffset);
    1180    
     1243
    11811244      simgw=(image->Width-width)*2;
    11821245      dimgw=image->Width-width;
     
    12101273      src=(unsigned char *)(image->Data+(yoffset*image->Width+xoffset)*3);
    12111274      dst=destimg+(yoffset*image->Width+xoffset);
    1212    
     1275
    12131276      simgw=(image->Width-width)*3;
    12141277      dimgw=image->Width-width;
     
    12201283          *dst++=((0xf8 & r) << (11-3))  |
    12211284            ((0xfc & g) << (5-3+1))      |
    1222             ((0xf8 & b) >> 3); 
     1285            ((0xf8 & b) >> 3);
    12231286        }
    12241287
     
    12321295  case GL_RGBA2:
    12331296  case GL_RGBA4:
    1234   case GL_RGB5_A1:
    12351297  case GL_RGBA8:
    12361298  case GL_RGB10_A2:
     
    12451307      src=(unsigned char *)(image->Data+(yoffset*image->Width+xoffset)*4);
    12461308      dst=destimg+(yoffset*image->Width+xoffset);
    1247    
     1309
    12481310      simgw=(image->Width-width)*4;
    12491311      dimgw=image->Width-width;
     
    12651327    }
    12661328    break;
     1329  case GL_RGB5_A1:
     1330    {
     1331      int x,y;
     1332      unsigned char *src;
     1333      unsigned short *dst,r,g,b,a;
     1334      int simgw,dimgw;
     1335
     1336      src=(unsigned char *)(image->Data+(yoffset*image->Width+xoffset)*4);
     1337      dst=destimg+(yoffset*image->Width+xoffset);
     1338
     1339      simgw=(image->Width-width)*4;
     1340      dimgw=image->Width-width;
     1341      for(y=0;y<height;y++) {
     1342        for(x=0;x<width;x++) {
     1343          r=*src++;
     1344          g=*src++;
     1345          b=*src++;
     1346          a=*src++;
     1347          *dst++=
     1348          ((0x80 & a) << 8) |
     1349          ((0xf8 & r) << 7)      |
     1350          ((0xf8 & g) << 2)      |
     1351          ((0xf8 & b) >> 3);
     1352        }
     1353
     1354        src += simgw;
     1355        dst += dimgw;
     1356      }
     1357    }
     1358    break;
    12671359  default:
    12681360    fprintf(stderr,"fx Driver: wrong internalFormat in fxTexBuildSubImageMap()\n");
    12691361    fxCloseHardware();
    1270     exit(-1);
    1271     break;
    1272   }
    1273 }
    1274  
     1362    EXIT(-1);
     1363    break;
     1364  }
     1365}
     1366
    12751367
    12761368void fxDDTexSubImg(GLcontext *ctx, GLenum target,
     
    12871379  if (MESA_VERBOSE&VERBOSE_DRIVER) {
    12881380     fprintf(stderr,
    1289              "fxmesa: (%d) fxDDTexSubImg(level=%d,target=%d,format=%x,width=%d,height=%d)\n",
    1290              tObj->Name, level, target, internalFormat, image->Width,
    1291              image->Height);
     1381             "fxmesa: (%d) fxDDTexSubImg(level=%d,target=%d,format=%x,width=%d,height=%d)\n",
     1382             tObj->Name, level, target, internalFormat, image->Width,
     1383             image->Height);
    12921384  }
    12931385
     
    13051397  if(mml->glideFormat!=gldformat) {
    13061398     if (MESA_VERBOSE&VERBOSE_DRIVER) {
    1307         fprintf(stderr,"fxmesa:  ti->info.format!=format in fxDDTexSubImg()\n");
     1399        fprintf(stderr,"fxmesa:  ti->info.format!=format in fxDDTexSubImg()\n");
    13081400     }
    13091401    fxDDTexImg(ctx,target,tObj,level,internalFormat,image);
     
    13161408  if((wscale!=1) || (hscale!=1)) {
    13171409     if (MESA_VERBOSE&VERBOSE_DRIVER) {
    1318         fprintf(stderr,"fxmesa:  (wscale!=1) || (hscale!=1) in fxDDTexSubImg()\n");
     1410        fprintf(stderr,"fxmesa:  (wscale!=1) || (hscale!=1) in fxDDTexSubImg()\n");
    13191411     }
    13201412    fxDDTexImg(ctx,target,tObj,level,internalFormat,image);
     
    13341426
    13351427
     1428
     1429/**********************************************************************/
     1430/**** NEW TEXTURE IMAGE FUNCTIONS                                  ****/
     1431/**********************************************************************/
     1432
     1433GLboolean fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
     1434                         GLenum format, GLenum type, const GLvoid *pixels,
     1435                         const struct gl_pixelstore_attrib *packing,
     1436                         struct gl_texture_object *texObj,
     1437                         struct gl_texture_image *texImage,
     1438                         GLboolean *retainInternalCopy)
     1439{
     1440  *retainInternalCopy = GL_TRUE;
     1441  return GL_FALSE;
     1442}
     1443
     1444
     1445GLboolean fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
     1446                            GLint xoffset, GLint yoffset,
     1447                            GLsizei width, GLsizei height,
     1448                            GLenum format, GLenum type, const GLvoid *pixels,
     1449                            const struct gl_pixelstore_attrib *packing,
     1450                            struct gl_texture_object *texObj,
     1451                            struct gl_texture_image *texImage)
     1452{
     1453
     1454  return GL_FALSE;
     1455}
     1456
     1457
    13361458#else
    13371459
  • trunk/src/opengl/mesa/3dfx/fxdrv.h

    r2965 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.
     
    7575#include "clip.h"
    7676#include "vbrender.h"
     77#include "mem.h"
    7778
    7879#ifdef XF86DRI
     
    8788
    8889
     90extern void fx_sanity_triangle( GrVertex *, GrVertex *, GrVertex * );
    8991#if defined(MESA_DEBUG) && 0
    90 extern void fx_sanity_triangle( GrVertex *, GrVertex *, GrVertex * );
    9192#define grDrawTriangle fx_sanity_triangle
    9293#endif
     
    113114#if FX_USE_PARGB
    114115
    115 #define CLIP_XCOORD 0           /* normal place */
    116 #define CLIP_YCOROD 1           /* normal place */
    117 #define CLIP_ZCOORD 2           /* normal place */
    118 #define CLIP_WCOORD 3           /* normal place */
    119 #define CLIP_GCOORD 4           /* GR_VERTEX_PARGB_OFFSET */
    120 #define CLIP_BCOORD 5           /* GR_VERTEX_SOW_TMU0_OFFSET */
    121 #define CLIP_RCOORD 6           /* GR_VERTEX_TOW_TMU0_OFFSET */
    122 #define CLIP_ACOORD 7           /* GR_VERTEX_OOW_TMU0_OFFSET */
     116#define CLIP_XCOORD 0           /* normal place */
     117#define CLIP_YCOROD 1           /* normal place */
     118#define CLIP_ZCOORD 2           /* normal place */
     119#define CLIP_WCOORD 3           /* normal place */
     120#define CLIP_GCOORD 4           /* GR_VERTEX_PARGB_OFFSET */
     121#define CLIP_BCOORD 5           /* GR_VERTEX_SOW_TMU0_OFFSET */
     122#define CLIP_RCOORD 6           /* GR_VERTEX_TOW_TMU0_OFFSET */
     123#define CLIP_ACOORD 7           /* GR_VERTEX_OOW_TMU0_OFFSET */
    123124
    124125#else
    125126
    126 #define CLIP_XCOORD 0           /* normal place */
    127 #define CLIP_YCOROD 1           /* normal place */
    128 #define CLIP_ZCOORD 2           /* GR_VERTEX_Z_OFFSET */
    129 #define CLIP_WCOORD 3           /* GR_VERTEX_R_OFFSET */
    130 #define CLIP_GCOORD 4           /* normal place */
    131 #define CLIP_BCOORD 5           /* normal place */
    132 #define CLIP_RCOORD 6           /* GR_VERTEX_OOZ_OFFSET */
    133 #define CLIP_ACOORD 7           /* normal place */
     127#define CLIP_XCOORD 0           /* normal place */
     128#define CLIP_YCOROD 1           /* normal place */
     129#define CLIP_ZCOORD 2           /* GR_VERTEX_Z_OFFSET */
     130#define CLIP_WCOORD 3           /* GR_VERTEX_R_OFFSET */
     131#define CLIP_GCOORD 4           /* normal place */
     132#define CLIP_BCOORD 5           /* normal place */
     133#define CLIP_RCOORD 6           /* GR_VERTEX_OOZ_OFFSET */
     134#define CLIP_ACOORD 7           /* normal place */
    134135
    135136
     
    139140 */
    140141typedef struct {
    141    GLfloat f[15];               /* Same layout as GrVertex */
    142    GLubyte mask;                /* Unsued  */
    143    GLubyte usermask;            /* Unused */
     142   GLfloat f[15];               /* Same layout as GrVertex */
     143   GLubyte mask;                /* Unsued  */
     144   GLubyte usermask;            /* Unused */
    144145} fxVertex;
    145146
     
    166167#endif
    167168
    168 #define FX_VB_COLOR(fxm, color)                         \
    169   do {                                                  \
    170     if (sizeof(GLint) == 4*sizeof(GLubyte)) {           \
    171       if (fxm->constColor != *(GLuint*)color) {         \
    172         fxm->constColor = *(GLuint*)color;              \
    173         FX_grConstantColorValue(FXCOLOR4(color));       \
    174       }                                                 \
    175     } else {                                            \
    176       FX_grConstantColorValue(FXCOLOR4(color));         \
    177     }                                                   \
     169#define FX_VB_COLOR(fxm, color)                         \
     170  do {                                                  \
     171    if (sizeof(GLint) == 4*sizeof(GLubyte)) {           \
     172      if (fxm->constColor != *(GLuint*)color) {         \
     173        fxm->constColor = *(GLuint*)color;              \
     174        FX_grConstantColorValue(FXCOLOR4(color));       \
     175      }                                                 \
     176    } else {                                            \
     177      FX_grConstantColorValue(FXCOLOR4(color));         \
     178    }                                                   \
    178179  } while (0)
    179180
    180 #define GOURAUD(x) {                                    \
    181   GLubyte *col = VB->ColorPtr->data[(x)];               \
    182   gWin[(x)].v.r=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[0]); \
    183   gWin[(x)].v.g=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[1]); \
    184   gWin[(x)].v.b=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[2]); \
    185   gWin[(x)].v.a=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[3]); \
     181#define GOURAUD(x) {                                    \
     182  GLubyte *col = VB->ColorPtr->data[(x)];               \
     183  gWin[(x)].v.r=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[0]); \
     184  gWin[(x)].v.g=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[1]); \
     185  gWin[(x)].v.b=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[2]); \
     186  gWin[(x)].v.a=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[3]); \
    186187}
    187188
    188189#if FX_USE_PARGB
    189 #define GOURAUD2(v, c) {                                                                                                                                \
    190   GLubyte *col = c;                                                                                                                                     \
    191   v->argb=MESACOLOR2PARGB(col);                                                                                                                 \
     190#define GOURAUD2(v, c) {                                                                                                                                \
     191  GLubyte *col = c;                                                                                                                                     \
     192  v->argb=MESACOLOR2PARGB(col);                                                                                                                 \
    192193}
    193194#else
    194 #define GOURAUD2(v, c) {                        \
    195   GLubyte *col = c;                             \
    196   v->r=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[0]);  \
    197   v->g=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[1]);  \
    198   v->b=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[2]);  \
    199   v->a=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[3]);  \
     195#define GOURAUD2(v, c) {                        \
     196  GLubyte *col = c;                             \
     197  v->r=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[0]);  \
     198  v->g=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[1]);  \
     199  v->b=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[2]);  \
     200  v->a=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[3]);  \
    200201}
    201202#endif
     
    230231#define FX_UM_E0_DECAL              0x00000004
    231232#define FX_UM_E0_BLEND              0x00000008
    232 #define FX_UM_E0_ADD                            0x00000010
     233#define FX_UM_E0_ADD                            0x00000010
    233234
    234235#define FX_UM_E1_REPLACE            0x00000020
     
    236237#define FX_UM_E1_DECAL              0x00000080
    237238#define FX_UM_E1_BLEND              0x00000100
    238 #define FX_UM_E1_ADD                            0x00000200
     239#define FX_UM_E1_ADD                            0x00000200
    239240
    240241#define FX_UM_E_ENVMODE             0x000003ff
     
    256257#define FX_UM_E_IFMT                0x00fff000
    257258
    258 #define FX_UM_COLOR_ITERATED        0x00100000
    259 #define FX_UM_COLOR_CONSTANT        0x00200000
    260 #define FX_UM_ALPHA_ITERATED        0x00400000
    261 #define FX_UM_ALPHA_CONSTANT        0x00800000
     259#define FX_UM_COLOR_ITERATED        0x01000000
     260#define FX_UM_COLOR_CONSTANT        0x02000000
     261#define FX_UM_ALPHA_ITERATED        0x04000000
     262#define FX_UM_ALPHA_CONSTANT        0x08000000
    262263
    263264typedef void (*tfxRenderVBFunc)(GLcontext *);
     
    272273
    273274typedef struct {
    274   GLsizei width, height;
    275   GLint glideFormat;
    276 
    277   unsigned short *data;
    278   GLboolean translated, used;
     275  GLsizei width, height;              /* image size */
     276  GrTextureFormat_t glideFormat;      /* Glide image format */
     277  unsigned short *data;         /* Glide-formated texture image */
     278  GLboolean translated;         /* True if data points to a reformated image */
     279  GLboolean used;               /* True if we've given the image to Glide */
    279280} tfxMipMapLevel;
    280281
     
    306307
    307308  GLfloat sScale, tScale;
    308   GLint int_sScale, int_tScale; /* x86 floating point trick for
    309                                 * multiplication by powers of 2.
    310                                 * Used in fxfasttmp.h
    311                                 */
     309  GLint int_sScale, int_tScale; /* x86 floating point trick for
     310                                * multiplication by powers of 2.
     311                                * Used in fxfasttmp.h
     312                                */
    312313
    313314  GuTexPalette palette;
     
    326327
    327328typedef void (*tfxTriViewClipFunc)( struct vertex_buffer *VB,
    328                                     GLuint v[],
    329                                     GLubyte mask );
     329                                    GLuint v[],
     330                                    GLubyte mask );
    330331
    331332typedef void (*tfxTriClipFunc)( struct vertex_buffer *VB,
    332                                 GLuint v[],
    333                                 GLuint mask );
     333                                GLuint v[],
     334                                GLuint mask );
    334335
    335336
    336337typedef void (*tfxLineClipFunc)( struct vertex_buffer *VB,
    337                                 GLuint v1, GLuint v2,
    338                                 GLubyte mask );
     338                                GLuint v1, GLuint v2,
     339                                GLubyte mask );
    339340
    340341
     
    396397   void *vert_store;
    397398#if defined(FX_GLIDE3)
    398    GrVertex **triangle_b;       /* Triangle buffer */
    399    GrVertex **strips_b;         /* Strips buffer */
     399   GrVertex **triangle_b;       /* Triangle buffer */
     400   GrVertex **strips_b;         /* Strips buffer */
    400401#endif
    401402
     
    438439  GrBuffer_t currentFB;
    439440
     441  GLboolean bgrOrder;
    440442  GrColor_t color;
    441443  GrColor_t clearC;
    442444  GrAlpha_t clearA;
    443445  GLuint constColor;
     446  GrCullMode_t cullMode;
    444447
    445448  tfxUnitsState unitsState;
     
    455458  GLuint render_index;
    456459  GLuint last_tri_caps;
    457   GLuint stw_hint_state;                /* for grHints */
     460  GLuint stw_hint_state;                /* for grHints */
    458461  GLuint is_in_hardware;
    459462  GLuint new_state;
     
    476479  GLenum fogTableMode;
    477480  GLfloat fogDensity;
     481  GLfloat fogStart, fogEnd;
    478482  GrFog_t *fogTable;
     483  GLint textureAlign;
    479484
    480485  /* Acc. functions */
     
    499504
    500505  GLboolean verbose;
    501   GLboolean haveTwoTMUs;        /* True if we really have 2 tmu's  */
    502   GLboolean emulateTwoTMUs;     /* True if we present 2 tmu's to mesa.  */
     506  GLboolean haveTwoTMUs;        /* True if we really have 2 tmu's  */
     507  GLboolean emulateTwoTMUs;     /* True if we present 2 tmu's to mesa.  */
    503508  GLboolean haveAlphaBuffer;
    504509  GLboolean haveZBuffer;
     
    530535extern int glbCurrentBoard;
    531536
     537extern void fxPrintSetupFlags( const char *msg, GLuint flags );
    532538extern void fxSetupFXUnits(GLcontext *);
    533539extern void fxSetupDDPointers(GLcontext *);
     
    542548
    543549extern void fxRenderClippedLine( struct vertex_buffer *VB,
    544                                 GLuint v1, GLuint v2 );
     550                                GLuint v1, GLuint v2 );
    545551
    546552extern void fxRenderClippedTriangle( struct vertex_buffer *VB,
    547                                      GLuint n, GLuint vlist[] );
     553                                     GLuint n, GLuint vlist[] );
    548554
    549555
     
    562568extern void fxSetupDDSpanPointers(GLcontext *);
    563569
    564 extern void fxDDBufferSize(GLcontext *, GLuint *, GLuint *);
    565 
    566570extern void fxPrintTextureData(tfxTexInfo *ti);
    567 extern void fxDDTexEnv(GLcontext *, GLenum, const GLfloat *);
    568571extern void fxDDTexImg(GLcontext *, GLenum, struct gl_texture_object *,
    569                        GLint, GLint, const struct gl_texture_image *);
     572                       GLint, GLint, const struct gl_texture_image *);
     573extern void fxDDTexSubImg(GLcontext *, GLenum, struct gl_texture_object *,
     574                          GLint, GLint, GLint, GLint, GLint, GLint,
     575                          const struct gl_texture_image *);
     576extern GLboolean fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
     577                              GLenum format, GLenum type, const GLvoid *pixels,
     578                              const struct gl_pixelstore_attrib *packing,
     579                              struct gl_texture_object *texObj,
     580                              struct gl_texture_image *texImage,
     581                              GLboolean *retainInternalCopy);
     582extern GLboolean fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
     583                              GLint xoffset, GLint yoffset,
     584                              GLsizei width, GLsizei height,
     585                              GLenum format, GLenum type, const GLvoid *pixels,
     586                              const struct gl_pixelstore_attrib *packing,
     587                              struct gl_texture_object *texObj,
     588                              struct gl_texture_image *texImage);
     589extern void fxDDTexEnv(GLcontext *, GLenum, GLenum, const GLfloat *);
    570590extern void fxDDTexParam(GLcontext *, GLenum, struct gl_texture_object *,
    571                         GLenum, const GLfloat *);
     591                        GLenum, const GLfloat *);
    572592extern void fxDDTexBind(GLcontext *, GLenum, struct gl_texture_object *);
    573593extern void fxDDTexDel(GLcontext *, struct gl_texture_object *);
    574594extern void fxDDTexPalette(GLcontext *, struct gl_texture_object *);
    575 extern void fxDDTexuseGlbPalette(GLcontext *, GLboolean);
    576 extern void fxDDTexSubImg(GLcontext *, GLenum, struct gl_texture_object *, GLint,
    577                           GLint, GLint, GLint, GLint, GLint, const struct gl_texture_image *);
    578595extern void fxDDTexUseGlbPalette(GLcontext *, GLboolean);
    579596
     
    589606
    590607extern void fxDDCheckMergeAndRender( GLcontext *ctx,
    591                                      struct gl_pipeline_stage *d );
     608                                     struct gl_pipeline_stage *d );
    592609
    593610extern void fxDDMergeAndRender( struct vertex_buffer *VB );
    594611
    595612extern void fxDDCheckPartialRasterSetup( GLcontext *ctx,
    596                                         struct gl_pipeline_stage *d );
     613                                        struct gl_pipeline_stage *d );
    597614
    598615extern void fxDDPartialRasterSetup( struct vertex_buffer *VB );
     
    601618
    602619extern GLuint fxDDRegisterPipelineStages( struct gl_pipeline_stage *out,
    603                                           const struct gl_pipeline_stage *in,
    604                                           GLuint nr );
     620                                          const struct gl_pipeline_stage *in,
     621                                          GLuint nr );
    605622
    606623extern GLboolean fxDDBuildPrecalcPipeline( GLcontext *ctx );
    607624
    608625extern void fxDDOptimizePrecalcPipeline( GLcontext *ctx,
    609                                         struct gl_pipeline *pipe );
     626                                        struct gl_pipeline *pipe );
    610627
    611628extern void fxDDRenderElementsDirect( struct vertex_buffer *VB );
     
    617634extern void fxTMInit(fxMesaContext ctx);
    618635extern void fxTMClose(fxMesaContext ctx);
     636extern void fxTMRestoreTextures_NoLock(fxMesaContext ctx);
    619637extern void fxTMMoveInTM(fxMesaContext, struct gl_texture_object *, GLint);
    620638extern void fxTMMoveOutTM(fxMesaContext, struct gl_texture_object *);
     639#define fxTMMoveOutTM_NoLock fxTMMoveOutTM
    621640extern void fxTMFreeTexture(fxMesaContext, struct gl_texture_object *);
    622641extern void fxTMReloadMipMapLevel(fxMesaContext, struct gl_texture_object *, GLint);
    623642extern void fxTMReloadSubMipMapLevel(fxMesaContext, struct gl_texture_object *,
    624                                      GLint, GLint, GLint);
     643                                     GLint, GLint, GLint);
    625644
    626645extern void fxTexGetFormat(GLenum, GrTextureFormat_t *, GLint *);
    627646extern int fxTexGetInfo(int, int, GrLOD_t *, GrAspectRatio_t *,
    628                         float *, float *, int *, int *, int *, int *);
     647                        float *, float *, int *, int *, int *, int *);
    629648
    630649extern void fxDDScissor( GLcontext *ctx,
    631                               GLint x, GLint y, GLsizei w, GLsizei h );
     650                              GLint x, GLint y, GLsizei w, GLsizei h );
    632651extern void fxDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *params );
    633652extern GLboolean fxDDColorMask(GLcontext *ctx,
    634                                GLboolean r, GLboolean g,
    635                                GLboolean b, GLboolean a );
    636 
    637 extern GLuint fxDDDepthTestSpanGeneric(GLcontext *ctx,
    638                                        GLuint n, GLint x, GLint y,
    639                                        const GLdepth z[],
    640                                        GLubyte mask[]);
    641 
    642 extern void fxDDDepthTestPixelsGeneric(GLcontext* ctx,
    643                                        GLuint n,
    644                                        const GLint x[], const GLint y[],
    645                                        const GLdepth z[], GLubyte mask[]);
    646 
    647 extern void fxDDReadDepthSpanFloat(GLcontext *ctx,
    648                                    GLuint n, GLint x, GLint y, GLfloat depth[]);
    649 
    650 extern void fxDDReadDepthSpanInt(GLcontext *ctx,
    651                                  GLuint n, GLint x, GLint y, GLdepth depth[]);
    652 
     653                               GLboolean r, GLboolean g,
     654                               GLboolean b, GLboolean a );
     655
     656extern void fxDDWriteDepthSpan(GLcontext *ctx, GLuint n, GLint x, GLint y,
     657                               const GLdepth depth[], const GLubyte mask[]);
     658
     659extern void fxDDReadDepthSpan(GLcontext *ctx, GLuint n, GLint x, GLint y,
     660                              GLdepth depth[]);
     661
     662extern void fxDDWriteDepthPixels(GLcontext *ctx, GLuint n,
     663                                 const GLint x[], const GLint y[],
     664                                 const GLdepth depth[], const GLubyte mask[]);
     665
     666extern void fxDDReadDepthPixels(GLcontext *ctx, GLuint n,
     667                                const GLint x[], const GLint y[],
     668                                GLdepth depth[]);
    653669
    654670extern void fxDDFastPath( struct vertex_buffer *VB );
     
    669685extern void fxSetScissorValues(GLcontext *ctx);
    670686extern void fxTMMoveInTM_NoLock(fxMesaContext fxMesa,
    671                                 struct gl_texture_object *tObj,
    672                                 GLint where);
    673 extern void fxSetupTexture_NoLock(GLcontext *ctx);
    674 extern void fxSetupTexture(GLcontext *ctx);
    675 
    676 extern void fxInitPixelTables(GLboolean bgrOrder);
    677 
    678 #endif
     687                                struct gl_texture_object *tObj,
     688                                GLint where);
     689extern void fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder);
     690
     691#endif
  • trunk/src/opengl/mesa/3dfx/fxfastpath.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.
     
    5656#include "fxdrv.h"
    5757#include "vertices.h"
    58 //#include "X86/common_x86asm.h"
     58#include "common_x86asm.h"
    5959
    6060
     
    7070
    7171
    72 #define CLIP(sgn,v,PLANE)                                       \
    73 if (mask & PLANE) {                                             \
    74    GLuint *indata = inlist[in];                                 \
    75    GLuint *outdata = inlist[in ^= 1];                           \
    76    GLuint nr = n;                                               \
    77    GLfloat *J = verts[indata[nr-1]].f;                          \
    78    GLfloat dpJ = (sgn J[v]) + J[CLIP_WCOORD];                   \
    79                                                                 \
    80    inlist[0] = vlist1;                                          \
    81    for (i = n = 0 ; i < nr ; i++) {                             \
    82       GLuint elt_i = indata[i];                                 \
    83       GLfloat *I = verts[elt_i].f;                              \
    84       GLfloat dpI = (sgn I[v]) + I[CLIP_WCOORD];                \
    85                                                                 \
    86       if (DIFFERENT_SIGNS(dpI, dpJ)) {                          \
    87          GLfloat *O = verts[next_vert].f;                       \
    88          GLfloat t = dpI / (dpI - dpJ);                         \
    89          GLuint j;                                              \
    90                                                                 \
    91          clipmask[next_vert] = 0;                               \
    92          outdata[n++] = next_vert++;                            \
    93                                                                 \
    94          for (j = 0 ; j < SIZE ; j += 2) {                      \
    95             O[j]   = LINTERP(t, I[j],   J[j]);                  \
    96             O[j+1] = LINTERP(t, I[j+1], J[j+1]);                \
    97          }                                                      \
    98       }                                                         \
    99                                                                 \
    100       clipmask[elt_i] |= PLANE;         /* don't set up */      \
    101                                                                 \
    102       if (!NEGATIVE(dpI)) {                                     \
    103          outdata[n++] = elt_i;                                  \
    104          clipmask[elt_i] &= ~PLANE;     /* set up after all */  \
    105       }                                                         \
    106                                                                 \
    107       J = I;                                                    \
    108       dpJ = dpI;                                                \
    109    }                                                            \
    110                                                                 \
    111    if (n < 3) return;                                           \
     72#define CLIP(sgn,v,PLANE)                                       \
     73if (mask & PLANE) {                                             \
     74   GLuint *indata = inlist[in];                                 \
     75   GLuint *outdata = inlist[in ^= 1];                           \
     76   GLuint nr = n;                                               \
     77   GLfloat *J = verts[indata[nr-1]].f;                          \
     78   GLfloat dpJ = (sgn J[v]) + J[CLIP_WCOORD];                   \
     79                                                                \
     80   inlist[0] = vlist1;                                          \
     81   for (i = n = 0 ; i < nr ; i++) {                             \
     82      GLuint elt_i = indata[i];                                 \
     83      GLfloat *I = verts[elt_i].f;                              \
     84      GLfloat dpI = (sgn I[v]) + I[CLIP_WCOORD];                \
     85                                                                \
     86      if (DIFFERENT_SIGNS(dpI, dpJ)) {                          \
     87         GLfloat *O = verts[next_vert].f;                       \
     88         GLfloat t = dpI / (dpI - dpJ);                         \
     89         GLuint j;                                              \
     90                                                                \
     91         clipmask[next_vert] = 0;                               \
     92         outdata[n++] = next_vert++;                            \
     93                                                                \
     94         for (j = 0 ; j < SIZE ; j += 2) {                      \
     95            O[j]   = LINTERP(t, I[j],   J[j]);                  \
     96            O[j+1] = LINTERP(t, I[j+1], J[j+1]);                \
     97         }                                                      \
     98      }                                                         \
     99                                                                \
     100      clipmask[elt_i] |= PLANE;         /* don't set up */      \
     101                                                                \
     102      if (!NEGATIVE(dpI)) {                                     \
     103         outdata[n++] = elt_i;                                  \
     104         clipmask[elt_i] &= ~PLANE;     /* set up after all */  \
     105      }                                                         \
     106                                                                \
     107      J = I;                                                    \
     108      dpJ = dpI;                                                \
     109   }                                                            \
     110                                                                \
     111   if (n < 3) return;                                           \
    112112}
    113113
    114 #define LINE_CLIP(x,y,z,w,PLANE)                                \
    115 if (mask & PLANE) {                                             \
    116    GLfloat dpI = DOT4V(I,x,y,z,w);                              \
    117    GLfloat dpJ = DOT4V(J,x,y,z,w);                              \
    118                                                                 \
    119    if (DIFFERENT_SIGNS(dpI, dpJ)) {                             \
    120       GLfloat *O = verts[next_vert].f;                          \
    121       GLfloat t = dpI / (dpI - dpJ);                            \
    122       GLuint j;                                                 \
    123                                                                 \
    124       for (j = 0 ; j < SIZE ; j += 2) {                         \
    125          O[j]   = LINTERP(t, I[j],   J[j]);                     \
    126          O[j+1] = LINTERP(t, I[j+1], J[j+1]);                   \
    127       }                                                         \
    128                                                                 \
    129       clipmask[next_vert] = 0;                                  \
    130                                                                 \
    131       if (NEGATIVE(dpI)) {                                      \
    132          clipmask[elts[0]] |= PLANE;                            \
    133          I = O; elts[0] = next_vert++;                          \
    134       } else {                                                  \
    135          clipmask[elts[1]] |= PLANE;                            \
    136          J = O; elts[1] = next_vert++;                          \
    137       }                                                         \
    138    }                                                            \
    139    else if (NEGATIVE(dpI))                                      \
    140       return;                                                   \
     114#define LINE_CLIP(x,y,z,w,PLANE)                                \
     115if (mask & PLANE) {                                             \
     116   GLfloat dpI = DOT4V(I,x,y,z,w);                              \
     117   GLfloat dpJ = DOT4V(J,x,y,z,w);                              \
     118                                                                \
     119   if (DIFFERENT_SIGNS(dpI, dpJ)) {                             \
     120      GLfloat *O = verts[next_vert].f;                          \
     121      GLfloat t = dpI / (dpI - dpJ);                            \
     122      GLuint j;                                                 \
     123                                                                \
     124      for (j = 0 ; j < SIZE ; j += 2) {                         \
     125         O[j]   = LINTERP(t, I[j],   J[j]);                     \
     126         O[j+1] = LINTERP(t, I[j+1], J[j+1]);                   \
     127      }                                                         \
     128                                                                \
     129      clipmask[next_vert] = 0;                                  \
     130                                                                \
     131      if (NEGATIVE(dpI)) {                                      \
     132         clipmask[elts[0]] |= PLANE;                            \
     133         I = O; elts[0] = next_vert++;                          \
     134      } else {                                                  \
     135         clipmask[elts[1]] |= PLANE;                            \
     136         J = O; elts[1] = next_vert++;                          \
     137      }                                                         \
     138   }                                                            \
     139   else if (NEGATIVE(dpI))                                      \
     140      return;                                                   \
    141141}
    142142
    143143
    144 #define CLIP_POINT( e )                         \
    145    if (mask[e])                                 \
    146       *out++ = e 
    147 
    148 #define CLIP_LINE( e1, e0 )                                             \
    149 do {                                                                    \
    150    GLubyte ormask = mask[e0] | mask[e1];                                \
    151    out[0] = e1;                                                         \
    152    out[1] = e0;                                                         \
    153    out+=2;                                                              \
    154    if (ormask) {                                                        \
    155       out-=2;                                                           \
    156       if (!(mask[e0] & mask[e1])) {                                     \
    157          TAG(fx_line_clip)( &out, verts, mask, &next_vert, ormask);     \
    158       }                                                                 \
    159    }                                                                    \
     144#define CLIP_POINT( e )                         \
     145   if (mask[e])                                 \
     146      *out++ = e
     147
     148#define CLIP_LINE( e1, e0 )                                             \
     149do {                                                                    \
     150   GLubyte ormask = mask[e0] | mask[e1];                                \
     151   out[0] = e1;                                                         \
     152   out[1] = e0;                                                         \
     153   out+=2;                                                              \
     154   if (ormask) {                                                        \
     155      out-=2;                                                           \
     156      if (!(mask[e0] & mask[e1])) {                                     \
     157         TAG(fx_line_clip)( &out, verts, mask, &next_vert, ormask);     \
     158      }                                                                 \
     159   }                                                                    \
    160160} while (0)
    161161
    162 #define CLIP_TRIANGLE( e2, e1, e0 )                                     \
    163 do {                                                                    \
    164    GLubyte ormask;                                                      \
    165    out[0] = e2;                                                         \
    166    out[1] = e1;                                                         \
    167    out[2] = e0;                                                         \
    168    out += 3;                                                            \
    169    ormask = mask[e2] | mask[e1] | mask[e0];                             \
    170    if (ormask) {                                                        \
    171       out -= 3;                                                         \
    172       if ( !(mask[e2] & mask[e1] & mask[e0])) {                         \
    173          TAG(fx_tri_clip)( &out, verts, mask, &next_vert, ormask );     \
    174       }                                                                 \
    175    }                                                                    \
     162#define CLIP_TRIANGLE( e2, e1, e0 )                                     \
     163do {                                                                    \
     164   GLubyte ormask;                                                      \
     165   out[0] = e2;                                                         \
     166   out[1] = e1;                                                         \
     167   out[2] = e0;                                                         \
     168   out += 3;                                                            \
     169   ormask = mask[e2] | mask[e1] | mask[e0];                             \
     170   if (ormask) {                                                        \
     171      out -= 3;                                                         \
     172      if ( !(mask[e2] & mask[e1] & mask[e0])) {                         \
     173         TAG(fx_tri_clip)( &out, verts, mask, &next_vert, ormask );     \
     174      }                                                                 \
     175   }                                                                    \
    176176} while (0)
    177177
    178178#if defined(FX_V2) || defined(DRIVERTS)
    179179
    180 #define VARS_XYZ                                \
    181   GLfloat vsx = mat[MAT_SX];                    \
    182   GLfloat vsy = mat[MAT_SY];                    \
    183   GLfloat vsz = mat[MAT_SZ];                    \
    184   GLfloat vtx = mat[MAT_TX];                    \
    185   GLfloat vty = mat[MAT_TY];                    \
     180#define VARS_XYZ                                \
     181  GLfloat vsx = mat[MAT_SX];                    \
     182  GLfloat vsy = mat[MAT_SY];                    \
     183  GLfloat vsz = mat[MAT_SZ];                    \
     184  GLfloat vtx = mat[MAT_TX];                    \
     185  GLfloat vty = mat[MAT_TY];                    \
    186186  GLfloat vtz = mat[MAT_TZ];
    187187
    188 #define DO_SETUP_XYZ                            \
    189   f[XCOORD] = f[0] * oow * vsx + vtx;           \
    190   f[YCOORD] = f[1] * oow * vsy + vty;           \
     188#define DO_SETUP_XYZ                            \
     189  f[XCOORD] = f[0] * oow * vsx + vtx;           \
     190  f[YCOORD] = f[1] * oow * vsy + vty;           \
    191191  f[ZCOORD] = f[2] * oow * vsz + vtz;
    192192
     
    194194#if defined(HAVE_FAST_MATH)
    195195
    196 #define VARS_XYZ                                \
    197   GLfloat vsx = mat[MAT_SX];                    \
    198   GLfloat vsy = mat[MAT_SY];                    \
    199   GLfloat vsz = mat[MAT_SZ];                    \
    200   const GLfloat snapper = (3L << 18);           \
    201   GLfloat vtx = mat[MAT_TX] + snapper;          \
    202   GLfloat vty = mat[MAT_TY] + snapper;          \
     196#define VARS_XYZ                                \
     197  GLfloat vsx = mat[MAT_SX];                    \
     198  GLfloat vsy = mat[MAT_SY];                    \
     199  GLfloat vsz = mat[MAT_SZ];                    \
     200  const GLfloat snapper = (3L << 18);           \
     201  GLfloat vtx = mat[MAT_TX] + snapper;          \
     202  GLfloat vty = mat[MAT_TY] + snapper;          \
    203203  GLfloat vtz = mat[MAT_TZ];
    204204
    205 #define DO_SETUP_XYZ                            \
    206   f[XCOORD] = f[0] * oow * vsx + vtx;           \
    207   f[XCOORD] -= snapper;                         \
    208   f[YCOORD] = f[1] * oow * vsy + vty;           \
    209   f[YCOORD] -= snapper;                         \
     205#define DO_SETUP_XYZ                            \
     206  f[XCOORD] = f[0] * oow * vsx + vtx;           \
     207  f[XCOORD] -= snapper;                         \
     208  f[YCOORD] = f[1] * oow * vsy + vty;           \
     209  f[YCOORD] -= snapper;                         \
    210210  f[ZCOORD] = f[2] * oow * vsz + vtz;
    211211
    212212#else
    213213
    214 #define VARS_XYZ                                \
    215   GLfloat vsx = mat[MAT_SX] * 16.0f;            \
    216   GLfloat vsy = mat[MAT_SY] * 16.0f;            \
    217   GLfloat vsz = mat[MAT_SZ];                    \
    218   GLfloat vtx = mat[MAT_TX] * 16.0f;            \
    219   GLfloat vty = mat[MAT_TY] * 16.0f;            \
     214#define VARS_XYZ                                \
     215  GLfloat vsx = mat[MAT_SX] * 16.0f;            \
     216  GLfloat vsy = mat[MAT_SY] * 16.0f;            \
     217  GLfloat vsz = mat[MAT_SZ];                    \
     218  GLfloat vtx = mat[MAT_TX] * 16.0f;            \
     219  GLfloat vty = mat[MAT_TY] * 16.0f;            \
    220220  GLfloat vtz = mat[MAT_TZ];
    221221
    222 #define DO_SETUP_XYZ                                    \
    223   f[XCOORD] = ((int)(f[0]*oow*vsx+vtx)) * (1.0f/16.0f); \
    224   f[YCOORD] = ((int)(f[1]*oow*vsy+vty)) * (1.0f/16.0f); \
     222#define DO_SETUP_XYZ                                    \
     223  f[XCOORD] = ((int)(f[0]*oow*vsx+vtx)) * (1.0f/16.0f); \
     224  f[YCOORD] = ((int)(f[1]*oow*vsy+vty)) * (1.0f/16.0f); \
    225225  f[ZCOORD] = f[2]*oow*vsz + vtz;
    226226
     
    231231
    232232
    233 struct fx_fast_tab 
     233struct fx_fast_tab
    234234{
    235235   void (*build_vertices)( struct vertex_buffer *VB, GLuint do_clip );
    236236
    237    void (*clip[GL_POLYGON+1])( struct vertex_buffer *VB, 
    238                                GLuint start,
    239                                GLuint count,
    240                                GLuint parity );
     237   void (*clip[GL_POLYGON+1])( struct vertex_buffer *VB,
     238                               GLuint start,
     239                               GLuint count,
     240                               GLuint parity );
    241241
    242242   void (*project_clipped_vertices)( GLfloat *first,
    243                                      GLfloat *last,
    244                                      const GLfloat *mat,
    245                                      GLuint stride,
    246                                      const GLubyte *mask );
     243                                     GLfloat *last,
     244                                     const GLfloat *mat,
     245                                     GLuint stride,
     246                                     const GLubyte *mask );
    247247
    248248   void (*project_vertices)( GLfloat *first,
    249                              GLfloat *last,
    250                              const GLfloat *mat,
    251                              GLuint stride );
     249                             GLfloat *last,
     250                             const GLfloat *mat,
     251                             GLuint stride );
    252252};
    253253
     
    258258#define CLIP_B  CLIP_BCOORD
    259259#define CLIP_A  CLIP_ACOORD
    260 #define CLIP_S0 4               
     260#define CLIP_S0 4
    261261#define CLIP_T0 5
    262262#define CLIP_S1 6
     
    337337   fx_init_fastpath_TMU0_TMU1( &fxFastTab[SETUP_TMU0|SETUP_TMU1] );
    338338   fx_init_fastpath_RGBA_TMU0_TMU1( &fxFastTab[SETUP_RGBA|SETUP_TMU0|
    339                                                SETUP_TMU1] );
     339                                               SETUP_TMU1] );
    340340}
    341341
     
    357357   GLfloat *mat = ctx->Viewport.WindowMap.m;
    358358
    359    gl_prepare_arrays_cva( VB );                 /* still need this */
     359   gl_prepare_arrays_cva( VB );                 /* still need this */
    360360
    361361   if (VB->EltPtr->count * 12 > fxVB->size) {
     
    377377   if (VB->ClipOrMask) {
    378378      if (!VB->ClipAndMask) {
    379         GLubyte tmp = VB->ClipOrMask;
    380 
    381         tab->clip[prim]( VB, 0, VB->EltPtr->count, 0 );   /* clip */
    382 
    383          tab->project_clipped_vertices( fxVB->verts->f,
    384                                         fxVB->last_vert->f,
    385                                         mat, 16 * 4,
    386                                         VB->ClipMask );
    387          
    388         ctx->CVA.elt_mode = gl_reduce_prim[prim];
    389         VB->EltPtr = &(FX_DRIVER_DATA(VB)->clipped_elements);
    390 
    391         VB->ClipOrMask = 0;
    392         fxDDRenderElementsDirect( VB );        /* render using new list */
    393         VB->ClipOrMask = tmp;
     379        GLubyte tmp = VB->ClipOrMask;
     380
     381        tab->clip[prim]( VB, 0, VB->EltPtr->count, 0 );   /* clip */
     382
     383         tab->project_clipped_vertices( fxVB->verts->f,
     384                                        fxVB->last_vert->f,
     385                                        mat, 16 * 4,
     386                                        VB->ClipMask );
     387
     388        ctx->CVA.elt_mode = gl_reduce_prim[prim];
     389        VB->EltPtr = &(FX_DRIVER_DATA(VB)->clipped_elements);
     390
     391        VB->ClipOrMask = 0;
     392        fxDDRenderElementsDirect( VB );        /* render using new list */
     393        VB->ClipOrMask = tmp;
    394394      }
    395395   } else {
    396       tab->project_vertices(  fxVB->verts->f, 
    397                               fxVB->last_vert->f,
    398                               mat, 16 * 4 ); 
     396      tab->project_vertices(  fxVB->verts->f,
     397                              fxVB->last_vert->f,
     398                              mat, 16 * 4 );
    399399
    400400      fxDDRenderElementsDirect( VB );           /* render using orig list */
     
    406406#endif
    407407
    408    /* This indicates that there is no cached data to reuse. 
     408   /* This indicates that there is no cached data to reuse.
    409409    */
    410410   VB->pipeline->data_valid = 0;
  • trunk/src/opengl/mesa/3dfx/fxfasttmp.h

    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.
     
    8989    */
    9090   gl_xform_points3_v16_general(FX_DRIVER_DATA(VB)->verts[0].f,
    91                                 m,
    92                                 VB->ObjPtr->start,
    93                                 VB->ObjPtr->stride,
    94                                 count);
     91                                m,
     92                                VB->ObjPtr->start,
     93                                VB->ObjPtr->stride,
     94                                count);
    9595
    9696   if (do_clip)
    9797   {
    98       VB->ClipAndMask = ~0; 
     98      VB->ClipAndMask = ~0;
    9999      VB->ClipOrMask = 0;
    100100      gl_cliptest_points4_v16(FX_DRIVER_DATA(VB)->verts[0].f,
    101                               FX_DRIVER_DATA(VB)->verts[count].f,
    102                               &(VB->ClipOrMask),
    103                               &(VB->ClipAndMask),
    104                               VB->ClipMask);
     101                              FX_DRIVER_DATA(VB)->verts[count].f,
     102                              &(VB->ClipOrMask),
     103                              &(VB->ClipAndMask),
     104                              VB->ClipMask);
    105105   }
    106106
     
    137137 */
    138138static void TAG(fx_project_vertices)( GLfloat *first,
    139                                       GLfloat *last,
    140                                       const GLfloat *mat,
    141                                       GLuint stride )
     139                                      GLfloat *last,
     140                                      const GLfloat *mat,
     141                                      GLuint stride )
    142142{
    143143   GLfloat *f;
    144144   VARS_XYZ;
    145145
    146    for ( f = first ; f != last ; STRIDE_F(f, stride)) 
     146   for ( f = first ; f != last ; STRIDE_F(f, stride))
    147147   {
    148       GLfloat oow = 1.0f/f[3];  /* urp! */
     148      GLfloat oow = 1.0f/f[CLIP_WCOORD];        /* urp! */
    149149
    150150#if FX_USE_PARGB
     
    154154#else
    155155      if (TYPE & SETUP_RGBA) {
    156         f[RCOORD]=f[CLIP_R];
     156        f[RCOORD]=f[CLIP_R];
    157157      }
    158158#endif
    159159      if (TYPE & SETUP_TMU1) {
    160         f[S1COORD] = f[CLIP_S1] * oow;
    161         f[T1COORD] = f[CLIP_T1] * oow;
     160        f[S1COORD] = f[CLIP_S1] * oow;
     161        f[T1COORD] = f[CLIP_T1] * oow;
    162162      }
    163163
    164164      if (TYPE & SETUP_TMU0) {
    165         f[T0COORD] = f[CLIP_T0] * oow;
    166         f[S0COORD] = f[CLIP_S0] * oow;
     165        f[T0COORD] = f[CLIP_T0] * oow;
     166        f[S0COORD] = f[CLIP_S0] * oow;
    167167      }
    168168
     
    174174
    175175static void TAG(fx_project_clipped_vertices)( GLfloat *first,
    176                                               GLfloat *last,
    177                                               const GLfloat *mat,
    178                                               GLuint stride,
    179                                               const GLubyte *mask )
     176                                              GLfloat *last,
     177                                              const GLfloat *mat,
     178                                              GLuint stride,
     179                                              const GLubyte *mask )
    180180{
    181181   GLfloat *f;
     
    185185      if (!*mask) {
    186186
    187          GLfloat oow = 1.0f / f[3];
     187         GLfloat oow = 1.0f / f[CLIP_WCOORD];
    188188#if FX_USE_PARGB
    189189        if (TYPE & SETUP_RGBA) {
     
    197197#else
    198198        if (TYPE & SETUP_RGBA) {
    199           f[RCOORD]=f[CLIP_R];
     199          f[RCOORD]=f[CLIP_R];
    200200        }
    201201#endif
    202202
    203         if (TYPE & SETUP_TMU1) {
    204             f[S1COORD] = f[CLIP_S1] * oow;
    205             f[T1COORD] = f[CLIP_T1] * oow;
    206         }
    207 
    208         if (TYPE & SETUP_TMU0) {
    209             f[T0COORD] = f[CLIP_T0] * oow;
    210             f[S0COORD] = f[CLIP_S0] * oow;
    211         }
    212 
    213         DO_SETUP_XYZ;
    214 
    215         f[OOWCOORD] = oow;
     203        if (TYPE & SETUP_TMU1) {
     204            f[S1COORD] = f[CLIP_S1] * oow;
     205            f[T1COORD] = f[CLIP_T1] * oow;
     206        }
     207
     208        if (TYPE & SETUP_TMU0) {
     209            f[T0COORD] = f[CLIP_T0] * oow;
     210            f[S0COORD] = f[CLIP_S0] * oow;
     211        }
     212
     213        DO_SETUP_XYZ;
     214
     215        f[OOWCOORD] = oow;
    216216      }
    217217   }
     
    224224#endif
    225225void TAG(fx_tri_clip)( GLuint **p_elts,
    226                        fxVertex *verts,
    227                        GLubyte *clipmask,
    228                        GLuint *p_next_vert,
    229                        GLubyte mask )
     226                       fxVertex *verts,
     227                       GLubyte *clipmask,
     228                       GLuint *p_next_vert,
     229                       GLubyte mask )
    230230{
    231231   GLuint *elts = *p_elts;
     
    266266
    267267static INLINE void TAG(fx_line_clip)( GLuint **p_elts,
    268                                       fxVertex *verts,
    269                                       GLubyte *clipmask,
    270                                       GLuint *p_next_vert,
    271                                       GLubyte mask )
     268                                      fxVertex *verts,
     269                                      GLubyte *clipmask,
     270                                      GLuint *p_next_vert,
     271                                      GLubyte mask )
    272272{
    273273   GLuint *elts = *p_elts;
     
    290290/* Build a table of functions to clip each primitive type.
    291291 */
    292 #define LOCAL_VARS                                                      \
    293    GLuint *elt = VB->EltPtr->data;                                      \
    294    fxVertex *verts = FX_DRIVER_DATA(VB)->verts;                         \
    295    GLuint next_vert = VB->Count;                                        \
    296    GLuint *out = FX_DRIVER_DATA(VB)->clipped_elements.data;             \
     292#define LOCAL_VARS                                                      \
     293   GLuint *elt = VB->EltPtr->data;                                      \
     294   fxVertex *verts = FX_DRIVER_DATA(VB)->verts;                         \
     295   GLuint next_vert = VB->Count;                                        \
     296   GLuint *out = FX_DRIVER_DATA(VB)->clipped_elements.data;             \
    297297   GLubyte *mask = VB->ClipMask;                                        \
    298298
    299299
    300 #define POSTFIX                                                 \
    301    FX_DRIVER_DATA(VB)->clipped_elements.count =                 \
    302           out - FX_DRIVER_DATA(VB)->clipped_elements.data;      \
     300#define POSTFIX                                                 \
     301   FX_DRIVER_DATA(VB)->clipped_elements.count =                 \
     302          out - FX_DRIVER_DATA(VB)->clipped_elements.data;      \
    303303   FX_DRIVER_DATA(VB)->last_vert = &verts[next_vert];
    304304
    305305#define INIT(x)
    306306
    307 #define RENDER_POINTS(start, count)                     \
    308 do {                                                    \
    309    GLuint i;                                            \
    310    for (i = start ; i < count ; i++ )                   \
    311       CLIP_POINT( elt[i] );                             \
     307#define RENDER_POINTS(start, count)                     \
     308do {                                                    \
     309   GLuint i;                                            \
     310   for (i = start ; i < count ; i++ )                   \
     311      CLIP_POINT( elt[i] );                             \
    312312} while (0)
    313313
    314 #define RENDER_LINE(i1, i0)                     \
     314#define RENDER_LINE(i1, i0)                     \
    315315   CLIP_LINE(elt[i1], elt[i0])
    316316
    317 #define RENDER_TRI(i2, i1, i0, pv, parroty)             \
    318 do {                                                    \
    319    GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0];     \
    320    if (parroty) e2 = elt[i1], e1 = elt[i2];             \
    321    CLIP_TRIANGLE( e2, e1, e0 );                         \
     317#define RENDER_TRI(i2, i1, i0, pv, parroty)             \
     318do {                                                    \
     319   GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0];     \
     320   if (parroty) e2 = elt[i1], e1 = elt[i2];             \
     321   CLIP_TRIANGLE( e2, e1, e0 );                         \
    322322} while (0)
    323323
    324 #define RENDER_QUAD(i3, i2, i1, i0, pv)         \
    325   CLIP_TRIANGLE(elt[i3], elt[i2], elt[i0]);     \
     324#define RENDER_QUAD(i3, i2, i1, i0, pv)         \
     325  CLIP_TRIANGLE(elt[i3], elt[i2], elt[i0]);     \
    326326  CLIP_TRIANGLE(elt[i2], elt[i1], elt[i0])
    327327
     
    344344   tab->project_clipped_vertices = TAG(fx_project_clipped_vertices);
    345345
    346 #if defined(USE_3DNOW_ASM) 
     346#if defined(USE_3DNOW_ASM)
    347347   if (gl_x86_cpu_features & GL_CPU_3Dnow) {
    348348      extern void TAG(fx_3dnow_project_vertices)( GLfloat *first,
    349                                                   GLfloat *last,
    350                                                   const GLfloat *mat,
    351                                                   GLuint stride );
     349                                                  GLfloat *last,
     350                                                  const GLfloat *mat,
     351                                                  GLuint stride );
    352352
    353353      extern void TAG(fx_3dnow_project_clipped_vertices)( GLfloat *first,
    354                                                           GLfloat *last,
    355                                                           const GLfloat *mat,
    356                                                           GLuint stride,
    357                                                           const GLubyte *mask );
     354                                                          GLfloat *last,
     355                                                          const GLfloat *mat,
     356                                                          GLuint stride,
     357                                                          const GLubyte *mask );
    358358
    359359      tab->project_vertices = TAG(fx_3dnow_project_vertices);
  • trunk/src/opengl/mesa/3dfx/fxglidew.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.
     
    4343 */
    4444
    45  
     45
    4646#ifdef HAVE_CONFIG_H
    4747#include "conf.h"
     
    5656#include <string.h>
    5757
    58 static FxI32 FX_grGetInteger_NoLock(FxU32 pname)
     58FxI32 FX_grGetInteger_NoLock(FxU32 pname)
    5959{
    6060#if !defined(FX_GLIDE3)
    61   switch (pname) 
     61  switch (pname)
    6262  {
    6363    case FX_FOG_TABLE_ENTRIES:
     
    6868       return FXFALSE;
    6969    case FX_PENDING_BUFFERSWAPS:
    70         return grBufferNumPending();
     70        return grBufferNumPending();
     71    case FX_TEXTURE_ALIGN:
     72        /* This is a guess from reading the glide3 docs */
     73        return 8;
    7174    default:
    7275       if (MESA_VERBOSE&VERBOSE_DRIVER) {
     
    7881  FxU32 grname;
    7982  FxI32 result;
    80  
     83
    8184  switch (pname)
    8285  {
     
    8588     case FX_LFB_PIXEL_PIPE:
    8689     case FX_PENDING_BUFFERSWAPS:
     90     case FX_TEXTURE_ALIGN:
    8791       grname = pname;
    8892       break;
     
    110114
    111115
    112 FxBool FX_grLfbLock(GrLock_t type, GrBuffer_t buffer, 
    113                     GrLfbWriteMode_t writeMode, GrOriginLocation_t origin,
    114                     FxBool pixelPipeline, GrLfbInfo_t *info ) {
     116FxBool FX_grLfbLock(GrLock_t type, GrBuffer_t buffer,
     117                    GrLfbWriteMode_t writeMode, GrOriginLocation_t origin,
     118                    FxBool pixelPipeline, GrLfbInfo_t *info ) {
    115119  FxBool result;
    116120
     
    177181   grGet(GR_FOG_TABLE_ENTRIES,sizeof(int),(void*)&result);
    178182   END_BOARD_LOCK();
    179    return result; 
     183   return result;
    180184}
    181185
     
    188192
    189193   return result;
    190    
     194
    191195}
    192196
     
    198202   grGet(GR_VIEWPORT,sizeof(FxI32)*4,result);
    199203   END_BOARD_LOCK();
    200    
     204
    201205   return result[2];
    202206}
     
    209213   grGet(GR_VIEWPORT,sizeof(FxI32)*4,result);
    210214   END_BOARD_LOCK();
    211    
     215
    212216   return result[3];
    213217}
     
    222226void FX_grSstPerfStats(GrSstPerfStats_t *st)
    223227{
    224   /* ToDo */
    225   st->pixelsIn = 0;
    226   st->chromaFail = 0;
    227   st->zFuncFail = 0;
    228   st->aFuncFail = 0;
    229   st->pixelsOut = 0;
     228  int n;
     229  grGet(GR_STATS_PIXELS_IN, 4, &n);              st->pixelsIn = n;
     230  grGet(GR_STATS_PIXELS_CHROMA_FAIL, 4, &n);     st->chromaFail = n;
     231  grGet(GR_STATS_PIXELS_DEPTHFUNC_FAIL, 4, &n);  st->zFuncFail = n;
     232  grGet(GR_STATS_PIXELS_AFUNC_FAIL, 4, &n);      st->aFuncFail = n;
     233  grGet(GR_STATS_PIXELS_OUT, 4, &n);             st->pixelsOut = n;
    230234}
    231235
     
    245249}
    246250
     251void FX_grDrawPolygonVertexList(int n, GrVertex *verts)
     252{
     253  BEGIN_CLIP_LOOP();
     254  grDrawVertexArrayContiguous(GR_POLYGON, n, verts, sizeof(GrVertex));
     255  END_CLIP_LOOP();
     256}
     257
    247258#if FX_USE_PARGB
    248259void FX_setupGrVertexLayout(void)
     
    250261  BEGIN_BOARD_LOCK();
    251262  grReset(GR_VERTEX_PARAMETER);
    252    
     263
    253264  grCoordinateSpace(GR_WINDOW_COORDS);
    254265  grVertexLayout(GR_PARAM_XY, GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
     
    256267  grVertexLayout(GR_PARAM_Q, GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
    257268  grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE);
    258   grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);       
    259   grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE); 
    260   grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);       
    261   grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);       
     269  grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
     270  grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
     271  grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
     272  grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
    262273  END_BOARD_LOCK();
    263274}
     
    267278  BEGIN_BOARD_LOCK();
    268279  grReset(GR_VERTEX_PARAMETER);
    269    
     280
    270281  grCoordinateSpace(GR_WINDOW_COORDS);
    271282  grVertexLayout(GR_PARAM_XY, GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
     
    273284  grVertexLayout(GR_PARAM_A, GR_VERTEX_A_OFFSET << 2, GR_PARAM_ENABLE);
    274285  grVertexLayout(GR_PARAM_Q, GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
    275   grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE);
    276   grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);       
     286  grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE);
     287  grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
    277288  grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
    278   grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);       
     289  grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
    279290  grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
    280291  END_BOARD_LOCK();
     
    288299    {
    289300      if (hintMask & GR_STWHINT_W_DIFF_TMU0)
    290         grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2,     GR_PARAM_ENABLE);
     301        grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2,     GR_PARAM_ENABLE);
    291302      else
    292         grVertexLayout(GR_PARAM_Q0,GR_VERTEX_OOW_TMU0_OFFSET << 2,      GR_PARAM_DISABLE);
    293      
     303        grVertexLayout(GR_PARAM_Q0,GR_VERTEX_OOW_TMU0_OFFSET << 2,      GR_PARAM_DISABLE);
     304
    294305      if (hintMask & GR_STWHINT_ST_DIFF_TMU1)
    295         grVertexLayout(GR_PARAM_ST1,GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_ENABLE);
     306        grVertexLayout(GR_PARAM_ST1,GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_ENABLE);
    296307      else
    297         grVertexLayout(GR_PARAM_ST1,GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
    298        
     308        grVertexLayout(GR_PARAM_ST1,GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
     309
    299310      if (hintMask & GR_STWHINT_W_DIFF_TMU1)
    300         grVertexLayout(GR_PARAM_Q1,GR_VERTEX_OOW_TMU1_OFFSET << 2,      GR_PARAM_ENABLE);
     311        grVertexLayout(GR_PARAM_Q1,GR_VERTEX_OOW_TMU1_OFFSET << 2,      GR_PARAM_ENABLE);
    301312      else
    302         grVertexLayout(GR_PARAM_Q1,GR_VERTEX_OOW_TMU1_OFFSET << 2,      GR_PARAM_DISABLE);
    303      
     313        grVertexLayout(GR_PARAM_Q1,GR_VERTEX_OOW_TMU1_OFFSET << 2,      GR_PARAM_DISABLE);
     314
    304315    }
    305316  }
     
    320331   grGet(GR_NUM_BOARDS,4,(void*)&(config->num_sst));
    321332   if (config->num_sst == 0)
    322         return 0;
     333        return 0;
    323334   for (i = 0; i< config->num_sst; i++)
    324335   {
     
    327338      grGet(GR_MEMORY_FB,4,(void*)&(config->SSTs[i].sstBoard.VoodooConfig.fbRam));
    328339      config->SSTs[i].sstBoard.VoodooConfig.fbRam/= 1024*1024;
    329      
     340
    330341      grGet(GR_NUM_TMU,4,(void*)&(config->SSTs[i].sstBoard.VoodooConfig.nTexelfx));
    331    
    332      
     342
     343
    333344      grGet(GR_NUM_FB,4,(void*)&numFB);
    334345      if (numFB > 1)
     
    338349      for (j = 0; j < config->SSTs[i].sstBoard.VoodooConfig.nTexelfx; j++)
    339350      {
    340         grGet(GR_MEMORY_TMU,4,(void*)&(config->SSTs[i].sstBoard.VoodooConfig.tmuConfig[j].tmuRam));
    341         config->SSTs[i].sstBoard.VoodooConfig.tmuConfig[j].tmuRam /= 1024*1024;
     351        grGet(GR_MEMORY_TMU,4,(void*)&(config->SSTs[i].sstBoard.VoodooConfig.tmuConfig[j].tmuRam));
     352        config->SSTs[i].sstBoard.VoodooConfig.tmuConfig[j].tmuRam /= 1024*1024;
    342353      }
    343354   }
     
    366377}
    367378
    368 int FX_grSstQueryHardware(GrHwConfiguration *c) 
     379int FX_grSstQueryHardware(GrHwConfiguration *c)
    369380{
    370381   int i;
     
    373384   END_BOARD_LOCK();
    374385   return i;
    375 } 
     386}
    376387
    377388FX_GrContext_t FX_grSstWinOpen( FxU32                hWnd,
     
    392403                     nColBuffers,
    393404                     nAuxBuffers );
    394    
     405
    395406#if 0
    396    fprintf(stderr, 
     407   fprintf(stderr,
    397408           "grSstWinOpen( win %d res %d ref %d fmt %d\n"
    398409           "              org %d ncol %d naux %d )\n"
     
    413424
    414425
    415 #endif 
     426#endif
    416427#else
    417428
  • trunk/src/opengl/mesa/3dfx/fxglidew.h

    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.
     
    4949#include <glide.h>
    5050
    51 /* 
    52  * General context: 
     51/*
     52 * General context:
    5353 */
    5454#if !defined(FX_GLIDE3)
    55      typedef FxU32       FX_GrContext_t;        /* Not used in Glide2 */
     55     typedef FxU32       FX_GrContext_t;        /* Not used in Glide2 */
    5656#else
    5757     typedef GrContext_t FX_GrContext_t;
    5858#endif
    5959
    60 /* 
    61  * Glide3 emulation on Glide2: 
     60/*
     61 * Glide3 emulation on Glide2:
    6262 */
    6363#if !defined(FX_GLIDE3)
    64         /* Constanst for FX_grGetInteger( ) */
    65         #define FX_FOG_TABLE_ENTRIES            0x0004    /* The number of entries in the hardware fog table. */
    66         #define FX_GLIDE_STATE_SIZE             0x0006    /* Size of buffer, in bytes, needed to save Glide state. */
    67         #define FX_LFB_PIXEL_PIPE               0x0009    /* 1 if LFB writes can go through the 3D pixel pipe. */               
    68         #define FX_PENDING_BUFFERSWAPS          0x0014    /* The number of buffer swaps pending. */
    69 #else
    70         #define FX_FOG_TABLE_ENTRIES            GR_FOG_TABLE_ENTRIES 
    71         #define FX_GLIDE_STATE_SIZE             GR_GLIDE_STATE_SIZE
    72         #define FX_LFB_PIXEL_PIPE               GR_LFB_PIXEL_PIPE               
    73         #define FX_PENDING_BUFFERSWAPS          GR_PENDING_BUFFERSWAPS 
     64        /* Constanst for FX_grGetInteger( ) */
     65        #define FX_FOG_TABLE_ENTRIES            0x0004    /* The number of entries in the hardware fog table. */
     66        #define FX_GLIDE_STATE_SIZE             0x0006    /* Size of buffer, in bytes, needed to save Glide state. */
     67        #define FX_LFB_PIXEL_PIPE               0x0009    /* 1 if LFB writes can go through the 3D pixel pipe. */
     68        #define FX_PENDING_BUFFERSWAPS          0x0014    /* The number of buffer swaps pending. */
     69        #define FX_TEXTURE_ALIGN                0x0024    /* The required alignment for textures */
     70#else
     71        #define FX_FOG_TABLE_ENTRIES            GR_FOG_TABLE_ENTRIES
     72        #define FX_GLIDE_STATE_SIZE             GR_GLIDE_STATE_SIZE
     73        #define FX_LFB_PIXEL_PIPE               GR_LFB_PIXEL_PIPE
     74        #define FX_PENDING_BUFFERSWAPS          GR_PENDING_BUFFERSWAPS
     75        #define FX_TEXTURE_ALIGN                GR_TEXTURE_ALIGN
    7476#endif
    7577
    7678/*
    7779 * Genral warper functions for Glide2/Glide3:
    78  */ 
     80 */
    7981extern FxI32 FX_grGetInteger(FxU32 pname);
     82extern FxI32 FX_grGetInteger_NoLock(FxU32 pname);
    8083
    8184/*
     
    9295#define GR_ASPECT_1x8 GR_ASPECT_LOG2_1x8
    9396
    94 #define GR_LOD_256      GR_LOD_LOG2_256
    95 #define GR_LOD_128      GR_LOD_LOG2_128
    96 #define GR_LOD_64       GR_LOD_LOG2_64
    97 #define GR_LOD_32       GR_LOD_LOG2_32 
    98 #define GR_LOD_16       GR_LOD_LOG2_16
    99 #define GR_LOD_8        GR_LOD_LOG2_8
    100 #define GR_LOD_4        GR_LOD_LOG2_4
    101 #define GR_LOD_2        GR_LOD_LOG2_2
    102 #define GR_LOD_1        GR_LOD_LOG2_1
     97#define GR_LOD_256      GR_LOD_LOG2_256
     98#define GR_LOD_128      GR_LOD_LOG2_128
     99#define GR_LOD_64       GR_LOD_LOG2_64
     100#define GR_LOD_32       GR_LOD_LOG2_32
     101#define GR_LOD_16       GR_LOD_LOG2_16
     102#define GR_LOD_8        GR_LOD_LOG2_8
     103#define GR_LOD_4        GR_LOD_LOG2_4
     104#define GR_LOD_2        GR_LOD_LOG2_2
     105#define GR_LOD_1        GR_LOD_LOG2_1
    103106
    104107#define GR_FOG_WITH_TABLE GR_FOG_WITH_TABLE_ON_Q
     
    164167#define GR_STWHINT_ST_DIFF_TMU2 FXBIT(6)
    165168
    166 #define GR_CONTROL_ACTIVATE             1
    167 #define GR_CONTROL_DEACTIVATE           0
    168 
    169 #define GrState                         void
     169#define GR_CONTROL_ACTIVATE             1
     170#define GR_CONTROL_DEACTIVATE           0
     171
     172#define GrState                         void
    170173
    171174/*
     
    174177typedef struct {
    175178  float  sow;                   /* s texture ordinate (s over w) */
    176   float  tow;                   /* t texture ordinate (t over w) */ 
     179  float  tow;                   /* t texture ordinate (t over w) */
    177180  float  oow;                   /* 1/w (used mipmapping - really 0xfff/w) */
    178181}  GrTmuVertex;
     
    202205#define GR_VERTEX_TOW_TMU1_OFFSET       9
    203206#define GR_VERTEX_OOW_TMU1_OFFSET       10
    204 #define GR_VERTEX_Z_OFFSET              11
    205 
    206 #define GET_PARGB(v)    ((FxU32*)(v))[GR_VERTEX_PARGB_OFFSET]
     207#define GR_VERTEX_Z_OFFSET              11
     208
     209#define GET_PARGB(v)    ((FxU32*)(v))[GR_VERTEX_PARGB_OFFSET]
    207210/* GET_PA: returns the alpha component */
    208211#if GLIDE_ENDIAN == GLIDE_ENDIAN_BIG
    209    #define GET_PA(v)            ((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4]
    210 #else 
    211    #define GET_PA(v)            ((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+3]
    212 #endif 
    213 #define MESACOLOR2PARGB(c)      (c[ACOMP] << 24 | c[GCOMP] << 16 | c[GCOMP] << 8 | c[BCOMP])
    214 #define PACK_4F_ARGB(dest,a,r,g,b) {                                                            \
    215                                              const GLuint cr = (int)r;                          \
    216                                              const GLuint cg = (int)g;                          \
    217                                              const GLuint ca = (int)a;                          \
    218                                              const GLuint cb = (int)b;                          \
    219                                              dest = ca << 24 | cr << 16 | cg << 8 | cb;         \
    220                                         }
     212   #define GET_PA(v)            ((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4]
     213#else
     214   #define GET_PA(v)            ((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+3]
     215#endif
     216#define MESACOLOR2PARGB(c)      (c[ACOMP] << 24 | c[GCOMP] << 16 | c[GCOMP] << 8 | c[BCOMP])
     217#define PACK_4F_ARGB(dest,a,r,g,b) {                                                            \
     218                                             const GLuint cr = (int)r;                          \
     219                                             const GLuint cg = (int)g;                          \
     220                                             const GLuint ca = (int)a;                          \
     221                                             const GLuint cb = (int)b;                          \
     222                                             dest = ca << 24 | cr << 16 | cg << 8 | cb;         \
     223                                        }
    221224
    222225#else /* FX_USE_PARGB */
     
    256259 */
    257260#if defined(FX_GLIDE3)
    258 #define FX_grTexDownloadTable(TMU,type,data)    \
    259   do {                                          \
    260     BEGIN_BOARD_LOCK();                         \
    261     grTexDownloadTable(type,data);              \
    262     END_BOARD_LOCK();                           \
     261#define FX_grTexDownloadTable(TMU,type,data)    \
     262  do {                                          \
     263    BEGIN_BOARD_LOCK();                         \
     264    grTexDownloadTable(type,data);              \
     265    END_BOARD_LOCK();                           \
    263266  } while (0);
    264267#define FX_grTexDownloadTable_NoLock(TMU,type,data) \
    265268  grTexDownloadTable(type, data)
    266269#else
    267 #define FX_grTexDownloadTable(TMU,type,data)    \
    268   do {                                          \
    269     BEGIN_BOARD_LOCK();                         \
    270     grTexDownloadTable(TMU,type,data);          \
    271     END_BOARD_LOCK();                           \
     270#define FX_grTexDownloadTable(TMU,type,data)    \
     271  do {                                          \
     272    BEGIN_BOARD_LOCK();                         \
     273    grTexDownloadTable(TMU,type,data);          \
     274    END_BOARD_LOCK();                           \
    272275  } while (0);
    273276#define FX_grTexDownloadTable_NoLock grTexDownloadTable
     
    278281 */
    279282#if defined(FX_GLIDE3)
    280 #define FX_grFlush()    \
    281   do {                  \
     283#define FX_grFlush()    \
     284  do {                  \
    282285    BEGIN_BOARD_LOCK(); \
    283     grFlush();          \
    284     END_BOARD_LOCK();   \
    285   } while (0)
    286 #else
    287 #define FX_grFlush()    \
    288   do {                  \
     286    grFlush();          \
     287    END_BOARD_LOCK();   \
     288  } while (0)
     289#else
     290#define FX_grFlush()    \
     291  do {                  \
    289292    BEGIN_BOARD_LOCK(); \
    290     grSstIdle();        \
    291     END_BOARD_LOCK();   \
    292   } while (0)
    293 #endif 
    294 
    295 #define FX_grFinish()   \
    296   do {                  \
     293    grSstIdle();        \
     294    END_BOARD_LOCK();   \
     295  } while (0)
     296#endif
     297
     298#define FX_grFinish()   \
     299  do {                  \
    297300    BEGIN_BOARD_LOCK(); \
    298     grFinish();         \
    299     END_BOARD_LOCK();   \
     301    grFinish();         \
     302    END_BOARD_LOCK();   \
    300303  } while (0)
    301304
     
    304307 */
    305308#if defined(FX_GLIDE3)
    306 #define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)         \
    307   do {                          \
    308     BEGIN_BOARD_LOCK();         \
    309     grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,FXFALSE,src_stride,src_data);       \
    310     END_BOARD_LOCK();           \
     309#define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)         \
     310  do {                          \
     311    BEGIN_BOARD_LOCK();         \
     312    grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,FXFALSE,src_stride,src_data);       \
     313    END_BOARD_LOCK();           \
    311314  } while(0)
    312315#else
    313 #define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)         \
    314   do {                          \
    315     BEGIN_BOARD_LOCK();         \
    316     grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data);               \
    317     END_BOARD_LOCK();           \
     316#define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)         \
     317  do {                          \
     318    BEGIN_BOARD_LOCK();         \
     319    grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data);               \
     320    END_BOARD_LOCK();           \
    318321  } while (0)
    319322#endif
     
    322325 * Read region
    323326 */
    324 #define FX_grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data)                     \
    325   do {                          \
    326     BEGIN_BOARD_LOCK();         \
    327     grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data);                           \
    328     END_BOARD_LOCK();           \
     327#define FX_grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data)                     \
     328  do {                          \
     329    BEGIN_BOARD_LOCK();         \
     330    grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data);                           \
     331    END_BOARD_LOCK();           \
    329332  } while (0);
    330333
     
    332335 * Draw triangle
    333336 */
    334 #define FX_grDrawTriangle(a,b,c)        \
    335   do {                                  \
    336     BEGIN_CLIP_LOOP();                  \
    337     grDrawTriangle(a,b,c);              \
    338     END_CLIP_LOOP();                    \
     337#define FX_grDrawTriangle(a,b,c)        \
     338  do {                                  \
     339    BEGIN_CLIP_LOOP();                  \
     340    grDrawTriangle(a,b,c);              \
     341    END_CLIP_LOOP();                    \
    339342  } while (0)
    340343
     
    343346 */
    344347#if defined(FX_GLIDE3)
    345         #define FX_largeLodLog2(info)           (info).largeLodLog2
    346 #else
    347         #define FX_largeLodLog2(info)           (info).largeLod
    348 #endif
    349 
    350 #if defined(FX_GLIDE3)
    351         #define FX_aspectRatioLog2(info)                (info).aspectRatioLog2
    352 #else
    353         #define FX_aspectRatioLog2(info)                (info).aspectRatio
    354 #endif
    355 
    356 #if defined(FX_GLIDE3)
    357         #define FX_smallLodLog2(info)           (info).smallLodLog2
    358 #else
    359         #define FX_smallLodLog2(info)           (info).smallLod
    360 #endif
    361 
    362 #if defined(FX_GLIDE3)
    363         #define FX_lodToValue(val)              ((int)(GR_LOD_256-val))
    364 #else
    365         #define FX_lodToValue(val)              ((int)(val))
    366 #endif
    367 
    368 #if defined(FX_GLIDE3)
    369         #define FX_largeLodValue(info)          ((int)(GR_LOD_256-(info).largeLodLog2))
    370 #else
    371         #define FX_largeLodValue(info)          ((int)(info).largeLod)
     348        #define FX_largeLodLog2(info)           (info).largeLodLog2
     349#else
     350        #define FX_largeLodLog2(info)           (info).largeLod
     351#endif
     352
     353#if defined(FX_GLIDE3)
     354        #define FX_aspectRatioLog2(info)                (info).aspectRatioLog2
     355#else
     356        #define FX_aspectRatioLog2(info)                (info).aspectRatio
     357#endif
     358
     359#if defined(FX_GLIDE3)
     360        #define FX_smallLodLog2(info)           (info).smallLodLog2
     361#else
     362        #define FX_smallLodLog2(info)           (info).smallLod
     363#endif
     364
     365#if defined(FX_GLIDE3)
     366        #define FX_lodToValue(val)              ((int)(GR_LOD_256-val))
     367#else
     368        #define FX_lodToValue(val)              ((int)(val))
     369#endif
     370
     371#if defined(FX_GLIDE3)
     372        #define FX_largeLodValue(info)          ((int)(GR_LOD_256-(info).largeLodLog2))
     373#else
     374        #define FX_largeLodValue(info)          ((int)(info).largeLod)
    372375#endif
    373376#define FX_largeLodValue_NoLock FX_largeLodValue
    374377
    375378#if defined(FX_GLIDE3)
    376         #define FX_smallLodValue(info)          ((int)(GR_LOD_256-(info).smallLodLog2))
    377 #else
    378         #define FX_smallLodValue(info)          ((int)(info).smallLod)
     379        #define FX_smallLodValue(info)          ((int)(GR_LOD_256-(info).smallLodLog2))
     380#else
     381        #define FX_smallLodValue(info)          ((int)(info).smallLod)
    379382#endif
    380383#define FX_smallLodValue_NoLock FX_smallLodValue
    381384
    382385#if defined(FX_GLIDE3)
    383         #define FX_valueToLod(val)              ((GrLOD_t)(GR_LOD_256-val))
    384 #else
    385         #define FX_valueToLod(val)              ((GrLOD_t)(val))
     386        #define FX_valueToLod(val)              ((GrLOD_t)(GR_LOD_256-val))
     387#else
     388        #define FX_valueToLod(val)              ((GrLOD_t)(val))
    386389#endif
    387390
     
    389392 * ScreenWidth/Height stuff.
    390393 */
    391         extern int FX_grSstScreenWidth(void);
    392         extern int FX_grSstScreenHeight(void);
     394        extern int FX_grSstScreenWidth(void);
     395        extern int FX_grSstScreenHeight(void);
    393396
    394397
     
    398401 */
    399402#if defined(FX_GLIDE3)
    400         extern void FX_grGlideGetVersion(char *buf);
    401 #else
    402         #define FX_grGlideGetVersion(b) \
    403         do {                            \
    404           BEGIN_BOARD_LOCK();           \
    405           grGlideGetVersion(b);         \
    406           END_BOARD_LOCK();             \
    407         } while (0)
     403        extern void FX_grGlideGetVersion(char *buf);
     404#else
     405        #define FX_grGlideGetVersion(b) \
     406        do {                            \
     407          BEGIN_BOARD_LOCK();           \
     408          grGlideGetVersion(b);         \
     409          END_BOARD_LOCK();             \
     410        } while (0)
    408411#endif
    409412/*
     
    413416        extern void FX_grSstPerfStats(GrSstPerfStats_t *st);
    414417#else
    415         #define FX_grSstPerfStats(s)    \
    416         do {                            \
    417           BEGIN_BOARD_LOCK();           \
    418           grSstPerfStats(s);            \
    419           END_BOARD_LOCK();             \
    420         } while (0)
     418        #define FX_grSstPerfStats(s)    \
     419        do {                            \
     420          BEGIN_BOARD_LOCK();           \
     421          grSstPerfStats(s);            \
     422          END_BOARD_LOCK();             \
     423        } while (0)
    421424#endif
    422425
     
    431434#if defined(FX_GLIDE3)
    432435        extern void FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask);
    433         extern void FX_grHints(GrHint_t hintType, FxU32 hintMask);
    434 #else
    435         #define FX_grHints(t,m)         \
    436         do {                            \
    437           BEGIN_BOARD_LOCK();           \
    438           grHints(t, m);                \
    439           END_BOARD_LOCK();             \
    440         } while(0)
     436        extern void FX_grHints(GrHint_t hintType, FxU32 hintMask);
     437#else
     438        #define FX_grHints(t,m)         \
     439        do {                            \
     440          BEGIN_BOARD_LOCK();           \
     441          grHints(t, m);                \
     442          END_BOARD_LOCK();             \
     443        } while(0)
    441444        #define FX_grHints_NoLock grHints
    442445#endif
     
    445448 */
    446449#if defined(FX_GLIDE3)
    447         extern void FX_grAADrawLine(GrVertex *a,GrVertex *b);
    448 #else
    449         #define FX_grAADrawLine(a,b)    \
    450         do {                            \
    451           BEGIN_CLIP_LOOP();            \
    452           grAADrawLine(a,b);            \
    453           END_CLIP_LOOP();              \
    454         } while (0)
    455 #endif
    456 
    457 #if defined(FX_GLIDE3)
    458         extern void FX_grAADrawPoint(GrVertex *a);
    459 #else
    460         #define FX_grAADrawPoint(a)     \
    461         do {                            \
    462           BEGIN_CLIP_LOOP();            \
    463           grAADrawPoint(a);             \
    464           END_CLIP_LOOP();              \
    465         } while (0)
     450        extern void FX_grAADrawLine(GrVertex *a,GrVertex *b);
     451#else
     452        #define FX_grAADrawLine(a,b)    \
     453        do {                            \
     454          BEGIN_CLIP_LOOP();            \
     455          grAADrawLine(a,b);            \
     456          END_CLIP_LOOP();              \
     457        } while (0)
     458#endif
     459
     460#if defined(FX_GLIDE3)
     461        extern void FX_grAADrawPoint(GrVertex *a);
     462#else
     463        #define FX_grAADrawPoint(a)     \
     464        do {                            \
     465          BEGIN_CLIP_LOOP();            \
     466          grAADrawPoint(a);             \
     467          END_CLIP_LOOP();              \
     468        } while (0)
    466469#endif
    467470
     
    470473 */
    471474#if defined(FX_GLIDE3)
    472         extern void FX_setupGrVertexLayout(void);
    473 #else
    474         #define FX_setupGrVertexLayout()                do {} while (0)
     475        extern void FX_setupGrVertexLayout(void);
     476#else
     477        #define FX_setupGrVertexLayout()                do {} while (0)
    475478#endif
    476479/*
     
    485488      extern void FX_grGammaCorrectionValue(float val);
    486489#else
    487       #define FX_grGammaCorrectionValue(v)      \
    488       do {                                      \
    489         BEGIN_BOARD_LOCK();                     \
    490         grGammaCorrectionValue(v)               \
    491         END_BOARD_LOCK();                       \
     490      #define FX_grGammaCorrectionValue(v)      \
     491      do {                                      \
     492        BEGIN_BOARD_LOCK();                     \
     493        grGammaCorrectionValue(v)               \
     494        END_BOARD_LOCK();                       \
    492495      } while (0)
    493496#endif
    494497
    495498#if defined(FX_GLIDE3)
    496 #define FX_grSstWinClose(w)     \
    497   do {                          \
    498     BEGIN_BOARD_LOCK();         \
    499     grSstWinClose(w);           \
    500     END_BOARD_LOCK();           \
    501   } while (0)
    502 #else
    503 #define FX_grSstWinClose(w)     \
    504   do {                          \
    505     BEGIN_BOARD_LOCK();         \
    506     grSstWinClose();            \
    507     END_BOARD_LOCK();           \
     499#define FX_grSstWinClose(w)     \
     500  do {                          \
     501    BEGIN_BOARD_LOCK();         \
     502    grSstWinClose(w);           \
     503    END_BOARD_LOCK();           \
     504  } while (0)
     505#else
     506#define FX_grSstWinClose(w)     \
     507  do {                          \
     508    BEGIN_BOARD_LOCK();         \
     509    grSstWinClose();            \
     510    END_BOARD_LOCK();           \
    508511  } while (0)
    509512#endif
     
    519522
    520523
    521 #define FX_grDrawLine(v1, v2)   \
    522   do {                          \
    523     BEGIN_CLIP_LOOP();          \
    524     grDrawLine(v1, v2);         \
    525     END_CLIP_LOOP();            \
    526   } while (0)
    527 
    528 #define FX_grDrawPoint(p)       \
    529   do {                          \
    530     BEGIN_CLIP_LOOP();          \
    531     grDrawPoint(p);             \
    532     END_CLIP_LOOP();            \
    533   } while (0)
    534 
    535 #define FX_grDitherMode(m)      \
    536   do {                          \
    537     BEGIN_BOARD_LOCK();         \
    538     grDitherMode(m);            \
    539     END_BOARD_LOCK();           \
    540   } while (0)
    541 
    542 #define FX_grRenderBuffer(b)    \
    543   do {                          \
    544     BEGIN_BOARD_LOCK();         \
    545     grRenderBuffer(b);          \
    546     END_BOARD_LOCK();           \
    547   } while (0)
    548 
    549 #define FX_grBufferClear(c, a, d)       \
    550   do {                                  \
    551     BEGIN_CLIP_LOOP();                  \
    552     grBufferClear(c, a, d);             \
    553     END_CLIP_LOOP();                    \
    554   } while (0)
    555 
    556 #define FX_grDepthMask(m)       \
    557   do {                          \
    558     BEGIN_BOARD_LOCK();         \
    559     grDepthMask(m);             \
    560     END_BOARD_LOCK();           \
    561   } while (0)
    562 
    563 #define FX_grColorMask(c, a)    \
    564   do {                          \
    565     BEGIN_BOARD_LOCK();         \
    566     grColorMask(c, a);          \
    567     END_BOARD_LOCK();           \
    568   } while (0)
    569 
    570 extern FxBool FX_grLfbLock(GrLock_t type, GrBuffer_t buffer,
    571                            GrLfbWriteMode_t writeMode,
    572                            GrOriginLocation_t origin, FxBool pixelPipeline,
    573                            GrLfbInfo_t *info );
    574 
    575 #define FX_grLfbUnlock(t, b)    \
    576   do {                          \
    577     BEGIN_BOARD_LOCK();         \
    578     grLfbUnlock(t, b);          \
    579     END_BOARD_LOCK();           \
    580   } while (0)
    581 
    582 #define FX_grConstantColorValue(v)      \
    583   do {                                  \
    584     BEGIN_BOARD_LOCK();                 \
    585     grConstantColorValue(v);            \
    586     END_BOARD_LOCK();                   \
     524#define FX_grDrawLine(v1, v2)   \
     525  do {                          \
     526    BEGIN_CLIP_LOOP();          \
     527    grDrawLine(v1, v2);         \
     528    END_CLIP_LOOP();            \
     529  } while (0)
     530
     531#define FX_grDrawPoint(p)       \
     532  do {                          \
     533    BEGIN_CLIP_LOOP();          \
     534    grDrawPoint(p);             \
     535    END_CLIP_LOOP();            \
     536  } while (0)
     537
     538#if defined(FX_GLIDE3)
     539extern void FX_grDrawPolygonVertexList(int n, GrVertex *v);
     540#else
     541#define FX_grDrawPolygonVertexList(n, v)        \
     542  do {                                          \
     543    BEGIN_CLIP_LOOP();                          \
     544    grDrawPolygonVertexList(n, v);              \
     545    END_CLIP_LOOP();                            \
     546  } while (0)
     547#endif
     548
     549#define FX_grDitherMode(m)      \
     550  do {                          \
     551    BEGIN_BOARD_LOCK();         \
     552    grDitherMode(m);            \
     553    END_BOARD_LOCK();           \
     554  } while (0)
     555
     556#define FX_grRenderBuffer(b)    \
     557  do {                          \
     558    BEGIN_BOARD_LOCK();         \
     559    grRenderBuffer(b);          \
     560    END_BOARD_LOCK();           \
     561  } while (0)
     562
     563#define FX_grBufferClear(c, a, d)       \
     564  do {                                  \
     565    BEGIN_CLIP_LOOP();                  \
     566    grBufferClear(c, a, d);             \
     567    END_CLIP_LOOP();                    \
     568  } while (0)
     569
     570#define FX_grDepthMask(m)       \
     571  do {                          \
     572    BEGIN_BOARD_LOCK();         \
     573    grDepthMask(m);             \
     574    END_BOARD_LOCK();           \
     575  } while (0)
     576
     577#define FX_grColorMask(c, a)    \
     578  do {                          \
     579    BEGIN_BOARD_LOCK();         \
     580    grColorMask(c, a);          \
     581    END_BOARD_LOCK();           \
     582  } while (0)
     583
     584extern FxBool FX_grLfbLock(GrLock_t type, GrBuffer_t buffer,
     585                           GrLfbWriteMode_t writeMode,
     586                           GrOriginLocation_t origin, FxBool pixelPipeline,
     587                           GrLfbInfo_t *info );
     588
     589#define FX_grLfbUnlock(t, b)    \
     590  do {                          \
     591    BEGIN_BOARD_LOCK();         \
     592    grLfbUnlock(t, b);          \
     593    END_BOARD_LOCK();           \
     594  } while (0)
     595
     596#define FX_grConstantColorValue(v)      \
     597  do {                                  \
     598    BEGIN_BOARD_LOCK();                 \
     599    grConstantColorValue(v);            \
     600    END_BOARD_LOCK();                   \
    587601  } while (0)
    588602
    589603#define FX_grConstantColorValue_NoLock grConstantColorValue
    590604
    591 #define FX_grAADrawTriangle(a, b, c, ab, bc, ca)        \
    592   do {                                                  \
    593     BEGIN_CLIP_LOOP();                                  \
    594     grAADrawTriangle(a, b, c, ab, bc, ca);              \
    595     END_CLIP_LOOP();                                    \
    596   } while (0)
    597 
    598 #define FX_grAlphaBlendFunction(rs, rd, as, ad) \
    599   do {                                          \
    600     BEGIN_BOARD_LOCK();                         \
    601     grAlphaBlendFunction(rs, rd, as, ad);       \
    602     END_BOARD_LOCK();                           \
    603   } while (0)
    604 
    605 #define FX_grAlphaCombine(func, fact, loc, oth, inv)    \
    606   do {                                                  \
    607     BEGIN_BOARD_LOCK();                                 \
    608     grAlphaCombine(func, fact, loc, oth, inv);          \
    609     END_BOARD_LOCK();                                   \
     605#define FX_grAADrawTriangle(a, b, c, ab, bc, ca)        \
     606  do {                                                  \
     607    BEGIN_CLIP_LOOP();                                  \
     608    grAADrawTriangle(a, b, c, ab, bc, ca);              \
     609    END_CLIP_LOOP();                                    \
     610  } while (0)
     611
     612#define FX_grAlphaBlendFunction(rs, rd, as, ad) \
     613  do {                                          \
     614    BEGIN_BOARD_LOCK();                         \
     615    grAlphaBlendFunction(rs, rd, as, ad);       \
     616    END_BOARD_LOCK();                           \
     617  } while (0)
     618
     619#define FX_grAlphaCombine(func, fact, loc, oth, inv)    \
     620  do {                                                  \
     621    BEGIN_BOARD_LOCK();                                 \
     622    grAlphaCombine(func, fact, loc, oth, inv);          \
     623    END_BOARD_LOCK();                                   \
    610624  } while (0)
    611625
    612626#define FX_grAlphaCombine_NoLock grAlphaCombine
    613627
    614 #define FX_grAlphaTestFunction(f)       \
    615   do {                                  \
    616     BEGIN_BOARD_LOCK();                 \
    617     grAlphaTestFunction(f);             \
    618     END_BOARD_LOCK();                   \
    619   } while (0)
    620 
    621 #define FX_grAlphaTestReferenceValue(v) \
    622   do {                                  \
    623     BEGIN_BOARD_LOCK();                 \
    624     grAlphaTestReferenceValue(v);       \
    625     END_BOARD_LOCK();                   \
    626   } while (0)
    627 
    628 #define FX_grClipWindow(minx, miny, maxx, maxy) \
    629   do {                                          \
    630     BEGIN_BOARD_LOCK();                         \
    631     grClipWindow(minx, miny, maxx, maxy);       \
    632     END_BOARD_LOCK();                           \
     628#define FX_grAlphaTestFunction(f)       \
     629  do {                                  \
     630    BEGIN_BOARD_LOCK();                 \
     631    grAlphaTestFunction(f);             \
     632    END_BOARD_LOCK();                   \
     633  } while (0)
     634
     635#define FX_grAlphaTestReferenceValue(v) \
     636  do {                                  \
     637    BEGIN_BOARD_LOCK();                 \
     638    grAlphaTestReferenceValue(v);       \
     639    END_BOARD_LOCK();                   \
     640  } while (0)
     641
     642#define FX_grClipWindow(minx, miny, maxx, maxy) \
     643  do {                                          \
     644    BEGIN_BOARD_LOCK();                         \
     645    grClipWindow(minx, miny, maxx, maxy);       \
     646    END_BOARD_LOCK();                           \
    633647  } while (0)
    634648
    635649#define FX_grClipWindow_NoLock grClipWindow
    636650
    637 #define FX_grColorCombine(func, fact, loc, oth, inv)    \
    638   do {                                                  \
    639     BEGIN_BOARD_LOCK();                                 \
    640     grColorCombine(func, fact, loc, oth, inv);          \
    641     END_BOARD_LOCK();                                   \
     651#define FX_grColorCombine(func, fact, loc, oth, inv)    \
     652  do {                                                  \
     653    BEGIN_BOARD_LOCK();                                 \
     654    grColorCombine(func, fact, loc, oth, inv);          \
     655    END_BOARD_LOCK();                                   \
    642656  } while (0)
    643657
    644658#define FX_grColorCombine_NoLock grColorCombine
    645659
    646 #define FX_grCullMode(m)        \
    647   do {                          \
    648     BEGIN_BOARD_LOCK();         \
    649     grCullMode(m);              \
    650     END_BOARD_LOCK();           \
    651   } while (0)
    652 
    653 #define FX_grDepthBiasLevel(lev)        \
    654   do {                                  \
    655     BEGIN_BOARD_LOCK();                 \
    656     grDepthBiasLevel(lev);              \
    657     END_BOARD_LOCK();                   \
    658   } while (0)
    659 
    660 #define FX_grDepthBufferFunction(func)  \
    661   do {                                  \
    662     BEGIN_BOARD_LOCK();                 \
    663     grDepthBufferFunction(func);        \
    664     END_BOARD_LOCK();                   \
    665   } while (0)
    666 
    667 #define FX_grFogColorValue(c)           \
    668   do {                                  \
    669     BEGIN_BOARD_LOCK();                 \
    670     grFogColorValue(c);                 \
    671     END_BOARD_LOCK();                   \
    672   } while (0)
    673 
    674 #define FX_grFogMode(m) \
    675   do {                  \
     660#define FX_grCullMode(m)        \
     661  do {                          \
     662    BEGIN_BOARD_LOCK();         \
     663    grCullMode(m);              \
     664    END_BOARD_LOCK();           \
     665  } while (0)
     666
     667#define FX_grDepthBiasLevel(lev)        \
     668  do {                                  \
     669    BEGIN_BOARD_LOCK();                 \
     670    grDepthBiasLevel(lev);              \
     671    END_BOARD_LOCK();                   \
     672  } while (0)
     673
     674#define FX_grDepthBufferFunction(func)  \
     675  do {                                  \
     676    BEGIN_BOARD_LOCK();                 \
     677    grDepthBufferFunction(func);        \
     678    END_BOARD_LOCK();                   \
     679  } while (0)
     680
     681#define FX_grFogColorValue(c)           \
     682  do {                                  \
     683    BEGIN_BOARD_LOCK();                 \
     684    grFogColorValue(c);                 \
     685    END_BOARD_LOCK();                   \
     686  } while (0)
     687
     688#define FX_grFogMode(m) \
     689  do {                  \
    676690    BEGIN_BOARD_LOCK(); \
    677     grFogMode(m);       \
    678     END_BOARD_LOCK();   \
    679   } while (0)
    680 
    681 #define FX_grFogTable(t)        \
    682   do {                          \
    683     BEGIN_BOARD_LOCK();         \
    684     grFogTable(t);              \
    685     END_BOARD_LOCK();           \
    686   } while (0)
    687 
    688 #define FX_grTexClampMode(t, sc, tc)    \
    689   do {                                  \
    690     BEGIN_BOARD_LOCK();                 \
    691     grTexClampMode(t, sc, tc);          \
    692     END_BOARD_LOCK();                   \
     691    grFogMode(m);       \
     692    END_BOARD_LOCK();   \
     693  } while (0)
     694
     695#define FX_grFogTable(t)        \
     696  do {                          \
     697    BEGIN_BOARD_LOCK();         \
     698    grFogTable(t);              \
     699    END_BOARD_LOCK();           \
     700  } while (0)
     701
     702#define FX_grTexClampMode(t, sc, tc)    \
     703  do {                                  \
     704    BEGIN_BOARD_LOCK();                 \
     705    grTexClampMode(t, sc, tc);          \
     706    END_BOARD_LOCK();                   \
    693707  } while (0)
    694708
    695709#define FX_grTexClampMode_NoLock grTexClampMode
    696710
    697 #define FX_grTexCombine(t, rfunc, rfact, afunc, afact, rinv, ainv)      \
    698   do {                                                                  \
    699     BEGIN_BOARD_LOCK();                                                 \
    700     grTexCombine(t, rfunc, rfact, afunc, afact, rinv, ainv);            \
    701     END_BOARD_LOCK();                                                   \
     711#define FX_grTexCombine(t, rfunc, rfact, afunc, afact, rinv, ainv)      \
     712  do {                                                                  \
     713    BEGIN_BOARD_LOCK();                                                 \
     714    grTexCombine(t, rfunc, rfact, afunc, afact, rinv, ainv);            \
     715    END_BOARD_LOCK();                                                   \
    702716  } while (0)
    703717
    704718#define FX_grTexCombine_NoLock grTexCombine
    705719
    706 #define FX_grTexDownloadMipMapLevel(t, sa, tlod, llod, ar, f, eo, d)    \
    707   do {                                                                  \
    708     BEGIN_BOARD_LOCK();                                                 \
    709     grTexDownloadMipMapLevel(t, sa, tlod, llod, ar, f, eo, d);          \
    710     END_BOARD_LOCK();                                                   \
     720#define FX_grTexDownloadMipMapLevel(t, sa, tlod, llod, ar, f, eo, d)    \
     721  do {                                                                  \
     722    BEGIN_BOARD_LOCK();                                                 \
     723    grTexDownloadMipMapLevel(t, sa, tlod, llod, ar, f, eo, d);          \
     724    END_BOARD_LOCK();                                                   \
    711725  } while (0)
    712726
    713727#define FX_grTexDownloadMipMapLevel_NoLock grTexDownloadMipMapLevel
    714728
    715 #define FX_grTexDownloadMipMapLevelPartial(t, sa, tlod, llod, ar, f, eo, d, s, e);      \
    716   do {                                                                      \
    717     BEGIN_BOARD_LOCK();                                                     \
     729#define FX_grTexDownloadMipMapLevelPartial(t, sa, tlod, llod, ar, f, eo, d, s, e);      \
     730  do {                                                                      \
     731    BEGIN_BOARD_LOCK();                                                     \
    718732    grTexDownloadMipMapLevelPartial(t, sa, tlod, llod, ar, f, eo, d, s, e); \
    719     END_BOARD_LOCK();                                                       \
    720   } while (0)
    721 
    722 #define FX_grTexFilterMode(t, minf, magf)       \
    723   do {                                          \
    724     BEGIN_BOARD_LOCK();                         \
    725     grTexFilterMode(t, minf, magf);             \
    726     END_BOARD_LOCK();                           \
     733    END_BOARD_LOCK();                                                       \
     734  } while (0)
     735
     736#define FX_grTexFilterMode(t, minf, magf)       \
     737  do {                                          \
     738    BEGIN_BOARD_LOCK();                         \
     739    grTexFilterMode(t, minf, magf);             \
     740    END_BOARD_LOCK();                           \
    727741  } while (0)
    728742
     
    732746extern FxU32 FX_grTexMaxAddress(GrChipID_t tmu);
    733747
    734 #define FX_grTexMipMapMode(t, m, lod)   \
    735   do {                                  \
    736     BEGIN_BOARD_LOCK();                 \
    737     grTexMipMapMode(t, m, lod);         \
    738     END_BOARD_LOCK();                   \
     748#define FX_grTexMipMapMode(t, m, lod)   \
     749  do {                                  \
     750    BEGIN_BOARD_LOCK();                 \
     751    grTexMipMapMode(t, m, lod);         \
     752    END_BOARD_LOCK();                   \
    739753  } while (0)
    740754
    741755#define FX_grTexMipMapMode_NoLock grTexMipMapMode
    742756
    743 #define FX_grTexSource(t, sa, eo, i)    \
    744   do {                                  \
    745     BEGIN_BOARD_LOCK();                 \
    746     grTexSource(t, sa, eo, i);          \
    747     END_BOARD_LOCK();                   \
     757#define FX_grTexSource(t, sa, eo, i)    \
     758  do {                                  \
     759    BEGIN_BOARD_LOCK();                 \
     760    grTexSource(t, sa, eo, i);          \
     761    END_BOARD_LOCK();                   \
    748762  } while (0)
    749763
     
    753767#define FX_grTexTextureMemRequired_NoLock grTexTextureMemRequired
    754768
    755 #define FX_grGlideGetState(s)   \
    756   do {                          \
    757     BEGIN_BOARD_LOCK();         \
    758     grGlideGetState(s);         \
    759     END_BOARD_LOCK();           \
    760   } while (0)
    761 
    762 #define FX_grDRIBufferSwap(i)   \
    763   do {                          \
    764     BEGIN_BOARD_LOCK();         \
    765     grDRIBufferSwap(i);         \
    766     END_BOARD_LOCK();           \
    767   } while (0)
    768 
    769 #define FX_grSstSelect(b)       \
    770   do {                          \
    771     BEGIN_BOARD_LOCK();         \
    772     grSstSelect(b);             \
    773     END_BOARD_LOCK();           \
     769#define FX_grGlideGetState(s)   \
     770  do {                          \
     771    BEGIN_BOARD_LOCK();         \
     772    grGlideGetState(s);         \
     773    END_BOARD_LOCK();           \
     774  } while (0)
     775#define FX_grGlideGetState_NoLock(s) grGlideGetState(s);
     776
     777#define FX_grDRIBufferSwap(i)   \
     778  do {                          \
     779    BEGIN_BOARD_LOCK();         \
     780    grDRIBufferSwap(i);         \
     781    END_BOARD_LOCK();           \
     782  } while (0)
     783
     784#define FX_grSstSelect(b)       \
     785  do {                          \
     786    BEGIN_BOARD_LOCK();         \
     787    grSstSelect(b);             \
     788    END_BOARD_LOCK();           \
    774789  } while (0)
    775790
    776791#define FX_grSstSelect_NoLock grSstSelect
    777792
    778 #define FX_grGlideSetState(s)   \
    779   do {                          \
    780     BEGIN_BOARD_LOCK();         \
    781     grGlideSetState(s);         \
    782     END_BOARD_LOCK();           \
    783   } while (0)
    784 
    785 #define FX_grDepthBufferMode(m) \
    786   do {                          \
    787     BEGIN_BOARD_LOCK();         \
    788     grDepthBufferMode(m);       \
    789     END_BOARD_LOCK();           \
    790   } while (0)
    791 
    792 #define FX_grLfbWriteColorFormat(f)     \
    793   do {                                  \
    794     BEGIN_BOARD_LOCK();                 \
    795     grLfbWriteColorFormat(f);           \
    796     END_BOARD_LOCK();                   \
    797   } while (0)
    798 
    799 #define FX_grDrawVertexArray(m, c, p)   \
    800   do {                                  \
    801     BEGIN_CLIP_LOOP();                  \
    802     grDrawVertexArray(m, c, p);         \
    803     END_CLIP_LOOP();                    \
    804   } while (0)
    805 
    806 #define FX_grGlideShutdown()            \
    807   do {                                  \
    808     BEGIN_CLIP_LOOP();                  \
    809     grGlideShutdown();                  \
    810     END_CLIP_LOOP();                    \
     793#define FX_grGlideSetState(s)   \
     794  do {                          \
     795    BEGIN_BOARD_LOCK();         \
     796    grGlideSetState(s);         \
     797    END_BOARD_LOCK();           \
     798  } while (0)
     799#define FX_grGlideSetState_NoLock(s) grGlideSetState(s);
     800
     801#define FX_grDepthBufferMode(m) \
     802  do {                          \
     803    BEGIN_BOARD_LOCK();         \
     804    grDepthBufferMode(m);       \
     805    END_BOARD_LOCK();           \
     806  } while (0)
     807
     808#define FX_grLfbWriteColorFormat(f)     \
     809  do {                                  \
     810    BEGIN_BOARD_LOCK();                 \
     811    grLfbWriteColorFormat(f);           \
     812    END_BOARD_LOCK();                   \
     813  } while (0)
     814
     815#define FX_grDrawVertexArray(m, c, p)   \
     816  do {                                  \
     817    BEGIN_CLIP_LOOP();                  \
     818    grDrawVertexArray(m, c, p);         \
     819    END_CLIP_LOOP();                    \
     820  } while (0)
     821
     822#define FX_grGlideShutdown()            \
     823  do {                                  \
     824    BEGIN_CLIP_LOOP();                  \
     825    grGlideShutdown();                  \
     826    END_CLIP_LOOP();                    \
    811827  } while (0)
    812828
  • trunk/src/opengl/mesa/3dfx/fxpipeline.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.
     
    6565       ((ctx->Texture.ReallyEnabled & 0xf) && VB->TexCoordPtr[0]->size>2) ||
    6666       ((ctx->Texture.ReallyEnabled & 0xf0) && VB->TexCoordPtr[1]->size>2) ||
    67         (VB->ClipPtr->size != 4)) /* Brokes clipping otherwise */
     67        (VB->ClipPtr->size != 4))              /* Brokes clipping otherwise*/
    6868      gl_render_elts( VB );
    69    else 
     69   else
    7070      fxDDRenderElementsDirect( VB );
    7171}
    7272
    73 static void fxDDCheckRenderVBIndirect( GLcontext *ctx, 
    74                                        struct gl_pipeline_stage *d )
    75 {   
     73static void fxDDCheckRenderVBIndirect( GLcontext *ctx,
     74                                       struct gl_pipeline_stage *d )
     75{
    7676   d->type = 0;
    7777
    7878   if ((ctx->IndirectTriangles & DD_SW_SETUP) == 0 &&
    79        ctx->Driver.MultipassFunc == 0) 
     79       ctx->Driver.MultipassFunc == 0)
    8080   {
    8181      d->type = PIPE_IMMEDIATE;
    8282      d->inputs = VERT_SETUP_FULL | VERT_ELT | VERT_PRECALC_DATA;
    83    }     
     83   }
    8484}
    8585
     
    122122 */
    123123GLuint fxDDRegisterPipelineStages( struct gl_pipeline_stage *out,
    124                                    const struct gl_pipeline_stage *in,
    125                                    GLuint nr )
     124                                   const struct gl_pipeline_stage *in,
     125                                   GLuint nr )
    126126{
    127127   GLuint i, o;
     
    130130      switch (in[i].ops) {
    131131      case PIPE_OP_RAST_SETUP_1|PIPE_OP_RENDER:
    132         out[o] = in[i];
    133         out[o].state_change = NEW_CLIENT_STATE;
    134         out[o].check = fxDDCheckMergeAndRender;
    135          out[o].run = fxDDMergeAndRender;       
    136         o++;
    137         break;
     132        out[o] = in[i];
     133        out[o].state_change = NEW_CLIENT_STATE;
     134        out[o].check = fxDDCheckMergeAndRender;
     135         out[o].run = fxDDMergeAndRender;
     136        o++;
     137        break;
    138138      case PIPE_OP_RAST_SETUP_0:
    139         out[o] = in[i];
    140         out[o].cva_state_change = NEW_LIGHTING|NEW_TEXTURING|NEW_RASTER_OPS;
    141         out[o].state_change = ~0;
    142         out[o].check = fxDDCheckPartialRasterSetup;
    143         out[o].run = fxDDPartialRasterSetup;
    144         o++;
    145         break;
     139        out[o] = in[i];
     140        out[o].cva_state_change = NEW_LIGHTING|NEW_TEXTURING|NEW_RASTER_OPS;
     141        out[o].state_change = ~0;
     142        out[o].check = fxDDCheckPartialRasterSetup;
     143        out[o].run = fxDDPartialRasterSetup;
     144        o++;
     145        break;
    146146      case PIPE_OP_RAST_SETUP_0|PIPE_OP_RAST_SETUP_1:
    147         out[o] = in[i];
    148         out[o].run = fxDDDoRasterSetup;
    149         o++;
    150         break;
     147        out[o] = in[i];
     148        out[o].run = fxDDDoRasterSetup;
     149        o++;
     150        break;
    151151      case PIPE_OP_RENDER:
    152         out[o] = in[i];
    153         if (in[i].run == gl_render_elts) {
    154             out[o].run = fxDDRenderElements;
    155         } else if (in[i].run == gl_render_vb_indirect) {
    156             out[o].check = fxDDCheckRenderVBIndirect;
    157             out[o].run = fxDDRenderVBIndirect;
    158         } else if (in[i].run == gl_render_vb) {
    159             out[o].run = fxDDRenderVB;
    160         }
    161 
    162         o++;
    163         break;
     152        out[o] = in[i];
     153        if (in[i].run == gl_render_elts) {
     154            out[o].run = fxDDRenderElements;
     155        } else if (in[i].run == gl_render_vb_indirect) {
     156            out[o].check = fxDDCheckRenderVBIndirect;
     157            out[o].run = fxDDRenderVBIndirect;
     158        } else if (in[i].run == gl_render_vb) {
     159            out[o].run = fxDDRenderVB;
     160        }
     161
     162        o++;
     163        break;
    164164      default:
    165         out[o++] = in[i];
    166         break;
     165        out[o++] = in[i];
     166        break;
    167167      }
    168168   }
     
    171171}
    172172
    173 #define ILLEGAL_ENABLES (TEXTURE0_3D|           \
    174                          TEXTURE1_3D|           \
    175                          ENABLE_TEXMAT0 |       \
    176                          ENABLE_TEXMAT1 |       \
    177                          ENABLE_TEXGEN0 |       \
    178                          ENABLE_TEXGEN1 |       \
    179                          ENABLE_USERCLIP |      \
    180                          ENABLE_LIGHT |         \
    181                         ENABLE_FOG)
    182 
    183 
    184                          
     173#define ILLEGAL_ENABLES (TEXTURE0_3D|           \
     174                         TEXTURE1_3D|           \
     175                         ENABLE_TEXMAT0 |       \
     176                         ENABLE_TEXMAT1 |       \
     177                         ENABLE_TEXGEN0 |       \
     178                         ENABLE_TEXGEN1 |       \
     179                         ENABLE_USERCLIP |      \
     180                         ENABLE_LIGHT |         \
     181                        ENABLE_FOG)
     182
     183
     184
    185185/* Because this is slotted in by the OptimizePipeline function, most
    186186 * of the information here is just for gl_print_pipeline().  Only the
    187  * run member is required. 
     187 * run member is required.
    188188 */
    189189static struct gl_pipeline_stage fx_fast_stage = {
     
    199199   0,
    200200   0,
    201    0,                           /* never called */
     201   0,                           /* never called */
    202202   fxDDFastPath
    203203};
     
    210210 */
    211211GLboolean fxDDBuildPrecalcPipeline( GLcontext *ctx )
    212 {   
     212{
    213213   struct gl_pipeline *pipe = &ctx->CVA.pre;
    214214   fxMesaContext fxMesa = FX_CONTEXT(ctx);
    215    
     215
    216216
    217217   if (fxMesa->is_in_hardware &&
    218        fxMesa->render_index == 0 && 
     218       fxMesa->render_index == 0 &&
    219219       (ctx->Enabled & ILLEGAL_ENABLES) == 0 &&
    220220       (ctx->Array.Flags & (VERT_OBJ_234|
    221                             VERT_TEX0_4|
    222                             VERT_TEX1_4|
    223                             VERT_ELT)) == (VERT_OBJ_23|VERT_ELT))
     221                            VERT_TEX0_4|
     222                            VERT_TEX1_4|
     223                            VERT_ELT)) == (VERT_OBJ_23|VERT_ELT))
    224224   {
    225       if (MESA_VERBOSE & (VERBOSE_STATE|VERBOSE_DRIVER)) 
    226         if (!fxMesa->using_fast_path)
    227             fprintf(stderr, "fxMesa: using fast path\n");
     225      if (MESA_VERBOSE & (VERBOSE_STATE|VERBOSE_DRIVER))
     226        if (!fxMesa->using_fast_path)
     227            fprintf(stderr, "fxMesa: using fast path\n");
    228228
    229229      pipe->stages[0] = &fx_fast_stage;
     
    233233      fxMesa->using_fast_path = 1;
    234234      return 1;
    235    } 
    236 
    237    if (fxMesa->using_fast_path) 
     235   }
     236
     237   if (fxMesa->using_fast_path)
    238238   {
    239       if (MESA_VERBOSE & (VERBOSE_STATE|VERBOSE_DRIVER)) 
    240          fprintf(stderr, "fxMesa: fall back to full pipeline %x %x %x %x %x\n",
    241                 fxMesa->is_in_hardware,
    242                 fxMesa->render_index,
    243                 (ctx->Enabled & ILLEGAL_ENABLES),
    244                 (ctx->Array.Summary & (VERT_OBJ_23)),
    245                 (ctx->Array.Summary & (VERT_OBJ_4|VERT_TEX0_4|VERT_TEX1_4)));
     239      if (MESA_VERBOSE & (VERBOSE_STATE|VERBOSE_DRIVER))
     240         fprintf(stderr, "fxMesa: fall back to full pipeline %x %x %x %x %x\n",
     241                fxMesa->is_in_hardware,
     242                fxMesa->render_index,
     243                (ctx->Enabled & ILLEGAL_ENABLES),
     244                (ctx->Array.Summary & (VERT_OBJ_23)),
     245                (ctx->Array.Summary & (VERT_OBJ_4|VERT_TEX0_4|VERT_TEX1_4)));
    246246
    247247      fxMesa->using_fast_path = 0;
     
    251251      return 0;
    252252   }
    253    
     253
    254254   return 0;
    255255}
     
    271271
    272272   if (fxMesa->is_in_hardware &&
    273        fxMesa->render_index == 0 && 
     273       fxMesa->render_index == 0 &&
    274274       (ctx->Enabled & ILLEGAL_ENABLES) == 0 &&
    275275       (ctx->Array.Summary & VERT_ELT))
  • trunk/src/opengl/mesa/3dfx/fxrender.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.
     
    6060 * endpoints must be clipped.
    6161 */
    62 #if !defined(__MWERKS__) 
     62#if !defined(__MWERKS__)
    6363INLINE
    6464#endif
    65 void fxRenderClippedLine( struct vertex_buffer *VB, 
    66                                 GLuint v1, GLuint v2 )
     65void fxRenderClippedLine( struct vertex_buffer *VB,
     66                                GLuint v1, GLuint v2 )
    6767{
    6868  fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
     
    7979 */
    8080INLINE void fxRenderClippedTriangle( struct vertex_buffer *VB,
    81                                         GLuint n, GLuint vlist[] )
     81                                        GLuint n, GLuint vlist[] )
    8282{
    8383  GLubyte mask = 0;
     
    9292      return;
    9393  }
    94    
     94
    9595  n = (VB->ctx->poly_clip_tab[VB->ClipPtr->size])( VB, n, vlist, mask );
    9696  if (n >= 3) {
     
    100100    GrVertex *i2 = (GrVertex *)gWin[vlist[2]].f;
    101101    GLuint i;
    102      
     102
    103103    for (i=2;i<n;i++, i1 = i2, i2 = (GrVertex *)gWin[vlist[i]].f) {
    104104      FX_grDrawTriangle(i0,i1,i2);
     
    111111
    112112
    113 static INLINE void fxSafeClippedLine( struct vertex_buffer *VB, 
    114                                       GLuint v1, GLuint v2 )
     113static INLINE void fxSafeClippedLine( struct vertex_buffer *VB,
     114                                      GLuint v1, GLuint v2 )
    115115{
    116116  GLubyte mask = VB->ClipMask[v1] | VB->ClipMask[v2];
     
    127127
    128128static INLINE void fxSafeClippedTriangle( struct vertex_buffer *VB,
    129                                           fxVertex *gWin,
    130                                           tfxTriClipFunc cliptri,
    131                                           GLuint v2, GLuint v1, GLuint v )
     129                                          fxVertex *gWin,
     130                                          tfxTriClipFunc cliptri,
     131                                          GLuint v2, GLuint v1, GLuint v )
    132132{
    133133  GLubyte *clipmask = VB->ClipMask;
     
    136136  if (!mask) {
    137137    FX_grDrawTriangle((GrVertex *)gWin[v2].f,
    138                       (GrVertex *)gWin[v1].f,
    139                       (GrVertex *)gWin[v].f);
     138                      (GrVertex *)gWin[v1].f,
     139                      (GrVertex *)gWin[v].f);
    140140    return;
    141141  }
     
    149149      GLubyte *userclipmask = VB->UserClipMask;
    150150      if (userclipmask[v2] & userclipmask[v1] & userclipmask[v])
    151         return;
     151        return;
    152152      imask |= (userclipmask[v2] | userclipmask[v1] | userclipmask[v]) << 8;
    153153    }
     
    160160
    161161static INLINE void fxSafeClippedTriangle2( struct vertex_buffer *VB,
    162                                            fxVertex *gWin,
    163                                            tfxTriViewClipFunc cliptri,
    164                                            GLuint v2, GLuint v1, GLuint v )
     162                                           fxVertex *gWin,
     163                                           tfxTriViewClipFunc cliptri,
     164                                           GLuint v2, GLuint v1, GLuint v )
    165165{
    166166  GLubyte *clipmask = VB->ClipMask;
     
    169169  if (!mask) {
    170170    FX_grDrawTriangle((GrVertex *)gWin[v2].f,(GrVertex *)gWin[v1].f,
    171                       (GrVertex *)gWin[v].f);
     171                      (GrVertex *)gWin[v].f);
    172172  } else if (!(clipmask[v2] & clipmask[v1] & clipmask[v])) {
    173173    GLuint vl[3];
     
    179179
    180180static INLINE void fxSafeClippedTriangle3( struct vertex_buffer *VB,
    181                                            fxVertex *gWin,
    182                                            tfxTriClipFunc cliptri,
    183                                            GLuint v2, GLuint v1, GLuint v )
     181                                           fxVertex *gWin,
     182                                           tfxTriClipFunc cliptri,
     183                                           GLuint v2, GLuint v1, GLuint v )
    184184{
    185185  GLubyte *clipmask = VB->ClipMask;
     
    213213 */
    214214
    215 #define RENDER_POINTS( start, count )                           \
    216    (void) gWin;                                                 \
    217    (void) VB;                                                   \
     215#define RENDER_POINTS( start, count )                           \
     216   (void) gWin;                                                 \
     217   (void) VB;                                                   \
    218218   (VB->ctx->Driver.PointsFunc)( VB->ctx, start, count-1 )
    219219
    220 #define RENDER_LINE( i1, i )                    \
    221   do {                                          \
    222      RVB_COLOR(i);                              \
    223      FX_grDrawLine((GrVertex *)gWin[i1].f,      \
    224                 (GrVertex *)gWin[i].f);         \
    225   } while (0)
    226 
    227 #define RENDER_TRI( i2, i1, i, pv, parity )     \
    228   do {                                          \
    229     RVB_COLOR(pv);                              \
    230     if (parity) {                               \
    231       FX_grDrawTriangle((GrVertex *)gWin[i1].f, \
    232                       (GrVertex *)gWin[i2].f,   \
    233                       (GrVertex *)gWin[i].f);   \
    234     } else {                                    \
    235       FX_grDrawTriangle((GrVertex *)gWin[i2].f, \
    236                       (GrVertex *)gWin[i1].f,   \
    237                       (GrVertex *)gWin[i].f);   \
    238     }                                           \
    239   } while (0)
    240 
    241 #define RENDER_QUAD( i3, i2, i1, i, pv )        \
    242   do {                                          \
    243     RVB_COLOR(pv);                              \
    244     FX_grDrawTriangle((GrVertex *)gWin[i3].f,   \
    245                     (GrVertex *)gWin[i2].f,     \
    246                     (GrVertex *)gWin[i].f);     \
    247     FX_grDrawTriangle((GrVertex *)gWin[i2].f,   \
    248                     (GrVertex *)gWin[i1].f,     \
    249                     (GrVertex *)gWin[i].f);     \
    250   } while (0)
    251 
    252 
    253 
    254 #define LOCAL_VARS                                              \
    255    fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx;      \
    256    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;                  \
     220#define RENDER_LINE( i1, i )                    \
     221  do {                                          \
     222     RVB_COLOR(i);                              \
     223     FX_grDrawLine((GrVertex *)gWin[i1].f,      \
     224                (GrVertex *)gWin[i].f);         \
     225  } while (0)
     226
     227#define RENDER_TRI( i2, i1, i, pv, parity )     \
     228  do {                                          \
     229    RVB_COLOR(pv);                              \
     230    if (parity) {                               \
     231      FX_grDrawTriangle((GrVertex *)gWin[i1].f, \
     232                      (GrVertex *)gWin[i2].f,   \
     233                      (GrVertex *)gWin[i].f);   \
     234    } else {                                    \
     235      FX_grDrawTriangle((GrVertex *)gWin[i2].f, \
     236                      (GrVertex *)gWin[i1].f,   \
     237                      (GrVertex *)gWin[i].f);   \
     238    }                                           \
     239  } while (0)
     240
     241#define RENDER_QUAD( i3, i2, i1, i, pv )        \
     242  do {                                          \
     243    RVB_COLOR(pv);                              \
     244    FX_grDrawTriangle((GrVertex *)gWin[i3].f,   \
     245                    (GrVertex *)gWin[i2].f,     \
     246                    (GrVertex *)gWin[i].f);     \
     247    FX_grDrawTriangle((GrVertex *)gWin[i2].f,   \
     248                    (GrVertex *)gWin[i1].f,     \
     249                    (GrVertex *)gWin[i].f);     \
     250  } while (0)
     251
     252
     253
     254#define LOCAL_VARS                                              \
     255   fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx;      \
     256   fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;                  \
    257257   (void) fxMesa;
    258258
    259 #define INIT(x) 
     259#define INIT(x)
    260260
    261261#define TAG(x) x##_fx_flat_raw
     
    276276/* Render with clipped and/or culled primitives with cullmask information.
    277277 */
    278 #define RENDER_POINTS( start, count )                           \
    279    (void) gWin;                                                 \
    280    (void) cullmask;                                             \
     278#define RENDER_POINTS( start, count )                           \
     279   (void) gWin;                                                 \
     280   (void) cullmask;                                             \
    281281   (VB->ctx->Driver.PointsFunc)( VB->ctx, start, count-1 )
    282282
    283283
    284 #define RENDER_LINE( i1, i )                                            \
    285   do {                                                                  \
    286     const GLubyte flags = cullmask[i];                                  \
    287                                                                         \
    288     if (!(flags & PRIM_NOT_CULLED))                                     \
    289       continue;                                                         \
    290                                                                         \
    291     RVB_COLOR(i);                                                       \
    292     if (flags & PRIM_ANY_CLIP)                                          \
    293       fxRenderClippedLine( VB, i1, i );                                 \
    294     else                                                                \
    295       FX_grDrawLine( (GrVertex *)gWin[i1].f, (GrVertex *)gWin[i].f );   \
     284#define RENDER_LINE( i1, i )                                            \
     285  do {                                                                  \
     286    const GLubyte flags = cullmask[i];                                  \
     287                                                                        \
     288    if (!(flags & PRIM_NOT_CULLED))                                     \
     289      continue;                                                         \
     290                                                                        \
     291    RVB_COLOR(i);                                                       \
     292    if (flags & PRIM_ANY_CLIP)                                          \
     293      fxRenderClippedLine( VB, i1, i );                                 \
     294    else                                                                \
     295      FX_grDrawLine( (GrVertex *)gWin[i1].f, (GrVertex *)gWin[i].f );   \
    296296 } while (0)
    297297
    298298
    299 #define RENDER_TRI( i2, i1, i, pv, parity)              \
    300   do {                                                  \
    301     const GLubyte flags = cullmask[i];                  \
    302     GLuint e2,e1;                                       \
    303                                                         \
    304     if (!(flags & PRIM_NOT_CULLED))                     \
    305       continue;                                         \
    306                                                         \
    307      e2=i2, e1=i1;                                      \
    308      if (parity) { e2=i1; e1=i2; }                      \
    309                                                         \
    310      RVB_COLOR(pv);                                     \
    311      if (flags & PRIM_ANY_CLIP) {                       \
    312        fxSafeClippedTriangle3(VB,gWin,cliptri,e2,e1,i); \
    313      } else {                                           \
    314        FX_grDrawTriangle((GrVertex *)gWin[e2].f,        \
    315                     (GrVertex *)gWin[e1].f,             \
    316                     (GrVertex *)gWin[i].f);             \
    317      }                                                  \
    318   } while (0)
    319 
    320 
    321 #define RENDER_QUAD(i3, i2, i1, i, pv)                  \
    322   do {                                                  \
    323     const GLubyte flags = cullmask[i];                  \
    324                                                         \
    325     if (!(flags & PRIM_NOT_CULLED))                     \
    326       continue;                                         \
    327                                                         \
    328     RVB_COLOR(pv);                                      \
    329     if (flags&PRIM_ANY_CLIP) {                          \
    330       fxSafeClippedTriangle3(VB,gWin,cliptri,i3,i2,i);  \
    331       fxSafeClippedTriangle3(VB,gWin,cliptri,i2,i1,i);  \
    332     } else {                                            \
    333       FX_grDrawTriangle((GrVertex *)gWin[i3].f,         \
    334                      (GrVertex *)gWin[i2].f,            \
    335                      (GrVertex *)gWin[i].f);            \
    336       FX_grDrawTriangle((GrVertex *)gWin[i2].f,         \
    337                      (GrVertex *)gWin[i1].f,            \
    338                      (GrVertex *)gWin[i].f);            \
    339     }                                                   \
    340   } while (0)
    341 
    342 
    343 
    344 
    345 
    346 #define LOCAL_VARS                                              \
    347    fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx;      \
    348    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;                  \
    349    const GLubyte *cullmask = VB->CullMask;                      \
     299#define RENDER_TRI( i2, i1, i, pv, parity)              \
     300  do {                                                  \
     301    const GLubyte flags = cullmask[i];                  \
     302    GLuint e2,e1;                                       \
     303                                                        \
     304    if (!(flags & PRIM_NOT_CULLED))                     \
     305      continue;                                         \
     306                                                        \
     307     e2=i2, e1=i1;                                      \
     308     if (parity) { e2=i1; e1=i2; }                      \
     309                                                        \
     310     RVB_COLOR(pv);                                     \
     311     if (flags & PRIM_ANY_CLIP) {                       \
     312       fxSafeClippedTriangle3(VB,gWin,cliptri,e2,e1,i); \
     313     } else {                                           \
     314       FX_grDrawTriangle((GrVertex *)gWin[e2].f,        \
     315                    (GrVertex *)gWin[e1].f,             \
     316                    (GrVertex *)gWin[i].f);             \
     317     }                                                  \
     318  } while (0)
     319
     320
     321#define RENDER_QUAD(i3, i2, i1, i, pv)                  \
     322  do {                                                  \
     323    const GLubyte flags = cullmask[i];                  \
     324                                                        \
     325    if (!(flags & PRIM_NOT_CULLED))                     \
     326      continue;                                         \
     327                                                        \
     328    RVB_COLOR(pv);                                      \
     329    if (flags&PRIM_ANY_CLIP) {                          \
     330      fxSafeClippedTriangle3(VB,gWin,cliptri,i3,i2,i);  \
     331      fxSafeClippedTriangle3(VB,gWin,cliptri,i2,i1,i);  \
     332    } else {                                            \
     333      FX_grDrawTriangle((GrVertex *)gWin[i3].f,         \
     334                     (GrVertex *)gWin[i2].f,            \
     335                     (GrVertex *)gWin[i].f);            \
     336      FX_grDrawTriangle((GrVertex *)gWin[i2].f,         \
     337                     (GrVertex *)gWin[i1].f,            \
     338                     (GrVertex *)gWin[i].f);            \
     339    }                                                   \
     340  } while (0)
     341
     342
     343
     344
     345
     346#define LOCAL_VARS                                              \
     347   fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx;      \
     348   fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;                  \
     349   const GLubyte *cullmask = VB->CullMask;                      \
    350350   tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
    351351
     
    371371
    372372/* Direct, with the possibility of clipping.
    373  */ 
    374 #define RENDER_POINTS( start, count )           \
    375   do {                                          \
    376     fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
    377     GLubyte *clipmask = VB->ClipMask;           \
    378     GLuint i;                                   \
    379     for (i = start ; i <= count ; i++)          \
    380       if (clipmask[i] == 0) {                   \
    381         RVB_COLOR(i);                           \
     373 */
     374#define RENDER_POINTS( start, count )           \
     375  do {                                          \
     376    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
     377    GLubyte *clipmask = VB->ClipMask;           \
     378    GLuint i;                                   \
     379    for (i = start ; i <= count ; i++)          \
     380      if (clipmask[i] == 0) {                   \
     381        RVB_COLOR(i);                           \
    382382        FX_grDrawPoint( (GrVertex *)gWin[i].f );\
    383       }                                         \
    384   } while (0)
    385 
    386 #define RENDER_LINE( i1, i )                    \
    387   do {                                          \
    388     RVB_COLOR(i);                               \
    389     fxSafeClippedLine( VB, i1, i );             \
    390   } while (0)
    391 
    392 #define RENDER_TRI( i2, i1, i, pv, parity)              \
    393   do {                                                  \
    394     GLuint e2=i2, e1=i1;                                        \
    395     if (parity) { GLuint t=e2; e2=e1; e1=t; }           \
    396     RVB_COLOR(pv);                                      \
    397     fxSafeClippedTriangle(VB,gWin,cliptri,e2,e1,i);     \
    398   } while (0)
    399 
    400 #define RENDER_QUAD( i3, i2, i1, i, pv)                 \
    401   do {                                                  \
    402     RVB_COLOR(pv);                                      \
    403     fxSafeClippedTriangle(VB,gWin,cliptri,i3,i2,i);     \
    404     fxSafeClippedTriangle(VB,gWin,cliptri,i2,i1,i);     \
    405   } while (0)
    406 
    407 #define LOCAL_VARS                                              \
    408    fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx;      \
    409    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;                  \
     383      }                                         \
     384  } while (0)
     385
     386#define RENDER_LINE( i1, i )                    \
     387  do {                                          \
     388    RVB_COLOR(i);                               \
     389    fxSafeClippedLine( VB, i1, i );             \
     390  } while (0)
     391
     392#define RENDER_TRI( i2, i1, i, pv, parity)              \
     393  do {                                                  \
     394    GLuint e2=i2, e1=i1;                                        \
     395    if (parity) { GLuint t=e2; e2=e1; e1=t; }           \
     396    RVB_COLOR(pv);                                      \
     397    fxSafeClippedTriangle(VB,gWin,cliptri,e2,e1,i);     \
     398  } while (0)
     399
     400#define RENDER_QUAD( i3, i2, i1, i, pv)                 \
     401  do {                                                  \
     402    RVB_COLOR(pv);                                      \
     403    fxSafeClippedTriangle(VB,gWin,cliptri,i3,i2,i);     \
     404    fxSafeClippedTriangle(VB,gWin,cliptri,i2,i1,i);     \
     405  } while (0)
     406
     407#define LOCAL_VARS                                              \
     408   fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx;      \
     409   fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;                  \
    410410   tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
    411411
     
    430430
    431431/* Indirect, with the possibility of clipping.
    432  */ 
    433 #define RENDER_POINTS( start, count )                   \
    434   do {                                                  \
    435     fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;         \
    436     GLuint e;                                           \
    437     GLubyte *clipmask = VB->ClipMask;                   \
    438     for(e=start;e<=count;e++)                           \
    439       if(clipmask[elt[e]]==0) {                         \
    440         FX_grDrawPoint((GrVertex *)gWin[elt[e]].f);     \
    441       }                                                 \
    442   } while (0)
    443 
    444 #define RENDER_LINE( i1, i )                    \
    445   do {                                          \
    446     GLuint e1 = elt[i1], e = elt[i];            \
    447     RVB_COLOR(e);                               \
    448     fxSafeClippedLine( VB, e1, e );             \
    449   } while (0)
    450 
    451 #define RENDER_TRI( i2, i1, i, pv, parity)              \
    452   do {                                                  \
    453     GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i];      \
    454     if (parity) { GLuint t=e2; e2=e1; e1=t; }           \
    455     fxSafeClippedTriangle(VB,gWin,cliptri,e2,e1,e);     \
    456   } while (0)
    457 
    458 #define RENDER_QUAD( i3, i2, i1, i, pv)                         \
    459   do {                                                          \
     432 */
     433#define RENDER_POINTS( start, count )                   \
     434  do {                                                  \
     435    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;         \
     436    GLuint e;                                           \
     437    GLubyte *clipmask = VB->ClipMask;                   \
     438    for(e=start;e<=count;e++)                           \
     439      if(clipmask[elt[e]]==0) {                         \
     440        FX_grDrawPoint((GrVertex *)gWin[elt[e]].f);     \
     441      }                                                 \
     442  } while (0)
     443
     444#define RENDER_LINE( i1, i )                    \
     445  do {                                          \
     446    GLuint e1 = elt[i1], e = elt[i];            \
     447    RVB_COLOR(e);                               \
     448    fxSafeClippedLine( VB, e1, e );             \
     449  } while (0)
     450
     451#define RENDER_TRI( i2, i1, i, pv, parity)              \
     452  do {                                                  \
     453    GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i];      \
     454    if (parity) { GLuint t=e2; e2=e1; e1=t; }           \
     455    fxSafeClippedTriangle(VB,gWin,cliptri,e2,e1,e);     \
     456  } while (0)
     457
     458#define RENDER_QUAD( i3, i2, i1, i, pv)                         \
     459  do {                                                          \
    460460    GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i];\
    461     fxSafeClippedTriangle(VB,gWin,cliptri,e3,e2,e);             \
    462     fxSafeClippedTriangle(VB,gWin,cliptri,e2,e1,e);             \
    463   } while (0)
    464 
    465 #define LOCAL_VARS const GLuint *elt = VB->EltPtr->data;        \
    466    fxMesaContext fxMesa = (fxMesaContext)VB->ctx->DriverCtx;    \
    467    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;                  \
     461    fxSafeClippedTriangle(VB,gWin,cliptri,e3,e2,e);             \
     462    fxSafeClippedTriangle(VB,gWin,cliptri,e2,e1,e);             \
     463  } while (0)
     464
     465#define LOCAL_VARS const GLuint *elt = VB->EltPtr->data;        \
     466   fxMesaContext fxMesa = (fxMesaContext)VB->ctx->DriverCtx;    \
     467   fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;                  \
    468468   tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
    469469
     
    478478/* Indirect, clipped, but no user clip.
    479479 */
    480 #define RENDER_POINTS( start, count )                   \
    481   do {                                                  \
    482     fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;         \
    483     GLuint e;                                           \
    484     GLubyte *clipmask = VB->ClipMask;                   \
    485     for(e=start;e<=count;e++)                           \
    486       if(clipmask[elt[e]]==0) {                         \
    487         FX_grDrawPoint((GrVertex *)gWin[elt[e]].f);     \
    488       }                                                 \
    489   } while (0)
    490 
    491 #define RENDER_LINE( i1, i )                    \
    492   do {                                          \
    493     GLuint e1 = elt[i1], e = elt[i];            \
    494     RVB_COLOR(e);                               \
    495     fxSafeClippedLine( VB, e1, e );             \
    496   } while (0)
    497 
    498 #define RENDER_TRI( i2, i1, i, pv, parity)              \
    499   do {                                                  \
    500     GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i];      \
    501     if (parity) { GLuint t=e2; e2=e1; e1=t; }           \
    502     fxSafeClippedTriangle2(VB,gWin,cliptri,e2,e1,e);    \
    503   } while (0)
    504 
    505 #define RENDER_QUAD( i3, i2, i1, i, pv)                         \
    506   do {                                                          \
     480#define RENDER_POINTS( start, count )                   \
     481  do {                                                  \
     482    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;         \
     483    GLuint e;                                           \
     484    GLubyte *clipmask = VB->ClipMask;                   \
     485    for(e=start;e<=count;e++)                           \
     486      if(clipmask[elt[e]]==0) {                         \
     487        FX_grDrawPoint((GrVertex *)gWin[elt[e]].f);     \
     488      }                                                 \
     489  } while (0)
     490
     491#define RENDER_LINE( i1, i )                    \
     492  do {                                          \
     493    GLuint e1 = elt[i1], e = elt[i];            \
     494    RVB_COLOR(e);                               \
     495    fxSafeClippedLine( VB, e1, e );             \
     496  } while (0)
     497
     498#define RENDER_TRI( i2, i1, i, pv, parity)              \
     499  do {                                                  \
     500    GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i];      \
     501    if (parity) { GLuint t=e2; e2=e1; e1=t; }           \
     502    fxSafeClippedTriangle2(VB,gWin,cliptri,e2,e1,e);    \
     503  } while (0)
     504
     505#define RENDER_QUAD( i3, i2, i1, i, pv)                         \
     506  do {                                                          \
    507507    GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i];\
    508     fxSafeClippedTriangle2(VB,gWin,cliptri,e3,e2,e);            \
    509     fxSafeClippedTriangle2(VB,gWin,cliptri,e2,e1,e);            \
    510   } while (0)
    511 
    512 #define LOCAL_VARS const GLuint *elt = VB->EltPtr->data;        \
    513    fxMesaContext fxMesa = (fxMesaContext)VB->ctx->DriverCtx;    \
    514    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;                  \
     508    fxSafeClippedTriangle2(VB,gWin,cliptri,e3,e2,e);            \
     509    fxSafeClippedTriangle2(VB,gWin,cliptri,e2,e1,e);            \
     510  } while (0)
     511
     512#define LOCAL_VARS const GLuint *elt = VB->EltPtr->data;        \
     513   fxMesaContext fxMesa = (fxMesaContext)VB->ctx->DriverCtx;    \
     514   fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;                  \
    515515   tfxTriViewClipFunc cliptri = fxMesa->view_clip_tri;
    516516
     
    530530/* Indirect, and no clipping required.
    531531 */
    532 #define RENDER_POINTS( start, count )                   \
    533   do {                                                  \
    534     GLuint e;                                           \
    535     for(e=start;e<=count;e++) {                         \
    536       FX_grDrawPoint((GrVertex *)gWin[elt[e]].f);       \
    537     }                                                   \
    538   } while (0)
    539 
    540 #define RENDER_LINE( i1, i )                                            \
    541   do {                                                                  \
    542     GLuint e1 = elt[i1], e = elt[i];                                    \
    543     FX_grDrawLine((GrVertex *)gWin[e1].f, (GrVertex *)gWin[e].f);       \
    544   } while (0)
    545 
    546 
    547 #define RENDER_TRI( i2, i1, i, pv, parity)              \
    548   do {                                                  \
    549     GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i];      \
    550     if (parity) {GLuint tmp = e2; e2 = e1; e1 = tmp;}   \
    551     FX_grDrawTriangle((GrVertex *)gWin[e2].f,           \
    552                  (GrVertex *)gWin[e1].f,                \
    553                  (GrVertex *)gWin[e].f);                \
    554   } while (0)
    555 
    556 
    557 #define RENDER_QUAD( i3, i2, i1, i, pv)                         \
    558   do {                                                          \
     532#define RENDER_POINTS( start, count )                   \
     533  do {                                                  \
     534    GLuint e;                                           \
     535    for(e=start;e<=count;e++) {                         \
     536      FX_grDrawPoint((GrVertex *)gWin[elt[e]].f);       \
     537    }                                                   \
     538  } while (0)
     539
     540#define RENDER_LINE( i1, i )                                            \
     541  do {                                                                  \
     542    GLuint e1 = elt[i1], e = elt[i];                                    \
     543    FX_grDrawLine((GrVertex *)gWin[e1].f, (GrVertex *)gWin[e].f);       \
     544  } while (0)
     545
     546
     547#define RENDER_TRI( i2, i1, i, pv, parity)              \
     548  do {                                                  \
     549    GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i];      \
     550    if (parity) {GLuint tmp = e2; e2 = e1; e1 = tmp;}   \
     551    FX_grDrawTriangle((GrVertex *)gWin[e2].f,           \
     552                 (GrVertex *)gWin[e1].f,                \
     553                 (GrVertex *)gWin[e].f);                \
     554  } while (0)
     555
     556
     557#define RENDER_QUAD( i3, i2, i1, i, pv)                         \
     558  do {                                                          \
    559559    GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i];\
    560     FX_grDrawTriangle((GrVertex *)gWin[e3].f,                   \
    561                  (GrVertex *)gWin[e2].f,                        \
    562                  (GrVertex *)gWin[e].f);                        \
    563     FX_grDrawTriangle((GrVertex *)gWin[e2].f,                   \
    564                  (GrVertex *)gWin[e1].f,                        \
    565                  (GrVertex *)gWin[e].f);                        \
    566   } while (0)
    567 
    568 #define LOCAL_VARS                              \
    569    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;  \
     560    FX_grDrawTriangle((GrVertex *)gWin[e3].f,                   \
     561                 (GrVertex *)gWin[e2].f,                        \
     562                 (GrVertex *)gWin[e].f);                        \
     563    FX_grDrawTriangle((GrVertex *)gWin[e2].f,                   \
     564                 (GrVertex *)gWin[e1].f,                        \
     565                 (GrVertex *)gWin[e].f);                        \
     566  } while (0)
     567
     568#define LOCAL_VARS                              \
     569   fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;  \
    570570   const GLuint *elt = VB->EltPtr->data;
    571571
    572 #define INIT(x) 
     572#define INIT(x)
    573573
    574574#define TAG(x) x##_fx_smooth_indirect
     
    586586 * 'safe' set of clipping routines which don't require write-access to
    587587 * the arrays in the vertex buffer, and don't care about array
    588  * stride. 
    589  *
    590  * Thus there is no call to gl_import_arrays() in this function. 
     588 * stride.
     589 *
     590 * Thus there is no call to gl_import_arrays() in this function.
    591591 *
    592592 * This safe clipping should be generalized to call driver->trianglefunc
     
    606606  GLuint p = 0;
    607607
    608   if (!nr) 
     608  if (!nr)
    609609    return;
    610610
    611   if (fxMesa->new_state) 
     611  if (fxMesa->new_state)
    612612    fxSetupFXUnits(ctx);
    613613
     
    619619      func = render_tab_fx_smooth_indirect_clipped[prim];
    620620  }
    621    
    622   ctx->VB = VB;                 /* kludge */
     621
     622  ctx->VB = VB;                 /* kludge */
    623623
    624624  do {
    625625    func( VB, 0, nr, 0 );
    626626  } while (ctx->Driver.MultipassFunc &&
    627            ctx->Driver.MultipassFunc( VB, ++p ));
     627           ctx->Driver.MultipassFunc( VB, ++p ));
    628628
    629629
     
    644644  if (cvaVB->ClipOrMask)
    645645    tab = render_tab_fx_smooth_indirect_clipped;
    646    
     646
    647647  if (!VB->CullDone)
    648648    gl_fast_copy_vb( VB );
    649649
    650   if (fxMesa->new_state) 
     650  if (fxMesa->new_state)
    651651    fxSetupFXUnits( ctx );
    652652
     
    657657    GLuint parity = VB->Parity;
    658658
    659     for (i = VB->CopyStart ; i < count ; parity = 0, i = next) 
     659    for (i = VB->CopyStart ; i < count ; parity = 0, i = next)
    660660    {
    661661      GLuint prim = VB->Primitive[i];
     
    665665    /* loop never taken */
    666666  } while (ctx->Driver.MultipassFunc &&
    667            ctx->Driver.MultipassFunc( cvaVB, ++p ));
     667           ctx->Driver.MultipassFunc( cvaVB, ++p ));
    668668
    669669  cvaVB->EltPtr = 0;
     
    719719  fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
    720720
    721   if (ctx->IndirectTriangles & DD_SW_SETUP) 
    722     return null_tables; 
     721  if (ctx->IndirectTriangles & DD_SW_SETUP)
     722    return null_tables;
    723723
    724724  switch (fxMesa->render_index) {
     
    726726    return fxDDRenderVBFlat_tables;
    727727  case 0:
    728     return fxDDRenderVBSmooth_tables; 
     728    return fxDDRenderVBSmooth_tables;
    729729  default:
    730     return null_tables;   
     730    return null_tables;
    731731  }
    732732}
     
    743743   GLint p = 0;
    744744
    745    if (fxMesa->new_state) 
     745   if (fxMesa->new_state)
    746746     fxSetupFXUnits(ctx);
    747747
    748    if (VB->Indirect) { 
    749       return; 
     748   if (VB->Indirect) {
     749      return;
    750750   } else if (VB->CullMode & CLIP_MASK_ACTIVE) {
    751751      tab = fxMesa->RenderVBClippedTab;
     
    758758
    759759   do
    760    {     
    761       for ( i= VB->CopyStart ; i < count ; parity = 0, i = next ) 
     760   {
     761      for ( i= VB->CopyStart ; i < count ; parity = 0, i = next )
    762762      {
    763         prim = VB->Primitive[i];
    764         next = VB->NextPrimitive[i];
    765         tab[prim]( VB, i, next, parity );
     763        prim = VB->Primitive[i];
     764        next = VB->NextPrimitive[i];
     765        tab[prim]( VB, i, next, parity );
    766766      }
    767767
    768768   } while (ctx->Driver.MultipassFunc &&
    769             ctx->Driver.MultipassFunc( VB, ++p ));
     769            ctx->Driver.MultipassFunc( VB, ++p ));
    770770}
    771771
  • trunk/src/opengl/mesa/3dfx/fxsanity.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.
     
    6868
    6969   GLfloat area = ((v1->x - v3->x) * (v2->y - v3->y) -
    70                    (v1->y - v3->y) * (v2->x - v3->x));
     70                   (v1->y - v3->y) * (v2->x - v3->x));
    7171
    7272   if (v1->x < 0 || v1->y < 0 || v1->x > WID || v1->y > HI ||
    7373       v2->x < 0 || v2->y < 0 || v2->x > WID || v2->y > HI ||
    74        v3->x < 0 || v3->y < 0 || v3->x > WID || v3->y > HI) 
     74       v3->x < 0 || v3->y < 0 || v3->x > WID || v3->y > HI)
    7575   {
    7676      fprintf(stderr,"not clipped/set up!!!!!\n");
     
    9494   if (print) {
    9595      fprintf(stderr,"v1: %f %f %f %f col %.0f %.0f %.0f %.0f t0 %f %f %f t1 %f %f %f\n",
    96               v1->x, v1->y, v1->ooz, v1->oow,
    97               v1->r, v1->g, v1->b, v1->a,
    98               v1->tmuvtx[0].sow, v1->tmuvtx[0].tow, v1->tmuvtx[0].oow,
    99               v1->tmuvtx[1].sow, v1->tmuvtx[1].tow, v1->tmuvtx[1].oow);
     96              v1->x, v1->y, v1->ooz, v1->oow,
     97              v1->r, v1->g, v1->b, v1->a,
     98              v1->tmuvtx[0].sow, v1->tmuvtx[0].tow, v1->tmuvtx[0].oow,
     99              v1->tmuvtx[1].sow, v1->tmuvtx[1].tow, v1->tmuvtx[1].oow);
    100100      fprintf(stderr,"v2: %f %f %f %f col %.0f %.0f %.0f %.0f t0 %f %f %f t1 %f %f %f\n",
    101               v2->x, v2->y, v2->ooz, v2->oow,
    102               v2->r, v2->g, v2->b, v2->a,
    103               v2->tmuvtx[0].sow, v2->tmuvtx[0].tow, v2->tmuvtx[0].oow,
    104               v2->tmuvtx[1].sow, v2->tmuvtx[1].tow, v2->tmuvtx[1].oow);
     101              v2->x, v2->y, v2->ooz, v2->oow,
     102              v2->r, v2->g, v2->b, v2->a,
     103              v2->tmuvtx[0].sow, v2->tmuvtx[0].tow, v2->tmuvtx[0].oow,
     104              v2->tmuvtx[1].sow, v2->tmuvtx[1].tow, v2->tmuvtx[1].oow);
    105105      fprintf(stderr,"v3: %f %f %f %f col %.0f %.0f %.0f %.0f t0 %f %f %f t1 %f %f %f\n",
    106               v3->x, v3->y, v3->ooz, v3->oow,
    107               v3->r, v3->g, v3->b, v3->a,
    108               v3->tmuvtx[0].sow, v3->tmuvtx[0].tow, v3->tmuvtx[0].oow,
    109               v3->tmuvtx[1].sow, v3->tmuvtx[1].tow, v3->tmuvtx[1].oow);
     106              v3->x, v3->y, v3->ooz, v3->oow,
     107              v3->r, v3->g, v3->b, v3->a,
     108              v3->tmuvtx[0].sow, v3->tmuvtx[0].tow, v3->tmuvtx[0].oow,
     109              v3->tmuvtx[1].sow, v3->tmuvtx[1].tow, v3->tmuvtx[1].oow);
    110110   }
    111111
    112    if (1) 
     112   if (1)
    113113      FX_grDrawTriangle(v1,v2,v3);
    114    else 
     114   else
    115115      fprintf(stderr, "\n\n\n");
    116116}
    117117
     118#else
     119
     120void gl_fxsanity_dummy()
     121{
     122}
     123
    118124#endif
  • trunk/src/opengl/mesa/3dfx/fxsdettmp.h

    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.
     
    4242 * See fxapi.h for more revision/author details.
    4343 */
    44  
    45  
    46 /* 
     44
     45
     46/*
    4747 * Notes: the folowing code works only if count is > start.
    4848 * Corrently we are looking for the pattern:
     
    5050 *
    5151 * For this:
    52  * #define STRIP0               ((u1 == v1) && (u2 == v0))     
    53  * #define STRIP1               ((u0 == v0) && (u2 == v1))
     52 * #define STRIP0               ((u1 == v1) && (u2 == v0))
     53 * #define STRIP1               ((u0 == v0) && (u2 == v1))
    5454 *
    5555 */
     
    5757
    5858static void TAG(render_vb_triangles_smooth_indirect_sd)
    59         ( struct vertex_buffer  *VB,
    60           GLuint                start,
    61           GLuint                count,
    62           GLuint                parity)
     59        ( struct vertex_buffer  *VB,
     60          GLuint                start,
     61          GLuint                count,
     62          GLuint                parity)
    6363{
    6464   GLint u0,u1,u2;
    6565   GLint v0,v1,v2;
    6666   GLuint *elt = VB->EltPtr->data;
    67    
    68    int   i;
     67
     68   int   i;
    6969   LOCAL_VARS
    70    
     70
    7171   INIT(GL_TRIANGLES);
    72    
     72
    7373   elt = &elt[start-1];
    7474   u0 = *(++elt);
     
    8181      v1 = *(++elt);
    8282      v2 = *(++elt);
    83    
    84       if (CLIPPED(u0,u1,u2)) 
     83
     84      if (CLIPPED(u0,u1,u2))
    8585      {
    86         if (!CULLED(u0,u1,u2))  SENDCLIPTRI(u0,u1,u2);
     86        if (!CULLED(u0,u1,u2))  SENDCLIPTRI(u0,u1,u2);
    8787      }
    8888      else
    8989      {
    90         if (STRIP0(u,v))
     90        if (STRIP0(u,v))
    9191         {
    9292            int   is_strips = 1;
    9393            int   parity = 0;
    9494            STRIPSLOCAL_VAR
    95            
    96             FLUSHTRI();
    97             STARTSTRIPS(u0,u1,u2);
    98             while (is_strips && i < count)
    99             {
    100                SENDSTRIPS(v2);
    101                
    102                u0 = v0; u1 = v1; u2 = v2; i+= 3;
    103                v0 = *(++elt);   
    104                v1 = *(++elt);
    105                v2 = *(++elt);
    106            
    107                if (parity) {
    108                   is_strips = STRIP0(u,v);
    109                   parity = 0;
    110                } else {
    111                   is_strips  = STRIP1(u,v);
    112                   parity = 1;
    113                }
    114              }
    115              FLUSHSTRIPS();
    116              
    117              if (i >= count)
    118                 return;
    119          }
    120          else
    121         {
     95
     96            FLUSHTRI();
     97            STARTSTRIPS(u0,u1,u2);
     98            while (is_strips && i < count)
     99            {
     100               SENDSTRIPS(v2);
     101
     102               u0 = v0; u1 = v1; u2 = v2; i+= 3;
     103               v0 = *(++elt);
     104               v1 = *(++elt);
     105               v2 = *(++elt);
     106
     107               if (parity) {
     108                  is_strips = STRIP0(u,v);
     109                  parity = 0;
     110               } else {
     111                  is_strips  = STRIP1(u,v);
     112                  parity = 1;
     113               }
     114             }
     115             FLUSHSTRIPS();
     116
     117             if (i >= count)
     118                return;
     119         }
     120         else
     121        {
    122122             SENDTRI(u0,u1,u2);
    123         }
     123        }
    124124      }
    125125      u0 = v0; u1 = v1; u2 = v2; i+= 3;
     
    127127   if (CLIPPED(u0,u1,u2))
    128128   {
    129       if (!CULLED(u0,u1,u2))    SENDCLIPTRI(u0,u1,u2);
     129      if (!CULLED(u0,u1,u2))    SENDCLIPTRI(u0,u1,u2);
    130130   }
    131131   else
     
    134134   }
    135135   FLUSHTRI();
    136    
     136
    137137}
    138  
     138
    139139#ifndef PRESERVE_VB_DEFS
    140140#undef SENDTRI
  • trunk/src/opengl/mesa/3dfx/fxsetup.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.
     
    5757
    5858static GLuint fxGetTexSetConfiguration(GLcontext *ctx,
    59                                 struct gl_texture_object *tObj0,
    60                                 struct gl_texture_object *tObj1);
     59                                struct gl_texture_object *tObj0,
     60                                struct gl_texture_object *tObj1);
    6161static 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);
     62static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa,
     63                             struct gl_texture_object *tObj0,
     64                             struct gl_texture_object *tObj1);
     65static void fxSetupTexture_NoLock(GLcontext *ctx);
     66static void fxSetupTexture(GLcontext *ctx);
    6667static void fxSetupBlend(GLcontext *ctx);
    6768static void fxSetupDepthTest(GLcontext *ctx);
    68 static void fxFogTableGenerate(GLcontext *ctx);
    69 static void fxSetupFog(GLcontext *ctx, GLboolean forceTableRebuild);
    7069static void fxSetupScissor(GLcontext *ctx);
    7170static void fxSetupCull(GLcontext *ctx);
     
    8584  if(ti->validated) {
    8685     if (MESA_VERBOSE&VERBOSE_DRIVER) {
    87         fprintf(stderr,"fxmesa: fxTexValidate(...) End (validated=GL_TRUE)\n");
     86        fprintf(stderr,"fxmesa: fxTexValidate(...) End (validated=GL_TRUE)\n");
    8887     }
    8988    return;
     
    9594
    9695  fxTexGetInfo(tObj->Image[minl]->Width, tObj->Image[minl]->Height,
    97                &(FX_largeLodLog2(ti->info)), &(FX_aspectRatioLog2(ti->info)),
    98                &(ti->sScale), &(ti->tScale),
    99                &(ti->int_sScale), &(ti->int_tScale),           
    100                NULL, NULL);
     96               &(FX_largeLodLog2(ti->info)), &(FX_aspectRatioLog2(ti->info)),
     97               &(ti->sScale), &(ti->tScale),
     98               &(ti->int_sScale), &(ti->int_tScale),
     99               NULL, NULL);
    101100
    102101  if((tObj->MinFilter!=GL_NEAREST) && (tObj->MinFilter!=GL_LINEAR))
    103102    fxTexGetInfo(tObj->Image[maxl]->Width,tObj->Image[maxl]->Height,
    104                 &(FX_smallLodLog2(ti->info)),NULL,
    105                 NULL,NULL,
    106                 NULL,NULL,
    107                 NULL,NULL);
     103                &(FX_smallLodLog2(ti->info)),NULL,
     104                NULL,NULL,
     105                NULL,NULL,
     106                NULL,NULL);
    108107  else
    109108    FX_smallLodLog2(ti->info)=FX_largeLodLog2(ti->info);
    110109
    111   fxTexGetFormat(tObj->Image[minl]->Format,&(ti->info.format),&(ti->baseLevelInternalFormat));
     110  fxTexGetFormat(tObj->Image[minl]->IntFormat,&(ti->info.format),&(ti->baseLevelInternalFormat));
    112111
    113112  switch (tObj->WrapS) {
     
    147146static void fxPrintUnitsMode( const char *msg, GLuint mode )
    148147{
    149    fprintf(stderr, 
    150            "%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",
    151            msg,
    152            mode,
    153            (mode & FX_UM_E0_REPLACE)         ? "E0_REPLACE, " : "",
    154            (mode & FX_UM_E0_MODULATE)        ? "E0_MODULATE, " : "",
    155            (mode & FX_UM_E0_DECAL)           ? "E0_DECAL, " : "",
    156            (mode & FX_UM_E0_BLEND)           ? "E0_BLEND, " : "",
    157            (mode & FX_UM_E1_REPLACE)         ? "E1_REPLACE, " : "",
    158            (mode & FX_UM_E1_MODULATE)        ? "E1_MODULATE, " : "",
    159            (mode & FX_UM_E1_DECAL)           ? "E1_DECAL, " : "",
    160            (mode & FX_UM_E1_BLEND)           ? "E1_BLEND, " : "",
    161            (mode & FX_UM_E0_ALPHA)           ? "E0_ALPHA, " : "",
    162            (mode & FX_UM_E0_LUMINANCE)       ? "E0_LUMINANCE, " : "",
    163            (mode & FX_UM_E0_LUMINANCE_ALPHA) ? "E0_LUMINANCE_ALPHA, " : "",
    164            (mode & FX_UM_E0_INTENSITY)       ? "E0_INTENSITY, " : "",
    165            (mode & FX_UM_E0_RGB)             ? "E0_RGB, " : "",
    166            (mode & FX_UM_E0_RGBA)            ? "E0_RGBA, " : "",
    167            (mode & FX_UM_E1_ALPHA)           ? "E1_ALPHA, " : "",
    168            (mode & FX_UM_E1_LUMINANCE)       ? "E1_LUMINANCE, " : "",
    169            (mode & FX_UM_E1_LUMINANCE_ALPHA) ? "E1_LUMINANCE_ALPHA, " : "",
    170            (mode & FX_UM_E1_INTENSITY)       ? "E1_INTENSITY, " : "",
    171            (mode & FX_UM_E1_RGB)             ? "E1_RGB, " : "",
    172            (mode & FX_UM_E1_RGBA)            ? "E1_RGBA, " : "",
    173            (mode & FX_UM_COLOR_ITERATED)     ? "COLOR_ITERATED, " : "",
    174            (mode & FX_UM_COLOR_CONSTANT)     ? "COLOR_CONSTANT, " : "",
    175            (mode & FX_UM_ALPHA_ITERATED)     ? "ALPHA_ITERATED, " : "",
    176            (mode & FX_UM_ALPHA_CONSTANT)     ? "ALPHA_CONSTANT, " : "");
     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, " : "");
    177176}
    178177
    179178static GLuint fxGetTexSetConfiguration(GLcontext *ctx,
    180                                        struct gl_texture_object *tObj0,
    181                                        struct gl_texture_object *tObj1)
     179                                       struct gl_texture_object *tObj0,
     180                                       struct gl_texture_object *tObj1)
    182181{
    183182  GLuint unitsmode=0;
     
    198197    unitsmode|=FX_UM_COLOR_CONSTANT;
    199198
     199  /*
     200     OpenGL Feeds Texture 0 into Texture 1
     201     Glide Feeds Texture 1 into Texture 0
     202  */
    200203  if(tObj0) {
    201204    tfxTexInfo *ti0=fxTMGetTexInfo(tObj0);
     
    310313{
    311314  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 */
    313329  if (!ti->isInTM) {
    314330    if (ti->LODblend)
     
    316332    else {
    317333      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        }
    334341      } else
    335         fxTMMoveInTM_NoLock(fxMesa,tObj,FX_TMU0);
     342        fxTMMoveInTM_NoLock(fxMesa,tObj,FX_TMU0);
    336343    }
    337344  }
     
    340347    if ((ti->info.format==GR_TEXFMT_P_8) && (!fxMesa->haveGlobalPaletteTexture)) {
    341348       if (MESA_VERBOSE&VERBOSE_DRIVER) {
    342           fprintf(stderr,"fxmesa: uploading texture palette\n");
     349          fprintf(stderr,"fxmesa: uploading texture palette\n");
    343350       }
    344351      FX_grTexDownloadTable_NoLock(GR_TMU0,GR_TEXTABLE_PALETTE,&(ti->palette));
     
    354361
    355362    FX_grTexSource_NoLock(GR_TMU0,ti->tm[FX_TMU0]->startAddr,
    356                           GR_MIPMAPLEVELMASK_ODD,&(ti->info));
     363                          GR_MIPMAPLEVELMASK_ODD,&(ti->info));
    357364    FX_grTexSource_NoLock(GR_TMU1,ti->tm[FX_TMU1]->startAddr,
    358                           GR_MIPMAPLEVELMASK_EVEN,&(ti->info));
     365                          GR_MIPMAPLEVELMASK_EVEN,&(ti->info));
    359366  } else {
     367    if (ti->whichTMU==FX_TMU_BOTH) tmu=FX_TMU0;
     368    else tmu=ti->whichTMU;
     369
    360370    if((ti->info.format==GR_TEXFMT_P_8) && (!fxMesa->haveGlobalPaletteTexture)) {
    361371       if (MESA_VERBOSE&VERBOSE_DRIVER) {
    362           fprintf(stderr,"fxmesa: uploading texture palette\n");
     372          fprintf(stderr,"fxmesa: uploading texture palette\n");
    363373       }
    364       FX_grTexDownloadTable_NoLock(ti->whichTMU,GR_TEXTABLE_PALETTE,&(ti->palette));
     374      FX_grTexDownloadTable_NoLock(tmu, GR_TEXTABLE_PALETTE, &(ti->palette));
    365375    }
    366376
    367377    /* KW: The alternative is to do the download to the other tmu.  If
    368378     * 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.
    370380     */
    371381    if (ti->LODblend && (MESA_VERBOSE&VERBOSE_DRIVER))
    372382       fprintf(stderr, "fxmesa: not blending texture - only on one tmu\n");
    373383
    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
     393static 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) {
    398401    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);
    409413    fxMesa->tmuSrc=FX_TMU_SPLIT;
    410   } else {
    411     if(tmu==FX_TMU0) {
     414  }
     415  else {
     416    if (tmu!=FX_TMU1) {
    412417      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      }
    416427      fxMesa->tmuSrc=FX_TMU0;
    417     } else {
     428    }
     429    else {
    418430      FX_grTexCombine_NoLock(GR_TMU1,
    419                              GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE,
    420                              GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE,
    421                              FXFALSE,FXFALSE);
    422    
     431                             GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE,
     432                             GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE,
     433                             FXFALSE,FXFALSE);
     434
    423435      /* GR_COMBINE_FUNCTION_SCALE_OTHER doesn't work ?!? */
    424    
     436
    425437      FX_grTexCombine_NoLock(GR_TMU0,
    426                              GR_COMBINE_FUNCTION_BLEND,
    427                              GR_COMBINE_FACTOR_ONE,
    428                              GR_COMBINE_FUNCTION_BLEND,
    429                              GR_COMBINE_FACTOR_ONE,
    430                              FXFALSE,FXFALSE);
    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
    432444      fxMesa->tmuSrc=FX_TMU1;
    433445    }
     
    443455  tfxTexInfo *ti;
    444456  struct gl_texture_object *tObj=ctx->Texture.Unit[textureset].CurrentD[2];
     457  int tmu;
    445458
    446459  if (MESA_VERBOSE&VERBOSE_DRIVER) {
     
    454467  fxSetupSingleTMU_NoLock(fxMesa,tObj);
    455468
    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);
    458473
    459474  if(textureset==0 || !fxMesa->haveTwoTMUs)
     
    484499  if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE))
    485500     fprintf(stderr, "fxMesa: fxSetupTextureSingleTMU, envmode is %s\n",
    486              gl_lookup_enum_by_nr(ctx->Texture.Unit[textureset].EnvMode));
     501             gl_lookup_enum_by_nr(ctx->Texture.Unit[textureset].EnvMode));
    487502
    488503  switch(ctx->Texture.Unit[textureset].EnvMode) {
    489504  case GL_DECAL:
    490505    FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
    491                              GR_COMBINE_FACTOR_NONE,
    492                              locala,
    493                              GR_COMBINE_OTHER_NONE,
    494                              FXFALSE);
     506                             GR_COMBINE_FACTOR_NONE,
     507                             locala,
     508                             GR_COMBINE_OTHER_NONE,
     509                             FXFALSE);
    495510
    496511    FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_BLEND,
    497                              GR_COMBINE_FACTOR_TEXTURE_ALPHA,
    498                              localc,
    499                              GR_COMBINE_OTHER_TEXTURE,
    500                              FXFALSE);
     512                             GR_COMBINE_FACTOR_TEXTURE_ALPHA,
     513                             localc,
     514                             GR_COMBINE_OTHER_TEXTURE,
     515                             FXFALSE);
    501516    break;
    502517  case GL_MODULATE:
    503518    FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
    504                              GR_COMBINE_FACTOR_LOCAL,
    505                              locala,
    506                              GR_COMBINE_OTHER_TEXTURE,
    507                              FXFALSE);
     519                             GR_COMBINE_FACTOR_LOCAL,
     520                             locala,
     521                             GR_COMBINE_OTHER_TEXTURE,
     522                             FXFALSE);
    508523
    509524    if(ifmt==GL_ALPHA)
    510525      FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
    511                                GR_COMBINE_FACTOR_NONE,
    512                                localc,
    513                                GR_COMBINE_OTHER_NONE,
    514                                FXFALSE);
     526                               GR_COMBINE_FACTOR_NONE,
     527                               localc,
     528                               GR_COMBINE_OTHER_NONE,
     529                               FXFALSE);
    515530    else
    516531      FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
    517                                GR_COMBINE_FACTOR_LOCAL,
    518                                localc,
    519                                GR_COMBINE_OTHER_TEXTURE,
    520                                FXFALSE);
     532                               GR_COMBINE_FACTOR_LOCAL,
     533                               localc,
     534                               GR_COMBINE_OTHER_TEXTURE,
     535                               FXFALSE);
    521536    break;
    522537  case GL_BLEND:
     538#if 0
    523539    FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
    524                              GR_COMBINE_FACTOR_LOCAL,
    525                              locala,
    526                              GR_COMBINE_OTHER_TEXTURE,
    527                              FXFALSE);
     540                             GR_COMBINE_FACTOR_LOCAL,
     541                             locala,
     542                             GR_COMBINE_OTHER_TEXTURE,
     543                             FXFALSE);
    528544    if (ifmt==GL_ALPHA)
    529545      FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
    530                                GR_COMBINE_FACTOR_NONE,
    531                                localc,
    532                                GR_COMBINE_OTHER_NONE,
    533                                FXFALSE);
     546                               GR_COMBINE_FACTOR_NONE,
     547                               localc,
     548                               GR_COMBINE_OTHER_NONE,
     549                               FXFALSE);
    534550    else
    535551      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
    541562    break;
    542563  case GL_REPLACE:
    543564    if((ifmt==GL_RGB) || (ifmt==GL_LUMINANCE))
    544565      FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
    545                                GR_COMBINE_FACTOR_NONE,
    546                                locala,
    547                                GR_COMBINE_OTHER_NONE,
    548                                FXFALSE);
     566                               GR_COMBINE_FACTOR_NONE,
     567                               locala,
     568                               GR_COMBINE_OTHER_NONE,
     569                               FXFALSE);
    549570    else
    550571      FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
    551                                GR_COMBINE_FACTOR_ONE,
    552                                locala,
    553                                GR_COMBINE_OTHER_TEXTURE,
    554                                FXFALSE);
    555    
     572                               GR_COMBINE_FACTOR_ONE,
     573                               locala,
     574                               GR_COMBINE_OTHER_TEXTURE,
     575                               FXFALSE);
     576
    556577    if(ifmt==GL_ALPHA)
    557578      FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
    558                                GR_COMBINE_FACTOR_NONE,
    559                                localc,
    560                                GR_COMBINE_OTHER_NONE,
    561                                FXFALSE);
     579                               GR_COMBINE_FACTOR_NONE,
     580                               localc,
     581                               GR_COMBINE_OTHER_NONE,
     582                               FXFALSE);
    562583    else
    563584      FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
    564                                GR_COMBINE_FACTOR_ONE,
    565                                localc,
    566                                GR_COMBINE_OTHER_TEXTURE,
    567                                FXFALSE);
     585                               GR_COMBINE_FACTOR_ONE,
     586                               localc,
     587                               GR_COMBINE_OTHER_TEXTURE,
     588                               FXFALSE);
    568589    break;
    569590  default:
     
    587608/************************* Double Texture Set ***************************/
    588609
    589 static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa, 
    590                                     struct gl_texture_object *tObj0,
    591                                     struct gl_texture_object *tObj1)
     610static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa,
     611                                    struct gl_texture_object *tObj0,
     612                                    struct gl_texture_object *tObj1)
    592613{
    593614#define T0_NOT_IN_TMU  0x01
     
    601622  tfxTexInfo *ti1=fxTMGetTexInfo(tObj1);
    602623  GLuint tstate=0;
     624  int tmu0=0, tmu1=1;
    603625
    604626  if (MESA_VERBOSE&VERBOSE_DRIVER) {
     
    606628  }
    607629
    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:
    610641      tstate|=T0_IN_TMU0;
    611     else if(ti0->whichTMU==FX_TMU1)
     642      break;
     643    case FX_TMU1:
    612644      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:
    615650      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:
    622658      tstate|=T1_IN_TMU0;
    623     else if(ti1->whichTMU==FX_TMU1)
     659      break;
     660    case FX_TMU1:
    624661      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:
    627667      tstate|=T1_NOT_IN_TMU;
    628     }
    629   } else
    630     tstate|=T1_NOT_IN_TMU;
     668      break;
     669    }
     670  } else tstate|=T1_NOT_IN_TMU;
    631671
    632672  ti0->lastTimeUsed=fxMesa->texBindNumber;
    633673  ti1->lastTimeUsed=fxMesa->texBindNumber;
    634674
    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    }
    684705  }
    685706
     
    687708    if (ti0->info.format==GR_TEXFMT_P_8) {
    688709       if (MESA_VERBOSE&VERBOSE_DRIVER) {
    689           fprintf(stderr,"fxmesa: uploading texture palette TMU0\n");
     710          fprintf(stderr,"fxmesa: uploading texture palette TMU0\n");
    690711       }
    691        FX_grTexDownloadTable_NoLock(ti0->whichTMU,GR_TEXTABLE_PALETTE,&(ti0->palette));
     712       FX_grTexDownloadTable_NoLock(tmu0, GR_TEXTABLE_PALETTE, &(ti0->palette));
    692713    }
    693714
    694715    if (ti1->info.format==GR_TEXFMT_P_8) {
    695716       if (MESA_VERBOSE&VERBOSE_DRIVER) {
    696           fprintf(stderr,"fxmesa: uploading texture palette TMU1\n");
     717          fprintf(stderr,"fxmesa: uploading texture palette TMU1\n");
    697718       }
    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);
    715734
    716735#undef T0_NOT_IN_TMU
     
    730749  struct gl_texture_object *tObj1=ctx->Texture.Unit[1].CurrentD[2];
    731750  GLuint envmode,ifmt,unitsmode;
     751  int tmu0=0, tmu1=1;
    732752
    733753  if (MESA_VERBOSE&VERBOSE_DRIVER) {
     
    769789  if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE))
    770790     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  }
    775799  fxMesa->tmuSrc=FX_TMU_BOTH;
    776800  switch(envmode) {
     
    780804
    781805      if(ti0->baseLevelInternalFormat==GL_ALPHA)
    782         isalpha[ti0->whichTMU]=GL_TRUE;
     806        isalpha[tmu0]=GL_TRUE;
    783807      else
    784         isalpha[ti0->whichTMU]=GL_FALSE;
     808        isalpha[tmu0]=GL_FALSE;
    785809
    786810      if(ti1->baseLevelInternalFormat==GL_ALPHA)
    787         isalpha[ti1->whichTMU]=GL_TRUE;
     811        isalpha[tmu1]=GL_TRUE;
    788812      else
    789         isalpha[ti1->whichTMU]=GL_FALSE;
    790        
     813        isalpha[tmu1]=GL_FALSE;
     814
    791815      if(isalpha[FX_TMU1])
    792         FX_grTexCombine_NoLock(GR_TMU1,
    793                                GR_COMBINE_FUNCTION_ZERO,
    794                                GR_COMBINE_FACTOR_NONE,
    795                                GR_COMBINE_FUNCTION_LOCAL,
    796                                GR_COMBINE_FACTOR_NONE,
    797                                FXTRUE,FXFALSE);
     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);
    798822      else
    799         FX_grTexCombine_NoLock(GR_TMU1,
    800                                GR_COMBINE_FUNCTION_LOCAL,
    801                                GR_COMBINE_FACTOR_NONE,
    802                                GR_COMBINE_FUNCTION_LOCAL,
    803                                GR_COMBINE_FACTOR_NONE,
    804                                FXFALSE,FXFALSE);
     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);
    805829
    806830      if(isalpha[FX_TMU0])
    807         FX_grTexCombine_NoLock(GR_TMU0,
    808                                GR_COMBINE_FUNCTION_BLEND_OTHER,
    809                                GR_COMBINE_FACTOR_ONE,
    810                                GR_COMBINE_FUNCTION_BLEND_OTHER,
    811                                GR_COMBINE_FACTOR_LOCAL,
    812                                FXFALSE,FXFALSE);
     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);
    813837      else
    814         FX_grTexCombine_NoLock(GR_TMU0,
    815                                GR_COMBINE_FUNCTION_BLEND_OTHER,
    816                                GR_COMBINE_FACTOR_LOCAL,
    817                                GR_COMBINE_FUNCTION_BLEND_OTHER,
    818                                GR_COMBINE_FACTOR_LOCAL,
    819                                FXFALSE,FXFALSE);
     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);
    820844
    821845      FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
    822                                GR_COMBINE_FACTOR_LOCAL,
    823                                localc,
    824                                GR_COMBINE_OTHER_TEXTURE,
    825                                FXFALSE);
     846                               GR_COMBINE_FACTOR_LOCAL,
     847                               localc,
     848                               GR_COMBINE_OTHER_TEXTURE,
     849                               FXFALSE);
    826850
    827851      FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
    828                                GR_COMBINE_FACTOR_LOCAL,
    829                                locala,
    830                                GR_COMBINE_OTHER_TEXTURE,
    831                                FXFALSE);
     852                               GR_COMBINE_FACTOR_LOCAL,
     853                               locala,
     854                               GR_COMBINE_OTHER_TEXTURE,
     855                               FXFALSE);
    832856      break;
    833857    }
    834858  case (FX_UM_E0_REPLACE | FX_UM_E1_BLEND): /* Only for GLQuake */
    835     if(ti1->whichTMU==FX_TMU1) {
     859    if (tmu1==FX_TMU1) {
    836860      FX_grTexCombine_NoLock(GR_TMU1,
    837                              GR_COMBINE_FUNCTION_LOCAL,
    838                              GR_COMBINE_FACTOR_NONE,
    839                              GR_COMBINE_FUNCTION_LOCAL,
    840                              GR_COMBINE_FACTOR_NONE,
    841                              FXTRUE,FXFALSE);
    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
    843867      FX_grTexCombine_NoLock(GR_TMU0,
    844                              GR_COMBINE_FUNCTION_BLEND_OTHER,
    845                              GR_COMBINE_FACTOR_LOCAL,
    846                              GR_COMBINE_FUNCTION_BLEND_OTHER,
    847                              GR_COMBINE_FACTOR_LOCAL,
    848                              FXFALSE,FXFALSE);
     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);
    849873    } else {
    850874      FX_grTexCombine_NoLock(GR_TMU1,
    851                              GR_COMBINE_FUNCTION_LOCAL,
    852                              GR_COMBINE_FACTOR_NONE,
    853                              GR_COMBINE_FUNCTION_LOCAL,
    854                              GR_COMBINE_FACTOR_NONE,
    855                              FXFALSE,FXFALSE);
    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
    857881      FX_grTexCombine_NoLock(GR_TMU0,
    858                              GR_COMBINE_FUNCTION_BLEND_OTHER,
    859                              GR_COMBINE_FACTOR_ONE_MINUS_LOCAL,
    860                              GR_COMBINE_FUNCTION_BLEND_OTHER,
    861                              GR_COMBINE_FACTOR_ONE_MINUS_LOCAL,
    862                              FXFALSE,FXFALSE);
    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
    865889    FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
    866                              GR_COMBINE_FACTOR_NONE,
    867                              locala,
    868                              GR_COMBINE_OTHER_NONE,
    869                              FXFALSE);
     890                             GR_COMBINE_FACTOR_NONE,
     891                             locala,
     892                             GR_COMBINE_OTHER_NONE,
     893                             FXFALSE);
    870894
    871895    FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
    872                              GR_COMBINE_FACTOR_ONE,
    873                              localc,
    874                              GR_COMBINE_OTHER_TEXTURE,
    875                              FXFALSE);
     896                             GR_COMBINE_FACTOR_ONE,
     897                             localc,
     898                             GR_COMBINE_OTHER_TEXTURE,
     899                             FXFALSE);
    876900    break;
    877901  case (FX_UM_E0_REPLACE | FX_UM_E1_MODULATE): /* Quake 2 and 3 */
    878     if(ti1->whichTMU==FX_TMU1) {
     902    if (tmu1==FX_TMU1) {
    879903      FX_grTexCombine_NoLock(GR_TMU1,
    880                              GR_COMBINE_FUNCTION_LOCAL,
    881                              GR_COMBINE_FACTOR_NONE,
    882                              GR_COMBINE_FUNCTION_ZERO,
    883                              GR_COMBINE_FACTOR_NONE,
    884                              FXFALSE,FXTRUE);
    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
    886910      FX_grTexCombine_NoLock(GR_TMU0,
    887                              GR_COMBINE_FUNCTION_BLEND_OTHER,
    888                              GR_COMBINE_FACTOR_LOCAL,
    889                              GR_COMBINE_FUNCTION_BLEND_OTHER,
    890                              GR_COMBINE_FACTOR_LOCAL,
    891                              FXFALSE,FXFALSE);
     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);
    892916
    893917    } else {
    894918      FX_grTexCombine_NoLock(GR_TMU1,
    895                              GR_COMBINE_FUNCTION_LOCAL,
    896                              GR_COMBINE_FACTOR_NONE,
    897                              GR_COMBINE_FUNCTION_LOCAL,
    898                              GR_COMBINE_FACTOR_NONE,
    899                              FXFALSE,FXFALSE);
    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
    901925      FX_grTexCombine_NoLock(GR_TMU0,
    902                              GR_COMBINE_FUNCTION_BLEND_OTHER,
    903                              GR_COMBINE_FACTOR_LOCAL,
    904                              GR_COMBINE_FUNCTION_BLEND_OTHER,
    905                              GR_COMBINE_FACTOR_ONE,
    906                              FXFALSE,FXFALSE);
    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
    909933    if(ti0->baseLevelInternalFormat==GL_RGB)
    910934      FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
    911                                GR_COMBINE_FACTOR_NONE,
    912                                locala,
    913                                GR_COMBINE_OTHER_NONE,
    914                                FXFALSE);
     935                               GR_COMBINE_FACTOR_NONE,
     936                               locala,
     937                               GR_COMBINE_OTHER_NONE,
     938                               FXFALSE);
    915939    else
    916940      FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
    917                                GR_COMBINE_FACTOR_ONE,
    918                                locala,
    919                                GR_COMBINE_OTHER_NONE,
    920                                FXFALSE);
     941                               GR_COMBINE_FACTOR_ONE,
     942                               locala,
     943                               GR_COMBINE_OTHER_NONE,
     944                               FXFALSE);
    921945
    922946
    923947    FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
    924                              GR_COMBINE_FACTOR_ONE,
    925                              localc,
    926                              GR_COMBINE_OTHER_TEXTURE,
    927                              FXFALSE);
    928     break;
    929  
     948                             GR_COMBINE_FACTOR_ONE,
     949                             localc,
     950                             GR_COMBINE_OTHER_TEXTURE,
     951                             FXFALSE);
     952    break;
     953
    930954
    931955  case (FX_UM_E0_MODULATE | FX_UM_E1_ADD): /* Quake 3 Sky */
     
    934958
    935959      if(ti0->baseLevelInternalFormat==GL_ALPHA)
    936         isalpha[ti0->whichTMU]=GL_TRUE;
     960        isalpha[tmu0]=GL_TRUE;
    937961      else
    938         isalpha[ti0->whichTMU]=GL_FALSE;
     962        isalpha[tmu0]=GL_FALSE;
    939963
    940964      if(ti1->baseLevelInternalFormat==GL_ALPHA)
    941         isalpha[ti1->whichTMU]=GL_TRUE;
     965        isalpha[tmu1]=GL_TRUE;
    942966      else
    943         isalpha[ti1->whichTMU]=GL_FALSE;
    944        
     967        isalpha[tmu1]=GL_FALSE;
     968
    945969      if(isalpha[FX_TMU1])
    946         FX_grTexCombine_NoLock(GR_TMU1,
    947                                GR_COMBINE_FUNCTION_ZERO,
    948                                GR_COMBINE_FACTOR_NONE,
    949                                GR_COMBINE_FUNCTION_LOCAL,
    950                                GR_COMBINE_FACTOR_NONE,
    951                                FXTRUE,FXFALSE);
     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);
    952976      else
    953         FX_grTexCombine_NoLock(GR_TMU1,
    954                                GR_COMBINE_FUNCTION_LOCAL,
    955                                GR_COMBINE_FACTOR_NONE,
    956                                GR_COMBINE_FUNCTION_LOCAL,
    957                                GR_COMBINE_FACTOR_NONE,
    958                                FXFALSE,FXFALSE);
     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);
    959983
    960984      if(isalpha[FX_TMU0])
    961         FX_grTexCombine_NoLock(GR_TMU0,
    962                                GR_COMBINE_FUNCTION_SCALE_OTHER,
    963                                GR_COMBINE_FACTOR_ONE,
    964                                GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
    965                                GR_COMBINE_FACTOR_ONE,
    966                                FXFALSE,FXFALSE);
     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);
    967991      else
    968         FX_grTexCombine_NoLock(GR_TMU0,
    969                                GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
    970                                GR_COMBINE_FACTOR_ONE,
    971                                GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
    972                                GR_COMBINE_FACTOR_ONE,
    973                                FXFALSE,FXFALSE);
     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);
    974998
    975999      FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
    976                                GR_COMBINE_FACTOR_LOCAL,
    977                                localc,
    978                                GR_COMBINE_OTHER_TEXTURE,
    979                                FXFALSE);
     1000                               GR_COMBINE_FACTOR_LOCAL,
     1001                               localc,
     1002                               GR_COMBINE_OTHER_TEXTURE,
     1003                               FXFALSE);
    9801004
    9811005      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;
    9891015  }
    9901016
     
    10121038  else
    10131039    locala=GR_COMBINE_LOCAL_CONSTANT;
    1014  
     1040
    10151041  if(ctx->Light.ShadeModel==GL_SMOOTH)
    10161042    localc=GR_COMBINE_LOCAL_ITERATED;
    10171043  else
    10181044    localc=GR_COMBINE_LOCAL_CONSTANT;
    1019  
     1045
    10201046  FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
    1021                            GR_COMBINE_FACTOR_NONE,
    1022                            locala,
    1023                            GR_COMBINE_OTHER_NONE,
    1024                            FXFALSE);
     1047                           GR_COMBINE_FACTOR_NONE,
     1048                           locala,
     1049                           GR_COMBINE_OTHER_NONE,
     1050                           FXFALSE);
    10251051
    10261052  FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
    1027                            GR_COMBINE_FACTOR_NONE,
    1028                            localc,
    1029                            GR_COMBINE_OTHER_NONE,
    1030                            FXFALSE);
     1053                           GR_COMBINE_FACTOR_NONE,
     1054                           localc,
     1055                           GR_COMBINE_OTHER_NONE,
     1056                           FXFALSE);
    10311057
    10321058  fxMesa->lastUnitsMode=FX_UM_NONE;
     
    10371063/************************************************************************/
    10381064
    1039 void fxSetupTexture_NoLock(GLcontext *ctx)
     1065static void fxSetupTexture_NoLock(GLcontext *ctx)
    10401066{
    10411067  fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
     
    10511077
    10521078  /* Texture Combine, Color Combine and Alpha Combine.
    1053    */ 
     1079   */
    10541080  tex2Denabled = (ctx->Texture.ReallyEnabled & TEXTURE0_2D);
    10551081
    10561082  if (fxMesa->emulateTwoTMUs)
    10571083     tex2Denabled |= (ctx->Texture.ReallyEnabled & TEXTURE1_2D);
    1058  
     1084
    10591085  switch(tex2Denabled) {
    10601086  case TEXTURE0_2D:
    1061     fxSetupTextureSingleTMU_NoLock(ctx,0);   
     1087    fxSetupTextureSingleTMU_NoLock(ctx,0);
    10621088    break;
    10631089  case TEXTURE1_2D:
     
    10661092  case (TEXTURE0_2D|TEXTURE1_2D):
    10671093     if (fxMesa->haveTwoTMUs)
    1068         fxSetupTextureDoubleTMU_NoLock(ctx);
     1094        fxSetupTextureDoubleTMU_NoLock(ctx);
    10691095     else {
    1070         if (MESA_VERBOSE&VERBOSE_DRIVER)
    1071            fprintf(stderr, "fxmesa: enabling fake multitexture\n");
    1072 
    1073         fxSetupTextureSingleTMU_NoLock(ctx,0);
    1074         ctx->Driver.MultipassFunc = fxMultipassTexture;
     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;
    10751101     }
    10761102    break;
     
    10811107}
    10821108
    1083 void fxSetupTexture(GLcontext *ctx) {
     1109static void fxSetupTexture(GLcontext *ctx) {
    10841110  BEGIN_BOARD_LOCK();
    10851111  fxSetupTexture_NoLock(ctx);
     
    11811207    break;
    11821208  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;
    11841212    adfact=GR_BLEND_ZERO;
    11851213    break;
    11861214  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;
    11881218    adfact=GR_BLEND_ZERO;
    11891219    break;
     
    12151245  if(us->blendEnabled)
    12161246     FX_grAlphaBlendFunction(us->blendSrcFuncRGB,us->blendDstFuncRGB,
    1217                           us->blendSrcFuncAlpha,us->blendDstFuncAlpha);
     1247                          us->blendSrcFuncAlpha,us->blendDstFuncAlpha);
    12181248  else
    12191249     FX_grAlphaBlendFunction(GR_BLEND_ONE,GR_BLEND_ZERO,GR_BLEND_ONE,GR_BLEND_ZERO);
    12201250}
    1221  
     1251
    12221252/************************************************************************/
    12231253/************************** Alpha Test SetUp ****************************/
     
    12581288    fprintf(stderr,"fx Driver: internal error in fxDDAlphaFunc()\n");
    12591289    fxCloseHardware();
    1260     exit(-1);
     1290    EXIT(-1);
    12611291    break;
    12621292  }
     
    13251355    fprintf(stderr,"fx Driver: internal error in fxDDDepthFunc()\n");
    13261356    fxCloseHardware();
    1327     exit(-1);
     1357    EXIT(-1);
    13281358    break;
    13291359  }
     
    13661396/************************************************************************/
    13671397
    1368 GLboolean fxDDColorMask(GLcontext *ctx, 
    1369                         GLboolean r, GLboolean g,
    1370                         GLboolean b, GLboolean a )
     1398GLboolean fxDDColorMask(GLcontext *ctx,
     1399                        GLboolean r, GLboolean g,
     1400                        GLboolean b, GLboolean a )
    13711401{
    13721402  fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
     
    13741404  ctx->Driver.RenderStart = fxSetupFXUnits;
    13751405  (void) r; (void) g; (void) b; (void) a;
    1376   return 1;
     1406  return GL_FALSE;
    13771407}
    13781408
     
    13821412
    13831413  FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
    1384               ctx->Color.ColorMask[GCOMP] ||
    1385               ctx->Color.ColorMask[BCOMP],
    1386               ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
     1414              ctx->Color.ColorMask[GCOMP] ||
     1415              ctx->Color.ColorMask[BCOMP],
     1416              ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
    13871417}
    13881418
     
    13931423/************************************************************************/
    13941424
    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 */
     1428static 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 */
    14281434    GLubyte col[4];
    1429     FX_grFogMode(GR_FOG_WITH_TABLE);
    1430 
    14311435    col[0]=(unsigned int)(255*ctx->Fog.Color[0]);
    14321436    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]);
    14341438    col[3]=(unsigned int)(255*ctx->Fog.Color[3]);
    1435 
    14361439    FX_grFogColorValue(FXCOLOR4(col));
    14371440
    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
    14471465    FX_grFogTable(fxMesa->fogTable);
    1448   } else
     1466    FX_grFogMode(GR_FOG_WITH_TABLE);
     1467  }
     1468  else {
    14491469    FX_grFogMode(GR_FOG_DISABLE);
     1470  }
    14501471}
    14511472
     
    14861507  if (xmin<fxMesa->clipMinX) xmin=fxMesa->clipMinX;
    14871508  if (xmax>fxMesa->clipMaxX) xmax=fxMesa->clipMaxX;
    1488   if (ymin<fxMesa->screen_height-fxMesa->clipMaxY) 
     1509  if (ymin<fxMesa->screen_height-fxMesa->clipMaxY)
    14891510    ymin=fxMesa->screen_height-fxMesa->clipMaxY;
    14901511  if (ymax>fxMesa->screen_height-fxMesa->clipMinY)
     
    15181539   (void) mode;
    15191540   FX_CONTEXT(ctx)->new_state |= FX_NEW_CULL;
    1520    ctx->Driver.RenderStart = fxSetupFXUnits;   
     1541   ctx->Driver.RenderStart = fxSetupFXUnits;
    15211542}
    15221543
     
    15251546   (void) mode;
    15261547   FX_CONTEXT(ctx)->new_state |= FX_NEW_CULL;
    1527    ctx->Driver.RenderStart = fxSetupFXUnits;   
     1548   ctx->Driver.RenderStart = fxSetupFXUnits;
    15281549}
    15291550
     
    15311552static void fxSetupCull(GLcontext *ctx)
    15321553{
    1533    if(ctx->Polygon.CullFlag) {
    1534       switch(ctx->Polygon.CullFaceMode) {
    1535       case GL_BACK:
    1536          if(ctx->Polygon.FrontFace==GL_CCW)
    1537             FX_grCullMode(GR_CULL_NEGATIVE);
    1538         else
    1539             FX_grCullMode(GR_CULL_POSITIVE);
    1540         break;
    1541       case GL_FRONT:
    1542         if(ctx->Polygon.FrontFace==GL_CCW)
    1543             FX_grCullMode(GR_CULL_POSITIVE);
    1544         else
    1545             FX_grCullMode(GR_CULL_NEGATIVE);
    1546         break;
    1547       case GL_FRONT_AND_BACK:
    1548          FX_grCullMode(GR_CULL_DISABLE);
    1549         break;
    1550       default:
    1551         break;
    1552       }
    1553    } else
    1554       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);
    15551576}
    15561577
     
    15941615     fxMesa->new_state |= FX_NEW_SCISSOR;
    15951616     ctx->Driver.RenderStart = fxSetupFXUnits;
     1617     break;
     1618  case GL_SHARED_TEXTURE_PALETTE_EXT:
     1619     fxDDTexUseGlbPalette(ctx, state);
    15961620     break;
    15971621  case GL_FOG:
     
    16041628     break;
    16051629  case GL_LINE_SMOOTH:
     1630  case GL_LINE_STIPPLE:
    16061631  case GL_POINT_SMOOTH:
    16071632  case GL_POLYGON_SMOOTH:
     
    16121637  default:
    16131638    ;  /* XXX no-op? */
    1614   }   
     1639  }
    16151640}
    16161641
     
    16361661      case GL_NEVER:
    16371662      case GL_ALWAYS:
    1638         break;
     1663        break;
    16391664      default:
    1640         fxDDDepthFunc(ctx, GL_EQUAL);
    1641         break;
     1665        fxDDDepthFunc(ctx, GL_EQUAL);
     1666        break;
    16421667      }
    16431668      fxDDDepthMask(ctx, FALSE);
     
    16461671    /* ? Set the Constant Color ? */
    16471672    fxDDEnable(ctx, GL_BLEND, GL_TRUE);
    1648     fxDDBlendFunc(ctx, ?, ?);
    1649     fxSetupTextureSingleTMU(ctx, ?);
     1673    fxDDBlendFunc(ctx, XXX, XXX);
     1674    fxSetupTextureSingleTMU(ctx, XXX);
    16501675    fxSetupBlend(ctx);
    16511676    fxSetupDepthTest(ctx);
     
    16551680    /* Reset everything back to normal */
    16561681    fxMesa->unitsState = fxMesa->restoreUnitsState;
    1657     fxMesa->setupdone &= ?;
    1658     fxSetupTextureSingleTMU(ctx, ?);
     1682    fxMesa->setupdone &= XXX;
     1683    fxSetupTextureSingleTMU(ctx, XXX);
    16591684    fxSetupBlend(ctx);
    16601685    fxSetupDepthTest(ctx);
     
    16761701 * support almost the same subset using multipass blending on the
    16771702 * 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.
    16791704 */
    16801705static GLboolean fxMultipassTexture( struct vertex_buffer *VB, GLuint pass )
     
    16881713   case 1:
    16891714      if (MESA_VERBOSE&(VERBOSE_DRIVER|VERBOSE_PIPELINE|VERBOSE_TEXTURE))
    1690         fprintf(stderr, "fxmesa: Second texture pass\n");
     1715        fprintf(stderr, "fxmesa: Second texture pass\n");
    16911716
    16921717      for ( ; v != last ; v++) {
    1693         v->f[S0COORD] = v->f[S1COORD];
    1694         v->f[T0COORD] = v->f[T1COORD];
     1718        v->f[S0COORD] = v->f[S1COORD];
     1719        v->f[T0COORD] = v->f[T1COORD];
    16951720      }
    16961721
    1697       fxMesa->restoreUnitsState = fxMesa->unitsState; 
     1722      fxMesa->restoreUnitsState = fxMesa->unitsState;
    16981723      fxMesa->tmu_source[0] = 1;
    16991724
    17001725      if (ctx->Depth.Mask) {
    1701         switch (ctx->Depth.Func) {
    1702         case GL_NEVER:
    1703         case GL_ALWAYS:
    1704             break;
    1705         default:
    1706             fxDDDepthFunc( ctx, GL_EQUAL );
    1707             break;
    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 );
    17111736      }
    1712      
     1737
    17131738      if (ctx->Texture.Unit[1].EnvMode == GL_MODULATE) {
    1714         fxDDEnable( ctx, GL_BLEND, GL_TRUE );
    1715         fxDDBlendFunc( ctx, GL_DST_COLOR, GL_ZERO );
     1739        fxDDEnable( ctx, GL_BLEND, GL_TRUE );
     1740        fxDDBlendFunc( ctx, GL_DST_COLOR, GL_ZERO );
    17161741      }
    17171742
    1718       fxSetupTextureSingleTMU( ctx, 1 ); 
     1743      fxSetupTextureSingleTMU( ctx, 1 );
    17191744      fxSetupBlend( ctx );
    17201745      fxSetupDepthTest( ctx );
     
    17221747
    17231748   case 2:
    1724       /* Restore original state. 
     1749      /* Restore original state.
    17251750       */
    17261751      fxMesa->tmu_source[0] = 0;
    17271752      fxMesa->unitsState = fxMesa->restoreUnitsState;
    17281753      fxMesa->setupdone &= ~SETUP_TMU0;
    1729       fxSetupTextureSingleTMU( ctx, 0 ); 
     1754      fxSetupTextureSingleTMU( ctx, 0 );
    17301755      fxSetupBlend( ctx );
    17311756      fxSetupDepthTest( ctx );
     
    17331758   }
    17341759
    1735    return pass == 1;     
     1760   return pass == 1;
    17361761}
    17371762
     
    17571782static void gl_print_fx_state_flags( const char *msg, GLuint flags )
    17581783{
    1759    fprintf(stderr, 
    1760            "%s: (0x%x) %s%s%s%s%s%s%s\n",
    1761            msg,
    1762            flags,
    1763            (flags & FX_NEW_TEXTURING)   ? "texture, " : "",
    1764            (flags & FX_NEW_BLEND)       ? "blend, " : "",
    1765            (flags & FX_NEW_ALPHA)       ? "alpha, " : "",
    1766            (flags & FX_NEW_FOG)         ? "fog, " : "",
    1767            (flags & FX_NEW_SCISSOR)     ? "scissor, " : "",
    1768            (flags & FX_NEW_COLOR_MASK)  ? "colormask, " : "",
    1769            (flags & FX_NEW_CULL)        ? "cull, " : "");
     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, " : "");
    17701795}
    17711796
     
    17801805  if (newstate) {
    17811806     if (newstate & FX_NEW_TEXTURING)
    1782         fxSetupTexture(ctx);
     1807        fxSetupTexture(ctx);
    17831808
    17841809     if (newstate & FX_NEW_BLEND)
    1785         fxSetupBlend(ctx);
     1810        fxSetupBlend(ctx);
    17861811
    17871812     if (newstate & FX_NEW_ALPHA)
    1788         fxSetupAlphaTest(ctx);
    1789      
     1813        fxSetupAlphaTest(ctx);
     1814
    17901815     if (newstate & FX_NEW_DEPTH)
    1791         fxSetupDepthTest(ctx);
     1816        fxSetupDepthTest(ctx);
    17921817
    17931818     if (newstate & FX_NEW_FOG)
    1794         fxSetupFog(ctx,GL_FALSE);
     1819        fxSetupFog(ctx);
    17951820
    17961821     if (newstate & FX_NEW_SCISSOR)
    1797         fxSetupScissor(ctx);
     1822        fxSetupScissor(ctx);
    17981823
    17991824     if (newstate & FX_NEW_COLOR_MASK)
    1800         fxSetupColorMask(ctx);
     1825        fxSetupColorMask(ctx);
    18011826
    18021827     if (newstate & FX_NEW_CULL)
    1803         fxSetupCull(ctx);     
     1828        fxSetupCull(ctx);
    18041829
    18051830     fxMesa->new_state = 0;
  • trunk/src/opengl/mesa/3dfx/fxstripdet.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.
     
    5252#include "vbcull.h"
    5353
    54  
    55 #define STRIP0(u,v)             ((u1 == v1) && (u2 == v0))     
    56 #define STRIP1(u,v)             ((u0 == v0) && (u2 == v1))
    5754
    58 #define LOCAL_VARS              fxVertex* gWin = FX_DRIVER_DATA(VB)->verts;     \
    59                                 GrVertex** sb = FX_DRIVER_DATA(VB)->strips_b;   
    60                                
    61 #define STRIPSLOCAL_VAR         int sc         = 0;
     55#define STRIP0(u,v)             ((u1 == v1) && (u2 == v0))
     56#define STRIP1(u,v)             ((u0 == v0) && (u2 == v1))
    6257
    63 #define INIT(a)                 
     58#define LOCAL_VARS              fxVertex* gWin = FX_DRIVER_DATA(VB)->verts;     \
     59                                GrVertex** sb = FX_DRIVER_DATA(VB)->strips_b;
    6460
    65 #define SENDTRI(u0,u1,u2)       FX_grDrawTriangle((GrVertex*)&(gWin[u0].f),(GrVertex*)&(gWin[u1].f),(GrVertex*)&(gWin[u2].f))
    66 #define FLUSHTRI()              /* No-Op */
    67 #define STARTSTRIPS(u0,u1,u2)   { sb[sc++] = (GrVertex*)&(gWin[u0].f); sb[sc++] = (GrVertex*)&(gWin[u1].f); sb[sc++] = (GrVertex*)&(gWin[u2].f); }
    68 #define SENDSTRIPS(v2)          { sb[sc++] = (GrVertex*)&(gWin[v2].f); }
    69 #define FLUSHSTRIPS()           FX_grDrawVertexArray(GR_TRIANGLE_STRIP,sc,sb)
     61#define STRIPSLOCAL_VAR         int sc         = 0;
    7062
    71 #define CLIPPED(a,b,c)          0
    72 #define CULLED(a,b,c)           0
    73 #define SENDCLIPTRI(a,b,c)      /* NoOp */             
     63#define INIT(a)
    7464
    75 #define TAG(x)                  x##_fx
     65#define SENDTRI(u0,u1,u2)       FX_grDrawTriangle((GrVertex*)&(gWin[u0].f),(GrVertex*)&(gWin[u1].f),(GrVertex*)&(gWin[u2].f))
     66#define FLUSHTRI()              /* No-Op */
     67#define STARTSTRIPS(u0,u1,u2)   { sb[sc++] = (GrVertex*)&(gWin[u0].f); sb[sc++] = (GrVertex*)&(gWin[u1].f); sb[sc++] = (GrVertex*)&(gWin[u2].f); }
     68#define SENDSTRIPS(v2)          { sb[sc++] = (GrVertex*)&(gWin[v2].f); }
     69#define FLUSHSTRIPS()           FX_grDrawVertexArray(GR_TRIANGLE_STRIP,sc,sb)
     70
     71#define CLIPPED(a,b,c)          0
     72#define CULLED(a,b,c)           0
     73#define SENDCLIPTRI(a,b,c)      /* NoOp */
     74
     75#define TAG(x)                  x##_fx
    7676
    7777#include "fxsdettmp.h"
     
    7979
    8080/* Clipped but no userclip */
    81 #define STRIP0(u,v)             ((u1 == v1) && (u2 == v0)) && !clipmask[v2]     
    82 #define STRIP1(u,v)             ((u0 == v0) && (u2 == v1)) && !clipmask[v2]
     81#define STRIP0(u,v)             ((u1 == v1) && (u2 == v0)) && !clipmask[v2]
     82#define STRIP1(u,v)             ((u0 == v0) && (u2 == v1)) && !clipmask[v2]
    8383
    84 #define LOCAL_VARS              fxVertex* gWin = FX_DRIVER_DATA(VB)->verts;                     \
    85                                 GrVertex** sb = FX_DRIVER_DATA(VB)->strips_b;                   \
    86                                 const GLubyte *const clipmask = VB->ClipMask;                           \
    87                                 const fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx;   \
    88                                 const tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
    89                                
    90 #define STRIPSLOCAL_VAR         int sc         = 0;
     84#define LOCAL_VARS              fxVertex* gWin = FX_DRIVER_DATA(VB)->verts;                     \
     85                                GrVertex** sb = FX_DRIVER_DATA(VB)->strips_b;                   \
     86                                const GLubyte *const clipmask = VB->ClipMask;                           \
     87                                const fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx;   \
     88                                const tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
    9189
    92 #define INIT(a)                 
     90#define STRIPSLOCAL_VAR         int sc         = 0;
    9391
    94 #define SENDTRI(u0,u1,u2)       FX_grDrawTriangle((GrVertex*)&(gWin[u0].f),(GrVertex*)&(gWin[u1].f),(GrVertex*)&(gWin[u2].f))
    95 #define FLUSHTRI()              /* No-Op */
    96 #define STARTSTRIPS(u0,u1,u2)   { sb[sc++] = (GrVertex*)&(gWin[u0].f); sb[sc++] = (GrVertex*)&(gWin[u1].f); sb[sc++] = (GrVertex*)&(gWin[u2].f); }
    97 #define SENDSTRIPS(v2)          { sb[sc++] = (GrVertex*)&(gWin[v2].f); }
    98 #define FLUSHSTRIPS()           FX_grDrawVertexArray(GR_TRIANGLE_STRIP,sc,sb)
     92#define INIT(a)
    9993
    100 #define CLIPPED(u0,u1,u2)       (clipmask[u0] | clipmask[u1] | clipmask[u2])
    101 #define CULLED(u0,u1,u2)        (clipmask[u0] & clipmask[u1] & clipmask[u2])
    102 #define SENDCLIPTRI(u0,u1,u2)   {                                                                       \
    103                                    GLuint vl[3];                                                        \
    104                                    ASSIGN_3V(vl, u0, u1, u2 );                                          \
    105                                    cliptri(VB,vl,clipmask[u0] | clipmask[u1] | clipmask[u2]);           \
    106                                 }
    107  
    108 #define TAG(x)                  x##_fx_view_clipped
     94#define SENDTRI(u0,u1,u2)       FX_grDrawTriangle((GrVertex*)&(gWin[u0].f),(GrVertex*)&(gWin[u1].f),(GrVertex*)&(gWin[u2].f))
     95#define FLUSHTRI()              /* No-Op */
     96#define STARTSTRIPS(u0,u1,u2)   { sb[sc++] = (GrVertex*)&(gWin[u0].f); sb[sc++] = (GrVertex*)&(gWin[u1].f); sb[sc++] = (GrVertex*)&(gWin[u2].f); }
     97#define SENDSTRIPS(v2)          { sb[sc++] = (GrVertex*)&(gWin[v2].f); }
     98#define FLUSHSTRIPS()           FX_grDrawVertexArray(GR_TRIANGLE_STRIP,sc,sb)
     99
     100#define CLIPPED(u0,u1,u2)       (clipmask[u0] | clipmask[u1] | clipmask[u2])
     101#define CULLED(u0,u1,u2)        (clipmask[u0] & clipmask[u1] & clipmask[u2])
     102#define SENDCLIPTRI(u0,u1,u2)   {                                                                       \
     103                                   GLuint vl[3];                                                        \
     104                                   ASSIGN_3V(vl, u0, u1, u2 );                                          \
     105                                   cliptri(VB,vl,clipmask[u0] | clipmask[u1] | clipmask[u2]);           \
     106                                }
     107
     108#define TAG(x)                  x##_fx_view_clipped
    109109
    110110#include "fxsdettmp.h"
    111111
    112112/* Clipped and might be userclip */
    113 #define STRIP0(u,v)             ((u1 == v1) && (u2 == v0)) && !clipmask[v2]     
    114 #define STRIP1(u,v)             ((u0 == v0) && (u2 == v1)) && !clipmask[v2]
     113#define STRIP0(u,v)             ((u1 == v1) && (u2 == v0)) && !clipmask[v2]
     114#define STRIP1(u,v)             ((u0 == v0) && (u2 == v1)) && !clipmask[v2]
    115115
    116 #define LOCAL_VARS              fxVertex* gWin = FX_DRIVER_DATA(VB)->verts;                     \
    117                                 GrVertex** sb = FX_DRIVER_DATA(VB)->strips_b;                   \
    118                                 const GLubyte *const clipmask = VB->ClipMask;                   \
    119                                 const GLubyte *userclipmask = VB->UserClipMask;                 \
    120                                 const fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx;   \
    121                                 const tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
    122                                
    123 #define STRIPSLOCAL_VAR         int sc         = 0;
     116#define LOCAL_VARS              fxVertex* gWin = FX_DRIVER_DATA(VB)->verts;                     \
     117                                GrVertex** sb = FX_DRIVER_DATA(VB)->strips_b;                   \
     118                                const GLubyte *const clipmask = VB->ClipMask;                   \
     119                                const GLubyte *userclipmask = VB->UserClipMask;                 \
     120                                const fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx;   \
     121                                const tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
    124122
    125 #define INIT(a)                 
     123#define STRIPSLOCAL_VAR         int sc         = 0;
    126124
    127 #define SENDTRI(u0,u1,u2)       FX_grDrawTriangle((GrVertex*)&(gWin[u0].f),(GrVertex*)&(gWin[u1].f),(GrVertex*)&(gWin[u2].f))
    128 #define FLUSHTRI()              /* No-Op */
    129 #define STARTSTRIPS(u0,u1,u2)   { sb[sc++] = (GrVertex*)&(gWin[u0].f); sb[sc++] = (GrVertex*)&(gWin[u1].f); sb[sc++] = (GrVertex*)&(gWin[u2].f); }
    130 #define SENDSTRIPS(v2)          { sb[sc++] = (GrVertex*)&(gWin[v2].f); }
    131 #define FLUSHSTRIPS()           FX_grDrawVertexArray(GR_TRIANGLE_STRIP,sc,sb)
     125#define INIT(a)
    132126
    133 #define CLIPPED(u0,u1,u2)       (clipmask[u0] | clipmask[u1] | clipmask[u2])
    134 #define CULLED(u0,u1,u2)        (clipmask[u0] & clipmask[u1] & clipmask[u2] & CLIP_ALL_BITS)
    135 #define SENDCLIPTRI(u0,u1,u2)   {                                                                                         \
    136                                         GLuint vl[3];                                                                     \
    137                                         GLuint imask = (clipmask[u0] | clipmask[u1] | clipmask[u2]);                      \
    138                                                                                                                           \
    139                                         if (imask & CLIP_USER_BIT) {                                                      \
    140                                                 if (!(userclipmask[u2] & userclipmask[u1] & userclipmask[u0]))            \
    141                                                 { ASSIGN_3V(vl, u2, u1, u0 );                                             \
    142                                                   imask |= (userclipmask[u2] | userclipmask[u1] | userclipmask[u0]) << 8; \
    143                                                    cliptri( VB, vl, imask );}                                             \
    144                                         }                                                                                 \
    145                                         else { ASSIGN_3V(vl, u2, u1, u0 );                                                \
    146                                             cliptri( VB, vl, imask );   }                                                 \
    147                                 }
    148  
    149 #define TAG(x)                  x##_fx_clipped
     127#define SENDTRI(u0,u1,u2)       FX_grDrawTriangle((GrVertex*)&(gWin[u0].f),(GrVertex*)&(gWin[u1].f),(GrVertex*)&(gWin[u2].f))
     128#define FLUSHTRI()              /* No-Op */
     129#define STARTSTRIPS(u0,u1,u2)   { sb[sc++] = (GrVertex*)&(gWin[u0].f); sb[sc++] = (GrVertex*)&(gWin[u1].f); sb[sc++] = (GrVertex*)&(gWin[u2].f); }
     130#define SENDSTRIPS(v2)          { sb[sc++] = (GrVertex*)&(gWin[v2].f); }
     131#define FLUSHSTRIPS()           FX_grDrawVertexArray(GR_TRIANGLE_STRIP,sc,sb)
     132
     133#define CLIPPED(u0,u1,u2)       (clipmask[u0] | clipmask[u1] | clipmask[u2])
     134#define CULLED(u0,u1,u2)        (clipmask[u0] & clipmask[u1] & clipmask[u2] & CLIP_ALL_BITS)
     135#define SENDCLIPTRI(u0,u1,u2)   {                                                                                         \
     136                                        GLuint vl[3];                                                                     \
     137                                        GLuint imask = (clipmask[u0] | clipmask[u1] | clipmask[u2]);                      \
     138                                                                                                                          \
     139                                        if (imask & CLIP_USER_BIT) {                                                      \
     140                                                if (!(userclipmask[u2] & userclipmask[u1] & userclipmask[u0]))            \
     141                                                { ASSIGN_3V(vl, u2, u1, u0 );                                             \
     142                                                  imask |= (userclipmask[u2] | userclipmask[u1] | userclipmask[u0]) << 8; \
     143                                                   cliptri( VB, vl, imask );}                                             \
     144                                        }                                                                                 \
     145                                        else { ASSIGN_3V(vl, u2, u1, u0 );                                                \
     146                                            cliptri( VB, vl, imask );   }                                                 \
     147                                }
     148
     149#define TAG(x)                  x##_fx_clipped
    150150
    151151#include "fxsdettmp.h"
  • trunk/src/opengl/mesa/3dfx/fxtexman.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.
     
    5555#include "fxdrv.h"
    5656
     57int texSwaps=0;
     58
    5759#define FX_2MB_SPLIT 0x200000
    5860
    5961static struct gl_texture_object *fxTMFindOldestObject(fxMesaContext fxMesa,
    60                                                       int tmu);
     62                                                      int tmu);
    6163
    6264
     
    8284      fubar();
    8385    }
    84     if (prev && (prev->startAddr>=tmp->startAddr || 
    85         prev->endAddr>tmp->startAddr)) {
     86    if (prev && (prev->startAddr>=tmp->startAddr ||
     87        prev->endAddr>tmp->startAddr)) {
    8688      fprintf(stderr, "Sorting fubar\n");
    8789      fubar();
     
    101103      fubar();
    102104    }
    103     if (prev && (prev->startAddr>=tmp->startAddr || 
    104         prev->endAddr>tmp->startAddr)) {
     105    if (prev && (prev->startAddr>=tmp->startAddr ||
     106        prev->endAddr>tmp->startAddr)) {
    105107      fprintf(stderr, "Sorting fubar\n");
    106108      fubar();
     
    122124      fprintf(stderr, "fxDriver: out of memory!\n");
    123125      fxCloseHardware();
    124       exit(-1);
     126      EXIT(-1);
    125127    }
    126128  }
     
    162164    if(fxMesa->verbose)
    163165      fprintf(stderr,"    %07u-%07u\n",
    164               (unsigned int)blockstart,(unsigned int)blockend);
     166              (unsigned int)blockstart,(unsigned int)blockend);
    165167
    166168    tmn=fxTMNewRangeNode(fxMesa, blockstart, blockend);
     
    186188    while (tmp) {
    187189      if (tmp->endAddr-tmp->startAddr>=size) { /* Fits here */
    188         result=tmp->startAddr;
    189         tmp->startAddr+=size;
    190         if (tmp->startAddr==tmp->endAddr) { /* Empty */
    191           if (prev) {
    192             prev->next=tmp->next;
    193           } else {
    194             fxMesa->tmFree[tmu]=tmp->next;
    195           }
    196           fxTMDeleteRangeNode(fxMesa, tmp);
    197         }
    198         fxMesa->freeTexMem[tmu]-=size;
    199         return result;
     190        result=tmp->startAddr;
     191        tmp->startAddr+=size;
     192        if (tmp->startAddr==tmp->endAddr) { /* Empty */
     193          if (prev) {
     194            prev->next=tmp->next;
     195          } else {
     196            fxMesa->tmFree[tmu]=tmp->next;
     197          }
     198          fxTMDeleteRangeNode(fxMesa, tmp);
     199        }
     200        fxMesa->freeTexMem[tmu]-=size;
     201        return result;
    200202      }
    201203      prev=tmp;
     
    209211    }
    210212    fxTMMoveOutTM(fxMesa, obj);
     213    texSwaps++;
    211214  }
    212215}
     
    234237  range->next=tmp;
    235238  if (tmp) {
    236     if (range->endAddr==tmp->startAddr && tmp->startAddr&(FX_2MB_SPLIT-1)) { 
     239    if (range->endAddr==tmp->startAddr && tmp->startAddr&(FX_2MB_SPLIT-1)) {
    237240      /* Combine */
    238241      tmp->startAddr=range->startAddr;
     
    242245  }
    243246  if (prev) {
    244     if (prev->endAddr==range->startAddr && range->startAddr&(FX_2MB_SPLIT-1)) { 
     247    if (prev->endAddr==range->startAddr && range->startAddr&(FX_2MB_SPLIT-1)) {
    245248      /* Combine */
    246249      prev->endAddr=range->endAddr;
     
    254257
    255258static struct gl_texture_object *fxTMFindOldestObject(fxMesaContext fxMesa,
    256                                                       int tmu)
     259                                                      int tmu)
    257260{
    258261  GLuint age, old, lasttime, bindnumber;
     
    270273
    271274    if (info && info->isInTM &&
    272         (info->whichTMU==tmu || info->whichTMU==FX_TMU_BOTH ||
    273         info->whichTMU==FX_TMU_SPLIT)) {
     275        ((info->whichTMU==tmu) || (info->whichTMU==FX_TMU_BOTH) ||
     276        (info->whichTMU==FX_TMU_SPLIT))) {
    274277      lasttime=info->lastTimeUsed;
    275278
    276279      if (lasttime>bindnumber)
    277         age=bindnumber+(UINT_MAX-lasttime+1); /* TO DO: check wrap around */
     280        age=bindnumber+(UINT_MAX-lasttime+1); /* TO DO: check wrap around */
    278281      else
    279         age=bindnumber-lasttime;
     282        age=bindnumber-lasttime;
    280283
    281284      if (age>=old) {
    282         old=age;
    283         obj=tmp;
     285        old=age;
     286        obj=tmp;
    284287      }
    285288    }
     
    289292}
    290293
    291 static MemRange *fxTMAddObj(fxMesaContext fxMesa, 
    292                             struct gl_texture_object *tObj,
    293                             GLint tmu, int texmemsize)
     294static MemRange *fxTMAddObj(fxMesaContext fxMesa,
     295                            struct gl_texture_object *tObj,
     296                            GLint tmu, int texmemsize)
    294297{
    295298  FxU32 startAddr;
     
    319322    fprintf(stderr,"fx Driver: internal error in fxTMMoveInTM() -> not validated\n");
    320323    fxCloseHardware();
    321     exit(-1);
    322   }
    323 
    324   if (ti->isInTM) return;
     324    EXIT(-1);
     325  }
     326
     327  if (ti->isInTM) {
     328    if (ti->whichTMU==where) return;
     329    if (where==FX_TMU_SPLIT || ti->whichTMU==FX_TMU_SPLIT)
     330      fxTMMoveOutTM_NoLock(fxMesa, tObj);
     331    else {
     332      if (ti->whichTMU==FX_TMU_BOTH) return;
     333      where=FX_TMU_BOTH;
     334    }
     335  }
    325336
    326337  if (MESA_VERBOSE&(VERBOSE_DRIVER|VERBOSE_TEXTURE)) {
     
    334345  case FX_TMU1:
    335346    texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH,
    336                                                       &(ti->info));
     347                                                      &(ti->info));
    337348    ti->tm[where]=fxTMAddObj(fxMesa, tObj, where, texmemsize);
    338349    fxMesa->stats.memTexUpload+=texmemsize;
    339350
    340351    for (i=FX_largeLodValue(ti->info), l=ti->minLevel;
    341         i<=FX_smallLodValue(ti->info);
    342         i++,l++)
     352        i<=FX_smallLodValue(ti->info);
     353        i++,l++)
    343354      FX_grTexDownloadMipMapLevel_NoLock(where,
    344                                         ti->tm[where]->startAddr,
    345                                         FX_valueToLod(i),
    346                                         FX_largeLodLog2(ti->info),
    347                                         FX_aspectRatioLog2(ti->info),
    348                                         ti->info.format,
    349                                         GR_MIPMAPLEVELMASK_BOTH,
    350                                         ti->mipmapLevel[l].data);
    351     break;
    352   case FX_TMU_SPLIT: /* TO DO: alternate even/odd TMU0/TMU1 */
     355                                        ti->tm[where]->startAddr,
     356                                        FX_valueToLod(i),
     357                                        FX_largeLodLog2(ti->info),
     358                                        FX_aspectRatioLog2(ti->info),
     359                                        ti->info.format,
     360                                        GR_MIPMAPLEVELMASK_BOTH,
     361                                        ti->mipmapLevel[l].data);
     362    break;
     363  case FX_TMU_SPLIT:
    353364    texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_ODD,
    354                                                       &(ti->info));
     365                                                      &(ti->info));
    355366    ti->tm[FX_TMU0]=fxTMAddObj(fxMesa, tObj, FX_TMU0, texmemsize);
    356367    fxMesa->stats.memTexUpload+=texmemsize;
    357368
    358369    texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_EVEN,
    359                                                       &(ti->info));
     370                                                      &(ti->info));
    360371    ti->tm[FX_TMU1]=fxTMAddObj(fxMesa, tObj, FX_TMU1, texmemsize);
    361372    fxMesa->stats.memTexUpload+=texmemsize;
    362373
    363374    for (i=FX_largeLodValue(ti->info),l=ti->minLevel;
    364         i<=FX_smallLodValue(ti->info);
    365         i++,l++) {
     375        i<=FX_smallLodValue(ti->info);
     376        i++,l++) {
    366377      FX_grTexDownloadMipMapLevel_NoLock(GR_TMU0,
    367                                         ti->tm[FX_TMU0]->startAddr,
    368                                         FX_valueToLod(i),
    369                                         FX_largeLodLog2(ti->info),
    370                                         FX_aspectRatioLog2(ti->info),
    371                                         ti->info.format,
    372                                         GR_MIPMAPLEVELMASK_ODD,
    373                                         ti->mipmapLevel[l].data);
     378                                        ti->tm[FX_TMU0]->startAddr,
     379                                        FX_valueToLod(i),
     380                                        FX_largeLodLog2(ti->info),
     381                                        FX_aspectRatioLog2(ti->info),
     382                                        ti->info.format,
     383                                        GR_MIPMAPLEVELMASK_ODD,
     384                                        ti->mipmapLevel[l].data);
    374385
    375386      FX_grTexDownloadMipMapLevel_NoLock(GR_TMU1,
    376                                          ti->tm[FX_TMU1]->startAddr,
    377                                          FX_valueToLod(i),
    378                                          FX_largeLodLog2(ti->info),
    379                                          FX_aspectRatioLog2(ti->info),
    380                                          ti->info.format,
    381                                          GR_MIPMAPLEVELMASK_EVEN,
    382                                          ti->mipmapLevel[l].data);
     387                                         ti->tm[FX_TMU1]->startAddr,
     388                                         FX_valueToLod(i),
     389                                         FX_largeLodLog2(ti->info),
     390                                         FX_aspectRatioLog2(ti->info),
     391                                         ti->info.format,
     392                                         GR_MIPMAPLEVELMASK_EVEN,
     393                                         ti->mipmapLevel[l].data);
     394    }
     395    break;
     396  case FX_TMU_BOTH:
     397    texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH,
     398                                                      &(ti->info));
     399    ti->tm[FX_TMU0]=fxTMAddObj(fxMesa, tObj, FX_TMU0, texmemsize);
     400    fxMesa->stats.memTexUpload+=texmemsize;
     401
     402    texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH,
     403                                                      &(ti->info));
     404    ti->tm[FX_TMU1]=fxTMAddObj(fxMesa, tObj, FX_TMU1, texmemsize);
     405    fxMesa->stats.memTexUpload+=texmemsize;
     406
     407    for (i=FX_largeLodValue(ti->info),l=ti->minLevel;
     408         i<=FX_smallLodValue(ti->info);
     409         i++,l++) {
     410      FX_grTexDownloadMipMapLevel_NoLock(GR_TMU0,
     411                                         ti->tm[FX_TMU0]->startAddr,
     412                                         FX_valueToLod(i),
     413                                         FX_largeLodLog2(ti->info),
     414                                         FX_aspectRatioLog2(ti->info),
     415                                         ti->info.format,
     416                                         GR_MIPMAPLEVELMASK_BOTH,
     417                                         ti->mipmapLevel[l].data);
     418
     419      FX_grTexDownloadMipMapLevel_NoLock(GR_TMU1,
     420                                         ti->tm[FX_TMU1]->startAddr,
     421                                         FX_valueToLod(i),
     422                                         FX_largeLodLog2(ti->info),
     423                                         FX_aspectRatioLog2(ti->info),
     424                                         ti->info.format,
     425                                         GR_MIPMAPLEVELMASK_BOTH,
     426                                         ti->mipmapLevel[l].data);
    383427    }
    384428    break;
     
    386430    fprintf(stderr,"fx Driver: internal error in fxTMMoveInTM() -> wrong tmu (%d)\n",where);
    387431    fxCloseHardware();
    388     exit(-1);
     432    EXIT(-1);
    389433  }
    390434
     
    409453    fprintf(stderr,"fx Driver: internal error in fxTMReloadMipMapLevel() -> not validated\n");
    410454    fxCloseHardware();
    411     exit(-1);
     455    EXIT(-1);
    412456  }
    413457
     
    416460
    417461  fxTexGetInfo(ti->mipmapLevel[0].width,ti->mipmapLevel[0].height,
    418                &lodlevel, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    419 
     462               &lodlevel, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
     463
     464#ifdef FX_GLIDE3
     465  lodlevel-=level;
     466#else
     467  lodlevel+=level;
     468#endif
    420469  switch(tmu) {
    421470  case FX_TMU0:
    422471  case FX_TMU1:
    423472    FX_grTexDownloadMipMapLevel(tmu,
    424                                 ti->tm[tmu]->startAddr,
    425                                 FX_valueToLod(FX_lodToValue(lodlevel)+level),
    426                                 FX_largeLodLog2(ti->info),
    427                                 FX_aspectRatioLog2(ti->info),
    428                                 ti->info.format,
    429                                 GR_MIPMAPLEVELMASK_BOTH,
    430                                 ti->mipmapLevel[level].data);
    431     break;
    432   case FX_TMU_SPLIT: /* TO DO: alternate even/odd TMU0/TMU1 */
     473                                ti->tm[tmu]->startAddr,
     474                                FX_valueToLod(FX_lodToValue(lodlevel)),
     475                                FX_largeLodLog2(ti->info),
     476                                FX_aspectRatioLog2(ti->info),
     477                                ti->info.format,
     478                                GR_MIPMAPLEVELMASK_BOTH,
     479                                ti->mipmapLevel[level].data);
     480    break;
     481  case FX_TMU_SPLIT:
    433482    FX_grTexDownloadMipMapLevel(GR_TMU0,
    434                                 ti->tm[GR_TMU0]->startAddr,
    435                                 FX_valueToLod(FX_lodToValue(lodlevel)+level),
    436                                 FX_largeLodLog2(ti->info),
    437                                 FX_aspectRatioLog2(ti->info),
    438                                 ti->info.format,
    439                                 GR_MIPMAPLEVELMASK_ODD,
    440                                 ti->mipmapLevel[level].data);
    441    
     483                                ti->tm[GR_TMU0]->startAddr,
     484                                FX_valueToLod(FX_lodToValue(lodlevel)),
     485                                FX_largeLodLog2(ti->info),
     486                                FX_aspectRatioLog2(ti->info),
     487                                ti->info.format,
     488                                GR_MIPMAPLEVELMASK_ODD,
     489                                ti->mipmapLevel[level].data);
     490
    442491    FX_grTexDownloadMipMapLevel(GR_TMU1,
    443                                 ti->tm[GR_TMU1]->startAddr,
    444                                 FX_valueToLod(FX_lodToValue(lodlevel)+level),
    445                                 FX_largeLodLog2(ti->info),
    446                                 FX_aspectRatioLog2(ti->info),
    447                                 ti->info.format,
    448                                 GR_MIPMAPLEVELMASK_EVEN,
    449                                 ti->mipmapLevel[level].data);
    450     break;
     492                                ti->tm[GR_TMU1]->startAddr,
     493                                FX_valueToLod(FX_lodToValue(lodlevel)),
     494                                FX_largeLodLog2(ti->info),
     495                                FX_aspectRatioLog2(ti->info),
     496                                ti->info.format,
     497                                GR_MIPMAPLEVELMASK_EVEN,
     498                                ti->mipmapLevel[level].data);
     499    break;
     500  case FX_TMU_BOTH:
     501    FX_grTexDownloadMipMapLevel(GR_TMU0,
     502                                ti->tm[GR_TMU0]->startAddr,
     503                                FX_valueToLod(FX_lodToValue(lodlevel)),
     504                                FX_largeLodLog2(ti->info),
     505                                FX_aspectRatioLog2(ti->info),
     506                                ti->info.format,
     507                                GR_MIPMAPLEVELMASK_BOTH,
     508                                ti->mipmapLevel[level].data);
     509
     510    FX_grTexDownloadMipMapLevel(GR_TMU1,
     511                                ti->tm[GR_TMU1]->startAddr,
     512                                FX_valueToLod(FX_lodToValue(lodlevel)),
     513                                FX_largeLodLog2(ti->info),
     514                                FX_aspectRatioLog2(ti->info),
     515                                ti->info.format,
     516                                GR_MIPMAPLEVELMASK_BOTH,
     517                                ti->mipmapLevel[level].data);
     518    break;
     519
    451520  default:
    452521    fprintf(stderr,"fx Driver: internal error in fxTMReloadMipMapLevel() -> wrong tmu (%d)\n",tmu);
    453522    fxCloseHardware();
    454     exit(-1);
    455   }
    456 }
    457 
    458 void fxTMReloadSubMipMapLevel(fxMesaContext fxMesa, 
    459                               struct gl_texture_object *tObj,
    460                               GLint level, GLint yoffset, GLint height)
     523    EXIT(-1);
     524  }
     525}
     526
     527void fxTMReloadSubMipMapLevel(fxMesaContext fxMesa,
     528                              struct gl_texture_object *tObj,
     529                              GLint level, GLint yoffset, GLint height)
    461530{
    462531  tfxTexInfo *ti=fxTMGetTexInfo(tObj);
     
    468537    fprintf(stderr,"fx Driver: internal error in fxTMReloadSubMipMapLevel() -> not validated\n");
    469538    fxCloseHardware();
    470     exit(-1);
     539    EXIT(-1);
    471540  }
    472541
     
    475544
    476545  fxTexGetInfo(ti->mipmapLevel[0].width, ti->mipmapLevel[0].height,
    477                &lodlevel, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
     546               &lodlevel, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    478547
    479548  if((ti->info.format==GR_TEXFMT_INTENSITY_8) ||
     
    488557  case FX_TMU1:
    489558    FX_grTexDownloadMipMapLevelPartial(tmu,
    490                                        ti->tm[tmu]->startAddr,
    491                                        FX_valueToLod(FX_lodToValue(lodlevel)+level),
    492                                        FX_largeLodLog2(ti->info),
    493                                        FX_aspectRatioLog2(ti->info),
    494                                        ti->info.format,
    495                                        GR_MIPMAPLEVELMASK_BOTH,
    496                                        data,
    497                                        yoffset,yoffset+height-1);
    498     break;
    499   case FX_TMU_SPLIT: /* TO DO: alternate even/odd TMU0/TMU1 */
     559                                       ti->tm[tmu]->startAddr,
     560                                       FX_valueToLod(FX_lodToValue(lodlevel)+level),
     561                                       FX_largeLodLog2(ti->info),
     562                                       FX_aspectRatioLog2(ti->info),
     563                                       ti->info.format,
     564                                       GR_MIPMAPLEVELMASK_BOTH,
     565                                       data,
     566                                       yoffset,yoffset+height-1);
     567    break;
     568  case FX_TMU_SPLIT:
    500569    FX_grTexDownloadMipMapLevelPartial(GR_TMU0,
    501                                        ti->tm[FX_TMU0]->startAddr,
    502                                        FX_valueToLod(FX_lodToValue(lodlevel)+level),
    503                                        FX_largeLodLog2(ti->info),
    504                                        FX_aspectRatioLog2(ti->info),
    505                                        ti->info.format,
    506                                        GR_MIPMAPLEVELMASK_ODD,
    507                                        data,
    508                                        yoffset,yoffset+height-1);
     570                                       ti->tm[FX_TMU0]->startAddr,
     571                                       FX_valueToLod(FX_lodToValue(lodlevel)+level),
     572                                       FX_largeLodLog2(ti->info),
     573                                       FX_aspectRatioLog2(ti->info),
     574                                       ti->info.format,
     575                                       GR_MIPMAPLEVELMASK_ODD,
     576                                       data,
     577                                       yoffset,yoffset+height-1);
    509578
    510579    FX_grTexDownloadMipMapLevelPartial(GR_TMU1,
    511                                        ti->tm[FX_TMU1]->startAddr,
    512                                        FX_valueToLod(FX_lodToValue(lodlevel)+level),
    513                                        FX_largeLodLog2(ti->info),
    514                                        FX_aspectRatioLog2(ti->info),
    515                                        ti->info.format,
    516                                        GR_MIPMAPLEVELMASK_EVEN,
    517                                        data,
    518                                        yoffset,yoffset+height-1);
     580                                       ti->tm[FX_TMU1]->startAddr,
     581                                       FX_valueToLod(FX_lodToValue(lodlevel)+level),
     582                                       FX_largeLodLog2(ti->info),
     583                                       FX_aspectRatioLog2(ti->info),
     584                                       ti->info.format,
     585                                       GR_MIPMAPLEVELMASK_EVEN,
     586                                       data,
     587                                       yoffset,yoffset+height-1);
     588    break;
     589  case FX_TMU_BOTH:
     590    FX_grTexDownloadMipMapLevelPartial(GR_TMU0,
     591                                       ti->tm[FX_TMU0]->startAddr,
     592                                       FX_valueToLod(FX_lodToValue(lodlevel)+level),
     593                                       FX_largeLodLog2(ti->info),
     594                                       FX_aspectRatioLog2(ti->info),
     595                                       ti->info.format,
     596                                       GR_MIPMAPLEVELMASK_BOTH,
     597                                       data,
     598                                       yoffset,yoffset+height-1);
     599
     600    FX_grTexDownloadMipMapLevelPartial(GR_TMU1,
     601                                       ti->tm[FX_TMU1]->startAddr,
     602                                       FX_valueToLod(FX_lodToValue(lodlevel)+level),
     603                                       FX_largeLodLog2(ti->info),
     604                                       FX_aspectRatioLog2(ti->info),
     605                                       ti->info.format,
     606                                       GR_MIPMAPLEVELMASK_BOTH,
     607                                       data,
     608                                       yoffset,yoffset+height-1);
    519609    break;
    520610  default:
    521611    fprintf(stderr,"fx Driver: internal error in fxTMReloadSubMipMapLevel() -> wrong tmu (%d)\n",tmu);
    522612    fxCloseHardware();
    523     exit(-1);
     613    EXIT(-1);
    524614  }
    525615}
     
    541631    break;
    542632  case FX_TMU_SPLIT:
     633  case FX_TMU_BOTH:
    543634    fxTMRemoveRange(fxMesa, FX_TMU0, ti->tm[FX_TMU0]);
    544635    fxTMRemoveRange(fxMesa, FX_TMU1, ti->tm[FX_TMU1]);
     
    547638    fprintf(stderr,"fx Driver: internal error in fxTMMoveOutTM()\n");
    548639    fxCloseHardware();
    549     exit(-1);
     640    EXIT(-1);
    550641  }
    551642
     
    563654  for(i=0; i<MAX_TEXTURE_LEVELS; i++) {
    564655    if (ti->mipmapLevel[i].used &&
    565         ti->mipmapLevel[i].translated)
     656        ti->mipmapLevel[i].translated)
    566657      FREE(ti->mipmapLevel[i].data);
    567658
     
    618709}
    619710
    620 void fxTMRestore_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj)
    621 {
    622   tfxTexInfo *ti=fxTMGetTexInfo(tObj);
    623   int i,l, where;
    624 
    625   if (MESA_VERBOSE&VERBOSE_DRIVER) {
    626      fprintf(stderr,"fxmesa: fxRestore(%d)\n",tObj->Name);
    627   }
    628 
    629   if (!ti->validated) {
    630     fprintf(stderr,"fxDriver: internal error in fxRestore -> not validated\n");
    631     fxCloseHardware();
    632     exit(-1);
    633   }
    634 
    635   where=ti->whichTMU;
    636   if (MESA_VERBOSE&(VERBOSE_DRIVER|VERBOSE_TEXTURE)) {
    637     fprintf(stderr,"fxmesa: reloading %x (%d) in texture memory in %d\n",
    638             (GLuint)tObj, tObj->Name, where);
    639   }
    640 
    641   switch(where) {
    642   case FX_TMU0:
    643   case FX_TMU1:
    644     for (i=FX_largeLodValue_NoLock(ti->info), l=ti->minLevel;
    645          i<=FX_smallLodValue_NoLock(ti->info);
    646          i++,l++)
    647       if (ti->mipmapLevel[l].data)
    648         FX_grTexDownloadMipMapLevel_NoLock(where,
    649                                            ti->tm[where]->startAddr,
    650                                            FX_valueToLod(i),
    651                                            FX_largeLodLog2(ti->info),
    652                                            FX_aspectRatioLog2(ti->info),
    653                                            ti->info.format,
    654                                            GR_MIPMAPLEVELMASK_BOTH,
    655                                            ti->mipmapLevel[l].data);
    656     break;
    657   case FX_TMU_SPLIT: /* TO DO: alternate even/odd TMU0/TMU1 */
    658     for (i=FX_largeLodValue_NoLock(ti->info),l=ti->minLevel;
    659          i<=FX_smallLodValue_NoLock(ti->info);
    660          i++,l++) {
    661       if (ti->mipmapLevel[l].data) {
    662         FX_grTexDownloadMipMapLevel_NoLock(GR_TMU0,
    663                                            ti->tm[FX_TMU0]->startAddr,
    664                                            FX_valueToLod(i),
    665                                            FX_largeLodLog2(ti->info),
    666                                            FX_aspectRatioLog2(ti->info),
    667                                            ti->info.format,
    668                                            GR_MIPMAPLEVELMASK_ODD,
    669                                            ti->mipmapLevel[l].data);
    670         FX_grTexDownloadMipMapLevel_NoLock(GR_TMU1,
    671                                            ti->tm[FX_TMU1]->startAddr,
    672                                            FX_valueToLod(i),
    673                                            FX_largeLodLog2(ti->info),
    674                                            FX_aspectRatioLog2(ti->info),
    675                                            ti->info.format,
    676                                            GR_MIPMAPLEVELMASK_EVEN,
    677                                            ti->mipmapLevel[l].data);
    678       }
    679     }
    680     break;
    681   default:
    682     fprintf(stderr,"fxDriver: internal error in fxRestore -> bad tmu (%d)\n",
    683             where);
    684     fxCloseHardware();
    685     exit(-1);
    686   }
    687 }
    688 
    689711void
    690 fxTMRestoreTextures(fxMesaContext ctx) {
     712fxTMRestoreTextures_NoLock(fxMesaContext ctx) {
    691713  tfxTexInfo *ti;
    692714  struct gl_texture_object *tObj;
    693   int i;
     715  int i, where;
    694716
    695717  tObj=ctx->glCtx->Shared->TexObjectList;
     
    698720    if (ti && ti->isInTM) {
    699721      for (i=0; i<MAX_TEXTURE_UNITS; i++)
    700         if (ctx->glCtx->Texture.Unit[i].Current==tObj) {
    701           /* Force the texture onto the board, as it could be in use */
    702           fxTMRestore_NoLock(ctx, tObj);
    703           break;
    704         }
     722        if (ctx->glCtx->Texture.Unit[i].Current==tObj) {
     723          /* Force the texture onto the board, as it could be in use */
     724          where=ti->whichTMU;
     725          fxTMMoveOutTM_NoLock(ctx, tObj);
     726          fxTMMoveInTM_NoLock(ctx, tObj, where);
     727          break;
     728        }
    705729      if (i==MAX_TEXTURE_UNITS) /* Mark the texture as off the board */
    706         fxTMMoveOutTM(ctx, tObj);
     730        fxTMMoveOutTM_NoLock(ctx, tObj);
    707731    }
    708732    tObj=tObj->Next;
  • trunk/src/opengl/mesa/3dfx/fxtrifuncs.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.
     
    5858
    5959
    60 /* Is this enough?  Do we need more triangle funcs? 
     60/* Is this enough?  Do we need more triangle funcs?
    6161 */
    6262static triangle_func tri_tab[0x40];  /* only 0x20 actually used */
     
    129129#include "fxtritmp.h"
    130130
     131/* We don't actually do antialiasing correctly. Geometry has to be
     132   sorted for glide's antialiasing to operate */
     133#if 0
    131134#define IND (FX_ANTIALIAS)
    132135#define TAG(x) x##_aa
     
    192195#define TAG(x) x##_aa_flat_front_back_twoside_offset
    193196#include "fxtritmp.h"
    194 
    195 
    196 void fxDDTrifuncInit() 
     197#endif
     198
     199void fxDDTrifuncInit()
    197200{
    198201   init();
     
    212215   init_flat_front_back_twoside();
    213216   init_flat_front_back_twoside_offset();
     217#if 0
    214218   init_aa();
    215219   init_aa_offset();
     
    228232   init_aa_flat_front_back_twoside();
    229233   init_aa_flat_front_back_twoside_offset();
     234#endif
    230235}
    231236
     
    233238{
    234239   fprintf(stderr, "%s: (%x) %s%s%s%s%s%s\n",
    235            msg, state,
    236            (state & FX_ANTIALIAS)  ? "antialias, "  : "",
    237            (state & FX_FLAT)       ? "flat, "       : "",
    238            (state & FX_TWOSIDE)    ? "twoside, "    : "",
    239            (state & FX_OFFSET)     ? "offset, "     : "",
    240            (state & FX_FRONT_BACK) ? "front-back, " : "",
    241            (state & FX_FALLBACK)    ? "fallback"     : "");
     240           msg, state,
     241           (state & FX_ANTIALIAS)  ? "antialias, "  : "",
     242           (state & FX_FLAT)       ? "flat, "       : "",
     243           (state & FX_TWOSIDE)    ? "twoside, "    : "",
     244           (state & FX_OFFSET)     ? "offset, "     : "",
     245           (state & FX_FRONT_BACK) ? "front-back, " : "",
     246           (state & FX_FALLBACK)    ? "fallback"     : "");
    242247}
    243248
     
    246251{
    247252   fprintf(stderr, "%s: (%x) %s %s%s %s%s\n",
    248            msg, state,
    249            (state & GR_STWHINT_W_DIFF_FBI)    ? "w-fbi, "   : "",
    250            (state & GR_STWHINT_W_DIFF_TMU0)   ? "w-tmu0, "  : "",
    251            (state & GR_STWHINT_ST_DIFF_TMU0)  ? "st-tmu0, " : "",
    252            (state & GR_STWHINT_W_DIFF_TMU1)   ? "w-tmu1, "  : "",
    253            (state & GR_STWHINT_ST_DIFF_TMU1)  ? "st-tmu1, " : "");
     253           msg, state,
     254           (state & GR_STWHINT_W_DIFF_FBI)    ? "w-fbi, "   : "",
     255           (state & GR_STWHINT_W_DIFF_TMU0)   ? "w-tmu0, "  : "",
     256           (state & GR_STWHINT_ST_DIFF_TMU0)  ? "st-tmu0, " : "",
     257           (state & GR_STWHINT_W_DIFF_TMU1)   ? "w-tmu1, "  : "",
     258           (state & GR_STWHINT_ST_DIFF_TMU1)  ? "st-tmu1, " : "");
    254259
    255260}
     
    265270
    266271   if (flags) {
    267       if (fxMesa->render_index & FX_OFFSET) 
    268         FX_grDepthBiasLevel(0);
     272      if (fxMesa->render_index & FX_OFFSET)
     273        FX_grDepthBiasLevel(0);
    269274
    270275      if (flags & (DD_SELECT|DD_FEEDBACK)) {
    271          fxMesa->PointsFunc = 0;
    272          fxMesa->LineFunc = 0;
    273          fxMesa->TriangleFunc = 0;
    274          fxMesa->QuadFunc = 0;
    275          fxMesa->render_index = FX_FALLBACK;           
    276          ctx->IndirectTriangles |= DD_SW_RASTERIZE;
    277          return;
     276         fxMesa->PointsFunc = 0;
     277         fxMesa->LineFunc = 0;
     278         fxMesa->TriangleFunc = 0;
     279         fxMesa->QuadFunc = 0;
     280         fxMesa->render_index = FX_FALLBACK;
     281         ctx->IndirectTriangles |= DD_SW_RASTERIZE;
     282#if 0
     283         fprintf(stderr, "Fallback select|feeback\n");
     284#endif
     285         return;
    278286      }
    279    
     287
    280288      if (flags & DD_FLATSHADE)                    ind |= FX_FLAT;
    281289      if (flags & DD_TRI_LIGHT_TWOSIDE)            ind |= FX_TWOSIDE;
    282290      if (flags & DD_MULTIDRAW)                    ind |= FX_FRONT_BACK;
    283       if (flags & DD_POINT_SMOOTH)                 ind |= FX_ANTIALIAS;
    284       if (flags & (DD_POINT_SIZE|DD_POINT_ATTEN))  ind |= FX_FALLBACK;
     291      if (flags & (DD_POINT_ATTEN|DD_POINT_SMOOTH))  {
     292        ind |= FX_FALLBACK;
     293#if 0
     294        if (flags&DD_POINT_ATTEN)
     295          fprintf(stderr, "Fallback point atten\n");
     296        if (flags&DD_POINT_SMOOTH)
     297          fprintf(stderr, "Fallback point smooth\n");
     298#endif
     299      }
    285300
    286301      fxMesa->render_index = ind;
    287302      fxMesa->PointsFunc = points_tab[ind];
    288303      if (ind&FX_FALLBACK)
    289         ctx->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
     304        ctx->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
    290305      ind &= ~(FX_ANTIALIAS|FX_FALLBACK);
    291306
    292       if (flags & DD_LINE_SMOOTH)                   ind |= FX_ANTIALIAS;
    293       if (flags & (DD_LINE_WIDTH|DD_LINE_STIPPLE))  ind |= FX_FALLBACK;
     307      if (flags & (DD_LINE_STIPPLE|DD_LINE_SMOOTH))  {
     308        ind |= FX_FALLBACK;
     309#if 0
     310        if (flags&DD_LINE_STIPPLE)
     311          fprintf(stderr, "Fallback line stipple\n");
     312        if (flags&DD_LINE_SMOOTH)
     313          fprintf(stderr, "Fallback line smooth\n");
     314#endif
     315      }
    294316
    295317      fxMesa->render_index |= ind;
    296318      fxMesa->LineFunc = line_tab[ind];
    297319      if (ind&FX_FALLBACK)
    298         ctx->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
     320        ctx->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
    299321      ind &= ~(FX_ANTIALIAS|FX_FALLBACK);
    300322
    301       if (flags & DD_TRI_SMOOTH)                    ind |= FX_ANTIALIAS;
    302323      if (flags & DD_TRI_OFFSET)                    ind |= FX_OFFSET;
    303       if (flags & (DD_TRI_UNFILLED|DD_TRI_STIPPLE)) ind |= FX_FALLBACK;
     324      if (flags & (DD_TRI_UNFILLED|DD_TRI_STIPPLE|DD_TRI_SMOOTH)) {
     325        ind |= FX_FALLBACK;
     326#if 0
     327        if (flags&DD_TRI_UNFILLED)
     328          fprintf(stderr, "Fallback tri unfilled\n");
     329        if (flags&DD_TRI_STIPPLE)
     330          fprintf(stderr, "Fallback tri stippled\n");
     331        if (flags&DD_TRI_SMOOTH)
     332          fprintf(stderr, "Fallback tri smooth\n");
     333#endif
     334      }
    304335
    305336      fxMesa->render_index |= ind;
     
    308339
    309340      if (ind&FX_FALLBACK)
    310         ctx->IndirectTriangles |= DD_TRI_SW_RASTERIZE | DD_QUAD_SW_RASTERIZE;
    311    } 
     341        ctx->IndirectTriangles |= DD_TRI_SW_RASTERIZE | DD_QUAD_SW_RASTERIZE;
     342   }
    312343   else if (fxMesa->render_index)
    313344   {
    314       if (fxMesa->render_index & FX_OFFSET) 
    315         FX_grDepthBiasLevel(0);
     345      if (fxMesa->render_index & FX_OFFSET)
     346        FX_grDepthBiasLevel(0);
    316347
    317348      fxMesa->render_index = 0;
     
    333364 */
    334365
     366extern int gl_fx_dummy_function_tris(void);
    335367int gl_fx_dummy_function_tris(void)
    336368{
  • trunk/src/opengl/mesa/3dfx/fxtritmp.h

    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.
     
    4949   struct vertex_buffer *VB=ctx->VB;
    5050   fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
    51    GrVertex *v1 = (GrVertex *)gWin[e1].f; 
     51   GrVertex *v1 = (GrVertex *)gWin[e1].f;
    5252   GrVertex *v2 = (GrVertex *)gWin[e2].f;
    5353   GrVertex *v3 = (GrVertex *)gWin[e3].f;
     
    5555   (void) fxMesa;
    5656
    57    if (IND & (FX_TWOSIDE|FX_OFFSET)) 
     57   if (IND & (FX_TWOSIDE|FX_OFFSET))
    5858   {
    5959      GLfloat ex = v1->x - v3->x;
     
    6262      GLfloat fy = v2->y - v3->y;
    6363      GLfloat c = ex*fy-ey*fx;
    64          
     64
    6565      if (IND & FX_TWOSIDE) {
    66         GLuint facing = (c<0.0) ^ ctx->Polygon.FrontBit;
    67         GLubyte (*color)[4] = VB->Color[facing]->data;
    68         if (IND & FX_FLAT) {
    69             FX_VB_COLOR(fxMesa, color[pv]);
    70         } else {
    71             GOURAUD2(v1,color[e1]);
    72             GOURAUD2(v2,color[e2]);
    73             GOURAUD2(v3,color[e3]);
    74         }
    75       }
    76      
     66        GLuint facing = (c<0.0) ^ ctx->Polygon.FrontBit;
     67        GLubyte (*color)[4] = VB->Color[facing]->data;
     68        if (IND & FX_FLAT) {
     69            FX_VB_COLOR(fxMesa, color[pv]);
     70        } else {
     71            GOURAUD2(v1,color[e1]);
     72            GOURAUD2(v2,color[e2]);
     73            GOURAUD2(v3,color[e3]);
     74        }
     75      }
     76
    7777      /* Should apply a factor to ac to compensate for different x/y
    7878       * scaling introduced in the Viewport matrix.
     
    8181       */
    8282      if (IND & FX_OFFSET) {
    83         GLfloat offset = ctx->Polygon.OffsetUnits;
    84 
    85         if (c * c > 1e-16) {
    86             GLfloat factor = ctx->Polygon.OffsetFactor;
    87             GLfloat ez = v1->ooz - v3->ooz;
    88             GLfloat fz = v2->ooz - v3->ooz;
    89             GLfloat a = ey*fz-ez*fy;
    90             GLfloat b = ez*fx-ex*fz;
    91             GLfloat ic = 1.0 / c;
    92             GLfloat ac = a * ic;
    93             GLfloat bc = b * ic;
    94             if (ac<0.0F)  ac = -ac;
    95             if (bc<0.0F)  bc = -bc;
    96             offset += MAX2( ac, bc ) * factor;
    97         }
    98         /* Probably a lot quicker just to nudge the z values and put
    99           * them back afterwards.
    100           */
    101         FX_grDepthBiasLevel((int)offset);
     83        GLfloat offset = ctx->Polygon.OffsetUnits;
     84
     85        if (c * c > 1e-16) {
     86            GLfloat factor = ctx->Polygon.OffsetFactor;
     87            GLfloat ez = v1->ooz - v3->ooz;
     88            GLfloat fz = v2->ooz - v3->ooz;
     89            GLfloat a = ey*fz-ez*fy;
     90            GLfloat b = ez*fx-ex*fz;
     91            GLfloat ic = 1.0 / c;
     92            GLfloat ac = a * ic;
     93            GLfloat bc = b * ic;
     94            if (ac<0.0F)  ac = -ac;
     95            if (bc<0.0F)  bc = -bc;
     96            offset += MAX2( ac, bc ) * factor;
     97        }
     98        /* Probably a lot quicker just to nudge the z values and put
     99          * them back afterwards.
     100          */
     101        FX_grDepthBiasLevel((int)offset);
    102102      }
    103103   }
     
    109109   if (IND & FX_FRONT_BACK) {
    110110      FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
    111                   ctx->Color.ColorMask[GCOMP] ||
    112                   ctx->Color.ColorMask[BCOMP],
    113                   FXFALSE);
     111                  ctx->Color.ColorMask[GCOMP] ||
     112                  ctx->Color.ColorMask[BCOMP],
     113                  FXFALSE);
    114114
    115115      FX_grDepthMask(FXFALSE);
     
    117117   }
    118118
    119    if (IND & FX_ANTIALIAS) 
     119   if (IND & FX_ANTIALIAS)
    120120      FX_grAADrawTriangle(v1, v2, v3, FXTRUE, FXTRUE, FXTRUE);
    121    else 
     121   else
    122122      FX_grDrawTriangle(v1, v2, v3);
    123123
     
    126126   if (IND & FX_FRONT_BACK) {
    127127      FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
    128                   ctx->Color.ColorMask[GCOMP] ||
    129                   ctx->Color.ColorMask[BCOMP],
    130                   ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
     128                  ctx->Color.ColorMask[GCOMP] ||
     129                  ctx->Color.ColorMask[BCOMP],
     130                  ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
    131131
    132132      if(ctx->Depth.Mask) FX_grDepthMask(FXTRUE);
     
    135135
    136136      if (IND & FX_ANTIALIAS)
    137         FX_grAADrawTriangle(v1,v2,v3, FXTRUE,FXTRUE,FXTRUE);
     137        FX_grAADrawTriangle(v1,v2,v3, FXTRUE,FXTRUE,FXTRUE);
    138138      else
    139         FX_grDrawTriangle(v1, v2, v3);
    140    }   
     139        FX_grDrawTriangle(v1, v2, v3);
     140   }
    141141}
    142142
     
    145145 */
    146146static void TAG(fx_quad)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint e3,
    147                         GLuint e4, GLuint pv)
     147                        GLuint e4, GLuint pv)
    148148{
    149149   fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
    150150   struct vertex_buffer *VB=ctx->VB;
    151151   fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
    152    GrVertex *v1 = (GrVertex *)gWin[e1].f; 
     152   GrVertex *v1 = (GrVertex *)gWin[e1].f;
    153153   GrVertex *v2 = (GrVertex *)gWin[e2].f;
    154154   GrVertex *v3 = (GrVertex *)gWin[e3].f;
     
    157157   (void) fxMesa;
    158158
    159    if (IND & (FX_TWOSIDE|FX_OFFSET)) 
     159   if (IND & (FX_TWOSIDE|FX_OFFSET))
    160160   {
    161161      GLfloat ex = v3->x - v1->x;
     
    164164      GLfloat fy = v4->y - v2->y;
    165165      GLfloat c = ex*fy-ey*fx;
    166          
     166
    167167      if (IND & FX_TWOSIDE) {
    168         GLuint facing = (c<0.0) ^ ctx->Polygon.FrontBit;
    169         GLubyte (*color)[4] = VB->Color[facing]->data;
    170         if (IND & FX_FLAT) {
    171             FX_VB_COLOR(fxMesa, color[pv]);
    172         } else {
    173             GOURAUD2(v1,color[e1]);
    174             GOURAUD2(v2,color[e2]);
    175             GOURAUD2(v3,color[e3]);
    176             GOURAUD2(v4,color[e4]);
    177         }
    178       }
    179      
     168        GLuint facing = (c<0.0) ^ ctx->Polygon.FrontBit;
     169        GLubyte (*color)[4] = VB->Color[facing]->data;
     170        if (IND & FX_FLAT) {
     171            FX_VB_COLOR(fxMesa, color[pv]);
     172        } else {
     173            GOURAUD2(v1,color[e1]);
     174            GOURAUD2(v2,color[e2]);
     175            GOURAUD2(v3,color[e3]);
     176            GOURAUD2(v4,color[e4]);
     177        }
     178      }
     179
    180180      /* Should apply a factor to ac to compensate for different x/y
    181181       * scaling introduced in the Viewport matrix.
     
    184184       */
    185185      if (IND & FX_OFFSET) {
    186         GLfloat offset = ctx->Polygon.OffsetUnits;
    187 
    188         if (c * c > 1e-16) {
    189             GLfloat factor = ctx->Polygon.OffsetFactor;
    190             GLfloat ez = v3->ooz - v1->ooz;
    191             GLfloat fz = v4->ooz - v2->ooz;
    192             GLfloat a = ey*fz-ez*fy;
    193             GLfloat b = ez*fx-ex*fz;
    194             GLfloat ic = 1.0 / c;
    195             GLfloat ac = a * ic;
    196             GLfloat bc = b * ic;
    197             if (ac<0.0F)  ac = -ac;
    198             if (bc<0.0F)  bc = -bc;
    199             offset += MAX2( ac, bc ) * factor;
    200         }
    201         /* Probably a lot quicker just to nudge the z values and put
    202           * them back afterwards.
    203           */
    204         FX_grDepthBiasLevel((int)offset);
     186        GLfloat offset = ctx->Polygon.OffsetUnits;
     187
     188        if (c * c > 1e-16) {
     189            GLfloat factor = ctx->Polygon.OffsetFactor;
     190            GLfloat ez = v3->ooz - v1->ooz;
     191            GLfloat fz = v4->ooz - v2->ooz;
     192            GLfloat a = ey*fz-ez*fy;
     193            GLfloat b = ez*fx-ex*fz;
     194            GLfloat ic = 1.0 / c;
     195            GLfloat ac = a * ic;
     196            GLfloat bc = b * ic;
     197            if (ac<0.0F)  ac = -ac;
     198            if (bc<0.0F)  bc = -bc;
     199            offset += MAX2( ac, bc ) * factor;
     200        }
     201        /* Probably a lot quicker just to nudge the z values and put
     202          * them back afterwards.
     203          */
     204        FX_grDepthBiasLevel((int)offset);
    205205      }
    206206   }
     
    212212   if (IND & FX_FRONT_BACK) {
    213213      FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
    214                   ctx->Color.ColorMask[GCOMP] ||
    215                   ctx->Color.ColorMask[BCOMP],
    216                   FXFALSE);
     214                  ctx->Color.ColorMask[GCOMP] ||
     215                  ctx->Color.ColorMask[BCOMP],
     216                  FXFALSE);
    217217
    218218      FX_grDepthMask(FXFALSE);
     
    232232   if (IND & FX_FRONT_BACK) {
    233233      FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
    234                   ctx->Color.ColorMask[GCOMP] ||
    235                   ctx->Color.ColorMask[BCOMP],
    236                   ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
     234                  ctx->Color.ColorMask[GCOMP] ||
     235                  ctx->Color.ColorMask[BCOMP],
     236                  ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
    237237
    238238      if(ctx->Depth.Mask) FX_grDepthMask(FXTRUE);
     
    241241
    242242      if (IND & FX_ANTIALIAS) {
    243         FX_grAADrawTriangle(v1, v2, v4, FXTRUE, FXTRUE, FXTRUE);
    244         FX_grAADrawTriangle(v2, v3, v4, FXTRUE, FXTRUE, FXTRUE);
     243        FX_grAADrawTriangle(v1, v2, v4, FXTRUE, FXTRUE, FXTRUE);
     244        FX_grAADrawTriangle(v2, v3, v4, FXTRUE, FXTRUE, FXTRUE);
    245245      } else {
    246         FX_grDrawTriangle(v1, v2, v4);
    247         FX_grDrawTriangle(v2, v3, v4);
    248       }
    249    }   
     246        FX_grDrawTriangle(v1, v2, v4);
     247        FX_grDrawTriangle(v2, v3, v4);
     248      }
     249   }
    250250}
    251251
    252 
    253 
     252#define DRAW_LINE(tmp0, tmp1, width)    \
     253  do {                                  \
     254    GrVertex verts[4];                  \
     255    float dx, dy, wx, wy;               \
     256                                        \
     257    dx = tmp0->x - tmp1->x;             \
     258    dy = tmp0->y - tmp1->y;             \
     259                                        \
     260    if (dx * dx > dy * dy) {            \
     261      wx = 0;                           \
     262      wy = width;                       \
     263    } else {                            \
     264      wx = width;                       \
     265      wy = 0;                           \
     266    }                                   \
     267                                        \
     268   verts[0] = *tmp0;                    \
     269   verts[1] = *tmp0;                    \
     270   verts[2] = *tmp1;                    \
     271   verts[3] = *tmp1;                    \
     272                                        \
     273   verts[0].x = tmp0->x - wx;           \
     274   verts[0].y = tmp0->y - wy;           \
     275                                        \
     276   verts[1].x = tmp0->x + wx;           \
     277   verts[1].y = tmp0->y + wy;           \
     278                                        \
     279   verts[2].x = tmp1->x + wx;           \
     280   verts[2].y = tmp1->y + wy;           \
     281                                        \
     282   verts[3].x = tmp1->x - wx;           \
     283   verts[3].y = tmp1->y - wy;           \
     284                                        \
     285   FX_grDrawPolygonVertexList(4, verts); \
     286  } while (0)
    254287
    255288#if (IND & FX_OFFSET) == 0
     
    260293   fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
    261294   GLubyte (* const color)[4] = VB->Color[0]->data;
    262    GrVertex *v1 = (GrVertex *)gWin[e1].f; 
     295   GrVertex *v1 = (GrVertex *)gWin[e1].f;
    263296   GrVertex *v2 = (GrVertex *)gWin[e2].f;
    264 
    265    if (IND & FX_FLAT)
     297   GLfloat w = ctx->Line.Width*.5;
     298
     299   if (IND & FX_FLAT)
    266300   {
    267301      FX_VB_COLOR(fxMesa, color[pv]);
     
    271305        GLuint v1argb = v1->argb;
    272306        GLuint v2argb = v2->argb;
    273         v1->argb = (color[pv][ACOMP] << 24) | (v1argb & 0x00FFFFFF);
    274         v2->argb = (color[pv][ACOMP] << 24) | (v2argb & 0x00FFFFFF);
     307        v1->argb = (color[pv][ACOMP] << 24) | (v1argb & 0x00FFFFFF);
     308        v2->argb = (color[pv][ACOMP] << 24) | (v2argb & 0x00FFFFFF);
    275309      }
    276310#else
    277         v1->a = v2->a = UBYTE_COLOR_TO_FLOAT_255_COLOR(color[pv][3]);
    278 #endif 
    279    } 
    280    else if (IND & FX_TWOSIDE) 
     311        v1->a = v2->a = UBYTE_COLOR_TO_FLOAT_255_COLOR(color[pv][3]);
     312#endif
     313   }
     314   else if (IND & FX_TWOSIDE)
    281315   {
    282       GOURAUD2(v1,color[e1]); 
    283       GOURAUD2(v2,color[e2]); 
    284    }
    285 
    286    if (IND & FX_FRONT_BACK) {
    287       FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
    288                   ctx->Color.ColorMask[GCOMP] ||
    289                   ctx->Color.ColorMask[BCOMP],
    290                   FXFALSE);
     316      GOURAUD2(v1,color[e1]);
     317      GOURAUD2(v2,color[e2]);
     318   }
     319
     320   if (IND & FX_FRONT_BACK) {
     321      FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
     322                  ctx->Color.ColorMask[GCOMP] ||
     323                  ctx->Color.ColorMask[BCOMP],
     324                  FXFALSE);
    291325      FX_grDepthMask(FXFALSE);
    292326      FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
     
    296330      FX_grAADrawLine(v1,v2);
    297331   else
    298       FX_grDrawLine(v1,v2);
    299 
    300    if (IND & FX_FRONT_BACK) 
     332      DRAW_LINE(v1,v2,w);
     333
     334   if (IND & FX_FRONT_BACK)
    301335   {
    302336      FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
    303                   ctx->Color.ColorMask[GCOMP] ||
    304                   ctx->Color.ColorMask[BCOMP],
    305                   ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
     337                  ctx->Color.ColorMask[GCOMP] ||
     338                  ctx->Color.ColorMask[BCOMP],
     339                  ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
    306340
    307341      if(ctx->Depth.Mask)
    308         FX_grDepthMask(FXTRUE);
     342        FX_grDepthMask(FXTRUE);
    309343
    310344      FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
    311345
    312346      if (IND & FX_ANTIALIAS)
    313         FX_grAADrawLine(v1,v2);
     347        FX_grAADrawLine(v1,v2);
    314348      else
    315          FX_grDrawLine(v1,v2);
     349         DRAW_LINE(v1,v2,w);
    316350   }
    317351}
     
    336370#endif
    337371
    338 #if IND & FX_ANTIALIAS
    339 #define DRAW_POINT(i) FX_grAADrawPoint((GrVertex *)gWin[i].f);
    340 #else
    341 #define DRAW_POINT(i) FX_grDrawPoint((GrVertex *)gWin[i].f);
    342 #endif
    343 
     372
     373#define DRAW_POINT(i, sz)                       \
     374  do {                                          \
     375    GrVertex verts[4], *tmp;                    \
     376                                                \
     377    tmp = (GrVertex*)gWin[i].f;                 \
     378    verts[0] = *tmp;                            \
     379    verts[1] = *tmp;                            \
     380    verts[2] = *tmp;                            \
     381    verts[3] = *tmp;                            \
     382    verts[0].x = verts[3].x = tmp->x + sz;      \
     383    verts[0].y = verts[1].y = tmp->y + sz;      \
     384    verts[2].x = verts[1].x = tmp->x - sz;      \
     385    verts[2].y = verts[3].y = tmp->y - sz;      \
     386                                                \
     387    FX_grDrawPolygonVertexList(4, verts);       \
     388  } while (0)
    344389
    345390static void TAG(fx_points)(GLcontext *ctx, GLuint first, GLuint last)
     
    350395   GLubyte (*color)[4] = VB->ColorPtr->data;
    351396   GLuint i;
     397   GLfloat sz = ctx->Point.Size * .5;
    352398
    353399   (void) color; (void) fxMesa;
     
    355401   if (IND & FX_FRONT_BACK) {
    356402      FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
    357                   ctx->Color.ColorMask[GCOMP] ||
    358                   ctx->Color.ColorMask[BCOMP],
    359                   FXFALSE);
     403                  ctx->Color.ColorMask[GCOMP] ||
     404                  ctx->Color.ColorMask[BCOMP],
     405                  FXFALSE);
    360406
    361407      FX_grDepthMask(FXFALSE);
     
    365411   if(!VB->ClipOrMask) {
    366412      for(i=first;i<=last;i++) {
    367         FLAT_COLOR(fxMesa, color[i]);
    368          DRAW_POINT(i);
     413        FLAT_COLOR(fxMesa, color[i]);
     414         DRAW_POINT(i, sz);
    369415      }
    370416   } else {
    371417      for(i=first;i<=last;i++) {
    372         if(VB->ClipMask[i]==0) {
    373             FLAT_COLOR(fxMesa, color[i]);
    374             DRAW_POINT(i);
    375         }
    376       }
    377    }
    378 
    379    if (IND & FX_FRONT_BACK) {
    380       FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
    381                   ctx->Color.ColorMask[GCOMP] ||
    382                   ctx->Color.ColorMask[BCOMP],
    383                   ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
     418        if(VB->ClipMask[i]==0) {
     419            FLAT_COLOR(fxMesa, color[i]);
     420            DRAW_POINT(i, sz);
     421        }
     422      }
     423   }
     424
     425   if (IND & FX_FRONT_BACK) {
     426      FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
     427                  ctx->Color.ColorMask[GCOMP] ||
     428                  ctx->Color.ColorMask[BCOMP],
     429                  ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
    384430      if(ctx->Depth.Mask)
    385         FX_grDepthMask(FXTRUE);
     431        FX_grDepthMask(FXTRUE);
    386432      FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
    387433
    388434
    389435      if(!VB->ClipOrMask) {
    390         for(i=first;i<=last;i++) {
    391             FLAT_COLOR(fxMesa, color[i]);
    392             DRAW_POINT(i);
    393         }
     436        for(i=first;i<=last;i++) {
     437            FLAT_COLOR(fxMesa, color[i]);
     438            DRAW_POINT(i, sz);
     439        }
    394440      } else {
    395         for(i=first;i<=last;i++) {
    396             if(VB->ClipMask[i]==0) {
    397                FLAT_COLOR(fxMesa, color[i]);
    398                DRAW_POINT(i);
    399             }
    400         }
     441        for(i=first;i<=last;i++) {
     442            if(VB->ClipMask[i]==0) {
     443               FLAT_COLOR(fxMesa, color[i]);
     444               DRAW_POINT(i, sz);
     445            }
     446        }
    401447      }
    402448   }
     
    412458   quad_tab[IND] = TAG(fx_quad);
    413459
    414 #if ((IND & FX_OFFSET) == 0) 
     460#if ((IND & FX_OFFSET) == 0)
    415461      line_tab[IND] = TAG(fx_line);
    416462      points_tab[IND] = TAG(fx_points);
    417 #else 
     463#else
    418464      line_tab[IND] = line_tab[IND & ~FX_OFFSET];
    419465      points_tab[IND] = points_tab[IND & ~FX_OFFSET];
  • trunk/src/opengl/mesa/3dfx/fxvs_tmp.h

    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.
     
    122122   fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
    123123
    124    if (fxMesa->new_state) 
     124   if (fxMesa->new_state)
    125125      fxSetupFXUnits( ctx );
    126126
     
    137137
    138138      if (VB->ClipOrMask) {
    139         GLubyte *clipmask = &VB->ClipMask[start];
    140         for (;v!=vend;v+=16,clipmask++ INCR) {
    141             if (*clipmask == 0) {
    142                DO_SETUP;
    143             }
    144         }
    145       } else 
    146         for (;v!=vend;v+=16 INCR) {
    147             DO_SETUP;
    148         }
     139        GLubyte *clipmask = &VB->ClipMask[start];
     140        for (;v!=vend;v+=16,clipmask++ INCR) {
     141            if (*clipmask == 0) {
     142               DO_SETUP;
     143            }
     144        }
     145      } else
     146        for (;v!=vend;v+=16 INCR) {
     147            DO_SETUP;
     148        }
    149149
    150150      /* rare - I hope */
  • trunk/src/opengl/mesa/3dfx/fxvsetup.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.
     
    6161{
    6262   fprintf(stderr, "%s: %d %s%s%s%s%s%s\n",
    63           msg,
    64           flags,
    65           (flags & SETUP_XY) ? " xy," : "",
    66           (flags & SETUP_Z)  ? " z," : "",
    67           (flags & SETUP_W)  ? " w," : "",
    68           (flags & SETUP_RGBA) ? " rgba," : "",
    69           (flags & SETUP_TMU0)  ? " tmu0," : "",
    70           (flags & SETUP_TMU1)  ? " tmu1," : "");
     63          msg,
     64          flags,
     65          (flags & SETUP_XY) ? " xy," : "",
     66          (flags & SETUP_Z)  ? " z," : "",
     67          (flags & SETUP_W)  ? " w," : "",
     68          (flags & SETUP_RGBA) ? " rgba," : "",
     69          (flags & SETUP_TMU0)  ? " tmu0," : "",
     70          (flags & SETUP_TMU1)  ? " tmu1," : "");
    7171}
    7272
    7373static void project_texcoords( struct vertex_buffer *VB,
    74                                GLuint tmu_nr, GLuint tc_nr,
    75                                GLuint start, GLuint count )
    76 {                             
     74                               GLuint tmu_nr, GLuint tc_nr,
     75                               GLuint start, GLuint count )
     76{
    7777   fxVertex *v = FX_DRIVER_DATA(VB)->verts + start;
    7878   GrTmuVertex *tmu = &(((GrVertex *)v->f)->tmuvtx[tmu_nr]);
     
    8686      tmu->oow = v->f[OOWCOORD] * data[3];
    8787      tmu = (GrTmuVertex *)((char *)tmu + sizeof(fxVertex));
    88    }     
     88   }
    8989}
    9090
    9191
    9292static void copy_w( struct vertex_buffer *VB,
    93                     GLuint tmu_nr,
    94                     GLuint start, GLuint count )
    95 {                             
     93                    GLuint tmu_nr,
     94                    GLuint start, GLuint count )
     95{
    9696   fxVertex *v = FX_DRIVER_DATA(VB)->verts + start;
    9797   GrTmuVertex *tmu = &(((GrVertex *)v->f)->tmuvtx[tmu_nr]);
     
    101101      tmu->oow = v->f[OOWCOORD];
    102102      tmu = (GrTmuVertex *)((char *)tmu + sizeof(fxVertex));
    103    }     
     103   }
    104104}
    105105
     
    303303      setupindex |= SETUP_RGBA|SETUP_W;
    304304
    305    if ((ctx->Texture.ReallyEnabled & (TEXTURE0_2D|TEXTURE0_3D)) == TEXTURE0_2D) 
     305   if ((ctx->Texture.ReallyEnabled & (TEXTURE0_2D|TEXTURE0_3D)) == TEXTURE0_2D)
    306306   {
    307       if (ctx->Texture.Unit[0].EnvMode == GL_REPLACE) 
    308         setupindex &= ~SETUP_RGBA;
     307      if (ctx->Texture.Unit[0].EnvMode == GL_REPLACE)
     308        setupindex &= ~SETUP_RGBA;
    309309
    310310      setupindex |= SETUP_TMU0|SETUP_W;
     
    313313   if ((ctx->Texture.ReallyEnabled & (TEXTURE1_2D|TEXTURE1_3D)) == TEXTURE1_2D)
    314314   {
    315       if (setupindex & SETUP_TMU0) {
    316          struct gl_texture_object *tObj=ctx->Texture.Unit[0].CurrentD[2];
    317          tfxTexInfo *ti=fxTMGetTexInfo(tObj);
    318 
    319          setupindex |= SETUP_TMU1|SETUP_W;
    320 
    321          if(ti->whichTMU!=FX_TMU0) {
    322             fxMesa->tmu_source[0] = 1; fxMesa->tex_dest[1] = SETUP_TMU0;
    323             fxMesa->tmu_source[1] = 0; fxMesa->tex_dest[0] = SETUP_TMU1;
    324          }
    325       } else {
    326          setupindex |= SETUP_TMU0|SETUP_W;
    327          fxMesa->tmu_source[0] = 1; fxMesa->tex_dest[1] = SETUP_TMU0;
    328          /* not used: */
    329          fxMesa->tmu_source[1] = 0; fxMesa->tex_dest[0] = SETUP_TMU1;
    330       }
     315     setupindex |= SETUP_TMU1|SETUP_W;
     316     if (setupindex & SETUP_TMU0) { /* both TMUs in use */
     317       struct gl_texture_object *tObj=ctx->Texture.Unit[0].CurrentD[2];
     318       tfxTexInfo *ti=fxTMGetTexInfo(tObj);
     319
     320       if (ti->whichTMU!=FX_TMU0) { /* TMU0 and TMU1 are swapped */
     321         fxMesa->tmu_source[0] = 1; fxMesa->tex_dest[1] = SETUP_TMU0;
     322         fxMesa->tmu_source[1] = 0; fxMesa->tex_dest[0] = SETUP_TMU1;
     323       }
     324     }
    331325   }
    332326
     
    335329
    336330   if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_PIPELINE|VERBOSE_STATE))
    337       fxPrintSetupFlags("fxmesa: vertex setup function", setupindex); 
     331      fxPrintSetupFlags("fxmesa: vertex setup function", setupindex);
    338332
    339333   fxMesa->setupindex = setupindex;
     
    353347      return;
    354348   }
    355      
    356    if (VB->Type == VB_CVA_PRECALC) 
     349
     350   if (VB->Type == VB_CVA_PRECALC)
    357351      fxDDPartialRasterSetup( VB );
    358    else 
     352   else
    359353      ctx->Driver.RasterSetup( VB, VB->CopyStart, VB->Count );
    360354}
     
    366360 * we get a forbidden input in the elt pipeline - and therefore need to check
    367361 * whether we have one *now*.  Similarly need to know if state changes cause
    368  * size4 texcoords to be introduced. 
     362 * size4 texcoords to be introduced.
    369363 */
    370364void fxDDCheckPartialRasterSetup( GLcontext *ctx, struct gl_pipeline_stage *d )
     
    375369   d->type = 0;
    376370   d->pre_forbidden_inputs = 0;
    377    fxMesa->setupdone = 0;       /* cleared if we return */
    378 
    379    /* Indirect triangles must be rendered via the immediate pipeline. 
    380     * If all rasterization is software, no need to set up. 
     371   fxMesa->setupdone = 0;       /* cleared if we return */
     372
     373   /* Indirect triangles must be rendered via the immediate pipeline.
     374    * If all rasterization is software, no need to set up.
    381375    */
    382376   if ((ctx->Array.Summary & VERT_OBJ_ANY) == 0)
    383377      return;
    384    
     378
    385379   if ((ctx->IndirectTriangles & DD_SW_SETUP) ||
    386        (ctx->IndirectTriangles & DD_SW_RASTERIZE) == DD_SW_RASTERIZE) 
     380       (ctx->IndirectTriangles & DD_SW_RASTERIZE) == DD_SW_RASTERIZE)
    387381      return;
    388382
     
    391385   {
    392386      if (ctx->TextureMatrix[0].type == MATRIX_GENERAL ||
    393           ctx->TextureMatrix[0].type == MATRIX_PERSPECTIVE ||
    394           (ctx->Texture.Unit[1].TexGenEnabled & Q_BIT))
    395         return;
     387          ctx->TextureMatrix[0].type == MATRIX_PERSPECTIVE ||
     388          (ctx->Texture.Unit[1].TexGenEnabled & Q_BIT))
     389        return;
    396390
    397391      d->pre_forbidden_inputs |= VERT_TEX0_4;
     
    402396   {
    403397      if (ctx->TextureMatrix[1].type == MATRIX_GENERAL ||
    404           ctx->TextureMatrix[1].type == MATRIX_PERSPECTIVE ||
    405           (ctx->Texture.Unit[1].TexGenEnabled & Q_BIT))
    406         return;
     398          ctx->TextureMatrix[1].type == MATRIX_PERSPECTIVE ||
     399          (ctx->Texture.Unit[1].TexGenEnabled & Q_BIT))
     400        return;
    407401
    408402      d->pre_forbidden_inputs |= VERT_TEX1_4;
    409403   }
    410404
    411    
     405
    412406   fxMesa->setupdone = tmp;
    413407   d->inputs = 0;
     
    444438   if ((newout & VERT_WIN) == 0)
    445439      ind &= ~(fxMesa->setupdone & SETUP_W);
    446      
     440
    447441   fxMesa->setupdone &= ~ind;
    448442   ind &= fxMesa->setupindex;
     
    451445   if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_PIPELINE)) {
    452446      gl_print_vert_flags("new outputs", VB->pipeline->new_outputs);
    453       fxPrintSetupFlags("fxmesa: partial setup function", ind); 
    454    }
    455 
    456    if (ind) 
    457       setupfuncs[ind]( VB, VB->Start, VB->Count );   
     447      fxPrintSetupFlags("fxmesa: partial setup function", ind);
     448   }
     449
     450   if (ind)
     451      setupfuncs[ind]( VB, VB->Start, VB->Count );
    458452}
    459453
     
    472466   FREE( fvb->vert_store );
    473467   fvb->vert_store = MALLOC( sizeof(fxVertex) * fvb->size + 31);
    474    if (!fvb->vert_store || !VB->ClipMask) 
     468   if (!fvb->vert_store || !VB->ClipMask)
    475469   {
    476470     fprintf(stderr,"fx Driver: out of memory !\n");
    477471     fxCloseHardware();
    478      exit(-1);
     472     EXIT(-1);
    479473   }
    480474   fvb->verts = (fxVertex *)(((unsigned long)fvb->vert_store + 31) & ~31);
     
    482476   gl_vector1ui_free( &fvb->clipped_elements );
    483477   gl_vector1ui_alloc( &fvb->clipped_elements, VEC_WRITABLE, fvb->size, 32 );
    484    
     478
    485479   if (!fvb->clipped_elements.start) goto memerror;
    486    
     480
    487481   return;
    488 memerror: 
     482memerror:
    489483   fprintf(stderr,"fx Driver: out of memory !\n");
    490484   fxCloseHardware();
    491    exit(-1);
     485   EXIT(-1);
    492486}
    493487
     
    507501      fvb->vert_store = MALLOC( sizeof(fxVertex) * fvb->size + 31);
    508502      if (!fvb->vert_store) goto memerror;
    509 #if defined(FX_GLIDE3) 
     503#if defined(FX_GLIDE3)
    510504      fvb->triangle_b = MALLOC( sizeof(GrVertex*) *4* fvb->size+ 31);
    511505      if (!fvb->triangle_b)  goto memerror;
    512506      fvb->strips_b = MALLOC( sizeof(GrVertex*) *4* fvb->size+ 31);
    513       if (!fvb->strips_b )  goto memerror;         
    514 #endif     
     507      if (!fvb->strips_b )  goto memerror;
     508#endif
    515509      fvb->verts = (fxVertex *)(((unsigned long)fvb->vert_store + 31) & ~31);
    516510      gl_vector1ui_alloc( &fvb->clipped_elements, VEC_WRITABLE, fvb->size, 32 );
     
    519513      FREE( VB->ClipMask );
    520514      VB->ClipMask = (GLubyte *)MALLOC(sizeof(GLubyte) * fvb->size);
    521           if (!VB->ClipMask) goto memerror;
     515          if (!VB->ClipMask) goto memerror;
    522516
    523517   } else {
    524518      fvb->vert_store = MALLOC( sizeof(fxVertex) * (VB->Size + 12) + 31);
    525519      if (!fvb->vert_store) goto memerror;
    526 #if defined(FX_GLIDE3) 
     520#if defined(FX_GLIDE3)
    527521      fvb->triangle_b = MALLOC( sizeof(GrVertex*) *4* fvb->size+ 31);
    528522      if (!fvb->triangle_b)  goto memerror;
    529523      fvb->strips_b = MALLOC( sizeof(GrVertex*) *4* fvb->size+ 31);
    530       if (!fvb->strips_b )  goto memerror;     
    531 #endif       
     524      if (!fvb->strips_b )  goto memerror;
     525#endif
    532526      fvb->verts = (fxVertex *)(((unsigned long)fvb->vert_store + 31) & ~31);
    533527      fvb->size = VB->Size + 12;
    534528   }
    535529
    536    
     530
    537531   VB->driver_data = fvb;
    538532   return;
     
    540534   fprintf(stderr,"fx Driver: out of memory !\n");
    541535   fxCloseHardware();
    542    exit(-1);   
     536   EXIT(-1);
    543537}
    544538
     
    546540{
    547541   struct tfxMesaVertexBuffer *fvb = FX_DRIVER_DATA(VB);
    548    
     542
    549543   if (fvb) {
    550544      if (fvb->vert_store) FREE(fvb->vert_store);
     
    553547#if defined(FX_GLIDE3)
    554548      if (fvb->strips_b)
    555         FREE(fvb->strips_b);
     549        FREE(fvb->strips_b);
    556550      if (fvb->triangle_b)
    557         FREE(fvb->triangle_b);
     551        FREE(fvb->triangle_b);
    558552#endif
    559553      VB->driver_data = 0;
    560    }     
     554   }
    561555}
    562556
  • trunk/src/opengl/mesa/3dfx/fxvsetup.h

    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.
     
    4848
    4949
    50 #define VARS_W 
     50#define VARS_W
    5151
    5252#define VARS_Z
    5353
    54 #define VARS_TMU0                                                       \
    55   GLuint tmu0_source = fxMesa->tmu_source[0];                           \
    56   GLfloat *tmu0_data = VEC_ELT(VB->TexCoordPtr[tmu0_source],            \
    57                                GLfloat, start);                         \
    58   GLuint tmu0_stride = VB->TexCoordPtr[tmu0_source]->stride;            \
    59   GLuint tmu0_sz = VB->TexCoordPtr[tmu0_source]->size;                  \
    60   struct gl_texture_unit *t0 = &ctx->Texture.Unit[tmu0_source];         \
    61   GLfloat sscale0 = FX_TEXTURE_DATA(t0)->sScale;        \
     54#define VARS_TMU0                                                       \
     55  GLuint tmu0_source = fxMesa->tmu_source[0];                           \
     56  GLfloat *tmu0_data = VEC_ELT(VB->TexCoordPtr[tmu0_source],            \
     57                               GLfloat, start);                         \
     58  GLuint tmu0_stride = VB->TexCoordPtr[tmu0_source]->stride;            \
     59  GLuint tmu0_sz = VB->TexCoordPtr[tmu0_source]->size;                  \
     60  struct gl_texture_unit *t0 = &ctx->Texture.Unit[tmu0_source];         \
     61  GLfloat sscale0 = FX_TEXTURE_DATA(t0)->sScale;        \
    6262  GLfloat tscale0 = FX_TEXTURE_DATA(t0)->tScale;
    6363
    64 #define VARS_TMU1                                                       \
    65   GLuint tmu1_source = fxMesa->tmu_source[1];                           \
    66   GLfloat *tmu1_data = VEC_ELT(VB->TexCoordPtr[tmu1_source],            \
    67                                GLfloat, start);                         \
    68   GLuint tmu1_stride = VB->TexCoordPtr[tmu1_source]->stride;            \
    69   GLuint tmu1_sz = VB->TexCoordPtr[tmu1_source]->size;                  \
    70   struct gl_texture_unit *t1 = &ctx->Texture.Unit[tmu1_source];         \
    71   GLfloat sscale1 = FX_TEXTURE_DATA(t1)->sScale;        \
     64#define VARS_TMU1                                                       \
     65  GLuint tmu1_source = fxMesa->tmu_source[1];                           \
     66  GLfloat *tmu1_data = VEC_ELT(VB->TexCoordPtr[tmu1_source],            \
     67                               GLfloat, start);                         \
     68  GLuint tmu1_stride = VB->TexCoordPtr[tmu1_source]->stride;            \
     69  GLuint tmu1_sz = VB->TexCoordPtr[tmu1_source]->size;                  \
     70  struct gl_texture_unit *t1 = &ctx->Texture.Unit[tmu1_source];         \
     71  GLfloat sscale1 = FX_TEXTURE_DATA(t1)->sScale;        \
    7272  GLfloat tscale1 = FX_TEXTURE_DATA(t1)->tScale;
    7373
    74 #define VARS_RGBA                                               \
    75   GLubyte *color = VEC_ELT(VB->ColorPtr, GLubyte, start);       \
    76   GLuint col_stride = VB->ColorPtr->stride; 
     74#define VARS_RGBA                                               \
     75  GLubyte *color = VEC_ELT(VB->ColorPtr, GLubyte, start);       \
     76  GLuint col_stride = VB->ColorPtr->stride;
    7777
    78 #define VARS_XY GLfloat *win = VB->Win.data[start]; 
     78#define VARS_XY GLfloat *win = VB->Win.data[start];
    7979
    8080#define INCR_XY win += 4
     
    8282
    8383#ifdef FX_V2
    84 #  define DO_SETUP_XY                           \
    85   v[XCOORD]=win[0];                             \
    86   v[YCOORD]=win[1]; 
     84#  define DO_SETUP_XY                           \
     85  v[XCOORD]=win[0];                             \
     86  v[YCOORD]=win[1];
    8787#else
    8888#ifdef DRIVERTS
    89 #  define DO_SETUP_XY                           \
    90   v[XCOORD]=win[0]+fxMesa->x_offset;            \
    91   v[YCOORD]=win[1]+fxMesa->y_delta;             
     89#  define DO_SETUP_XY                           \
     90  v[XCOORD]=win[0]+fxMesa->x_offset;            \
     91  v[YCOORD]=win[1]+fxMesa->y_delta;
    9292#else
    9393#  if (defined(__linux__) && defined(__i386__)) || defined(macintosh)
    94 #    define DO_SETUP_XY {                       \
    95        GLfloat t1 = win[0] + snapper;   \
    96        GLfloat t2 = win[1] + snapper;   \
    97        v[XCOORD] = t1 - snapper;                        \
    98        v[YCOORD] = t2 - snapper;                        \
     94#    define DO_SETUP_XY {                       \
     95       GLfloat t1 = win[0] + snapper;   \
     96       GLfloat t2 = win[1] + snapper;   \
     97       v[XCOORD] = t1 - snapper;                        \
     98       v[YCOORD] = t2 - snapper;                        \
    9999     }
    100100#  else
    101 #    define DO_SETUP_XY {                               \
    102         /* trunc (x,y) to multiple of 1/16 */           \
    103         v[XCOORD]=((int)(win[0]*16.0f))*(1.0f/16.0f);   \
    104         v[YCOORD]=((int)(win[1]*16.0f))*(1.0f/16.0f);   \
     101#    define DO_SETUP_XY {                               \
     102        /* trunc (x,y) to multiple of 1/16 */           \
     103        v[XCOORD]=((int)(win[0]*16.0f))*(1.0f/16.0f);   \
     104        v[YCOORD]=((int)(win[1]*16.0f))*(1.0f/16.0f);   \
    105105     }
    106106#  endif
     
    109109
    110110
    111 #define DO_SETUP_W {                            \
    112    v[OOWCOORD]=win[3];                  \
     111#define DO_SETUP_W {                            \
     112   v[OOWCOORD]=win[3];                  \
    113113}
    114114
    115115#define DO_SETUP_Z v[ZCOORD]=win[2];
    116116
    117 #define DO_SETUP_TMU0                                   \
    118 {                                                       \
    119   v[S0COORD]=sscale0*tmu0_data[0]*v[OOWCOORD];          \
    120   v[T0COORD]=tscale0*tmu0_data[1]*v[OOWCOORD];          \
    121 } 
     117#define DO_SETUP_TMU0                                   \
     118{                                                       \
     119  v[S0COORD]=sscale0*tmu0_data[0]*v[OOWCOORD];          \
     120  v[T0COORD]=tscale0*tmu0_data[1]*v[OOWCOORD];          \
     121}
    122122
    123123#define INCR_TMU0 STRIDE_F(tmu0_data, tmu0_stride)
    124124
    125 #define DO_SETUP_TMU1                           \
    126 {                                               \
    127   v[S1COORD]=sscale1*tmu1_data[0]*v[OOWCOORD];  \
    128   v[T1COORD]=tscale1*tmu1_data[1]*v[OOWCOORD];  \
     125#define DO_SETUP_TMU1                           \
     126{                                               \
     127  v[S1COORD]=sscale1*tmu1_data[0]*v[OOWCOORD];  \
     128  v[T1COORD]=tscale1*tmu1_data[1]*v[OOWCOORD];  \
    129129}
    130130
     
    132132
    133133#if FX_USE_PARGB
    134 #define DO_SETUP_RGBA   \
     134#define DO_SETUP_RGBA   \
    135135 { GET_PARGB(v) = color[ACOMP] << 24 | color[RCOMP] << 16 | color[GCOMP] << 8 | color[BCOMP];}
    136  
     136
    137137#else
    138 #define DO_SETUP_RGBA                                   \
    139 {                                                       \
    140   UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[RCOORD], color[0]); \
    141   UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[GCOORD], color[1]); \
    142   UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[BCOORD], color[2]); \
    143   UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[ACOORD], color[3]); \
     138#define DO_SETUP_RGBA                                   \
     139{                                                       \
     140  UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[RCOORD], color[0]); \
     141  UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[GCOORD], color[1]); \
     142  UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[BCOORD], color[2]); \
     143  UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[ACOORD], color[3]); \
    144144}
    145145#endif
     
    148148
    149149
    150 #define _FIXUP_PRE                                                      \
    151    GLuint hs = fxMesa->stw_hint_state & ~(GR_STWHINT_W_DIFF_TMU0 |      \
    152                                           GR_STWHINT_W_DIFF_TMU1);
     150#define _FIXUP_PRE                                                      \
     151   GLuint hs = fxMesa->stw_hint_state & ~(GR_STWHINT_W_DIFF_TMU0 |      \
     152                                          GR_STWHINT_W_DIFF_TMU1);
    153153
    154 #define _FIXUP_TMU0                                                     \
    155    if (tmu0_sz == 4) {                                                  \
    156       project_texcoords( VB, 0, tmu0_source, start, end );              \
    157       hs |= GR_STWHINT_W_DIFF_TMU0;                     \
    158    } 
     154#define _FIXUP_TMU0                                                     \
     155   if (tmu0_sz == 4) {                                                  \
     156      project_texcoords( VB, 0, tmu0_source, start, end );              \
     157      hs |= GR_STWHINT_W_DIFF_TMU0;                     \
     158   }
    159159
    160160
    161 #define _FIXUP_TMU1                                                     \
    162    if (tmu1_sz == 4) {                                                  \
    163       project_texcoords( VB, 1, tmu1_source, start, end );              \
    164       hs |= GR_STWHINT_W_DIFF_TMU1;                     \
    165    } 
     161#define _FIXUP_TMU1                                                     \
     162   if (tmu1_sz == 4) {                                                  \
     163      project_texcoords( VB, 1, tmu1_source, start, end );              \
     164      hs |= GR_STWHINT_W_DIFF_TMU1;                     \
     165   }
    166166
    167167
    168 #define _FIXUP_TMU01                                            \
    169    if (tmu0_sz == 4) {                                          \
    170       project_texcoords( VB, 0, tmu0_source, start, end );      \
    171       if (tmu1_sz == 4)                                         \
    172          project_texcoords( VB, 1, tmu1_source, start, end );   \
    173       else                                                      \
    174          copy_w( VB, 1, start, end );                           \
    175       hs |= (GR_STWHINT_W_DIFF_TMU0|GR_STWHINT_W_DIFF_TMU1);    \
    176    } else if (tmu1_sz == 4) {                                   \
    177       project_texcoords( VB, 1, tmu1_source, start, end );      \
    178       hs |= GR_STWHINT_W_DIFF_TMU1;                             \
     168#define _FIXUP_TMU01                                            \
     169   if (tmu0_sz == 4) {                                          \
     170      project_texcoords( VB, 0, tmu0_source, start, end );      \
     171      if (tmu1_sz == 4)                                         \
     172         project_texcoords( VB, 1, tmu1_source, start, end );   \
     173      else                                                      \
     174         copy_w( VB, 1, start, end );                           \
     175      hs |= (GR_STWHINT_W_DIFF_TMU0|GR_STWHINT_W_DIFF_TMU1);    \
     176   } else if (tmu1_sz == 4) {                                   \
     177      project_texcoords( VB, 1, tmu1_source, start, end );      \
     178      hs |= GR_STWHINT_W_DIFF_TMU1;                             \
    179179   }
    180180
    181 #define _FIXUP_POST                                     \
    182    if (hs != fxMesa->stw_hint_state) {                  \
    183       fxMesa->stw_hint_state = hs;                      \
    184       FX_grHints(GR_HINT_STWHINT, hs);                  \
     181#define _FIXUP_POST                                     \
     182   if (hs != fxMesa->stw_hint_state) {                  \
     183      fxMesa->stw_hint_state = hs;                      \
     184      FX_grHints(GR_HINT_STWHINT, hs);                  \
    185185   }
    186186
  • trunk/src/opengl/mesa/3dfx/fxwgl.c

    r2977 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.
     
    5151
    5252#if defined(__WIN32__) || defined(__WIN32OS2__)
    53 
    5453#ifdef __cplusplus
    5554extern "C" {
     
    9089
    9190#ifdef GL_EXT_polygon_offset
    92    { (PROC)glPolygonOffsetEXT,                  "glPolygonOffsetEXT"            },
     91   { (PROC)glPolygonOffsetEXT,                  "glPolygonOffsetEXT"            },
    9392#endif
    94    { (PROC)glBlendEquationEXT,                  "glBlendEquationEXT"            },
    95    { (PROC)glBlendColorEXT,                     "glBlendColorExt"               },
    96    { (PROC)glVertexPointerEXT,                  "glVertexPointerEXT"            },
    97    { (PROC)glNormalPointerEXT,                  "glNormalPointerEXT"            },
    98    { (PROC)glColorPointerEXT,                   "glColorPointerEXT"             },
    99    { (PROC)glIndexPointerEXT,                   "glIndexPointerEXT"             },
    100    { (PROC)glTexCoordPointerEXT,                "glTexCoordPointer"             },
    101    { (PROC)glEdgeFlagPointerEXT,                "glEdgeFlagPointerEXT"          },
    102    { (PROC)glGetPointervEXT,                    "glGetPointervEXT"              },
    103    { (PROC)glArrayElementEXT,                   "glArrayElementEXT"             },
    104    { (PROC)glDrawArraysEXT,                     "glDrawArrayEXT"                },
    105    { (PROC)glAreTexturesResidentEXT,            "glAreTexturesResidentEXT"      },
    106    { (PROC)glBindTextureEXT,                    "glBindTextureEXT"              },
    107    { (PROC)glDeleteTexturesEXT,                 "glDeleteTexturesEXT"           },
    108    { (PROC)glGenTexturesEXT,                    "glGenTexturesEXT"              },
    109    { (PROC)glIsTextureEXT,                      "glIsTextureEXT"                },
    110    { (PROC)glPrioritizeTexturesEXT,             "glPrioritizeTexturesEXT"       },
    111    { (PROC)glCopyTexSubImage3DEXT,              "glCopyTexSubImage3DEXT"        },
    112    { (PROC)glTexImage3DEXT,                     "glTexImage3DEXT"               },
    113    { (PROC)glTexSubImage3DEXT,                  "glTexSubImage3DEXT"            },
    114    { (PROC)gl3DfxSetPaletteEXT,                 "3DFX_set_global_palette"       },
    115    { (PROC)glColorTableEXT,                     "glColorTableEXT"               },
    116    { (PROC)glColorSubTableEXT,                  "glColorSubTableEXT"            },
    117    { (PROC)glGetColorTableEXT,                  "glGetColorTableEXT"            },
    118    { (PROC)glGetColorTableParameterfvEXT,       "glGetColorTableParameterfvEXT" },
    119    { (PROC)glGetColorTableParameterivEXT,       "glGetColorTableParameterivEXT" },
    120    { (PROC)glPointParameterfEXT,                "glPointParameterfEXT"          },
    121    { (PROC)glPointParameterfvEXT,               "glPointParameterfvEXT"         },
    122    { (PROC)glBlendFuncSeparateINGR,             "glBlendFuncSeparateINGR"       },
    123    { (PROC)glActiveTextureARB,                  "glActiveTextureARB"            },
    124    { (PROC)glClientActiveTextureARB,            "glClientActiveTextureARB"      },
    125    { (PROC)glMultiTexCoord1dARB,                "glMultiTexCoord1dARB"          },
    126    { (PROC)glMultiTexCoord1dvARB,               "glMultiTexCoord1dvARB"         },
    127    { (PROC)glMultiTexCoord1fARB,                "glMultiTexCoord1fARB"          },
    128    { (PROC)glMultiTexCoord1fvARB,               "glMultiTexCoord1fvARB"         },
    129    { (PROC)glMultiTexCoord1iARB,                "glMultiTexCoord1iARB"          },
    130    { (PROC)glMultiTexCoord1ivARB,               "glMultiTexCoord1ivARB"         },
    131    { (PROC)glMultiTexCoord1sARB,                "glMultiTexCoord1sARB"          },
    132    { (PROC)glMultiTexCoord1svARB,               "glMultiTexCoord1svARB"         },
    133    { (PROC)glMultiTexCoord2dARB,                "glMultiTexCoord2dARB"          },
    134    { (PROC)glMultiTexCoord2dvARB,               "glMultiTexCoord2dvARB"         },
    135    { (PROC)glMultiTexCoord2fARB,                "glMultiTexCoord2fARB"          },
    136    { (PROC)glMultiTexCoord2fvARB,               "glMultiTexCoord2fvARB"         },
    137    { (PROC)glMultiTexCoord2iARB,                "glMultiTexCoord2iARB"          },
    138    { (PROC)glMultiTexCoord2ivARB,               "glMultiTexCoord2ivARB"         },
    139    { (PROC)glMultiTexCoord2sARB,                "glMultiTexCoord2sARB"          },
    140    { (PROC)glMultiTexCoord2svARB,               "glMultiTexCoord2svARB"         },
    141    { (PROC)glMultiTexCoord3dARB,                "glMultiTexCoord3dARB"          },
    142    { (PROC)glMultiTexCoord3dvARB,               "glMultiTexCoord3dvARB"         },
    143    { (PROC)glMultiTexCoord3fARB,                "glMultiTexCoord3fARB"          },
    144    { (PROC)glMultiTexCoord3fvARB,               "glMultiTexCoord3fvARB"         },
    145    { (PROC)glMultiTexCoord3iARB,                "glMultiTexCoord3iARB"          },
    146    { (PROC)glMultiTexCoord3ivARB,               "glMultiTexCoord3ivARB"         },
    147    { (PROC)glMultiTexCoord3sARB,                "glMultiTexCoord3sARB"          },
    148    { (PROC)glMultiTexCoord3svARB,               "glMultiTexCoord3svARB"         },
    149    { (PROC)glMultiTexCoord4dARB,                "glMultiTexCoord4dARB"          },
    150    { (PROC)glMultiTexCoord4dvARB,               "glMultiTexCoord4dvARB"         },
    151    { (PROC)glMultiTexCoord4fARB,                "glMultiTexCoord4fARB"          },
    152    { (PROC)glMultiTexCoord4fvARB,               "glMultiTexCoord4fvARB"         },
    153    { (PROC)glMultiTexCoord4iARB,                "glMultiTexCoord4iARB"          },
    154    { (PROC)glMultiTexCoord4ivARB,               "glMultiTexCoord4ivARB"         },
    155    { (PROC)glMultiTexCoord4sARB,                "glMultiTexCoord4sARB"          },
    156    { (PROC)glMultiTexCoord4svARB,               "glMultiTexCoord4svARB"         },
    157    { (PROC)glLockArraysEXT,                     "glLockArraysEXT"               },
    158    { (PROC)glUnlockArraysEXT,                   "glUnlockArraysEXT"             }
     93   { (PROC)glBlendEquationEXT,                  "glBlendEquationEXT"            },
     94   { (PROC)glBlendColorEXT,                     "glBlendColorExt"               },
     95   { (PROC)glVertexPointerEXT,                  "glVertexPointerEXT"            },
     96   { (PROC)glNormalPointerEXT,                  "glNormalPointerEXT"            },
     97   { (PROC)glColorPointerEXT,                   "glColorPointerEXT"             },
     98   { (PROC)glIndexPointerEXT,                   "glIndexPointerEXT"             },
     99   { (PROC)glTexCoordPointerEXT,                "glTexCoordPointer"             },
     100   { (PROC)glEdgeFlagPointerEXT,                "glEdgeFlagPointerEXT"          },
     101   { (PROC)glGetPointervEXT,                    "glGetPointervEXT"              },
     102   { (PROC)glArrayElementEXT,                   "glArrayElementEXT"             },
     103   { (PROC)glDrawArraysEXT,                     "glDrawArrayEXT"                },
     104   { (PROC)glAreTexturesResidentEXT,            "glAreTexturesResidentEXT"      },
     105   { (PROC)glBindTextureEXT,                    "glBindTextureEXT"              },
     106   { (PROC)glDeleteTexturesEXT,                 "glDeleteTexturesEXT"           },
     107   { (PROC)glGenTexturesEXT,                    "glGenTexturesEXT"              },
     108   { (PROC)glIsTextureEXT,                      "glIsTextureEXT"                },
     109   { (PROC)glPrioritizeTexturesEXT,             "glPrioritizeTexturesEXT"       },
     110   { (PROC)glCopyTexSubImage3DEXT,              "glCopyTexSubImage3DEXT"        },
     111   { (PROC)glTexImage3DEXT,                     "glTexImage3DEXT"               },
     112   { (PROC)glTexSubImage3DEXT,                  "glTexSubImage3DEXT"            },
     113   { (PROC)gl3DfxSetPaletteEXT,                 "3DFX_set_global_palette"       },
     114   { (PROC)glColorTableEXT,                     "glColorTableEXT"               },
     115   { (PROC)glColorSubTableEXT,                  "glColorSubTableEXT"            },
     116   { (PROC)glGetColorTableEXT,                  "glGetColorTableEXT"            },
     117   { (PROC)glGetColorTableParameterfvEXT,       "glGetColorTableParameterfvEXT" },
     118   { (PROC)glGetColorTableParameterivEXT,       "glGetColorTableParameterivEXT" },
     119   { (PROC)glPointParameterfEXT,                "glPointParameterfEXT"          },
     120   { (PROC)glPointParameterfvEXT,               "glPointParameterfvEXT"         },
     121   { (PROC)glBlendFuncSeparateINGR,             "glBlendFuncSeparateINGR"       },
     122   { (PROC)glActiveTextureARB,                  "glActiveTextureARB"            },
     123   { (PROC)glClientActiveTextureARB,            "glClientActiveTextureARB"      },
     124   { (PROC)glMultiTexCoord1dARB,                "glMultiTexCoord1dARB"          },
     125   { (PROC)glMultiTexCoord1dvARB,               "glMultiTexCoord1dvARB"         },
     126   { (PROC)glMultiTexCoord1fARB,                "glMultiTexCoord1fARB"          },
     127   { (PROC)glMultiTexCoord1fvARB,               "glMultiTexCoord1fvARB"         },
     128   { (PROC)glMultiTexCoord1iARB,                "glMultiTexCoord1iARB"          },
     129   { (PROC)glMultiTexCoord1ivARB,               "glMultiTexCoord1ivARB"         },
     130   { (PROC)glMultiTexCoord1sARB,                "glMultiTexCoord1sARB"          },
     131   { (PROC)glMultiTexCoord1svARB,               "glMultiTexCoord1svARB"         },
     132   { (PROC)glMultiTexCoord2dARB,                "glMultiTexCoord2dARB"          },
     133   { (PROC)glMultiTexCoord2dvARB,               "glMultiTexCoord2dvARB"         },
     134   { (PROC)glMultiTexCoord2fARB,                "glMultiTexCoord2fARB"          },
     135   { (PROC)glMultiTexCoord2fvARB,               "glMultiTexCoord2fvARB"         },
     136   { (PROC)glMultiTexCoord2iARB,                "glMultiTexCoord2iARB"          },
     137   { (PROC)glMultiTexCoord2ivARB,               "glMultiTexCoord2ivARB"         },
     138   { (PROC)glMultiTexCoord2sARB,                "glMultiTexCoord2sARB"          },
     139   { (PROC)glMultiTexCoord2svARB,               "glMultiTexCoord2svARB"         },
     140   { (PROC)glMultiTexCoord3dARB,                "glMultiTexCoord3dARB"          },
     141   { (PROC)glMultiTexCoord3dvARB,               "glMultiTexCoord3dvARB"         },
     142   { (PROC)glMultiTexCoord3fARB,                "glMultiTexCoord3fARB"          },
     143   { (PROC)glMultiTexCoord3fvARB,               "glMultiTexCoord3fvARB"         },
     144   { (PROC)glMultiTexCoord3iARB,                "glMultiTexCoord3iARB"          },
     145   { (PROC)glMultiTexCoord3ivARB,               "glMultiTexCoord3ivARB"         },
     146   { (PROC)glMultiTexCoord3sARB,                "glMultiTexCoord3sARB"          },
     147   { (PROC)glMultiTexCoord3svARB,               "glMultiTexCoord3svARB"         },
     148   { (PROC)glMultiTexCoord4dARB,                "glMultiTexCoord4dARB"          },
     149   { (PROC)glMultiTexCoord4dvARB,               "glMultiTexCoord4dvARB"         },
     150   { (PROC)glMultiTexCoord4fARB,                "glMultiTexCoord4fARB"          },
     151   { (PROC)glMultiTexCoord4fvARB,               "glMultiTexCoord4fvARB"         },
     152   { (PROC)glMultiTexCoord4iARB,                "glMultiTexCoord4iARB"          },
     153   { (PROC)glMultiTexCoord4ivARB,               "glMultiTexCoord4ivARB"         },
     154   { (PROC)glMultiTexCoord4sARB,                "glMultiTexCoord4sARB"          },
     155   { (PROC)glMultiTexCoord4svARB,               "glMultiTexCoord4svARB"         },
     156   { (PROC)glLockArraysEXT,                     "glLockArraysEXT"               },
     157   { (PROC)glUnlockArraysEXT,                   "glUnlockArraysEXT"             }
    159158};
    160159
     
    745744
    746745int GLAPIENTRY ChoosePixelFormat(HDC hdc,
    747                                CONST PIXELFORMATDESCRIPTOR *ppfd)
     746                               CONST PIXELFORMATDESCRIPTOR *ppfd)
    748747{
    749748  return wglChoosePixelFormat(hdc,ppfd);
     
    770769
    771770int GLAPIENTRY DescribePixelFormat(HDC hdc,int iPixelFormat,UINT nBytes,
    772                                 LPPIXELFORMATDESCRIPTOR ppfd)
     771                                LPPIXELFORMATDESCRIPTOR ppfd)
    773772{
    774773  return wglDescribePixelFormat(hdc,iPixelFormat,nBytes,ppfd);
     
    861860    }
    862861#endif
    863    
     862
    864863    BitBlt(hdcScreen, 0, 0,
    865864           width, height,
  • trunk/src/opengl/mesa/3dfx/makefile

    r3090 r3598  
    1 # $Id: makefile,v 1.8 2000-03-11 17:30:54 bird Exp $
     1# $Id: makefile,v 1.9 2000-05-23 20:41:24 jeroen Exp $
    22#
    33# Odin32 API
     
    1515# Compiler, tools, and interference rules.
    1616!include $(PDWIN32_INCLUDE)/pdwin32.mk
    17 MESADEFS= -DNO_PARALLEL -DNO_STEREO -DGL_MESA_window_pos -DTHREADS \
    18           -DUSE_X86_ASM_NOT -DUSE_MMX_ASM_NOT -DUSE_3DNOW_ASM_NOT \
    19           -DFX -DFX_V2 -DFX_SILENT -DBUILD_GL32
     17MESADEFS= -DNO_PARALLEL -DNO_STEREO -DGL_MESA_window_pos -DOS2_THREADS \
     18          -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM_NOT \
     19          -DFX -DFX_V2 -DFX_SILENT -DBUILD_GL32 -DFAST_MATH
    2020
    2121CFLAGS   = -I.. -I..\GL $(CFLAGS_WIN32APP) -I..\..\glut -I..\..\glide\cvg\glide -I..\..\glide\swlibs\fxmisc -I..\..\glide\cvg\incsrc $(MESADEFS) /Wcnd- /Tdp
    2222CXXFLAGS = -I.. -I..\GL $(CXXFLAGS_WIN32APP) -I..\..\glut -I..\..\glide\cvg\glide -I..\..\glide\swlibs\fxmisc -I..\..\glide\cvg\incsrc $(MESADEFS)
     23
     24ASFLAGS=$(ASFLAGS) -Fdo:$(OBJDIR)
    2325
    2426
     
    2830{..}.c{$(OBJDIR)}.obj:
    2931    $(CC) $(CFLAGS) -c -Fo$(OBJDIR)\$(@B).obj $<
     32
     33{..}.asm{$(OBJDIR)}.obj:
     34    $(AS) $(ASFLAGS) -Fdo:$(OBJDIR) $<
    3035
    3136
     
    5358$(OBJDIR)\alpha.obj \
    5459$(OBJDIR)\alphabuf.obj \
    55 $(OBJDIR)\api1.obj \
    56 $(OBJDIR)\api2.obj \
    57 $(OBJDIR)\apiext.obj \
     60$(OBJDIR)\glapi.obj \
     61$(OBJDIR)\glapinoop.obj \
    5862$(OBJDIR)\attrib.obj \
    5963$(OBJDIR)\bbox.obj \
     
    7680$(OBJDIR)\fog.obj \
    7781$(OBJDIR)\get.obj \
    78 $(OBJDIR)\glmisc.obj \
    7982$(OBJDIR)\hash.obj \
    8083$(OBJDIR)\image.obj \
     
    8588$(OBJDIR)\matrix.obj \
    8689$(OBJDIR)\mmath.obj \
    87 $(OBJDIR)\mthreads.obj \
     90$(OBJDIR)\glthread.obj \
     91$(OBJDIR)\os2thread.obj \
    8892$(OBJDIR)\pb.obj \
    8993$(OBJDIR)\pipeline.obj \
    9094$(OBJDIR)\pixel.obj \
    91 $(OBJDIR)\pointers.obj \
    9295$(OBJDIR)\points.obj \
    9396$(OBJDIR)\polygon.obj \
     
    107110$(OBJDIR)\translate.obj \
    108111$(OBJDIR)\triangle.obj \
     112$(OBJDIR)\aatriangle.obj \
    109113$(OBJDIR)\varray.obj \
    110114$(OBJDIR)\vb.obj \
     
    119123$(OBJDIR)\xform.obj \
    120124$(OBJDIR)\zoom.obj \
    121 $(OBJDIR)\osmesa.obj
     125$(OBJDIR)\osmesa.obj \
     126$(OBJDIR)\dispatch.obj \
     127$(OBJDIR)\imaging.obj \
     128$(OBJDIR)\state.obj \
     129$(OBJDIR)\hint.obj \
     130$(OBJDIR)\buffers.obj \
     131$(OBJDIR)\x86.obj \
     132$(OBJDIR)\x86a.obj \
     133$(OBJDIR)\common_x86.obj \
     134$(OBJDIR)\mmx_blend.obj \
     135$(OBJDIR)\vertex.obj
    122136
    123137
Note: See TracChangeset for help on using the changeset viewer.