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/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/************************************************************************/
Note: See TracChangeset for help on using the changeset viewer.