From 18a285a5e244b7405b85feb7315a30d99920ec5d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 16 Mar 2002 00:53:15 +0000 Subject: Lots of changes related to framebuffer/window buffer resizing. Basically, instead of passing a GLcontext* to ResizeBuffers(), pass a GLframebuffer*. The idea is that a window can be resized without it being bound to a rendering context. This makes for a nice clean-up in the XFree86 server-side GLX code. Renamed ctx->Driver.ResizeBuffersMESA() to ctx->Driver.ResizeBuffers(). --- src/mesa/swrast/s_accum.c | 36 +++++++-------- src/mesa/swrast/s_accum.h | 9 ++-- src/mesa/swrast/s_alphabuf.c | 103 ++++++++++++++++++------------------------- src/mesa/swrast/s_alphabuf.h | 8 ++-- src/mesa/swrast/s_buffers.c | 20 ++++----- src/mesa/swrast/s_depth.c | 41 ++++++++--------- src/mesa/swrast/s_depth.h | 6 +-- src/mesa/swrast/s_stencil.c | 20 ++++----- src/mesa/swrast/s_stencil.h | 4 +- src/mesa/swrast/swrast.h | 9 ++-- 10 files changed, 120 insertions(+), 136 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c index 167a655f33..faf8313d4d 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 014ca98b94..d46235d5e3 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 2a066aeee7..2b7c4f7de2 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 889a6c94e6..544ae070b1 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 50515415df..d787acfafb 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 a62926cc42..cadb0ecd10 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 610835c10d..2b7e9ddeb4 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 dd438e8dcb..6d62b65fd5 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 3658e9dba6..d15b5d2d4a 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 9359b26dfc..a6c07e5655 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 ); -- cgit v1.2.3