diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2000-03-03 17:47:39 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2000-03-03 17:47:39 +0000 |
commit | ed30dfa1264ec8875a3162c3c8778bc703bf11d5 (patch) | |
tree | 41e44fc1f73964396c96dea1452f235b42ff46ec /src/mesa/main | |
parent | 8df3d8ae6c48cbbe649e8cfeebd8a99f983784f7 (diff) |
runtime selectable depth buffer depth
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/config.h | 26 | ||||
-rw-r--r-- | src/mesa/main/context.c | 56 | ||||
-rw-r--r-- | src/mesa/main/dd.h | 4 | ||||
-rw-r--r-- | src/mesa/main/depth.c | 722 | ||||
-rw-r--r-- | src/mesa/main/depth.h | 12 | ||||
-rw-r--r-- | src/mesa/main/dlist.c | 5 | ||||
-rw-r--r-- | src/mesa/main/drawpix.c | 36 | ||||
-rw-r--r-- | src/mesa/main/feedback.c | 25 | ||||
-rw-r--r-- | src/mesa/main/image.c | 5 | ||||
-rw-r--r-- | src/mesa/main/matrix.c | 10 | ||||
-rw-r--r-- | src/mesa/main/polygon.c | 6 | ||||
-rw-r--r-- | src/mesa/main/rastpos.c | 6 |
12 files changed, 743 insertions, 170 deletions
diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index 8c4af7615a..af11356f36 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -1,4 +1,4 @@ -/* $Id: config.h,v 1.6 2000/02/21 14:46:28 brianp Exp $ */ +/* $Id: config.h,v 1.7 2000/03/03 17:47:39 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -126,26 +126,12 @@ /* - * Bits per depth buffer value: 16 or 32 + * Bits per depth buffer value: 16 or 32 (GLushort or GLuint) + * gl_create_visual() can select any depth in [0, 32]. */ -#ifdef MESAD3D - /* Mesa / Direct3D driver only */ - extern float g_DepthScale, g_MaxDepth; -# define DEPTH_BITS 32 -# define DEPTH_SCALE g_DepthScale -# define MAX_DEPTH g_MaxDepth -#else -# define DEPTH_BITS 16 -# if DEPTH_BITS==16 -# define MAX_DEPTH 0xffff -# define DEPTH_SCALE 65535.0F -# elif DEPTH_BITS==32 -# define MAX_DEPTH 0x3fffffff -# define DEPTH_SCALE ((GLfloat) MAX_DEPTH) -# else -# error "illegal number of depth bits" -# endif -#endif +#define DEFAULT_SOFTWARE_DEPTH_BITS 16 +#define DEFAULT_SOFTWARE_DEPTH_TYPE GLushort + /* diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 2fa8848dcf..eb3b7a8121 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1,4 +1,4 @@ -/* $Id: context.c,v 1.43 2000/02/12 17:26:15 brianp Exp $ */ +/* $Id: context.c,v 1.44 2000/03/03 17:47:39 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -255,12 +255,15 @@ static void print_timings( GLcontext *ctx ) * alphaFlag - alloc software alpha buffers? * dbFlag - double buffering? * stereoFlag - stereo buffer? - * depthFits - requested minimum bits per depth buffer value - * stencilFits - requested minimum bits per stencil buffer value - * accumFits - requested minimum bits per accum buffer component - * indexFits - number of bits per pixel if rgbFlag==GL_FALSE - * red/green/blue/alphaFits - number of bits per color component - * in frame buffer for RGB(A) mode. + * depthBits - requested bits per depth buffer value + * Any value in [0, 32] is acceptable but the actual + * depth type will be GLushort or GLuint as needed. + * stencilBits - requested minimum bits per stencil buffer value + * accumBits - requested minimum bits per accum buffer component + * indexBits - number of bits per pixel if rgbFlag==GL_FALSE + * red/green/blue/alphaBits - number of bits per color component + * in frame buffer for RGB(A) mode. + * We always use 8 in core Mesa though. * Return: pointer to new GLvisual or NULL if requested parameters can't * be met. */ @@ -279,16 +282,19 @@ GLvisual *gl_create_visual( GLboolean rgbFlag, { GLvisual *vis; - if (depthBits > (GLint) (8*sizeof(GLdepth))) { - /* can't meet depth buffer requirements */ + /* This is to catch bad values from device drivers not updated for + * Mesa 3.3. Some device drivers just passed 1. That's a REALLY + * bad value now (a 1-bit depth buffer!?!). + */ + assert(depthBits == 0 || depthBits > 1); + + if (depthBits < 0 || depthBits > 32) { return NULL; } - if (stencilBits > (GLint) (8*sizeof(GLstencil))) { - /* can't meet stencil buffer requirements */ + if (stencilBits < 0 || stencilBits > (GLint) (8 * sizeof(GLstencil))) { return NULL; } - if (accumBits > (GLint) (8*sizeof(GLaccum))) { - /* can't meet accum buffer requirements */ + if (accumBits < 0 || accumBits > (GLint) (8 * sizeof(GLaccum))) { return NULL; } @@ -303,15 +309,27 @@ GLvisual *gl_create_visual( GLboolean rgbFlag, vis->RedBits = redBits; vis->GreenBits = greenBits; vis->BlueBits = blueBits; - vis->AlphaBits = alphaFlag ? 8*sizeof(GLubyte) : alphaBits; + vis->AlphaBits = alphaFlag ? (8 * sizeof(GLubyte)) : alphaBits; vis->IndexBits = indexBits; - vis->DepthBits = (depthBits>0) ? 8*sizeof(GLdepth) : 0; - vis->AccumBits = (accumBits>0) ? 8*sizeof(GLaccum) : 0; - vis->StencilBits = (stencilBits>0) ? 8*sizeof(GLstencil) : 0; + vis->DepthBits = depthBits; + vis->AccumBits = (accumBits > 0) ? (8 * sizeof(GLaccum)) : 0; + vis->StencilBits = (stencilBits > 0) ? (8 * sizeof(GLstencil)) : 0; vis->SoftwareAlpha = alphaFlag; + if (depthBits == 0) { + /* Special case. Even if we don't have a depth buffer we need + * good values for DepthMax for Z vertex transformation purposes. + */ + vis->DepthMax = 1; + vis->DepthMaxF = 1.0F; + } + else { + vis->DepthMax = (1 << depthBits) - 1; + vis->DepthMaxF = (GLfloat) vis->DepthMax; + } + return vis; } @@ -1101,8 +1119,8 @@ static void init_attrib_groups( GLcontext *ctx ) #define Sz 10 #define Tz 14 - ctx->Viewport.WindowMap.m[Sz] = 0.5 * DEPTH_SCALE; - ctx->Viewport.WindowMap.m[Tz] = 0.5 * DEPTH_SCALE; + ctx->Viewport.WindowMap.m[Sz] = 0.5 * ctx->Visual->DepthMaxF; + ctx->Viewport.WindowMap.m[Tz] = 0.5 * ctx->Visual->DepthMaxF; #undef Sz #undef Tz diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 9a10fd0d4b..d2b985f384 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -1,4 +1,4 @@ -/* $Id: dd.h,v 1.13 2000/03/03 15:38:57 brianp Exp $ */ +/* $Id: dd.h,v 1.14 2000/03/03 17:54:56 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -391,6 +391,8 @@ struct dd_function_table { /*** *** For supporting hardware Z buffers: *** Either ALL or NONE of these functions must be implemented! + *** NOTE that Each depth value is a 32-bit GLuint. If the depth + *** buffer is less than 32 bits deep then the extra upperbits are zero. ***/ void (*WriteDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y, diff --git a/src/mesa/main/depth.c b/src/mesa/main/depth.c index 3d8b1a190b..ba7f6248ab 100644 --- a/src/mesa/main/depth.c +++ b/src/mesa/main/depth.c @@ -1,10 +1,10 @@ -/* $Id: depth.c,v 1.12 2000/02/02 22:16:04 brianp Exp $ */ +/* $Id: depth.c,v 1.13 2000/03/03 17:47:39 brianp Exp $ */ /* * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -125,6 +125,33 @@ _mesa_DepthMask( GLboolean flag ) /**********************************************************************/ +/***** Misc *****/ +/**********************************************************************/ + +/* + * Return address of depth buffer value for given window coord. + */ +GLvoid * +_mesa_zbuffer_address(GLcontext *ctx, GLint x, GLint y) +{ + if (ctx->Visual->DepthBits <= 16) + return (GLushort *) ctx->DrawBuffer->DepthBuffer + ctx->DrawBuffer->Width * y + x; + else + return (GLuint *) ctx->DrawBuffer->DepthBuffer + ctx->DrawBuffer->Width * y + x; +} + + +#define Z_ADDRESS16( CTX, X, Y ) \ + ( ((GLushort *) (CTX)->DrawBuffer->DepthBuffer) \ + + (CTX)->DrawBuffer->Width * (Y) + (X) ) + +#define Z_ADDRESS32( CTX, X, Y ) \ + ( ((GLuint *) (CTX)->DrawBuffer->DepthBuffer) \ + + (CTX)->DrawBuffer->Width * (Y) + (X) ) + + + +/**********************************************************************/ /***** Depth Testing Functions *****/ /**********************************************************************/ @@ -137,8 +164,8 @@ _mesa_DepthMask( GLboolean flag ) * Return: number of fragments which pass the test. */ static GLuint -depth_test_span( GLcontext *ctx, GLuint n, GLint x, GLint y, - GLdepth zbuffer[], const GLdepth z[], GLubyte mask[] ) +depth_test_span16( GLcontext *ctx, GLuint n, GLint x, GLint y, + GLushort zbuffer[], const GLdepth z[], GLubyte mask[] ) { GLuint passed = 0; @@ -358,7 +385,236 @@ depth_test_span( GLcontext *ctx, GLuint n, GLint x, GLint y, MEMSET(mask, 0, n * sizeof(GLubyte)); break; default: - gl_problem(ctx, "Bad depth func in depth_test_span"); + gl_problem(ctx, "Bad depth func in depth_test_span16"); + } + + return passed; +} + + +static GLuint +depth_test_span32( GLcontext *ctx, GLuint n, GLint x, GLint y, + GLuint zbuffer[], const GLdepth z[], GLubyte mask[] ) +{ + GLuint passed = 0; + + /* switch cases ordered from most frequent to less frequent */ + switch (ctx->Depth.Func) { + case GL_LESS: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + GLuint i; + for (i=0; i<n; i++) { + if (mask[i]) { + if (z[i] < zbuffer[i]) { + /* pass */ + zbuffer[i] = z[i]; + passed++; + } + else { + /* fail */ + mask[i] = 0; + } + } + } + } + else { + /* Don't update Z buffer */ + GLuint i; + for (i=0; i<n; i++) { + if (mask[i]) { + if (z[i] < zbuffer[i]) { + /* pass */ + passed++; + } + else { + mask[i] = 0; + } + } + } + } + break; + case GL_LEQUAL: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + GLuint i; + for (i=0;i<n;i++) { + if (mask[i]) { + if (z[i] <= zbuffer[i]) { + zbuffer[i] = z[i]; + passed++; + } + else { + mask[i] = 0; + } + } + } + } + else { + /* Don't update Z buffer */ + GLuint i; + for (i=0;i<n;i++) { + if (mask[i]) { + if (z[i] <= zbuffer[i]) { + /* pass */ + passed++; + } + else { + mask[i] = 0; + } + } + } + } + break; + case GL_GEQUAL: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + GLuint i; + for (i=0;i<n;i++) { + if (mask[i]) { + if (z[i] >= zbuffer[i]) { + zbuffer[i] = z[i]; + passed++; + } + else { + mask[i] = 0; + } + } + } + } + else { + /* Don't update Z buffer */ + GLuint i; + for (i=0;i<n;i++) { + if (mask[i]) { + if (z[i] >= zbuffer[i]) { + /* pass */ + passed++; + } + else { + mask[i] = 0; + } + } + } + } + break; + case GL_GREATER: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + GLuint i; + for (i=0;i<n;i++) { + if (mask[i]) { + if (z[i] > zbuffer[i]) { + zbuffer[i] = z[i]; + passed++; + } + else { + mask[i] = 0; + } + } + } + } + else { + /* Don't update Z buffer */ + GLuint i; + for (i=0;i<n;i++) { + if (mask[i]) { + if (z[i] > zbuffer[i]) { + /* pass */ + passed++; + } + else { + mask[i] = 0; + } + } + } + } + break; + case GL_NOTEQUAL: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + GLuint i; + for (i=0;i<n;i++) { + if (mask[i]) { + if (z[i] != zbuffer[i]) { + zbuffer[i] = z[i]; + passed++; + } + else { + mask[i] = 0; + } + } + } + } + else { + /* Don't update Z buffer */ + GLuint i; + for (i=0;i<n;i++) { + if (mask[i]) { + if (z[i] != zbuffer[i]) { + /* pass */ + passed++; + } + else { + mask[i] = 0; + } + } + } + } + break; + case GL_EQUAL: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + GLuint i; + for (i=0;i<n;i++) { + if (mask[i]) { + if (z[i] == zbuffer[i]) { + zbuffer[i] = z[i]; + passed++; + } + else { + mask[i] = 0; + } + } + } + } + else { + /* Don't update Z buffer */ + GLuint i; + for (i=0;i<n;i++) { + if (mask[i]) { + if (z[i] == zbuffer[i]) { + /* pass */ + passed++; + } + else { + mask[i] = 0; + } + } + } + } + break; + case GL_ALWAYS: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + GLuint i; + for (i=0;i<n;i++) { + if (mask[i]) { + zbuffer[i] = z[i]; + passed++; + } + } + } + else { + /* Don't update Z buffer or mask */ + passed = n; + } + break; + case GL_NEVER: + MEMSET(mask, 0, n * sizeof(GLubyte)); + break; + default: + gl_problem(ctx, "Bad depth func in depth_test_span32"); } return passed; @@ -373,31 +629,277 @@ GLuint _mesa_depth_test_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], GLubyte mask[] ) { - GLdepth zbuffer[MAX_WIDTH]; - GLdepth *zptr; - GLuint passed; - if (ctx->Driver.ReadDepthSpan) { - /* read depth values out of hardware Z buffer */ + /* hardware-based depth buffer */ + GLdepth zbuffer[MAX_WIDTH]; + GLuint passed; (*ctx->Driver.ReadDepthSpan)(ctx, n, x, y, zbuffer); - zptr = zbuffer; + passed = depth_test_span32(ctx, n, x, y, zbuffer, z, mask); + assert(ctx->Driver.WriteDepthSpan); + (*ctx->Driver.WriteDepthSpan)(ctx, n, x, y, zbuffer, mask); + return passed; } else { - /* test against software depth buffer values */ - zptr = Z_ADDRESS( ctx, x, y ); + /* software depth buffer */ + if (ctx->Visual->DepthBits <= 16) { + GLushort *zptr = (GLushort *) Z_ADDRESS16(ctx, x, y); + GLuint passed = depth_test_span16(ctx, n, x, y, zptr, z, mask); + return passed; + } + else { + GLuint *zptr = (GLuint *) Z_ADDRESS32(ctx, x, y); + GLuint passed = depth_test_span32(ctx, n, x, y, zptr, z, mask); + return passed; + } } +} - passed = depth_test_span( ctx, n, x, y, zptr, z, mask ); - if (ctx->Driver.WriteDepthSpan) { - /* write updated depth values into hardware Z buffer */ - assert(zptr == zbuffer); - (*ctx->Driver.WriteDepthSpan)(ctx, n, x, y, zbuffer, mask); - } - return passed; -} +/* + * Do depth testing for an array of fragments using software Z buffer. + */ +static void +software_depth_test_pixels16( GLcontext *ctx, GLuint n, + const GLint x[], const GLint y[], + const GLdepth z[], GLubyte mask[] ) +{ + /* switch cases ordered from most frequent to less frequent */ + switch (ctx->Depth.Func) { + case GL_LESS: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + GLuint i; + for (i=0; i<n; i++) { + if (mask[i]) { + GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]); + if (z[i] < *zptr) { + /* pass */ + *zptr = z[i]; + } + else { + /* fail */ + mask[i] = 0; + } + } + } + } + else { + /* Don't update Z buffer */ + GLuint i; + for (i=0; i<n; i++) { + if (mask[i]) { + GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]); + if (z[i] < *zptr) { + /* pass */ + } + else { + /* fail */ + mask[i] = 0; + } + } + } + } + break; + case GL_LEQUAL: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + GLuint i; + for (i=0; i<n; i++) { + if (mask[i]) { + GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]); + if (z[i] <= *zptr) { + /* pass */ + *zptr = z[i]; + } + else { + /* fail */ + mask[i] = 0; + } + } + } + } + else { + /* Don't update Z buffer */ + GLuint i; + for (i=0; i<n; i++) { + if (mask[i]) { + GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]); + if (z[i] <= *zptr) { + /* pass */ + } + else { + /* fail */ + mask[i] = 0; + } + } + } + } + break; + case GL_GEQUAL: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + GLuint i; + for (i=0; i<n; i++) { + if (mask[i]) { + GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]); + if (z[i] >= *zptr) { + /* pass */ + *zptr = z[i]; + } + else { + /* fail */ + mask[i] = 0; + } + } + } + } + else { + /* Don't update Z buffer */ + GLuint i; + for (i=0; i<n; i++) { + if (mask[i]) { + GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]); + if (z[i] >= *zptr) { + /* pass */ + } + else { + /* fail */ + mask[i] = 0; + } + } + } + } + break; + case GL_GREATER: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + GLuint i; + for (i=0; i<n; i++) { + if (mask[i]) { + GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]); + if (z[i] > *zptr) { + /* pass */ + *zptr = z[i]; + } + else { + /* fail */ + mask[i] = 0; + } + } + } + } + else { + /* Don't update Z buffer */ + GLuint i; + for (i=0; i<n; i++) { + if (mask[i]) { + GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]); + if (z[i] > *zptr) { + /* pass */ + } + else { + /* fail */ + mask[i] = 0; + } + } + } + } + break; + case GL_NOTEQUAL: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + GLuint i; + for (i=0; i<n; i++) { + if (mask[i]) { + GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]); + if (z[i] != *zptr) { + /* pass */ + *zptr = z[i]; + } + else { + /* fail */ + mask[i] = 0; + } + } + } + } + else { + /* Don't update Z buffer */ + GLuint i; + for (i=0; i<n; i++) { + if (mask[i]) { + GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]); + if (z[i] != *zptr) { + /* pass */ + } + else { + /* fail */ + mask[i] = 0; + } + } + } + } + break; + case GL_EQUAL: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + GLuint i; + for (i=0; i<n; i++) { + if (mask[i]) { + GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]); + if (z[i] == *zptr) { + /* pass */ + *zptr = z[i]; + } + else { + /* fail */ + mask[i] = 0; + } + } + } + } + else { + /* Don't update Z buffer */ + GLuint i; + for (i=0; i<n; i++) { + if (mask[i]) { + GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]); + if (z[i] == *zptr) { + /* pass */ + } + else { + /* fail */ + mask[i] = 0; + } + } + } + } + break; + case GL_ALWAYS: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + GLuint i; + for (i=0; i<n; i++) { + if (mask[i]) { + GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]); + *zptr = z[i]; + } + } + } + else { + /* Don't update Z buffer or mask */ + } + break; + case GL_NEVER: + /* depth test never passes */ + MEMSET(mask, 0, n * sizeof(GLubyte)); + break; + default: + gl_problem(ctx, "Bad depth func in software_depth_test_pixels"); + } +} @@ -405,9 +907,9 @@ _mesa_depth_test_span( GLcontext *ctx, GLuint n, GLint x, GLint y, * Do depth testing for an array of fragments using software Z buffer. */ static void -software_depth_test_pixels( GLcontext *ctx, GLuint n, - const GLint x[], const GLint y[], - const GLdepth z[], GLubyte mask[] ) +software_depth_test_pixels32( GLcontext *ctx, GLuint n, + const GLint x[], const GLint y[], + const GLdepth z[], GLubyte mask[] ) { /* switch cases ordered from most frequent to less frequent */ switch (ctx->Depth.Func) { @@ -417,7 +919,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n, GLuint i; for (i=0; i<n; i++) { if (mask[i]) { - GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]); + GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]); if (z[i] < *zptr) { /* pass */ *zptr = z[i]; @@ -434,7 +936,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n, GLuint i; for (i=0; i<n; i++) { if (mask[i]) { - GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]); + GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]); if (z[i] < *zptr) { /* pass */ } @@ -452,7 +954,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n, GLuint i; for (i=0; i<n; i++) { if (mask[i]) { - GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]); + GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]); if (z[i] <= *zptr) { /* pass */ *zptr = z[i]; @@ -469,7 +971,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n, GLuint i; for (i=0; i<n; i++) { if (mask[i]) { - GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]); + GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]); if (z[i] <= *zptr) { /* pass */ } @@ -487,7 +989,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n, GLuint i; for (i=0; i<n; i++) { if (mask[i]) { - GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]); + GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]); if (z[i] >= *zptr) { /* pass */ *zptr = z[i]; @@ -504,7 +1006,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n, GLuint i; for (i=0; i<n; i++) { if (mask[i]) { - GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]); + GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]); if (z[i] >= *zptr) { /* pass */ } @@ -522,7 +1024,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n, GLuint i; for (i=0; i<n; i++) { if (mask[i]) { - GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]); + GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]); if (z[i] > *zptr) { /* pass */ *zptr = z[i]; @@ -539,7 +1041,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n, GLuint i; for (i=0; i<n; i++) { if (mask[i]) { - GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]); + GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]); if (z[i] > *zptr) { /* pass */ } @@ -557,7 +1059,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n, GLuint i; for (i=0; i<n; i++) { if (mask[i]) { - GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]); + GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]); if (z[i] != *zptr) { /* pass */ *zptr = z[i]; @@ -574,7 +1076,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n, GLuint i; for (i=0; i<n; i++) { if (mask[i]) { - GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]); + GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]); if (z[i] != *zptr) { /* pass */ } @@ -592,7 +1094,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n, GLuint i; for (i=0; i<n; i++) { if (mask[i]) { - GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]); + GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]); if (z[i] == *zptr) { /* pass */ *zptr = z[i]; @@ -609,7 +1111,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n, GLuint i; for (i=0; i<n; i++) { if (mask[i]) { - GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]); + GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]); if (z[i] == *zptr) { /* pass */ } @@ -627,7 +1129,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n, GLuint i; for (i=0; i<n; i++) { if (mask[i]) { - GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]); + GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]); *zptr = z[i]; } } @@ -895,11 +1397,14 @@ _mesa_depth_test_pixels( GLcontext *ctx, /* update hardware Z buffer with new values */ assert(ctx->Driver.WriteDepthPixels); - (*ctx->Driver.WriteDepthPixels)(ctx, n, x, y, z, mask ); + (*ctx->Driver.WriteDepthPixels)(ctx, n, x, y, zbuffer, mask ); } else { /* software depth testing */ - software_depth_test_pixels(ctx, n, x, y, z, mask); + if (ctx->Visual->DepthBits <= 16) + software_depth_test_pixels16(ctx, n, x, y, z, mask); + else + software_depth_test_pixels32(ctx, n, x, y, z, mask); } } @@ -923,14 +1428,23 @@ void _mesa_read_depth_span_float( GLcontext* ctx, GLuint n, GLint x, GLint y, GLfloat depth[] ) { - const GLfloat scale = 1.0F / DEPTH_SCALE; + const GLfloat scale = 1.0F / ctx->Visual->DepthMaxF; - if (ctx->DrawBuffer->Depth) { + if (ctx->DrawBuffer->DepthBuffer) { /* read from software depth buffer */ - const GLdepth *zptr = Z_ADDRESS( ctx, x, y ); - GLuint i; - for (i = 0; i < n; i++) { - depth[i] = (GLfloat) zptr[i] * scale; + if (ctx->Visual->DepthBits <= 16) { + const GLushort *zptr = Z_ADDRESS16( ctx, x, y ); + GLuint i; + for (i = 0; i < n; i++) { + depth[i] = (GLfloat) zptr[i] * scale; + } + } + else { + const GLuint *zptr = Z_ADDRESS32( ctx, x, y ); + GLuint i; + for (i = 0; i < n; i++) { + depth[i] = (GLfloat) zptr[i] * scale; + } } } else if (ctx->Driver.ReadDepthSpan) { @@ -963,19 +1477,29 @@ _mesa_read_depth_span_float( GLcontext* ctx, * This function is only called through Driver.alloc_depth_buffer. */ void -_mesa_alloc_depth_buffer( GLcontext* ctx ) +_mesa_alloc_depth_buffer( GLcontext *ctx ) { /* deallocate current depth buffer if present */ if (ctx->DrawBuffer->UseSoftwareDepthBuffer) { + GLint bytesPerValue; + if (ctx->DrawBuffer->Depth) { FREE(ctx->DrawBuffer->Depth); + ctx->DrawBuffer->DepthBuffer = NULL; ctx->DrawBuffer->Depth = NULL; } /* allocate new depth buffer, but don't initialize it */ - ctx->DrawBuffer->Depth = (GLdepth *) MALLOC( ctx->DrawBuffer->Width - * ctx->DrawBuffer->Height - * sizeof(GLdepth) ); + if (ctx->Visual->DepthBits <= 16) + bytesPerValue = sizeof(GLushort); + else + bytesPerValue = sizeof(GLuint); + + ctx->DrawBuffer->DepthBuffer = MALLOC( ctx->DrawBuffer->Width + * ctx->DrawBuffer->Height + * bytesPerValue ); + ctx->DrawBuffer->Depth = (GLdepth *) ctx->DrawBuffer->DepthBuffer; + if (!ctx->DrawBuffer->Depth) { /* out of memory */ ctx->Depth.Test = GL_FALSE; @@ -994,11 +1518,11 @@ _mesa_alloc_depth_buffer( GLcontext* ctx ) * This function is only called through Driver.clear_depth_buffer. */ void -_mesa_clear_depth_buffer( GLcontext* ctx ) +_mesa_clear_depth_buffer( GLcontext *ctx ) { - GLdepth clear_value = (GLdepth) (ctx->Depth.Clear * DEPTH_SCALE); - - if (ctx->Visual->DepthBits==0 || !ctx->DrawBuffer->Depth || !ctx->Depth.Mask) { + if (ctx->Visual->DepthBits == 0 + || !ctx->DrawBuffer->DepthBuffer + || !ctx->Depth.Mask) { /* no depth buffer, or writing to it is disabled */ return; } @@ -1009,40 +1533,84 @@ _mesa_clear_depth_buffer( GLcontext* ctx ) if (ctx->Scissor.Enabled) { /* only clear scissor region */ - GLint y; - for (y=ctx->DrawBuffer->Ymin; y<=ctx->DrawBuffer->Ymax; y++) { - GLdepth *d = Z_ADDRESS( ctx, ctx->DrawBuffer->Xmin, y ); - GLint n = ctx->DrawBuffer->Xmax - ctx->DrawBuffer->Xmin + 1; - do { - *d++ = clear_value; - n--; - } while (n); + if (ctx->Visual->DepthBits <= 16) { + const GLushort clearValue = (GLushort) (ctx->Depth.Clear * ctx->Visual->DepthMax); + const GLint rows = ctx->DrawBuffer->Ymax - ctx->DrawBuffer->Ymin + 1; + const GLint width = ctx->DrawBuffer->Width; + GLushort *dRow = (GLushort *) ctx->DrawBuffer->DepthBuffer + + ctx->DrawBuffer->Ymin * width + ctx->DrawBuffer->Xmin; + GLint i, j; + for (i = 0; i < rows; i++) { + for (j = 0; j < width; j++) { + dRow[j] = clearValue; + } + dRow += width; + } + } + else { + const GLuint clearValue = (GLuint) (ctx->Depth.Clear * ctx->Visual->DepthMax); + const GLint rows = ctx->DrawBuffer->Ymax - ctx->DrawBuffer->Ymin + 1; + const GLint width = ctx->DrawBuffer->Width; + GLuint *dRow = (GLuint *) ctx->DrawBuffer->DepthBuffer + + ctx->DrawBuffer->Ymin * width + ctx->DrawBuffer->Xmin; + GLint i, j; + for (i = 0; i < rows; i++) { + for (j = 0; j < width; j++) { + dRow[j] = clearValue; + } + dRow += width; + } } } else { /* clear whole buffer */ - if (sizeof(GLdepth)==2 && (clear_value&0xff)==(clear_value>>8)) { - /* lower and upper bytes of clear_value are same, use MEMSET */ - MEMSET( ctx->DrawBuffer->Depth, clear_value & 0xff, - 2*ctx->DrawBuffer->Width * ctx->DrawBuffer->Height); + if (ctx->Visual->DepthBits <= 16) { + const GLushort clearValue = (GLushort) (ctx->Depth.Clear * ctx->Visual->DepthMax); + if ((clearValue & 0xff) == (clearValue >> 8)) { + /* lower and upper bytes of clear_value are same, use MEMSET */ + MEMSET( ctx->DrawBuffer->DepthBuffer, clearValue & 0xff, + 2 * ctx->DrawBuffer->Width * ctx->DrawBuffer->Height); + } + else { + GLushort *d = ctx->DrawBuffer->DepthBuffer; + GLint n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height; + while (n >= 16) { + d[0] = clearValue; d[1] = clearValue; + d[2] = clearValue; d[3] = clearValue; + d[4] = clearValue; d[5] = clearValue; + d[6] = clearValue; d[7] = clearValue; + d[8] = clearValue; d[9] = clearValue; + d[10] = clearValue; d[11] = clearValue; + d[12] = clearValue; d[13] = clearValue; + d[14] = clearValue; d[15] = clearValue; + d += 16; + n -= 16; + } + while (n > 0) { + *d++ = clearValue; + n--; + } + } } else { - GLdepth *d = ctx->DrawBuffer->Depth; + /* >16 bit depth buffer */ + GLuint *d = (GLuint *) ctx->DrawBuffer->DepthBuffer; + const GLuint clearValue = (GLuint) (ctx->Depth.Clear * ctx->Visual->DepthMax); GLint n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height; - while (n>=16) { - d[0] = clear_value; d[1] = clear_value; - d[2] = clear_value; d[3] = clear_value; - d[4] = clear_value; d[5] = clear_value; - d[6] = clear_value; d[7] = clear_value; - d[8] = clear_value; d[9] = clear_value; - d[10] = clear_value; d[11] = clear_value; - d[12] = clear_value; d[13] = clear_value; - d[14] = clear_value; d[15] = clear_value; + while (n >= 16) { + d[0] = clearValue; d[1] = clearValue; + d[2] = clearValue; d[3] = clearValue; + d[4] = clearValue; d[5] = clearValue; + d[6] = clearValue; d[7] = clearValue; + d[8] = clearValue; d[9] = clearValue; + d[10] = clearValue; d[11] = clearValue; + d[12] = clearValue; d[13] = clearValue; + d[14] = clearValue; d[15] = clearValue; d += 16; n -= 16; } - while (n>0) { - *d++ = clear_value; + while (n > 0) { + *d++ = clearValue; n--; } } diff --git a/src/mesa/main/depth.h b/src/mesa/main/depth.h index 39064a653b..ec16ecf37d 100644 --- a/src/mesa/main/depth.h +++ b/src/mesa/main/depth.h @@ -1,10 +1,10 @@ -/* $Id: depth.h,v 1.6 2000/02/02 22:16:04 brianp Exp $ */ +/* $Id: depth.h,v 1.7 2000/03/03 17:47:39 brianp Exp $ */ /* * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -49,14 +49,12 @@ _mesa_DepthMask( GLboolean flag ); - /* - * Return the address of the Z-buffer value for window coordinate (x,y): + * Internal functions */ -#define Z_ADDRESS( CTX, X, Y ) \ - ((CTX)->DrawBuffer->Depth + (CTX)->DrawBuffer->Width * (Y) + (X)) - +extern GLvoid * +_mesa_zbuffer_address(GLcontext *ctx, GLint x, GLint y); extern GLuint diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index fc4fbbd48b..2a317c7ba7 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -1,4 +1,4 @@ -/* $Id: dlist.c,v 1.33 2000/03/03 17:45:21 brianp Exp $ */ +/* $Id: dlist.c,v 1.34 2000/03/03 17:47:39 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -2177,7 +2177,8 @@ static void save_PolygonOffset( GLfloat factor, GLfloat units ) static void save_PolygonOffsetEXT( GLfloat factor, GLfloat bias ) { - save_PolygonOffset(factor, DEPTH_SCALE * bias); + GET_CURRENT_CONTEXT(ctx); + save_PolygonOffset(factor, ctx->Visual->DepthMaxF * bias); } diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c index 56ee2d76e3..49321a9459 100644 --- a/src/mesa/main/drawpix.c +++ b/src/mesa/main/drawpix.c @@ -1,4 +1,4 @@ -/* $Id: drawpix.c,v 1.13 2000/03/03 15:39:13 brianp Exp $ */ +/* $Id: drawpix.c,v 1.14 2000/03/03 17:54:56 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -34,6 +34,7 @@ #include "feedback.h" #include "image.h" #include "macros.h" +#include "mem.h" #include "mmath.h" #include "pixel.h" #include "span.h" @@ -174,7 +175,7 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y, } else { /* setup array of fragment Z value to pass to zoom function */ - GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * DEPTH_SCALE); + GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual->DepthMaxF); GLint i; assert(drawWidth < MAX_WIDTH); for (i=0; i<drawWidth; i++) @@ -412,7 +413,7 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y, /* Fragment depth values */ if (ctx->Depth.Test || ctx->Fog.Enabled) { - GLdepth zval = (GLdepth) (ctx->Current.RasterPos[2] * DEPTH_SCALE); + GLdepth zval = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual->DepthMaxF); GLint i; for (i = 0; i < drawWidth; i++) { zspan[i] = zval; @@ -539,30 +540,23 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, /* Special case: directly write 16-bit depth values */ GLint row; for (row = 0; row < height; row++, y++) { - const GLdepth *zptr = gl_pixel_addr_in_image(&ctx->Unpack, + GLdepth zspan[MAX_WIDTH]; + const GLushort *zptr = gl_pixel_addr_in_image(&ctx->Unpack, pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0); - gl_write_rgba_span( ctx, width, x, y, zptr, rgba, GL_BITMAP ); + GLint i; + for (i = 0; i < width; i++) + zspan[i] = zptr[i]; + gl_write_rgba_span( ctx, width, x, y, zspan, rgba, GL_BITMAP ); } } - else if (type==GL_UNSIGNED_INT && sizeof(GLdepth)==sizeof(GLuint) + else if (type==GL_UNSIGNED_INT && ctx->Visual->DepthBits == 32 && !bias_or_scale && !zoom && ctx->Visual->RGBAflag) { /* Special case: directly write 32-bit depth values */ - GLint i, row; - /* Compute shift value to scale 32-bit uints down to depth values. */ - GLuint shift = 0; - GLuint max = MAX_DEPTH; - while ((max & 0x80000000) == 0) { - max = max << 1; - shift++; - } + GLint row; for (row = 0; row < height; row++, y++) { - GLdepth zspan[MAX_WIDTH]; - const GLdepth *zptr = gl_pixel_addr_in_image(&ctx->Unpack, + const GLuint *zptr = gl_pixel_addr_in_image(&ctx->Unpack, pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0); - for (i=0;i<width;i++) { - zspan[i] = zptr[i] >> shift; - } - gl_write_rgba_span( ctx, width, x, y, zspan, rgba, GL_BITMAP ); + gl_write_rgba_span( ctx, width, x, y, zptr, rgba, GL_BITMAP ); } } else { @@ -619,7 +613,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, /* Fragment depth values */ if (ctx->Depth.Test || ctx->Fog.Enabled) { /* fill in array of z values */ - GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * DEPTH_SCALE); + GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual->DepthMaxF); GLint i; for (i=0;i<width;i++) { zspan[i] = z; diff --git a/src/mesa/main/feedback.c b/src/mesa/main/feedback.c index 71c1025d90..3a38db1d62 100644 --- a/src/mesa/main/feedback.c +++ b/src/mesa/main/feedback.c @@ -1,4 +1,4 @@ -/* $Id: feedback.c,v 1.8 2000/01/25 16:49:20 brianp Exp $ */ +/* $Id: feedback.c,v 1.9 2000/03/03 17:47:39 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -133,6 +133,7 @@ void gl_feedback_vertex( GLcontext *ctx, FEEDBACK_TOKEN( ctx, win[0] ); FEEDBACK_TOKEN( ctx, win[1] ); if (ctx->Feedback.Mask & FB_3D) { + printf("FB %g\n", win[2]); FEEDBACK_TOKEN( ctx, win[2] ); } if (ctx->Feedback.Mask & FB_4D) { @@ -168,7 +169,7 @@ static void feedback_vertex( GLcontext *ctx, GLuint v, GLuint pv ) win[0] = VB->Win.data[v][0]; win[1] = VB->Win.data[v][1]; - win[2] = VB->Win.data[v][2] / DEPTH_SCALE; + win[2] = VB->Win.data[v][2] / ctx->Visual->DepthMaxF; win[3] = 1.0 / VB->Win.data[v][3]; if (ctx->Light.ShadeModel == GL_SMOOTH) @@ -299,12 +300,13 @@ void gl_update_hitflag( GLcontext *ctx, GLfloat z ) void gl_select_triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv ) { - struct vertex_buffer *VB = ctx->VB; + const struct vertex_buffer *VB = ctx->VB; if (gl_cull_triangle( ctx, v0, v1, v2, 0 )) { - gl_update_hitflag( ctx, VB->Win.data[v0][2] / DEPTH_SCALE ); - gl_update_hitflag( ctx, VB->Win.data[v1][2] / DEPTH_SCALE ); - gl_update_hitflag( ctx, VB->Win.data[v2][2] / DEPTH_SCALE ); + const GLfloat zs = 1.0F / ctx->Visual->DepthMaxF; + gl_update_hitflag( ctx, VB->Win.data[v0][2] * zs ); + gl_update_hitflag( ctx, VB->Win.data[v1][2] * zs ); + gl_update_hitflag( ctx, VB->Win.data[v2][2] * zs ); } } @@ -312,21 +314,22 @@ void gl_select_triangle( GLcontext *ctx, void gl_select_line( GLcontext *ctx, GLuint v0, GLuint v1, GLuint pv ) { - struct vertex_buffer *VB = ctx->VB; - - gl_update_hitflag( ctx, VB->Win.data[v0][2] / DEPTH_SCALE ); - gl_update_hitflag( ctx, VB->Win.data[v1][2] / DEPTH_SCALE ); + const struct vertex_buffer *VB = ctx->VB; + const GLfloat zs = 1.0F / ctx->Visual->DepthMaxF; + gl_update_hitflag( ctx, VB->Win.data[v0][2] * zs ); + gl_update_hitflag( ctx, VB->Win.data[v1][2] * zs ); } void gl_select_points( GLcontext *ctx, GLuint first, GLuint last ) { struct vertex_buffer *VB = ctx->VB; + const GLfloat zs = 1.0F / ctx->Visual->DepthMaxF; GLuint i; for (i=first;i<=last;i++) { if (VB->ClipMask[i]==0) { - gl_update_hitflag( ctx, VB->Win.data[i][2] / DEPTH_SCALE); + gl_update_hitflag( ctx, VB->Win.data[i][2] * zs ); } } } diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index e37711e499..a1a0fe20ee 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.17 2000/02/21 16:33:20 brianp Exp $ */ +/* $Id: image.c,v 1.18 2000/03/03 17:47:39 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -2644,9 +2644,10 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLdepth *dest, /* clamp depth values to [0,1] and convert from floats to integers */ { + const GLfloat zs = ctx->Visual->DepthMaxF; GLuint i; for (i = 0; i < n; i++) { - dest[i] = (GLdepth) (CLAMP(depth[i], 0.0F, 1.0F) * DEPTH_SCALE); + dest[i] = (GLdepth) (CLAMP(depth[i], 0.0F, 1.0F) * zs); } } diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c index f340b1ecd1..c8f25c0cd5 100644 --- a/src/mesa/main/matrix.c +++ b/src/mesa/main/matrix.c @@ -1,4 +1,4 @@ -/* $Id: matrix.c,v 1.15 2000/02/21 23:00:51 brianp Exp $ */ +/* $Id: matrix.c,v 1.16 2000/03/03 17:47:39 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1460,8 +1460,8 @@ gl_Viewport( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height ) ctx->Viewport.WindowMap.m[MAT_TX] = ctx->Viewport.WindowMap.m[MAT_SX] + x; ctx->Viewport.WindowMap.m[MAT_SY] = (GLfloat) height / 2.0F; ctx->Viewport.WindowMap.m[MAT_TY] = ctx->Viewport.WindowMap.m[MAT_SY] + y; - ctx->Viewport.WindowMap.m[MAT_SZ] = 0.5 * DEPTH_SCALE; - ctx->Viewport.WindowMap.m[MAT_TZ] = 0.5 * DEPTH_SCALE; + ctx->Viewport.WindowMap.m[MAT_SZ] = 0.5 * ctx->Visual->DepthMaxF; + ctx->Viewport.WindowMap.m[MAT_TZ] = 0.5 * ctx->Visual->DepthMaxF; ctx->Viewport.WindowMap.flags = MAT_FLAG_GENERAL_SCALE|MAT_FLAG_TRANSLATION; ctx->Viewport.WindowMap.type = MATRIX_3D_NO_ROT; @@ -1518,8 +1518,8 @@ _mesa_DepthRange( GLclampd nearval, GLclampd farval ) ctx->Viewport.Near = n; ctx->Viewport.Far = f; - ctx->Viewport.WindowMap.m[MAT_SZ] = DEPTH_SCALE * ((f - n) / 2.0); - ctx->Viewport.WindowMap.m[MAT_TZ] = DEPTH_SCALE * ((f - n) / 2.0 + n); + ctx->Viewport.WindowMap.m[MAT_SZ] = ctx->Visual->DepthMaxF * ((f - n) / 2.0); + ctx->Viewport.WindowMap.m[MAT_TZ] = ctx->Visual->DepthMaxF * ((f - n) / 2.0 + n); ctx->ModelProjectWinMatrixUptodate = GL_FALSE; diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c index 94a747c402..b461ac2998 100644 --- a/src/mesa/main/polygon.c +++ b/src/mesa/main/polygon.c @@ -1,4 +1,4 @@ -/* $Id: polygon.c,v 1.8 2000/02/27 20:38:15 keithw Exp $ */ +/* $Id: polygon.c,v 1.9 2000/03/03 17:47:39 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -188,6 +188,8 @@ _mesa_PolygonOffset( GLfloat factor, GLfloat units ) void _mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias ) { - _mesa_PolygonOffset(factor, bias * DEPTH_SCALE ); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPolygonOffsetEXT"); + _mesa_PolygonOffset(factor, bias * ctx->Visual->DepthMaxF ); } diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c index 9d852bd59d..722431a948 100644 --- a/src/mesa/main/rastpos.c +++ b/src/mesa/main/rastpos.c @@ -1,10 +1,10 @@ -/* $Id: rastpos.c,v 1.5 2000/02/02 19:17:57 brianp Exp $ */ +/* $Id: rastpos.c,v 1.6 2000/03/03 17:47:39 brianp Exp $ */ /* * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -132,7 +132,7 @@ static void raster_pos4f( GLcontext *ctx, ctx->Current.RasterPos[1] = (ndc[1] * ctx->Viewport.WindowMap.m[MAT_SY] + ctx->Viewport.WindowMap.m[MAT_TY]); ctx->Current.RasterPos[2] = (ndc[2] * ctx->Viewport.WindowMap.m[MAT_SZ] + - ctx->Viewport.WindowMap.m[MAT_TZ]) / DEPTH_SCALE; + ctx->Viewport.WindowMap.m[MAT_TZ]) / ctx->Visual->DepthMaxF; ctx->Current.RasterPos[3] = clip[3]; ctx->Current.RasterPosValid = GL_TRUE; |