summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/glide/fxddspan.c65
-rw-r--r--src/mesa/drivers/osmesa/osmesa.c167
-rw-r--r--src/mesa/drivers/x11/fakeglx.c29
-rw-r--r--src/mesa/main/config.h26
-rw-r--r--src/mesa/main/context.c56
-rw-r--r--src/mesa/main/dd.h4
-rw-r--r--src/mesa/main/depth.c722
-rw-r--r--src/mesa/main/depth.h12
-rw-r--r--src/mesa/main/dlist.c5
-rw-r--r--src/mesa/main/drawpix.c36
-rw-r--r--src/mesa/main/feedback.c25
-rw-r--r--src/mesa/main/image.c5
-rw-r--r--src/mesa/main/matrix.c10
-rw-r--r--src/mesa/main/polygon.c6
-rw-r--r--src/mesa/main/rastpos.c6
15 files changed, 912 insertions, 262 deletions
diff --git a/src/mesa/drivers/glide/fxddspan.c b/src/mesa/drivers/glide/fxddspan.c
index ec55134802..89abdda951 100644
--- a/src/mesa/drivers/glide/fxddspan.c
+++ b/src/mesa/drivers/glide/fxddspan.c
@@ -396,7 +396,7 @@ static void fxDDReadRGBAPixels(const GLcontext *ctx,
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLuint i;
- GLint bottom=fxMesa->y_delta-1;
+ GLint bottom=fxMesa->height+fxMesa->y_offset-1;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDReadRGBAPixels(...)\n");
@@ -423,11 +423,11 @@ void fxDDWriteDepthSpan(GLcontext *ctx,
GLuint n, GLint x, GLint y, const GLdepth depth[],
const GLubyte mask[])
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLint bottom=fxMesa->height+fxMesa->y_offset-1;
+ fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
+ GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n");
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDWriteDepthSpan(...)\n");
}
x += fxMesa->x_offset;
@@ -436,14 +436,20 @@ void fxDDWriteDepthSpan(GLcontext *ctx,
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]);
+ GLshort d = depth[i];
+ writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x + i, bottom - y,
+ GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &d);
}
}
}
else {
- writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x, bottom-y,
- GR_LFB_SRC_FMT_ZA16, n, 1, 0, (void *) depth);
+ GLushort depth16[MAX_WIDTH];
+ GLint i;
+ for (i = 0; i < n; i++) {
+ depth16[i] = depth[i];
+ }
+ writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x, bottom - y,
+ GR_LFB_SRC_FMT_ZA16, n, 1, 0, (void *) depth16);
}
}
@@ -451,15 +457,20 @@ void fxDDWriteDepthSpan(GLcontext *ctx,
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;
+ fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
+ GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
+ GLushort depth16[MAX_WIDTH];
+ GLuint i;
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n");
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDReadDepthSpan(...)\n");
}
- x+=fxMesa->x_offset;
- FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depth);
+ x += fxMesa->x_offset;
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth16);
+ for (i = 0; i < n; i++) {
+ depth[i] = depth16[i];
+ }
}
@@ -468,20 +479,21 @@ void fxDDWriteDepthPixels(GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLdepth depth[], const GLubyte mask[])
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLint bottom=fxMesa->height+fxMesa->y_offset-1;
+ fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
+ GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
GLuint i;
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n");
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDWriteDepthPixels(...)\n");
}
for (i = 0; i < n; i++) {
if (mask[i]) {
int xpos = x[i] + fxMesa->x_offset;
int ypos = bottom - y[i];
+ GLushort d = depth[i];
writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, xpos, ypos,
- GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &depth[i]);
+ GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &d);
}
}
}
@@ -490,19 +502,20 @@ void fxDDWriteDepthPixels(GLcontext *ctx,
void fxDDReadDepthPixels(GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[], GLdepth depth[])
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLint bottom=fxMesa->height+fxMesa->y_offset-1;
+ fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
+ GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
GLuint i;
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n");
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDReadDepthPixels(...)\n");
}
-
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]);
+ GLushort d;
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, xpos, ypos, 1, 1, 0, &d);
+ depth[i] = d;
}
}
diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
index a5a71bfc2d..ea015236f0 100644
--- a/src/mesa/drivers/osmesa/osmesa.c
+++ b/src/mesa/drivers/osmesa/osmesa.c
@@ -1,4 +1,4 @@
-/* $Id: osmesa.c,v 1.9 2000/01/15 06:13:26 rjfrank Exp $ */
+/* $Id: osmesa.c,v 1.10 2000/03/03 17:50:09 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -206,7 +206,7 @@ OSMesaCreateContext( GLenum format, OSMesaContext sharelist )
swalpha, /* software alpha */
GL_FALSE, /* double buffer */
GL_FALSE, /* stereo */
- DEPTH_BITS,
+ DEFAULT_SOFTWARE_DEPTH_BITS,
STENCIL_BITS,
rgbmode ? ACCUM_BITS : 0,
indexBits,
@@ -400,7 +400,6 @@ OSMesaMakeCurrent( OSMesaContext ctx, void *buffer, GLenum type,
-
OSMesaContext GLAPIENTRY OSMesaGetCurrentContext( void )
{
GLcontext *ctx = gl_get_current_context();
@@ -1220,6 +1219,7 @@ static void flat_rgba_z_line( GLcontext *ctx,
#define INTERP_XY 1
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -1272,6 +1272,7 @@ static void flat_blend_rgba_line( GLcontext *ctx,
#endif
}
+
/*
* Draw a flat-shaded, Z-less, alpha-blended, RGB line into an osmesa buffer.
*/
@@ -1292,16 +1293,16 @@ static void flat_blend_rgba_z_line( GLcontext *ctx,
#define INTERP_XY 1
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define CLIP_HACK 1
-#define PLOT(X,Y) \
- if (Z < *zPtr) { \
- { GLuint *ptr4 = PIXELADDR4(X,Y); \
- GLuint pixel = 0; \
- pixel |=((((((*ptr4) >> rshift) & 0xff)*msavalue+rvalue)>>8) << rshift);\
- pixel |=((((((*ptr4) >> gshift) & 0xff)*msavalue+gvalue)>>8) << gshift);\
- pixel |=((((((*ptr4) >> bshift) & 0xff)*msavalue+bvalue)>>8) << bshift);\
- *ptr4 = pixel; \
- } \
+#define PLOT(X,Y) \
+ if (Z < *zPtr) { \
+ GLuint *ptr4 = PIXELADDR4(X,Y); \
+ GLuint pixel = 0; \
+ pixel |=((((((*ptr4) >> rshift) & 0xff)*msavalue+rvalue)>>8) << rshift); \
+ pixel |=((((((*ptr4) >> gshift) & 0xff)*msavalue+gvalue)>>8) << gshift); \
+ pixel |=((((((*ptr4) >> bshift) & 0xff)*msavalue+bvalue)>>8) << bshift); \
+ *ptr4 = pixel; \
}
#ifdef WIN32
@@ -1311,6 +1312,7 @@ static void flat_blend_rgba_z_line( GLcontext *ctx,
#endif
}
+
/*
* Draw a flat-shaded, Z-less, alpha-blended, RGB line into an osmesa buffer.
*/
@@ -1331,17 +1333,17 @@ static void flat_blend_rgba_z_line_write( GLcontext *ctx,
#define INTERP_XY 1
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define CLIP_HACK 1
-#define PLOT(X,Y) \
- if (Z < *zPtr) { \
- { GLuint *ptr4 = PIXELADDR4(X,Y); \
- GLuint pixel = 0; \
- pixel |=((((((*ptr4) >> rshift) & 0xff)*msavalue+rvalue)>>8) << rshift);\
- pixel |=((((((*ptr4) >> gshift) & 0xff)*msavalue+gvalue)>>8) << gshift);\
- pixel |=((((((*ptr4) >> bshift) & 0xff)*msavalue+bvalue)>>8) << bshift);\
- *ptr4 = pixel; \
- } \
- *zPtr = Z; \
+#define PLOT(X,Y) \
+ if (Z < *zPtr) { \
+ GLuint *ptr4 = PIXELADDR4(X,Y); \
+ GLuint pixel = 0; \
+ pixel |=((((((*ptr4) >> rshift) & 0xff)*msavalue+rvalue)>>8) << rshift); \
+ pixel |=((((((*ptr4) >> gshift) & 0xff)*msavalue+gvalue)>>8) << gshift); \
+ pixel |=((((((*ptr4) >> bshift) & 0xff)*msavalue+bvalue)>>8) << bshift); \
+ *ptr4 = pixel; \
+ *zPtr = Z; \
}
#ifdef WIN32
@@ -1369,7 +1371,8 @@ static line_func choose_line_function( GLcontext *ctx )
if (ctx->RasterMask==DEPTH_BIT
&& ctx->Depth.Func==GL_LESS
- && ctx->Depth.Mask==GL_TRUE) {
+ && ctx->Depth.Mask==GL_TRUE
+ && ctx->Visual->DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS) {
switch(osmesa->format) {
case OSMESA_RGBA:
case OSMESA_BGRA:
@@ -1394,6 +1397,7 @@ static line_func choose_line_function( GLcontext *ctx )
if (ctx->RasterMask==(DEPTH_BIT|BLEND_BIT)
&& ctx->Depth.Func==GL_LESS
&& ctx->Depth.Mask==GL_TRUE
+ && ctx->Visual->DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS
&& ctx->Color.BlendSrcRGB==GL_SRC_ALPHA
&& ctx->Color.BlendDstRGB==GL_ONE_MINUS_SRC_ALPHA
&& ctx->Color.BlendSrcA==GL_SRC_ALPHA
@@ -1412,6 +1416,7 @@ static line_func choose_line_function( GLcontext *ctx )
if (ctx->RasterMask==(DEPTH_BIT|BLEND_BIT)
&& ctx->Depth.Func==GL_LESS
&& ctx->Depth.Mask==GL_FALSE
+ && ctx->Visual->DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS
&& ctx->Color.BlendSrcRGB==GL_SRC_ALPHA
&& ctx->Color.BlendDstRGB==GL_ONE_MINUS_SRC_ALPHA
&& ctx->Color.BlendSrcA==GL_SRC_ALPHA
@@ -1467,6 +1472,7 @@ static void smooth_rgba_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
(void) pv;
osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define INTERP_ALPHA 1
#define INNER_LOOP( LEFT, RIGHT, Y ) \
@@ -1502,6 +1508,7 @@ static void flat_rgba_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
{
OSMesaContext osmesa = (OSMesaContext) ctx;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define SETUP_CODE \
GLubyte r = VB->ColorPtr->data[pv][0]; \
GLubyte g = VB->ColorPtr->data[pv][1]; \
@@ -1547,6 +1554,7 @@ static triangle_func choose_triangle_function( GLcontext *ctx )
if (ctx->RasterMask==DEPTH_BIT
&& ctx->Depth.Func==GL_LESS
&& ctx->Depth.Mask==GL_TRUE
+ && ctx->Visual->DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS
&& osmesa->format!=OSMESA_COLOR_INDEX) {
if (ctx->Light.ShadeModel==GL_SMOOTH) {
return smooth_rgba_z_triangle;
@@ -1558,6 +1566,8 @@ static triangle_func choose_triangle_function( GLcontext *ctx )
return NULL;
}
+
+
/**********************************************************************/
/***** Occlusion rendering routines *****/
/**********************************************************************/
@@ -1576,87 +1586,113 @@ static triangle_func choose_triangle_function( GLcontext *ctx )
} \
return;
-/***** Color Index *****/
+/**
+*** Color Index
+**/
+
static void write_index32_span_occ( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- const GLuint index[], const GLubyte mask[] )
+ GLuint n, GLint x, GLint y,
+ const GLuint index[], const GLubyte mask[] )
{
- OCC_STD_MASK_TEST
+ OCC_STD_MASK_TEST
}
+
+
static void write_index8_span_occ( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- const GLubyte index[], const GLubyte mask[] )
+ GLuint n, GLint x, GLint y,
+ const GLubyte index[], const GLubyte mask[] )
{
- OCC_STD_MASK_TEST
+ OCC_STD_MASK_TEST
}
+
+
static void write_monoindex_span_occ( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- const GLubyte mask[] )
+ GLuint n, GLint x, GLint y,
+ const GLubyte mask[] )
{
- OCC_STD_MASK_TEST
+ OCC_STD_MASK_TEST
}
+
+
static void write_index_pixels_occ( const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLuint index[], const GLubyte mask[] )
+ GLuint n, const GLint x[], const GLint y[],
+ const GLuint index[], const GLubyte mask[] )
{
- OCC_STD_MASK_TEST
+ OCC_STD_MASK_TEST
}
+
+
static void write_monoindex_pixels_occ( const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLubyte mask[] )
+ GLuint n, const GLint x[], const GLint y[],
+ const GLubyte mask[] )
{
- OCC_STD_MASK_TEST
+ OCC_STD_MASK_TEST
}
-/***** RGB/RGBA *****/
+/**
+*** RGB/RGBA
+**/
static void write_rgba_span_occ( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- CONST GLubyte rgba[][4], const GLubyte mask[] )
+ GLuint n, GLint x, GLint y,
+ CONST GLubyte rgba[][4], const GLubyte mask[] )
{
- OCC_STD_MASK_TEST
+ OCC_STD_MASK_TEST
}
+
+
static void write_rgb_span_occ( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- CONST GLubyte rgb[][3],
- const GLubyte mask[] )
+ GLuint n, GLint x, GLint y,
+ CONST GLubyte rgb[][3],
+ const GLubyte mask[] )
{
- OCC_STD_MASK_TEST
+ OCC_STD_MASK_TEST
}
+
+
static void write_rgba_pixels_occ( const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- CONST GLubyte rgba[][4], const GLubyte mask[] )
+ GLuint n, const GLint x[], const GLint y[],
+ CONST GLubyte rgba[][4], const GLubyte mask[] )
{
- OCC_STD_MASK_TEST
+ OCC_STD_MASK_TEST
}
+
+
static void write_monocolor_span_occ( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- const GLubyte mask[] )
+ GLuint n, GLint x, GLint y,
+ const GLubyte mask[] )
{
- OCC_STD_MASK_TEST
+ OCC_STD_MASK_TEST
}
+
+
static void write_monocolor_pixels_occ( const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLubyte mask[] )
+ GLuint n, const GLint x[], const GLint y[],
+ const GLubyte mask[] )
{
- OCC_STD_MASK_TEST
+ OCC_STD_MASK_TEST
}
-/***** Line Drawing *****/
+
+/**
+*** Line Drawing
+**/
static void line_occ( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pvert )
+ GLuint vert0, GLuint vert1, GLuint pvert )
{
OSMesaContext osmesa = (OSMesaContext) ctx->DriverCtx;
osmesa->bVisible = GL_TRUE;
}
+
static void line_z_occ( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pvert )
+ GLuint vert0, GLuint vert1, GLuint pvert )
{
OSMesaContext osmesa = (OSMesaContext) ctx->DriverCtx;
if (osmesa->bVisible) return;
#define INTERP_XY 1
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -1671,19 +1707,25 @@ static void line_z_occ( GLcontext *ctx,
#endif
}
-/***** Triangle Drawing *****/
+
+/**
+*** Triangle Drawing
+**/
static void triangle_occ( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
+ GLuint v2, GLuint pv )
{
OSMesaContext osmesa = (OSMesaContext) ctx->DriverCtx;
osmesa->bVisible = GL_TRUE;
}
+
+
static void triangle_z_occ( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
+ GLuint v2, GLuint pv )
{
OSMesaContext osmesa = (OSMesaContext) ctx->DriverCtx;
if (osmesa->bVisible) return;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
GLint i, len = RIGHT-LEFT; \
@@ -1703,6 +1745,7 @@ static void triangle_z_occ( GLcontext *ctx, GLuint v0, GLuint v1,
#endif
}
+
static const GLubyte *get_string( GLcontext *ctx, GLenum name )
{
(void) ctx;
diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c
index 152e661e98..af8254fed9 100644
--- a/src/mesa/drivers/x11/fakeglx.c
+++ b/src/mesa/drivers/x11/fakeglx.c
@@ -1,4 +1,4 @@
-/* $Id: fakeglx.c,v 1.24 2000/02/27 18:26:54 brianp Exp $ */
+/* $Id: fakeglx.c,v 1.25 2000/03/03 17:50:09 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -300,6 +300,11 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
/*
* Create a GLX visual from a regular XVisualInfo.
+ * This is called when Fake GLX is given an XVisualInfo which wasn't
+ * returned by glXChooseVisual. Since this is the first time we're
+ * considering this visual we'll take a guess at reasonable values
+ * for depth buffer size, stencil size, accum size, etc.
+ * This is the best we can do with a client-side emulation of GLX.
*/
static XMesaVisual
create_glx_visual( Display *dpy, XVisualInfo *visinfo )
@@ -329,9 +334,9 @@ create_glx_visual( Display *dpy, XVisualInfo *visinfo )
GL_FALSE, /* alpha */
GL_TRUE, /* double */
GL_FALSE, /* stereo */
- 8*sizeof(GLdepth),
- 8*sizeof(GLstencil),
- 8*sizeof(GLaccum),
+ DEFAULT_SOFTWARE_DEPTH_BITS,
+ 8 * sizeof(GLstencil),
+ 8 * sizeof(GLaccum),
0 /* level */
);
}
@@ -1014,6 +1019,22 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list )
}
if (vis) {
+ /* Note: we're not exactly obeying the glXChooseVisual rules here.
+ * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
+ * largest depth buffer size, which is 32bits/value. However, we
+ * return 16 to maintain performance with earlier versions of Mesa.
+ */
+ if (depth_size == 1)
+ depth_size = DEFAULT_SOFTWARE_DEPTH_BITS;
+ else if (depth_size > 24)
+ depth_size = 31;
+ else if (depth_size > 16)
+ depth_size = 24;
+ /* we only support one size of stencil and accum buffers. */
+ if (stencil_size > 0)
+ stencil_size = STENCIL_BITS;
+ if (accum_size > 0)
+ accum_size = ACCUM_BITS;
if (!save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag,
stereo_flag,
depth_size, stencil_size, accum_size, level ))
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;