diff options
author | Brian Paul <[email protected]> | 1999-12-10 19:13:42 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 1999-12-10 19:13:42 +0000 |
commit | 147864793248ac106f3cd06d337eddf6be102be3 (patch) | |
tree | a8f5655aa6b0781a90becd6da49feaf6126fa1b7 | |
parent | 4c7fd2cfce9b5cd067837ac09309ea9eec9a96eb (diff) |
new depth buffer functions
-rw-r--r-- | src/mesa/drivers/glide/fxdd.c | 9 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxddspan.c | 485 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxdrv.h | 23 |
3 files changed, 64 insertions, 453 deletions
diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c index 0668195797b..af73a4d35d3 100644 --- a/src/mesa/drivers/glide/fxdd.c +++ b/src/mesa/drivers/glide/fxdd.c @@ -811,11 +811,10 @@ void fxSetupDDPointers(GLcontext *ctx) ctx->Driver.UpdateState=fxDDUpdateDDPointers; - ctx->Driver.AllocDepthBuffer=fxAllocDepthBuffer; - ctx->Driver.DepthTestSpan=fxDDDepthTestSpanGeneric; - ctx->Driver.DepthTestPixels=fxDDDepthTestPixelsGeneric; - ctx->Driver.ReadDepthSpanFloat=fxDDReadDepthSpanFloat; - ctx->Driver.ReadDepthSpanInt=fxDDReadDepthSpanInt; + ctx->Driver.WriteDepthSpan=fxDDWriteDepthSpan; + ctx->Driver.WriteDepthPixels=fxDDWriteDepthPixels; + ctx->Driver.ReadDepthSpan=fxDDReadDepthSpan; + ctx->Driver.ReadDepthPixels=fxDDReadDepthPixels; ctx->Driver.GetString=fxDDGetString; diff --git a/src/mesa/drivers/glide/fxddspan.c b/src/mesa/drivers/glide/fxddspan.c index 3dfc82b7044..b792caa0610 100644 --- a/src/mesa/drivers/glide/fxddspan.c +++ b/src/mesa/drivers/glide/fxddspan.c @@ -122,11 +122,6 @@ void LFB_WRITE_SPAN_MESA(GrBuffer_t dst_buffer, #if defined(FX_GLIDE3) && defined(XF86DRI) -static FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer, - FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format, - FxU32 src_width, FxU32 src_height, FxI32 src_stride, - void *src_data); - FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer, FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format, FxU32 src_width, FxU32 src_height, FxI32 src_stride, @@ -388,7 +383,7 @@ static void fxDDReadRGBAPixels(const GLcontext *ctx, { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint i; - GLint bottom=fxMesa->height+fxMesa->y_offset-1; + GLint bottom=fxMesa->y_delta-1; if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDReadRGBAPixels(...)\n"); @@ -411,30 +406,37 @@ static void fxDDReadRGBAPixels(const GLcontext *ctx, /***** Depth functions *****/ /************************************************************************/ -void fxDDReadDepthSpanFloat(GLcontext *ctx, - GLuint n, GLint x, GLint y, GLfloat depth[]) +void fxDDWriteDepthSpan(GLcontext *ctx, + GLuint n, GLint x, GLint y, const GLdepth depth[], + const GLubyte mask[]) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - GLuint i; GLint bottom=fxMesa->height+fxMesa->y_offset-1; - GLushort data[MAX_WIDTH]; if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDReadDepthSpanFloat(...)\n"); + fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n"); } - x+=fxMesa->x_offset; - FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,data); + x += fxMesa->x_offset; - /* - convert the read values to float values [0.0 .. 1.0]. - */ - for(i=0;i<n;i++) - depth[i]=data[i]/65535.0f; + if (mask) { + GLint i; + for (i = 0; i < n; i++) { + if (mask[i]) { + writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x + i, bottom-y, + GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &depth[i]); + } + } + } + else { + writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x, bottom-y, + GR_LFB_SRC_FMT_ZA16, n, 1, 0, (void *) depth); + } } -void fxDDReadDepthSpanInt(GLcontext *ctx, - GLuint n, GLint x, GLint y, GLdepth depth[]) + +void fxDDReadDepthSpan(GLcontext *ctx, + GLuint n, GLint x, GLint y, GLdepth depth[]) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLint bottom=fxMesa->height+fxMesa->y_offset-1; @@ -447,440 +449,53 @@ void fxDDReadDepthSpanInt(GLcontext *ctx, FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depth); } -GLuint fxDDDepthTestSpanGeneric(GLcontext *ctx, - GLuint n, GLint x, GLint y, const GLdepth z[], - GLubyte mask[]) + + +void fxDDWriteDepthPixels(GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLdepth depth[], const GLubyte mask[]) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - GLushort depthdata[MAX_WIDTH]; - GLdepth *zptr=depthdata; - GLubyte *m=mask; - GLuint i; - GLuint passed=0; GLint bottom=fxMesa->height+fxMesa->y_offset-1; + GLuint i; if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDDepthTestSpanGeneric(...)\n"); + fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n"); } - x+=fxMesa->x_offset; - FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depthdata); - - /* switch cases ordered from most frequent to less frequent */ - switch (ctx->Depth.Func) { - case GL_LESS: - if (ctx->Depth.Mask) { - /* Update Z buffer */ - for (i=0; i<n; i++,zptr++,m++) { - if (*m) { - if (z[i] < *zptr) { - /* pass */ - *zptr = z[i]; - passed++; - } else { - /* fail */ - *m = 0; - } - } - } - } else { - /* Don't update Z buffer */ - for (i=0; i<n; i++,zptr++,m++) { - if (*m) { - if (z[i] < *zptr) { - /* pass */ - passed++; - } else { - *m = 0; - } - } - } + for (i = 0; i < n; i++) { + if (mask[i]) { + int xpos = x[i] + fxMesa->x_offset; + int ypos = bottom - y[i]; + writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, xpos, ypos, + GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &depth[i]); } - break; - case GL_LEQUAL: - if (ctx->Depth.Mask) { - /* Update Z buffer */ - for (i=0;i<n;i++,zptr++,m++) { - if (*m) { - if (z[i] <= *zptr) { - *zptr = z[i]; - passed++; - } else { - *m = 0; - } - } - } - } else { - /* Don't update Z buffer */ - for (i=0;i<n;i++,zptr++,m++) { - if (*m) { - if (z[i] <= *zptr) { - /* pass */ - passed++; - } else { - *m = 0; - } - } - } - } - break; - case GL_GEQUAL: - if (ctx->Depth.Mask) { - /* Update Z buffer */ - for (i=0;i<n;i++,zptr++,m++) { - if (*m) { - if (z[i] >= *zptr) { - *zptr = z[i]; - passed++; - } else { - *m = 0; - } - } - } - } else { - /* Don't update Z buffer */ - for (i=0;i<n;i++,zptr++,m++) { - if (*m) { - if (z[i] >= *zptr) { - /* pass */ - passed++; - } else { - *m = 0; - } - } - } - } - break; - case GL_GREATER: - if (ctx->Depth.Mask) { - /* Update Z buffer */ - for (i=0;i<n;i++,zptr++,m++) { - if (*m) { - if (z[i] > *zptr) { - *zptr = z[i]; - passed++; - } else { - *m = 0; - } - } - } - } else { - /* Don't update Z buffer */ - for (i=0;i<n;i++,zptr++,m++) { - if (*m) { - if (z[i] > *zptr) { - /* pass */ - passed++; - } else { - *m = 0; - } - } - } - } - break; - case GL_NOTEQUAL: - if (ctx->Depth.Mask) { - /* Update Z buffer */ - for (i=0;i<n;i++,zptr++,m++) { - if (*m) { - if (z[i] != *zptr) { - *zptr = z[i]; - passed++; - } else { - *m = 0; - } - } - } - } else { - /* Don't update Z buffer */ - for (i=0;i<n;i++,zptr++,m++) { - if (*m) { - if (z[i] != *zptr) { - /* pass */ - passed++; - } else { - *m = 0; - } - } - } - } - break; - case GL_EQUAL: - if (ctx->Depth.Mask) { - /* Update Z buffer */ - for (i=0;i<n;i++,zptr++,m++) { - if (*m) { - if (z[i] == *zptr) { - *zptr = z[i]; - passed++; - } else { - *m =0; - } - } - } - } else { - /* Don't update Z buffer */ - for (i=0;i<n;i++,zptr++,m++) { - if (*m) { - if (z[i] == *zptr) { - /* pass */ - passed++; - } else { - *m =0; - } - } - } - } - break; - case GL_ALWAYS: - if (ctx->Depth.Mask) { - /* Update Z buffer */ - for (i=0;i<n;i++,zptr++,m++) { - if (*m) { - *zptr = z[i]; - passed++; - } - } - } else { - /* Don't update Z buffer or mask */ - passed = n; - } - break; - case GL_NEVER: - for (i=0;i<n;i++) { - mask[i] = 0; - } - break; - default: - ; - } /*switch*/ - - if(passed) - writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x,bottom-y,GR_LFB_SRC_FMT_ZA16,n,1,0,depthdata); - - return passed; + } } -void fxDDDepthTestPixelsGeneric(GLcontext* ctx, - GLuint n, const GLint x[], const GLint y[], - const GLdepth z[], GLubyte mask[]) + +void fxDDReadDepthPixels(GLcontext *ctx, GLuint n, + const GLint x[], const GLint y[], GLdepth depth[]) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - GLdepth zval; - GLuint i; GLint bottom=fxMesa->height+fxMesa->y_offset-1; + GLuint i; if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDDepthTestPixelsGeneric(...)\n"); + fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n"); } - /* switch cases ordered from most frequent to less frequent */ - switch (ctx->Depth.Func) { - case GL_LESS: - if (ctx->Depth.Mask) { - /* Update Z buffer */ - for (i=0; i<n; i++) { - if (mask[i]) { - FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval); - if (z[i] < zval) { - /* pass */ - writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); - } else { - /* fail */ - mask[i] = 0; - } - } - } - } else { - /* Don't update Z buffer */ - for (i=0; i<n; i++) { - if (mask[i]) { - FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval); - if (z[i] < zval) { - /* pass */ - } - else { - /* fail */ - mask[i] = 0; - } - } - } - } - break; - case GL_LEQUAL: - if (ctx->Depth.Mask) { - /* Update Z buffer */ - for (i=0; i<n; i++) { - if (mask[i]) { - FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval); - if (z[i] <= zval) { - /* pass */ - writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); - } else { - /* fail */ - mask[i] = 0; - } - } - } - } else { - /* Don't update Z buffer */ - for (i=0; i<n; i++) { - if (mask[i]) { - FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval); - if (z[i] <= zval) { - /* pass */ - } else { - /* fail */ - mask[i] = 0; - } - } - } - } - break; - case GL_GEQUAL: - if (ctx->Depth.Mask) { - /* Update Z buffer */ - for (i=0; i<n; i++) { - if (mask[i]) { - FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval); - if (z[i] >= zval) { - /* pass */ - writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); - } else { - /* fail */ - mask[i] = 0; - } - } - } - } else { - /* Don't update Z buffer */ - for (i=0; i<n; i++) { - if (mask[i]) { - FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval); - if (z[i] >= zval) { - /* pass */ - } else { - /* fail */ - mask[i] = 0; - } - } - } - } - break; - case GL_GREATER: - if (ctx->Depth.Mask) { - /* Update Z buffer */ - for (i=0; i<n; i++) { - if (mask[i]) { - FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval); - if (z[i] > zval) { - /* pass */ - writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); - } else { - /* fail */ - mask[i] = 0; - } - } - } - } else { - /* Don't update Z buffer */ - for (i=0; i<n; i++) { - if (mask[i]) { - FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval); - if (z[i] > zval) { - /* pass */ - } else { - /* fail */ - mask[i] = 0; - } - } - } - } - break; - case GL_NOTEQUAL: - if (ctx->Depth.Mask) { - /* Update Z buffer */ - for (i=0; i<n; i++) { - if (mask[i]) { - FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval); - if (z[i] != zval) { - /* pass */ - writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); - } else { - /* fail */ - mask[i] = 0; - } - } - } - } else { - /* Don't update Z buffer */ - for (i=0; i<n; i++) { - if (mask[i]) { - FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval); - if (z[i] != zval) { - /* pass */ - } - else { - /* fail */ - mask[i] = 0; - } - } - } - } - break; - case GL_EQUAL: - if (ctx->Depth.Mask) { - /* Update Z buffer */ - for (i=0; i<n; i++) { - if (mask[i]) { - FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval); - if (z[i] == zval) { - /* pass */ - writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); - } else { - /* fail */ - mask[i] = 0; - } - } - } - } else { - /* Don't update Z buffer */ - for (i=0; i<n; i++) { - if (mask[i]) { - FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval); - if (z[i] == zval) { - /* pass */ - } else { - /* fail */ - mask[i] = 0; - } - } - } - } - break; - case GL_ALWAYS: - if (ctx->Depth.Mask) { - /* Update Z buffer */ - for (i=0; i<n; i++) { - if (mask[i]) { - writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); - } - } - } else { - /* Don't update Z buffer or mask */ - } - break; - case GL_NEVER: - /* depth test never passes */ - for (i=0;i<n;i++) { - mask[i] = 0; - } - break; - default: - ; - } /*switch*/ + + for (i = 0; i < n; i++) { + int xpos = x[i] + fxMesa->x_offset; + int ypos = bottom - y[i]; + FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,xpos,ypos,1,1,0,&depth[i]); + } } + + + /************************************************************************/ diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h index 57d35ff63e3..d4d3ca59137 100644 --- a/src/mesa/drivers/glide/fxdrv.h +++ b/src/mesa/drivers/glide/fxdrv.h @@ -636,22 +636,19 @@ extern GLboolean fxDDColorMask(GLcontext *ctx, GLboolean r, GLboolean g, GLboolean b, GLboolean a ); -extern GLuint fxDDDepthTestSpanGeneric(GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLdepth z[], - GLubyte mask[]); +extern void fxDDWriteDepthSpan(GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLdepth depth[], const GLubyte mask[]); -extern void fxDDDepthTestPixelsGeneric(GLcontext* ctx, - GLuint n, - const GLint x[], const GLint y[], - const GLdepth z[], GLubyte mask[]); +extern void fxDDReadDepthSpan(GLcontext *ctx, GLuint n, GLint x, GLint y, + GLdepth depth[]); -extern void fxDDReadDepthSpanFloat(GLcontext *ctx, - GLuint n, GLint x, GLint y, GLfloat depth[]); - -extern void fxDDReadDepthSpanInt(GLcontext *ctx, - GLuint n, GLint x, GLint y, GLdepth depth[]); +extern void fxDDWriteDepthPixels(GLcontext *ctx, GLuint n, + const GLint x[], const GLint y[], + const GLdepth depth[], const GLubyte mask[]); +extern void fxDDReadDepthPixels(GLcontext *ctx, GLuint n, + const GLint x[], const GLint y[], + GLdepth depth[]); extern void fxDDFastPath( struct vertex_buffer *VB ); |