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

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/opengl/mesa/3dfx/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;
Note: See TracChangeset for help on using the changeset viewer.