summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/drivers/dos/dmesa.c9
-rw-r--r--src/mesa/drivers/glide/fxdd.c25
-rw-r--r--src/mesa/drivers/osmesa/osmesa.c16
-rw-r--r--src/mesa/drivers/svga/svgamesa.c5
-rw-r--r--src/mesa/drivers/windows/wmesa.c9
-rw-r--r--src/mesa/drivers/x11/xm_api.c17
-rw-r--r--src/mesa/drivers/x11/xm_dd.c113
-rw-r--r--src/mesa/drivers/x11/xmesaP.h6
-rw-r--r--src/mesa/main/buffers.c56
-rw-r--r--src/mesa/main/context.c5
-rw-r--r--src/mesa/main/mtypes.h4
-rw-r--r--src/mesa/swrast/s_accum.c36
-rw-r--r--src/mesa/swrast/s_accum.h9
-rw-r--r--src/mesa/swrast/s_alphabuf.c103
-rw-r--r--src/mesa/swrast/s_alphabuf.h8
-rw-r--r--src/mesa/swrast/s_buffers.c20
-rw-r--r--src/mesa/swrast/s_depth.c41
-rw-r--r--src/mesa/swrast/s_depth.h6
-rw-r--r--src/mesa/swrast/s_stencil.c20
-rw-r--r--src/mesa/swrast/s_stencil.h4
-rw-r--r--src/mesa/swrast/swrast.h9
21 files changed, 281 insertions, 240 deletions
diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c
index 454b891c08b..d150cdca5ac 100644
--- a/src/mesa/drivers/dos/dmesa.c
+++ b/src/mesa/drivers/dos/dmesa.c
@@ -540,8 +540,13 @@ static GLboolean set_draw_buffer (GLcontext *ctx, GLenum mode)
* If anything special has to been done when the buffer/window is
* resized, do it now.
*/
-static void get_buffer_size (GLcontext *ctx, GLuint *width, GLuint *height)
+static void get_buffer_size (GLframebuffer *buffer, GLuint *width, GLuint *height)
{
+ /* XXX this may not be right. We should query the size of the DOS window
+ * associated with <buffer>. This function should work whether or
+ * not there is a current context.
+ */
+ GET_CURRENT_CONTEXT(ctx);
DMesaContext c = (DMesaContext)ctx->DriverCtx;
*width = c->Buffer->width;
@@ -636,7 +641,7 @@ void dmesa_init_pointers (GLcontext *ctx)
ctx->Driver.Accum = _swrast_Accum;
ctx->Driver.Bitmap = _swrast_Bitmap;
ctx->Driver.Clear = clear;
- ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;
+ ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c
index 720ef41d3fc..8cdbe35382a 100644
--- a/src/mesa/drivers/glide/fxdd.c
+++ b/src/mesa/drivers/glide/fxdd.c
@@ -1,4 +1,4 @@
-/* $Id: fxdd.c,v 1.84 2001/09/23 16:50:01 brianp Exp $ */
+/* $Id: fxdd.c,v 1.85 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -103,19 +103,22 @@ fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder)
/* Return buffer size information */
static void
-fxDDBufferSize(GLcontext * ctx, GLuint * width, GLuint * height)
+fxDDBufferSize(GLframebuffer *buffer, GLuint * width, GLuint * height)
{
- fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GET_CURRENT_CONTEXT(ctx);
+ if (ctx && ctx->DriverCtx) {
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDBufferSize(...) Start\n");
- }
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDBufferSize(...) Start\n");
+ }
- *width = fxMesa->width;
- *height = fxMesa->height;
+ *width = fxMesa->width;
+ *height = fxMesa->height;
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDBufferSize(...) End\n");
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDBufferSize(...) End\n");
+ }
}
}
@@ -1002,7 +1005,7 @@ fxSetupDDPointers(GLcontext * ctx)
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = fxDDReadPixels;
- ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;
+ ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
ctx->Driver.Finish = fxDDFinish;
ctx->Driver.Flush = NULL;
ctx->Driver.ChooseTextureFormat = fxDDChooseTextureFormat;
diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
index 842ad6652b4..1cc7439afd1 100644
--- a/src/mesa/drivers/osmesa/osmesa.c
+++ b/src/mesa/drivers/osmesa/osmesa.c
@@ -1,4 +1,4 @@
-/* $Id: osmesa.c,v 1.74 2002/03/01 04:23:36 brianp Exp $ */
+/* $Id: osmesa.c,v 1.75 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -875,11 +875,15 @@ static void clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
-static void buffer_size( GLcontext *ctx, GLuint *width, GLuint *height )
+static void buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
{
- OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
- *width = osmesa->width;
- *height = osmesa->height;
+ GET_CURRENT_CONTEXT(ctx);
+ (void) buffer;
+ if (ctx) {
+ OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
+ *width = osmesa->width;
+ *height = osmesa->height;
+ }
}
@@ -2023,7 +2027,7 @@ static void osmesa_update_state( GLcontext *ctx, GLuint new_state )
ctx->Driver.GetString = get_string;
ctx->Driver.UpdateState = osmesa_update_state;
ctx->Driver.SetDrawBuffer = set_draw_buffer;
- ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;
+ ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
ctx->Driver.GetBufferSize = buffer_size;
ctx->Driver.Accum = _swrast_Accum;
diff --git a/src/mesa/drivers/svga/svgamesa.c b/src/mesa/drivers/svga/svgamesa.c
index db97d20194c..c841f46f012 100644
--- a/src/mesa/drivers/svga/svgamesa.c
+++ b/src/mesa/drivers/svga/svgamesa.c
@@ -1,4 +1,4 @@
-/* $Id: svgamesa.c,v 1.16 2001/09/23 16:11:27 brianp Exp $ */
+/* $Id: svgamesa.c,v 1.17 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -210,7 +210,7 @@ static void copy_buffer( const GLubyte * buffer) {
}
}
-static void get_buffer_size( GLcontext *ctx, GLuint *width, GLuint *height )
+static void get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
{
*width = SVGAMesa->width = vga_getxdim();
*height = SVGAMesa->height = vga_getydim();
@@ -286,6 +286,7 @@ static void svgamesa_update_state( GLcontext *ctx, GLuint new_state )
ctx->Driver.GetBufferSize = get_buffer_size;
ctx->Driver.SetDrawBuffer = set_draw_buffer;
+ ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
/* Software rasterizer pixel paths:
*/
diff --git a/src/mesa/drivers/windows/wmesa.c b/src/mesa/drivers/windows/wmesa.c
index 47edef993e6..4f057bfad73 100644
--- a/src/mesa/drivers/windows/wmesa.c
+++ b/src/mesa/drivers/windows/wmesa.c
@@ -1,4 +1,4 @@
-/* $Id: wmesa.c,v 1.25 2002/01/16 15:42:17 kschultz Exp $ */
+/* $Id: wmesa.c,v 1.26 2002/03/16 00:53:15 brianp Exp $ */
/*
* Windows (Win32) device driver for Mesa 3.4
@@ -583,8 +583,9 @@ static void set_read_buffer(GLcontext *ctx, GLframebuffer *colorBuffer,
/* Return characteristics of the output buffer. */
-static void buffer_size( GLcontext* ctx, GLuint *width, GLuint *height )
+static void buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
{
+ GET_CURRENT_CONTEXT(ctx);
int New_Size;
RECT CR;
@@ -1021,7 +1022,7 @@ static void SetFunctionPointers(GLcontext *ctx)
ctx->Driver.GetString = get_string;
ctx->Driver.UpdateState = wmesa_update_state;
ctx->Driver.SetDrawBuffer = set_draw_buffer;
- ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;
+ ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
ctx->Driver.GetBufferSize = buffer_size;
ctx->Driver.Accum = _swrast_Accum;
@@ -1100,7 +1101,7 @@ static void wmesa_update_state( GLcontext *ctx, GLuint new_state )
ctx->Driver.GetString = get_string;
ctx->Driver.UpdateState = wmesa_update_state;
ctx->Driver.SetDrawBuffer = set_draw_buffer;
- ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;
+ ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
ctx->Driver.GetBufferSize = buffer_size;
ctx->Driver.Accum = _swrast_Accum;
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c
index ce5576d68d5..9ee36a45ca0 100644
--- a/src/mesa/drivers/x11/xm_api.c
+++ b/src/mesa/drivers/x11/xm_api.c
@@ -1,8 +1,8 @@
-/* $Id: xm_api.c,v 1.34 2002/03/12 21:55:50 brianp Exp $ */
+/* $Id: xm_api.c,v 1.35 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 4.0.2
*
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
@@ -2329,9 +2329,8 @@ void XMesaSwapBuffers( XMesaBuffer b )
/* If we're swapping the buffer associated with the current context
* we have to flush any pending rendering commands first.
*/
- if (ctx && ctx->DrawBuffer == &(b->mesa_buffer)) {
+ if (ctx && ctx->DrawBuffer == &(b->mesa_buffer))
_mesa_swapbuffers(ctx);
- }
if (b->db_state) {
#ifdef FX
@@ -2630,3 +2629,13 @@ unsigned long XMesaDitherColor( XMesaContext xmesa, GLint x, GLint y,
}
+/*
+ * This is typically called when the window size changes and we need
+ * to reallocate the buffer's back/depth/stencil/accum buffers.
+ */
+void XMesaResizeBuffers( XMesaBuffer b )
+{
+ xmesa_resize_buffers( &(b->mesa_buffer) );
+
+}
+
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c
index ec79f3c5149..642aee8a229 100644
--- a/src/mesa/drivers/x11/xm_dd.c
+++ b/src/mesa/drivers/x11/xm_dd.c
@@ -1,8 +1,8 @@
-/* $Id: xm_dd.c,v 1.29 2002/03/01 04:28:32 brianp Exp $ */
+/* $Id: xm_dd.c,v 1.30 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 4.0.2
*
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
@@ -48,17 +48,18 @@
/*
- * Return the size (width,height of the current color buffer.
- * This function should be called by the glViewport function because
- * glViewport is often called when the window gets resized. We need to
- * update some X/Mesa stuff when that happens.
+ * Return the size (width, height) of the X window for the given GLframebuffer.
* Output: width - width of buffer in pixels.
* height - height of buffer in pixels.
*/
static void
-get_buffer_size( GLcontext *ctx, GLuint *width, GLuint *height )
+get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ /* We can do this cast because the first field in the XMesaBuffer
+ * struct is a GLframebuffer struct. If this weren't true, we'd
+ * need a pointer from the GLframebuffer to the XMesaBuffer.
+ */
+ const XMesaBuffer xmBuffer = (XMesaBuffer) buffer;
unsigned int winwidth, winheight;
#ifndef XFree86Server
Window root;
@@ -66,58 +67,19 @@ get_buffer_size( GLcontext *ctx, GLuint *width, GLuint *height )
unsigned int bw, d;
_glthread_LOCK_MUTEX(_xmesa_lock);
- XGetGeometry( xmesa->display, xmesa->xm_buffer->frontbuffer, &root,
+ XGetGeometry( xmBuffer->xm_visual->display, xmBuffer->frontbuffer, &root,
&winx, &winy, &winwidth, &winheight, &bw, &d );
_glthread_UNLOCK_MUTEX(_xmesa_lock);
#else
-
- winwidth = xmesa->xm_buffer->frontbuffer->width;
- winheight = xmesa->xm_buffer->frontbuffer->height;
+ /* XFree86 GLX renderer */
+ winwidth = xmBuffer->frontbuffer->width;
+ winheight = xmBuffer->frontbuffer->height;
#endif
(void)kernel8; /* Muffle compiler */
*width = winwidth;
*height = winheight;
-
- if ( winwidth!=xmesa->xm_buffer->width
- || winheight!=xmesa->xm_buffer->height) {
- xmesa->xm_buffer->width = winwidth;
- xmesa->xm_buffer->height = winheight;
- xmesa_alloc_back_buffer( xmesa->xm_buffer );
- }
-
- /* Needed by FLIP macro */
- xmesa->xm_buffer->bottom = (int) winheight - 1;
-
- if (xmesa->xm_buffer->backimage) {
- /* Needed by PIXELADDR1 macro */
- xmesa->xm_buffer->ximage_width1
- = xmesa->xm_buffer->backimage->bytes_per_line;
- xmesa->xm_buffer->ximage_origin1
- = (GLubyte *) xmesa->xm_buffer->backimage->data
- + xmesa->xm_buffer->ximage_width1 * (winheight-1);
-
- /* Needed by PIXELADDR2 macro */
- xmesa->xm_buffer->ximage_width2
- = xmesa->xm_buffer->backimage->bytes_per_line / 2;
- xmesa->xm_buffer->ximage_origin2
- = (GLushort *) xmesa->xm_buffer->backimage->data
- + xmesa->xm_buffer->ximage_width2 * (winheight-1);
-
- /* Needed by PIXELADDR3 macro */
- xmesa->xm_buffer->ximage_width3
- = xmesa->xm_buffer->backimage->bytes_per_line;
- xmesa->xm_buffer->ximage_origin3
- = (GLubyte *) xmesa->xm_buffer->backimage->data
- + xmesa->xm_buffer->ximage_width3 * (winheight-1);
-
- /* Needed by PIXELADDR4 macro */
- xmesa->xm_buffer->ximage_width4 = xmesa->xm_buffer->backimage->width;
- xmesa->xm_buffer->ximage_origin4
- = (GLuint *) xmesa->xm_buffer->backimage->data
- + xmesa->xm_buffer->ximage_width4 * (winheight-1);
- }
}
@@ -780,10 +742,51 @@ clear_buffers( GLcontext *ctx, GLbitfield mask,
}
-static void
-resize_buffers( GLcontext *ctx )
+/*
+ * When we detect that the user has resized the window this function will
+ * get called. Here we'll reallocate the back buffer, depth buffer,
+ * stencil buffer etc. to match the new window size.
+ */
+void
+xmesa_resize_buffers( GLframebuffer *buffer )
{
- _swrast_alloc_buffers( ctx );
+ int height = (int) buffer->Height;
+ /* We can do this cast because the first field in the XMesaBuffer
+ * struct is a GLframebuffer struct. If this weren't true, we'd
+ * need a pointer from the GLframebuffer to the XMesaBuffer.
+ */
+ XMesaBuffer xmBuffer = (XMesaBuffer) buffer;
+
+ xmBuffer->width = buffer->Width;
+ xmBuffer->height = buffer->Height;
+ xmesa_alloc_back_buffer( xmBuffer );
+
+ /* Needed by FLIP macro */
+ xmBuffer->bottom = height - 1;
+
+ if (xmBuffer->backimage) {
+ /* Needed by PIXELADDR1 macro */
+ xmBuffer->ximage_width1 = xmBuffer->backimage->bytes_per_line;
+ xmBuffer->ximage_origin1 = (GLubyte *) xmBuffer->backimage->data
+ + xmBuffer->ximage_width1 * (height-1);
+
+ /* Needed by PIXELADDR2 macro */
+ xmBuffer->ximage_width2 = xmBuffer->backimage->bytes_per_line / 2;
+ xmBuffer->ximage_origin2 = (GLushort *) xmBuffer->backimage->data
+ + xmBuffer->ximage_width2 * (height-1);
+
+ /* Needed by PIXELADDR3 macro */
+ xmBuffer->ximage_width3 = xmBuffer->backimage->bytes_per_line;
+ xmBuffer->ximage_origin3 = (GLubyte *) xmBuffer->backimage->data
+ + xmBuffer->ximage_width3 * (height-1);
+
+ /* Needed by PIXELADDR4 macro */
+ xmBuffer->ximage_width4 = xmBuffer->backimage->width;
+ xmBuffer->ximage_origin4 = (GLuint *) xmBuffer->backimage->data
+ + xmBuffer->ximage_width4 * (height-1);
+ }
+
+ _swrast_alloc_buffers( buffer );
}
#if 0
@@ -951,7 +954,7 @@ void xmesa_init_pointers( GLcontext *ctx )
ctx->Driver.Accum = _swrast_Accum;
ctx->Driver.Bitmap = _swrast_Bitmap;
ctx->Driver.Clear = clear_buffers;
- ctx->Driver.ResizeBuffersMESA = resize_buffers;
+ ctx->Driver.ResizeBuffers = xmesa_resize_buffers;
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h
index 409ea225678..d61ee88e55e 100644
--- a/src/mesa/drivers/x11/xmesaP.h
+++ b/src/mesa/drivers/x11/xmesaP.h
@@ -1,8 +1,8 @@
-/* $Id: xmesaP.h,v 1.26 2002/03/12 21:55:50 brianp Exp $ */
+/* $Id: xmesaP.h,v 1.27 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.2
+ * Version: 4.0.2
*
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
@@ -532,4 +532,6 @@ extern void XMesaReset( void );
extern void xmesa_set_read_buffer( GLcontext *ctx,
GLframebuffer *buffer, GLenum mode );
+extern void xmesa_resize_buffers( GLframebuffer *buffer );
+
#endif
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index b4feb219fbf..be793417d48 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -1,4 +1,4 @@
-/* $Id: buffers.c,v 1.32 2002/02/15 16:25:16 brianp Exp $ */
+/* $Id: buffers.c,v 1.33 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -350,33 +350,59 @@ _mesa_ReadBuffer( GLenum mode )
/*
* GL_MESA_resize_buffers extension
+ * When this function is called, we'll ask the window system how large
+ * the current window is. If it's not what we expect, we'll have to
+ * resize/reallocate the software accum/stencil/depth/alpha buffers.
*/
void
_mesa_ResizeBuffersMESA( void )
{
GLcontext *ctx = _mesa_get_current_context();
- GLuint buf_width, buf_height;
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx );
-
if (MESA_VERBOSE & VERBOSE_API)
fprintf(stderr, "glResizeBuffersMESA\n");
- /* ask device driver for size of output buffer */
- (*ctx->Driver.GetBufferSize)( ctx, &buf_width, &buf_height );
+ if (ctx) {
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx );
- /* see if size of device driver's color buffer (window) has changed */
- if (ctx->DrawBuffer->Width == (GLint) buf_width &&
- ctx->DrawBuffer->Height == (GLint) buf_height)
- return;
+ if (ctx->DrawBuffer) {
+ GLuint buf_width, buf_height;
+ GLframebuffer *buffer = ctx->DrawBuffer;
+
+ /* ask device driver for size of output buffer */
+ (*ctx->Driver.GetBufferSize)( buffer, &buf_width, &buf_height );
- ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */
+ /* see if size of device driver's color buffer (window) has changed */
+ if (buffer->Width == (GLint) buf_width &&
+ buffer->Height == (GLint) buf_height)
+ return; /* size is as expected */
+
+ buffer->Width = buf_width;
+ buffer->Height = buf_height;
+
+ ctx->Driver.ResizeBuffers( buffer );
+ }
- /* save buffer size */
- ctx->DrawBuffer->Width = buf_width;
- ctx->DrawBuffer->Height = buf_height;
+ if (ctx->ReadBuffer && ctx->ReadBuffer != ctx->DrawBuffer) {
+ GLuint buf_width, buf_height;
+ GLframebuffer *buffer = ctx->DrawBuffer;
- ctx->Driver.ResizeBuffersMESA( ctx );
+ /* ask device driver for size of output buffer */
+ (*ctx->Driver.GetBufferSize)( buffer, &buf_width, &buf_height );
+
+ /* see if size of device driver's color buffer (window) has changed */
+ if (buffer->Width == (GLint) buf_width &&
+ buffer->Height == (GLint) buf_height)
+ return; /* size is as expected */
+
+ buffer->Width = buf_width;
+ buffer->Height = buf_height;
+
+ ctx->Driver.ResizeBuffers( buffer );
+ }
+
+ ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */
+ }
}
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 18477f32771..5ed31a18bc0 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.155 2002/03/13 04:33:32 brianp Exp $ */
+/* $Id: context.c,v 1.156 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -2084,6 +2084,9 @@ _mesa_error( GLcontext *ctx, GLenum error, const char *where )
fprintf(stderr, "Mesa user error: %s in %s\n", errstr, where);
}
+ if (!ctx)
+ return;
+
if (ctx->ErrorValue == GL_NO_ERROR) {
ctx->ErrorValue = error;
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index efa26afe8b1..807a7b24ccd 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1,4 +1,4 @@
-/* $Id: mtypes.h,v 1.66 2002/03/13 04:33:16 brianp Exp $ */
+/* $Id: mtypes.h,v 1.67 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1312,7 +1312,7 @@ struct gl_shared_state {
struct gl_frame_buffer {
GLvisual Visual; /* The corresponding visual */
- GLint Width, Height; /* size of frame buffer in pixels */
+ GLuint Width, Height; /* size of frame buffer in pixels */
GLboolean UseSoftwareDepthBuffer;
GLboolean UseSoftwareAccumBuffer;
diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c
index 167a655f33b..faf8313d4d1 100644
--- a/src/mesa/swrast/s_accum.c
+++ b/src/mesa/swrast/s_accum.c
@@ -1,4 +1,4 @@
-/* $Id: s_accum.c,v 1.14 2002/02/02 17:24:11 brianp Exp $ */
+/* $Id: s_accum.c,v 1.15 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -67,38 +67,38 @@
#endif
-
void
-_mesa_alloc_accum_buffer( GLcontext *ctx )
+_mesa_alloc_accum_buffer( GLframebuffer *buffer )
{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GET_CURRENT_CONTEXT(ctx);
GLint n;
- if (ctx->DrawBuffer->Accum) {
- FREE( ctx->DrawBuffer->Accum );
- ctx->DrawBuffer->Accum = NULL;
+ if (buffer->Accum) {
+ FREE( buffer->Accum );
+ buffer->Accum = NULL;
}
/* allocate accumulation buffer if not already present */
- n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height * 4 * sizeof(GLaccum);
- ctx->DrawBuffer->Accum = (GLaccum *) MALLOC( n );
- if (!ctx->DrawBuffer->Accum) {
+ n = buffer->Width * buffer->Height * 4 * sizeof(GLaccum);
+ buffer->Accum = (GLaccum *) MALLOC( n );
+ if (!buffer->Accum) {
/* unable to setup accumulation buffer */
- _mesa_error( ctx, GL_OUT_OF_MEMORY, "glAccum" );
+ _mesa_error( NULL, GL_OUT_OF_MEMORY, "glAccum" );
}
+
+ if (ctx) {
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ /* XXX these fields should probably be in the GLframebuffer */
#ifdef USE_OPTIMIZED_ACCUM
- swrast->_IntegerAccumMode = GL_TRUE;
+ swrast->_IntegerAccumMode = GL_TRUE;
#else
- swrast->_IntegerAccumMode = GL_FALSE;
+ swrast->_IntegerAccumMode = GL_FALSE;
#endif
- swrast->_IntegerAccumScaler = 0.0;
+ swrast->_IntegerAccumScaler = 0.0;
+ }
}
-
-
-
-
/*
* This is called when we fall out of optimized/unscaled accum buffer mode.
* That is, we convert each unscaled accum buffer value into a scaled value
diff --git a/src/mesa/swrast/s_accum.h b/src/mesa/swrast/s_accum.h
index 014ca98b94b..d46235d5e3e 100644
--- a/src/mesa/swrast/s_accum.h
+++ b/src/mesa/swrast/s_accum.h
@@ -1,10 +1,10 @@
-/* $Id: s_accum.h,v 1.3 2001/03/12 00:48:41 gareth Exp $ */
+/* $Id: s_accum.h,v 1.4 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 4.0.2
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2002 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"),
@@ -34,12 +34,11 @@
extern void
-_mesa_alloc_accum_buffer( GLcontext *ctx );
+_mesa_alloc_accum_buffer( GLframebuffer *buffer );
extern void
_mesa_clear_accum_buffer( GLcontext *ctx );
-
#endif
diff --git a/src/mesa/swrast/s_alphabuf.c b/src/mesa/swrast/s_alphabuf.c
index 2a066aeee70..2b7c4f7de26 100644
--- a/src/mesa/swrast/s_alphabuf.c
+++ b/src/mesa/swrast/s_alphabuf.c
@@ -1,10 +1,10 @@
-/* $Id: s_alphabuf.c,v 1.8 2001/07/13 20:07:37 brianp Exp $ */
+/* $Id: s_alphabuf.c,v 1.9 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 4.0.2
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2002 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"),
@@ -38,8 +38,6 @@
#include "s_alphabuf.h"
-
-
#define ALPHA_DRAW_ADDR(X,Y) \
(ctx->DrawBuffer->Alpha + (Y) * ctx->DrawBuffer->Width + (X))
@@ -47,85 +45,72 @@
(ctx->ReadBuffer->Alpha + (Y) * ctx->ReadBuffer->Width + (X))
-
/*
- * Allocate new front/back/left/right alpha buffers.
- * Input: ctx - the context
- *
+ * Allocate a new front and back alpha buffer.
*/
-static void
-alloc_alpha_buffers( GLcontext *ctx, GLframebuffer *buf )
+void
+_mesa_alloc_alpha_buffers( GLframebuffer *buffer )
{
- GLint bytes = buf->Width * buf->Height * sizeof(GLchan);
+ GET_CURRENT_CONTEXT(ctx);
+ const GLint bytes = buffer->Width * buffer->Height * sizeof(GLchan);
- ASSERT(ctx->DrawBuffer->UseSoftwareAlphaBuffers);
+ ASSERT(buffer->UseSoftwareAlphaBuffers);
- if (buf->FrontLeftAlpha) {
- FREE( buf->FrontLeftAlpha );
+ if (buffer->FrontLeftAlpha) {
+ FREE( buffer->FrontLeftAlpha );
}
- buf->FrontLeftAlpha = (GLchan *) MALLOC( bytes );
- if (!buf->FrontLeftAlpha) {
+ buffer->FrontLeftAlpha = (GLchan *) MALLOC( bytes );
+ if (!buffer->FrontLeftAlpha) {
/* out of memory */
- _mesa_error( ctx, GL_OUT_OF_MEMORY,
- "Couldn't allocate front-left alpha buffer" );
+ _mesa_error( NULL, GL_OUT_OF_MEMORY,
+ "Couldn't allocate front-left alpha buffer" );
}
- if (ctx->Visual.doubleBufferMode) {
- if (buf->BackLeftAlpha) {
- FREE( buf->BackLeftAlpha );
+ if (buffer->Visual.doubleBufferMode) {
+ if (buffer->BackLeftAlpha) {
+ FREE( buffer->BackLeftAlpha );
}
- buf->BackLeftAlpha = (GLchan *) MALLOC( bytes );
- if (!buf->BackLeftAlpha) {
+ buffer->BackLeftAlpha = (GLchan *) MALLOC( bytes );
+ if (!buffer->BackLeftAlpha) {
/* out of memory */
- _mesa_error( ctx, GL_OUT_OF_MEMORY,
+ _mesa_error( NULL, GL_OUT_OF_MEMORY,
"Couldn't allocate back-left alpha buffer" );
}
}
- if (ctx->Visual.stereoMode) {
- if (buf->FrontRightAlpha) {
- FREE( buf->FrontRightAlpha );
+ if (buffer->Visual.stereoMode) {
+ if (buffer->FrontRightAlpha) {
+ FREE( buffer->FrontRightAlpha );
}
- buf->FrontRightAlpha = (GLchan *) MALLOC( bytes );
- if (!buf->FrontRightAlpha) {
+ buffer->FrontRightAlpha = (GLchan *) MALLOC( bytes );
+ if (!buffer->FrontRightAlpha) {
/* out of memory */
- _mesa_error( ctx, GL_OUT_OF_MEMORY,
- "Couldn't allocate front-right alpha buffer" );
+ _mesa_error( NULL, GL_OUT_OF_MEMORY,
+ "Couldn't allocate front-right alpha buffer" );
}
- if (ctx->Visual.doubleBufferMode) {
- if (buf->BackRightAlpha) {
- FREE( buf->BackRightAlpha );
+ if (buffer->Visual.doubleBufferMode) {
+ if (buffer->BackRightAlpha) {
+ FREE( buffer->BackRightAlpha );
}
- buf->BackRightAlpha = (GLchan *) MALLOC( bytes );
- if (!buf->BackRightAlpha) {
+ buffer->BackRightAlpha = (GLchan *) MALLOC( bytes );
+ if (!buffer->BackRightAlpha) {
/* out of memory */
- _mesa_error( ctx, GL_OUT_OF_MEMORY,
- "Couldn't allocate back-right alpha buffer" );
+ _mesa_error( NULL, GL_OUT_OF_MEMORY,
+ "Couldn't allocate back-right alpha buffer" );
}
}
}
- if (ctx->Color.DriverDrawBuffer == GL_FRONT_LEFT)
- buf->Alpha = buf->FrontLeftAlpha;
- else if (ctx->Color.DriverDrawBuffer == GL_BACK_LEFT)
- buf->Alpha = buf->BackLeftAlpha;
- else if (ctx->Color.DriverDrawBuffer == GL_FRONT_RIGHT)
- buf->Alpha = buf->FrontRightAlpha;
- else if (ctx->Color.DriverDrawBuffer == GL_BACK_RIGHT)
- buf->Alpha = buf->BackRightAlpha;
-}
-
-
-/*
- * Allocate a new front and back alpha buffer.
- */
-void
-_mesa_alloc_alpha_buffers( GLcontext *ctx )
-{
- alloc_alpha_buffers( ctx, ctx->DrawBuffer );
- if (ctx->ReadBuffer != ctx->DrawBuffer) {
- alloc_alpha_buffers( ctx, ctx->ReadBuffer );
+ if (ctx) {
+ if (ctx->Color.DriverDrawBuffer == GL_FRONT_LEFT)
+ buffer->Alpha = buffer->FrontLeftAlpha;
+ else if (ctx->Color.DriverDrawBuffer == GL_BACK_LEFT)
+ buffer->Alpha = buffer->BackLeftAlpha;
+ else if (ctx->Color.DriverDrawBuffer == GL_FRONT_RIGHT)
+ buffer->Alpha = buffer->FrontRightAlpha;
+ else if (ctx->Color.DriverDrawBuffer == GL_BACK_RIGHT)
+ buffer->Alpha = buffer->BackRightAlpha;
}
}
diff --git a/src/mesa/swrast/s_alphabuf.h b/src/mesa/swrast/s_alphabuf.h
index 889a6c94e6b..544ae070b16 100644
--- a/src/mesa/swrast/s_alphabuf.h
+++ b/src/mesa/swrast/s_alphabuf.h
@@ -1,10 +1,10 @@
-/* $Id: s_alphabuf.h,v 1.3 2001/03/12 00:48:41 gareth Exp $ */
+/* $Id: s_alphabuf.h,v 1.4 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 4.0.2
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2002 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"),
@@ -34,7 +34,7 @@
extern void
-_mesa_alloc_alpha_buffers( GLcontext *ctx );
+_mesa_alloc_alpha_buffers( GLframebuffer *buffer );
extern void
diff --git a/src/mesa/swrast/s_buffers.c b/src/mesa/swrast/s_buffers.c
index 50515415df5..d787acfafb1 100644
--- a/src/mesa/swrast/s_buffers.c
+++ b/src/mesa/swrast/s_buffers.c
@@ -1,4 +1,4 @@
-/* $Id: s_buffers.c,v 1.9 2002/02/02 17:24:11 brianp Exp $ */
+/* $Id: s_buffers.c,v 1.10 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -242,19 +242,19 @@ _swrast_Clear( GLcontext *ctx, GLbitfield mask,
void
-_swrast_alloc_buffers( GLcontext *ctx )
+_swrast_alloc_buffers( GLframebuffer *buffer )
{
/* Reallocate other buffers if needed. */
- if (ctx->DrawBuffer->UseSoftwareDepthBuffer) {
- _mesa_alloc_depth_buffer( ctx );
+ if (buffer->UseSoftwareDepthBuffer) {
+ _mesa_alloc_depth_buffer( buffer );
}
- if (ctx->DrawBuffer->UseSoftwareStencilBuffer) {
- _mesa_alloc_stencil_buffer( ctx );
+ if (buffer->UseSoftwareStencilBuffer) {
+ _mesa_alloc_stencil_buffer( buffer );
}
- if (ctx->DrawBuffer->UseSoftwareAccumBuffer) {
- _mesa_alloc_accum_buffer( ctx );
+ if (buffer->UseSoftwareAccumBuffer) {
+ _mesa_alloc_accum_buffer( buffer );
}
- if (ctx->DrawBuffer->UseSoftwareAlphaBuffers) {
- _mesa_alloc_alpha_buffers( ctx );
+ if (buffer->UseSoftwareAlphaBuffers) {
+ _mesa_alloc_alpha_buffers( buffer );
}
}
diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c
index a62926cc42b..cadb0ecd109 100644
--- a/src/mesa/swrast/s_depth.c
+++ b/src/mesa/swrast/s_depth.c
@@ -1,4 +1,4 @@
-/* $Id: s_depth.c,v 1.17 2002/02/06 03:22:00 brianp Exp $ */
+/* $Id: s_depth.c,v 1.18 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1513,32 +1513,33 @@ _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( GLframebuffer *buffer )
{
- /* deallocate current depth buffer if present */
- if (ctx->DrawBuffer->UseSoftwareDepthBuffer) {
- GLint bytesPerValue;
+ GLint bytesPerValue;
- if (ctx->DrawBuffer->DepthBuffer) {
- FREE(ctx->DrawBuffer->DepthBuffer);
- ctx->DrawBuffer->DepthBuffer = NULL;
- }
+ ASSERT(buffer->UseSoftwareDepthBuffer);
- /* allocate new depth buffer, but don't initialize it */
- if (ctx->Visual.depthBits <= 16)
- bytesPerValue = sizeof(GLushort);
- else
- bytesPerValue = sizeof(GLuint);
+ /* deallocate current depth buffer if present */
+ if (buffer->DepthBuffer) {
+ FREE(buffer->DepthBuffer);
+ buffer->DepthBuffer = NULL;
+ }
+
+ /* allocate new depth buffer, but don't initialize it */
+ if (buffer->Visual.depthBits <= 16)
+ bytesPerValue = sizeof(GLushort);
+ else
+ bytesPerValue = sizeof(GLuint);
- ctx->DrawBuffer->DepthBuffer = MALLOC( ctx->DrawBuffer->Width
- * ctx->DrawBuffer->Height
- * bytesPerValue );
+ buffer->DepthBuffer =MALLOC(buffer->Width * buffer->Height * bytesPerValue);
- if (!ctx->DrawBuffer->DepthBuffer) {
- /* out of memory */
+ if (!buffer->DepthBuffer) {
+ /* out of memory */
+ GET_CURRENT_CONTEXT(ctx);
+ if (ctx) {
ctx->Depth.Test = GL_FALSE;
ctx->NewState |= _NEW_DEPTH;
- _mesa_error( ctx, GL_OUT_OF_MEMORY, "Couldn't allocate depth buffer" );
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Couldn't allocate depth buffer");
}
}
}
diff --git a/src/mesa/swrast/s_depth.h b/src/mesa/swrast/s_depth.h
index 610835c10dd..2b7e9ddeb48 100644
--- a/src/mesa/swrast/s_depth.h
+++ b/src/mesa/swrast/s_depth.h
@@ -1,4 +1,4 @@
-/* $Id: s_depth.h,v 1.5 2002/02/04 15:59:29 brianp Exp $ */
+/* $Id: s_depth.h,v 1.6 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -54,11 +54,11 @@ _mesa_read_depth_span_float( GLcontext *ctx, GLint n, GLint x, GLint y,
extern void
-_mesa_alloc_depth_buffer( GLcontext* ctx );
+_mesa_alloc_depth_buffer( GLframebuffer *buffer );
extern void
-_mesa_clear_depth_buffer( GLcontext* ctx );
+_mesa_clear_depth_buffer( GLcontext *ctx );
#endif
diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c
index dd438e8dcba..6d62b65fd56 100644
--- a/src/mesa/swrast/s_stencil.c
+++ b/src/mesa/swrast/s_stencil.c
@@ -1,4 +1,4 @@
-/* $Id: s_stencil.c,v 1.20 2002/02/04 15:59:30 brianp Exp $ */
+/* $Id: s_stencil.c,v 1.21 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1112,22 +1112,20 @@ _mesa_write_stencil_span( GLcontext *ctx, GLint n, GLint x, GLint y,
* deallocated first. The new stencil buffer will be uninitialized.
*/
void
-_mesa_alloc_stencil_buffer( GLcontext *ctx )
+_mesa_alloc_stencil_buffer( GLframebuffer *buffer )
{
- GLuint buffersize = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height;
-
/* deallocate current stencil buffer if present */
- if (ctx->DrawBuffer->Stencil) {
- FREE(ctx->DrawBuffer->Stencil);
- ctx->DrawBuffer->Stencil = NULL;
+ if (buffer->Stencil) {
+ FREE(buffer->Stencil);
+ buffer->Stencil = NULL;
}
/* allocate new stencil buffer */
- ctx->DrawBuffer->Stencil = (GLstencil *) MALLOC(buffersize * sizeof(GLstencil));
- if (!ctx->DrawBuffer->Stencil) {
+ buffer->Stencil = (GLstencil *) MALLOC(buffer->Width * buffer->Height
+ * sizeof(GLstencil));
+ if (!buffer->Stencil) {
/* out of memory */
-/* _mesa_set_enable( ctx, GL_STENCIL_TEST, GL_FALSE ); */
- _mesa_error( ctx, GL_OUT_OF_MEMORY, "_mesa_alloc_stencil_buffer" );
+ _mesa_error( NULL, GL_OUT_OF_MEMORY, "_mesa_alloc_stencil_buffer" );
}
}
diff --git a/src/mesa/swrast/s_stencil.h b/src/mesa/swrast/s_stencil.h
index 3658e9dba69..d15b5d2d4a1 100644
--- a/src/mesa/swrast/s_stencil.h
+++ b/src/mesa/swrast/s_stencil.h
@@ -1,4 +1,4 @@
-/* $Id: s_stencil.h,v 1.6 2002/02/02 21:40:34 brianp Exp $ */
+/* $Id: s_stencil.h,v 1.7 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -50,7 +50,7 @@ _mesa_write_stencil_span( GLcontext *ctx, GLint n, GLint x, GLint y,
extern void
-_mesa_alloc_stencil_buffer( GLcontext *ctx );
+_mesa_alloc_stencil_buffer( GLframebuffer *buffer );
extern void
diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h
index 9359b26dfcb..a6c07e56551 100644
--- a/src/mesa/swrast/swrast.h
+++ b/src/mesa/swrast/swrast.h
@@ -1,4 +1,4 @@
-/* $Id: swrast.h,v 1.20 2002/02/02 17:24:11 brianp Exp $ */
+/* $Id: swrast.h,v 1.21 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -134,9 +134,10 @@ struct sw_span {
GLfixed index, indexStep;
GLfixed z, zStep;
GLfloat fog, fogStep;
- GLfloat tex[MAX_TEXTURE_UNITS][4], texStep[MAX_TEXTURE_UNITS][4];
+ GLfloat tex[MAX_TEXTURE_UNITS][4];
+ GLfloat texStepX[MAX_TEXTURE_UNITS][4];
+ GLfloat texStepY[MAX_TEXTURE_UNITS][4];
GLfixed intTex[2], intTexStep[2];
- GLfloat rho[MAX_TEXTURE_UNITS]; /* for texture lambda/lod computation */
/**
* This bitmask (of SPAN_* flags) indicates which of the fragment arrays
@@ -182,7 +183,7 @@ struct swrast_device_driver;
/* These are the public-access functions exported from swrast.
*/
extern void
-_swrast_alloc_buffers( GLcontext *ctx );
+_swrast_alloc_buffers( GLframebuffer *buffer );
extern GLboolean
_swrast_CreateContext( GLcontext *ctx );