summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2004-11-27 22:47:59 +0000
committerBrian Paul <[email protected]>2004-11-27 22:47:59 +0000
commit65a66f5bc37383c00423c21baf8ba9d6771e0259 (patch)
tree0d98e004b457adde579dd27b9fe32182d54268b6 /src/mesa/drivers
parent118a8bad73bda88fc54f802b2beeb687c8ddb45a (diff)
Remove _mesa_ResizeBuffersMESA() call from _mesa_set_viewport().
Now, the driver's Viewport routine should call _mesa_ResizeBuffersMESA() if necessary. Cleaned up code related to GLframebuffer width/height initialization. Set initial viewport/scissor params in _mesa_make_current2(), instead of in the drivers' MakeCurrent functions.
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/allegro/amesa.c15
-rw-r--r--src/mesa/drivers/beos/GLView.cpp9
-rw-r--r--src/mesa/drivers/dos/dmesa.c17
-rw-r--r--src/mesa/drivers/dri/fb/fb_dri.c14
-rw-r--r--src/mesa/drivers/dri/ffb/ffb_state.c3
-rw-r--r--src/mesa/drivers/dri/ffb/ffb_xmesa.c6
-rw-r--r--src/mesa/drivers/dri/gamma/gamma_state.c3
-rw-r--r--src/mesa/drivers/dri/gamma/gamma_xmesa.c5
-rw-r--r--src/mesa/drivers/dri/i810/i810context.c3
-rw-r--r--src/mesa/drivers/dri/i810/i810state.c3
-rw-r--r--src/mesa/drivers/dri/i830/i830_context.c4
-rw-r--r--src/mesa/drivers/dri/i830/i830_state.c3
-rw-r--r--src/mesa/drivers/dri/i915/intel_context.c3
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_context.c5
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_state.c3
-rw-r--r--src/mesa/drivers/dri/mga/mga_xmesa.c5
-rw-r--r--src/mesa/drivers/dri/mga/mgastate.c3
-rw-r--r--src/mesa/drivers/dri/r128/r128_context.c6
-rw-r--r--src/mesa/drivers/dri/r128/r128_state.c3
-rw-r--r--src/mesa/drivers/dri/r200/r200_context.c5
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_context.c5
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_state.c3
-rw-r--r--src/mesa/drivers/dri/savage/savage_xmesa.c4
-rw-r--r--src/mesa/drivers/dri/savage/savagestate.c3
-rw-r--r--src/mesa/drivers/dri/sis/sis_context.c5
-rw-r--r--src/mesa/drivers/dri/sis/sis_state.c3
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_context.c4
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_state.c3
-rw-r--r--src/mesa/drivers/dri/unichrome/via_context.c3
-rw-r--r--src/mesa/drivers/dri/unichrome/via_state.c3
-rw-r--r--src/mesa/drivers/dri/x11/x11_dri.c5
-rw-r--r--src/mesa/drivers/fbdev/glfbdev.c10
-rw-r--r--src/mesa/drivers/ggi/ggimesa.c18
-rw-r--r--src/mesa/drivers/glide/fxapi.c4
-rw-r--r--src/mesa/drivers/glide/fxdd.c12
-rw-r--r--src/mesa/drivers/svga/svgamesa.c11
-rw-r--r--src/mesa/drivers/windows/gdi/wmesa.c18
-rw-r--r--src/mesa/drivers/x11/xm_dd.c19
38 files changed, 144 insertions, 107 deletions
diff --git a/src/mesa/drivers/allegro/amesa.c b/src/mesa/drivers/allegro/amesa.c
index 92fd1b70683..cb46efa56ac 100644
--- a/src/mesa/drivers/allegro/amesa.c
+++ b/src/mesa/drivers/allegro/amesa.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <allegro.h>
+#include "buffers.h"
#include "context.h"
#include "imports.h"
#include "matrix.h"
@@ -144,6 +145,13 @@ static void get_buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
}
+static void viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ /* poll for window size change and realloc software Z/stencil/etc if needed */
+ _mesa_ResizeBuffersMESA();
+}
+
+
/**********************************************************************/
/**********************************************************************/
@@ -155,8 +163,9 @@ static void setup_dd_pointers(GLcontext *ctx)
/* a new context is made current or we change buffers via set_buffer! */
ctx->Driver.UpdateState = setup_dd_pointers;
- ctx->Driver.SetBuffer = set_buffer;
- ctx->Driver.GetBufferSize = get_buffer_size;
+ ctx->Driver.SetBuffer = set_buffer;
+ ctx->Driver.GetBufferSize = get_buffer_size;
+ ctx->Driver.Viewport = viewport;
ctx->Driver.Color = set_color_generic;
ctx->Driver.ClearColor = clear_color_generic;
@@ -371,9 +380,9 @@ GLboolean AMesaMakeCurrent(AMesaContext context, AMesaBuffer buffer)
setup_dd_pointers(context->GLContext);
_mesa_make_current(context->GLContext, buffer->GLBuffer);
- _mesa_set_viewport(context->GLContext, 0, 0, buffer->Width, buffer->Height);
}
else {
+ /* XXX I don't think you want to destroy anything here! */
destroy_bitmap(context->Buffer->Screen);
context->Buffer->Screen = NULL;
context->Buffer->Active = NULL;
diff --git a/src/mesa/drivers/beos/GLView.cpp b/src/mesa/drivers/beos/GLView.cpp
index 43aa13e7010..45473a8ef27 100644
--- a/src/mesa/drivers/beos/GLView.cpp
+++ b/src/mesa/drivers/beos/GLView.cpp
@@ -153,6 +153,7 @@ private:
GLuint *height);
static void Error(GLcontext *ctx);
static const GLubyte * GetString(GLcontext *ctx, GLenum name);
+ static void Viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
// Front-buffer functions
static void WriteRGBASpanFront(const GLcontext *ctx, GLuint n,
@@ -317,6 +318,7 @@ BGLView::BGLView(BRect rect, char *name,
functions.ClearIndex = md->ClearIndex;
functions.ClearColor = md->ClearColor;
functions.Error = md->Error;
+ functions.Viewport = md->Viewport;
// create core context
GLcontext *ctx = _mesa_create_context(visual, NULL, &functions, md);
@@ -1028,6 +1030,13 @@ void MesaDriver::GetBufferSize(GLframebuffer * framebuffer, GLuint *width,
}
+void MesaDriver::Viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ /* poll for window size change and realloc software Z/stencil/etc if needed */
+ _mesa_ResizeBuffersMESA();
+}
+
+
const GLubyte *MesaDriver::GetString(GLcontext *ctx, GLenum name)
{
switch (name) {
diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c
index 41e0f4d8b31..e0b2cf52b14 100644
--- a/src/mesa/drivers/dos/dmesa.c
+++ b/src/mesa/drivers/dos/dmesa.c
@@ -36,6 +36,7 @@
#include "imports.h"
#ifndef FX
#include "bufferobj.h"
+#include "buffers.h"
#include "extensions.h"
#include "macros.h"
#include "matrix.h"
@@ -812,6 +813,14 @@ get_buffer_size (GLframebuffer *buffer, GLuint *width, GLuint *height)
}
+static void
+viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ /* poll for window size change and realloc software Z/stencil/etc if needed */
+ _mesa_ResizeBuffersMESA();
+}
+
+
static const GLubyte *
get_string (GLcontext *ctx, GLenum name)
{
@@ -898,6 +907,7 @@ dmesa_init_driver_functions (DMesaVisual visual,
driver->UpdateState = dmesa_update_state;
driver->GetString = get_string;
driver->GetBufferSize = get_buffer_size;
+ driver->Viewport = viewport;
driver->Flush = flush;
driver->Finish = finish;
driver->Clear = clear;
@@ -1271,11 +1281,8 @@ DMesaMakeCurrent (DMesaContext c, DMesaBuffer b)
c->buffer = b;
_mesa_make_current((GLcontext *)c, (GLframebuffer *)b);
- if (((GLcontext *)c)->Viewport.Width == 0) {
- /* initialize viewport to window size */
- _mesa_Viewport(0, 0, b->width, b->height);
- }
- } else {
+ }
+ else {
/* Detach */
_mesa_make_current(NULL, NULL);
}
diff --git a/src/mesa/drivers/dri/fb/fb_dri.c b/src/mesa/drivers/dri/fb/fb_dri.c
index 49ae5c98e8d..16540ed0518 100644
--- a/src/mesa/drivers/dri/fb/fb_dri.c
+++ b/src/mesa/drivers/dri/fb/fb_dri.c
@@ -63,6 +63,7 @@
#include "miniglxP.h" /* window-system-specific */
#include "dri_util.h" /* window-system-specific-ish */
+#include "buffers.h"
#include "context.h"
#include "extensions.h"
#include "imports.h"
@@ -133,6 +134,13 @@ get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
}
+static void
+viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ _mesa_ResizeBuffersMESA();
+}
+
+
/* specifies the buffer for swrast span rendering/reading */
static void
set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
@@ -166,6 +174,7 @@ init_core_functions( struct dd_function_table *functions )
functions->UpdateState = update_state;
functions->ResizeBuffers = _swrast_alloc_buffers;
functions->GetBufferSize = get_buffer_size;
+ functions->Viewport = viewport;
functions->Clear = _swrast_Clear; /* could accelerate with blits */
}
@@ -536,11 +545,6 @@ fbMakeCurrent( __DRIcontextPrivate *driContextPriv,
_mesa_make_current2( newFbCtx->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
-
- if ( !newFbCtx->glCtx->Viewport.Width ) {
- _mesa_set_viewport( newFbCtx->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h );
- }
} else {
_mesa_make_current( 0, 0 );
}
diff --git a/src/mesa/drivers/dri/ffb/ffb_state.c b/src/mesa/drivers/dri/ffb/ffb_state.c
index 86f92c83db7..53d56d20436 100644
--- a/src/mesa/drivers/dri/ffb/ffb_state.c
+++ b/src/mesa/drivers/dri/ffb/ffb_state.c
@@ -26,6 +26,7 @@
*/
#include "mtypes.h"
+#include "buffers.h"
#include "colormac.h"
#include "mm.h"
#include "ffb_dd.h"
@@ -444,6 +445,8 @@ void ffbCalcViewport(GLcontext *ctx)
static void ffbDDViewport(GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height)
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
ffbCalcViewport(ctx);
}
diff --git a/src/mesa/drivers/dri/ffb/ffb_xmesa.c b/src/mesa/drivers/dri/ffb/ffb_xmesa.c
index 43c1f346610..4e38d082373 100644
--- a/src/mesa/drivers/dri/ffb/ffb_xmesa.c
+++ b/src/mesa/drivers/dri/ffb/ffb_xmesa.c
@@ -494,12 +494,6 @@ ffbMakeCurrent(__DRIcontextPrivate *driContextPriv,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate);
- if (!fmesa->glCtx->Viewport.Width)
- _mesa_set_viewport(fmesa->glCtx,
- 0, 0,
- driDrawPriv->w,
- driDrawPriv->h);
-
first_time = 0;
if (fmesa->wid == ~0) {
first_time = 1;
diff --git a/src/mesa/drivers/dri/gamma/gamma_state.c b/src/mesa/drivers/dri/gamma/gamma_state.c
index 7beabc69265..29f1a57959f 100644
--- a/src/mesa/drivers/dri/gamma/gamma_state.c
+++ b/src/mesa/drivers/dri/gamma/gamma_state.c
@@ -27,6 +27,7 @@
#include "gamma_context.h"
#include "gamma_macros.h"
+#include "buffers.h"
#include "macros.h"
#include "glint_dri.h"
#include "colormac.h"
@@ -1098,6 +1099,8 @@ void gammaUpdateWindow( GLcontext *ctx )
static void gammaDDViewport( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
gammaUpdateWindow( ctx );
}
diff --git a/src/mesa/drivers/dri/gamma/gamma_xmesa.c b/src/mesa/drivers/dri/gamma/gamma_xmesa.c
index 64ba0d909ac..00f6aa32aeb 100644
--- a/src/mesa/drivers/dri/gamma/gamma_xmesa.c
+++ b/src/mesa/drivers/dri/gamma/gamma_xmesa.c
@@ -225,11 +225,6 @@ newGammaCtx->new_state |= GAMMA_NEW_WINDOW; /* FIXME */
_mesa_make_current2( newGammaCtx->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
-
- if (!newGammaCtx->glCtx->Viewport.Width) {
- _mesa_set_viewport(newGammaCtx->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
- }
} else {
_mesa_make_current( 0, 0 );
}
diff --git a/src/mesa/drivers/dri/i810/i810context.c b/src/mesa/drivers/dri/i810/i810context.c
index 7db354d193f..4443c7eac5c 100644
--- a/src/mesa/drivers/dri/i810/i810context.c
+++ b/src/mesa/drivers/dri/i810/i810context.c
@@ -431,9 +431,6 @@ i810MakeCurrent(__DRIcontextPrivate *driContextPriv,
/* Are these necessary?
*/
i810XMesaWindowMoved( imesa );
- if (!imesa->glCtx->Viewport.Width)
- _mesa_set_viewport(imesa->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
}
else {
_mesa_make_current(0,0);
diff --git a/src/mesa/drivers/dri/i810/i810state.c b/src/mesa/drivers/dri/i810/i810state.c
index 35fad6529c9..42df2e8b9ee 100644
--- a/src/mesa/drivers/dri/i810/i810state.c
+++ b/src/mesa/drivers/dri/i810/i810state.c
@@ -3,6 +3,7 @@
#include <stdio.h>
#include "glheader.h"
+#include "buffers.h"
#include "context.h"
#include "macros.h"
#include "enums.h"
@@ -682,6 +683,8 @@ static void i810Viewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
i810CalcViewport( ctx );
}
diff --git a/src/mesa/drivers/dri/i830/i830_context.c b/src/mesa/drivers/dri/i830/i830_context.c
index 3e6f8a9a1fb..082476f2118 100644
--- a/src/mesa/drivers/dri/i830/i830_context.c
+++ b/src/mesa/drivers/dri/i830/i830_context.c
@@ -530,10 +530,6 @@ GLboolean i830MakeCurrent(__DRIcontextPrivate *driContextPriv,
_mesa_make_current2(imesa->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate);
-
- if (!imesa->glCtx->Viewport.Width)
- _mesa_set_viewport(imesa->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
} else {
_mesa_make_current(0,0);
}
diff --git a/src/mesa/drivers/dri/i830/i830_state.c b/src/mesa/drivers/dri/i830/i830_state.c
index 12cec35c3da..f8979c70187 100644
--- a/src/mesa/drivers/dri/i830/i830_state.c
+++ b/src/mesa/drivers/dri/i830/i830_state.c
@@ -36,6 +36,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "glheader.h"
+#include "buffers.h"
#include "context.h"
#include "macros.h"
#include "enums.h"
@@ -1228,6 +1229,8 @@ static void i830Viewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
i830CalcViewport( ctx );
}
diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c
index 302ddfa840e..1ff7b8be7f4 100644
--- a/src/mesa/drivers/dri/i915/intel_context.c
+++ b/src/mesa/drivers/dri/i915/intel_context.c
@@ -534,9 +534,6 @@ GLboolean intelMakeCurrent(__DRIcontextPrivate *driContextPriv,
_mesa_make_current2(&intel->ctx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate);
-
- if (!intel->ctx.Viewport.Width)
- _mesa_set_viewport(&intel->ctx, 0, 0, driDrawPriv->w, driDrawPriv->h);
} else {
_mesa_make_current(0,0);
}
diff --git a/src/mesa/drivers/dri/mach64/mach64_context.c b/src/mesa/drivers/dri/mach64/mach64_context.c
index 0bbda3a43de..1978c5d6151 100644
--- a/src/mesa/drivers/dri/mach64/mach64_context.c
+++ b/src/mesa/drivers/dri/mach64/mach64_context.c
@@ -312,11 +312,6 @@ mach64MakeCurrent( __DRIcontextPrivate *driContextPriv,
newMach64Ctx->new_state |= MACH64_NEW_CLIP;
-
- if ( !newMach64Ctx->glCtx->Viewport.Width ) {
- _mesa_set_viewport(newMach64Ctx->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
- }
} else {
_mesa_make_current( 0, 0 );
}
diff --git a/src/mesa/drivers/dri/mach64/mach64_state.c b/src/mesa/drivers/dri/mach64/mach64_state.c
index 91f588bb788..ea55124d916 100644
--- a/src/mesa/drivers/dri/mach64/mach64_state.c
+++ b/src/mesa/drivers/dri/mach64/mach64_state.c
@@ -37,6 +37,7 @@
#include "mach64_tex.h"
#include "context.h"
+#include "buffers.h"
#include "enums.h"
#include "colormac.h"
#include "swrast/swrast.h"
@@ -646,6 +647,8 @@ static void mach64Viewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
mach64CalcViewport( ctx );
}
diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c
index 8bed48c423e..6fcef0c4488 100644
--- a/src/mesa/drivers/dri/mga/mga_xmesa.c
+++ b/src/mesa/drivers/dri/mga/mga_xmesa.c
@@ -802,11 +802,6 @@ mgaMakeCurrent(__DRIcontextPrivate *driContextPriv,
_mesa_make_current2(mmesa->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate);
-
- if (!mmesa->glCtx->Viewport.Width)
- _mesa_set_viewport(mmesa->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
-
}
else {
_mesa_make_current(NULL, NULL);
diff --git a/src/mesa/drivers/dri/mga/mgastate.c b/src/mesa/drivers/dri/mga/mgastate.c
index 295d3f5a088..69cc0f33a70 100644
--- a/src/mesa/drivers/dri/mga/mgastate.c
+++ b/src/mesa/drivers/dri/mga/mgastate.c
@@ -28,6 +28,7 @@
#include "mtypes.h"
+#include "buffers.h"
#include "colormac.h"
#include "dd.h"
@@ -695,6 +696,8 @@ static void mgaViewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
mgaCalcViewport( ctx );
}
diff --git a/src/mesa/drivers/dri/r128/r128_context.c b/src/mesa/drivers/dri/r128/r128_context.c
index 287f041a81c..2f417d9097f 100644
--- a/src/mesa/drivers/dri/r128/r128_context.c
+++ b/src/mesa/drivers/dri/r128/r128_context.c
@@ -341,13 +341,7 @@ r128MakeCurrent( __DRIcontextPrivate *driContextPriv,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
-
newR128Ctx->new_state |= R128_NEW_WINDOW | R128_NEW_CLIP;
-
- if ( !newR128Ctx->glCtx->Viewport.Width ) {
- _mesa_set_viewport(newR128Ctx->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
- }
} else {
_mesa_make_current( 0, 0 );
}
diff --git a/src/mesa/drivers/dri/r128/r128_state.c b/src/mesa/drivers/dri/r128/r128_state.c
index 4e43629f49b..320865c67b4 100644
--- a/src/mesa/drivers/dri/r128/r128_state.c
+++ b/src/mesa/drivers/dri/r128/r128_state.c
@@ -41,6 +41,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r128_tex.h"
#include "context.h"
+#include "buffers.h"
#include "enums.h"
#include "colormac.h"
#include "swrast/swrast.h"
@@ -664,6 +665,8 @@ static void r128Viewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
r128CalcViewport( ctx );
}
diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c
index d5d2ce150a5..7bf097b1253 100644
--- a/src/mesa/drivers/dri/r200/r200_context.c
+++ b/src/mesa/drivers/dri/r200/r200_context.c
@@ -624,11 +624,6 @@ r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
- if ( !newCtx->glCtx->Viewport.Width ) {
- _mesa_set_viewport( newCtx->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h );
- }
-
if (newCtx->vb.enabled)
r200VtxfmtMakeCurrent( newCtx->glCtx );
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c
index fc69ec1b5bc..9231697a49e 100644
--- a/src/mesa/drivers/dri/radeon/radeon_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_context.c
@@ -593,11 +593,6 @@ radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
- if ( !newCtx->glCtx->Viewport.Width ) {
- _mesa_set_viewport( newCtx->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h );
- }
-
if (newCtx->vb.enabled)
radeonVtxfmtMakeCurrent( newCtx->glCtx );
diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c
index bc94882a660..851b62035a5 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state.c
@@ -39,6 +39,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "enums.h"
#include "colormac.h"
#include "state.h"
+#include "buffers.h"
#include "context.h"
#include "swrast/swrast.h"
@@ -1451,6 +1452,8 @@ void radeonUpdateWindow( GLcontext *ctx )
static void radeonViewport( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
/* Don't pipeline viewport changes, conflict with window offset
* setting below. Could apply deltas to rescue pipelined viewport
* values, or keep the originals hanging around.
diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c
index adb7f2c82db..a80ffce5d74 100644
--- a/src/mesa/drivers/dri/savage/savage_xmesa.c
+++ b/src/mesa/drivers/dri/savage/savage_xmesa.c
@@ -676,10 +676,6 @@ savageMakeCurrent(__DRIcontextPrivate *driContextPriv,
(GLframebuffer *) driReadPriv->driverPrivate);
savageXMesaWindowMoved( imesa );
-
- if (!imesa->glCtx->Viewport.Width)
- _mesa_set_viewport(imesa->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
}
else
{
diff --git a/src/mesa/drivers/dri/savage/savagestate.c b/src/mesa/drivers/dri/savage/savagestate.c
index c6545fbcca3..75289fcbfd4 100644
--- a/src/mesa/drivers/dri/savage/savagestate.c
+++ b/src/mesa/drivers/dri/savage/savagestate.c
@@ -26,6 +26,7 @@
#include <stdio.h>
#include "mtypes.h"
+#include "buffers.h"
#include "enums.h"
#include "macros.h"
#include "dd.h"
@@ -704,6 +705,8 @@ static void savageViewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
savageCalcViewport( ctx );
}
diff --git a/src/mesa/drivers/dri/sis/sis_context.c b/src/mesa/drivers/dri/sis/sis_context.c
index 0d15bfa5e90..3b23b7df4e5 100644
--- a/src/mesa/drivers/dri/sis/sis_context.c
+++ b/src/mesa/drivers/dri/sis/sis_context.c
@@ -312,11 +312,6 @@ sisMakeCurrent( __DRIcontextPrivate *driContextPriv,
sisUpdateBufferSize( newSisCtx );
sisUpdateClipping( newSisCtx->glCtx );
-
- if ( newSisCtx->glCtx->Viewport.Width == 0 ) {
- _mesa_set_viewport(newSisCtx->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
- }
} else {
_mesa_make_current( 0, 0 );
}
diff --git a/src/mesa/drivers/dri/sis/sis_state.c b/src/mesa/drivers/dri/sis/sis_state.c
index 2cca1611df7..b269d694b0f 100644
--- a/src/mesa/drivers/dri/sis/sis_state.c
+++ b/src/mesa/drivers/dri/sis/sis_state.c
@@ -39,6 +39,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "sis_tex.h"
#include "context.h"
+#include "buffers.h"
#include "enums.h"
#include "colormac.h"
#include "swrast/swrast.h"
@@ -436,6 +437,8 @@ static void sisDDViewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
sisCalcViewport( ctx );
}
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_context.c b/src/mesa/drivers/dri/tdfx/tdfx_context.c
index 56b1e459b74..683c9bd5f24 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_context.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_context.c
@@ -666,10 +666,6 @@ tdfxMakeCurrent( __DRIcontextPrivate *driContextPriv,
_mesa_make_current2( newCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
-
- if ( !newCtx->Viewport.Width ) {
- _mesa_set_viewport( newCtx, 0, 0, driDrawPriv->w, driDrawPriv->h );
- }
} else {
_mesa_make_current( 0, 0 );
}
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_state.c b/src/mesa/drivers/dri/tdfx/tdfx_state.c
index 818a9bc23f4..6edf804b2ec 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_state.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_state.c
@@ -40,6 +40,7 @@
*/
#include "mtypes.h"
+#include "buffers.h"
#include "colormac.h"
#include "texformat.h"
#include "texstore.h"
@@ -902,6 +903,8 @@ static void tdfxDDViewport( GLcontext *ctx, GLint x, GLint y,
GLsizei w, GLsizei h )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
FLUSH_BATCH( fxMesa );
fxMesa->new_state |= TDFX_NEW_VIEWPORT;
}
diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c
index f058424e64d..490f574ad1a 100644
--- a/src/mesa/drivers/dri/unichrome/via_context.c
+++ b/src/mesa/drivers/dri/unichrome/via_context.c
@@ -959,9 +959,6 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
if (VIA_DEBUG) fprintf(stderr, "Context %d MakeCurrent\n", vmesa->hHWContext);
#endif
viaXMesaWindowMoved(vmesa);
- if (!vmesa->glCtx->Viewport.Width)
- _mesa_set_viewport(vmesa->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
}
else {
_mesa_make_current(0,0);
diff --git a/src/mesa/drivers/dri/unichrome/via_state.c b/src/mesa/drivers/dri/unichrome/via_state.c
index 79ce4cbe88d..4c78a3f263e 100644
--- a/src/mesa/drivers/dri/unichrome/via_state.c
+++ b/src/mesa/drivers/dri/unichrome/via_state.c
@@ -25,6 +25,7 @@
#include <stdio.h>
#include "glheader.h"
+#include "buffers.h"
#include "context.h"
#include "macros.h"
#include "colormac.h"
@@ -464,6 +465,8 @@ static void viaViewport(GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height)
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
viaCalcViewport(ctx);
}
diff --git a/src/mesa/drivers/dri/x11/x11_dri.c b/src/mesa/drivers/dri/x11/x11_dri.c
index f7d25271fba..f414b7e424b 100644
--- a/src/mesa/drivers/dri/x11/x11_dri.c
+++ b/src/mesa/drivers/dri/x11/x11_dri.c
@@ -409,11 +409,6 @@ x11MakeCurrent(__DRIcontextPrivate *driContextPriv,
_mesa_make_current2(newFbCtx->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate);
-
- if (!newFbCtx->glCtx->Viewport.Width) {
- _mesa_set_viewport(newFbCtx->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
- }
} else {
_mesa_make_current(0, 0);
}
diff --git a/src/mesa/drivers/fbdev/glfbdev.c b/src/mesa/drivers/fbdev/glfbdev.c
index cfb6a70f60b..9cf0be0e16b 100644
--- a/src/mesa/drivers/fbdev/glfbdev.c
+++ b/src/mesa/drivers/fbdev/glfbdev.c
@@ -45,6 +45,7 @@
#include "glheader.h"
#include <linux/fb.h>
#include "GL/glfbdev.h"
+#include "buffers.h"
#include "context.h"
#include "extensions.h"
#include "imports.h"
@@ -151,6 +152,14 @@ get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
}
+static void
+viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ /* poll for window size change and realloc software Z/stencil/etc if needed */
+ _mesa_ResizeBuffersMESA();
+}
+
+
/* specifies the buffer for swrast span rendering/reading */
static void
set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
@@ -639,6 +648,7 @@ glFBDevCreateContext( const GLFBDevVisualPtr visual, GLFBDevContextPtr share )
functions.GetString = get_string;
functions.UpdateState = update_state;
functions.GetBufferSize = get_buffer_size;
+ functions.Viewport = viewport;
if (!_mesa_initialize_context(&ctx->glcontext, &visual->glvisual,
share ? &share->glcontext : NULL,
diff --git a/src/mesa/drivers/ggi/ggimesa.c b/src/mesa/drivers/ggi/ggimesa.c
index cb34c1a5410..0652d762487 100644
--- a/src/mesa/drivers/ggi/ggimesa.c
+++ b/src/mesa/drivers/ggi/ggimesa.c
@@ -30,6 +30,7 @@
#include <ggi/mesa/ggimesa_int.h>
#include <ggi/mesa/debug.h>
#include "extensions.h"
+#include "buffers.h"
#include "colormac.h"
#include "imports.h"
#include "matrix.h"
@@ -256,6 +257,13 @@ static void gl_ggiGetSize(GLframebuffer *fb, GLuint *width, GLuint *height)
printf("returning %d, %d\n", *width, *height);
}
+static void gl_ggiViewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ /* poll for window size change and realloc software Z/stencil/etc if needed */
+ _mesa_ResizeBuffersMESA();
+}
+
+
static void gl_ggiSetIndex(GLcontext *ctx, GLuint ci)
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
@@ -400,6 +408,7 @@ static void gl_ggiSetupPointers(GLcontext *ctx)
/* General information */
ctx->Driver.GetString = gl_ggiGetString;
ctx->Driver.GetBufferSize = gl_ggiGetSize;
+ ctx->Driver.Viewport = gl_ggiViewport;
ctx->Driver.Finish = gl_ggiFlush;
ctx->Driver.Flush = gl_ggiFlush;
@@ -632,15 +641,6 @@ void ggiMesaMakeCurrent(ggi_mesa_context_t ctx, ggi_visual_t vis)
}
_mesa_make_current(ctx->gl_ctx, &LIBGGI_MESAEXT(vis)->mesa_buffer);
-
- if (ctx->gl_ctx->Viewport.Width == 0)
- {
- _mesa_Viewport(0, 0,
- LIBGGI_VIRTX(vis),
- LIBGGI_VIRTY(vis));
- ctx->gl_ctx->Scissor.Width = LIBGGI_VIRTX(vis);
- ctx->gl_ctx->Scissor.Height = LIBGGI_VIRTY(vis);
- }
}
diff --git a/src/mesa/drivers/glide/fxapi.c b/src/mesa/drivers/glide/fxapi.c
index 708dad51f41..a96709c4fa2 100644
--- a/src/mesa/drivers/glide/fxapi.c
+++ b/src/mesa/drivers/glide/fxapi.c
@@ -873,10 +873,6 @@ fxMesaMakeCurrent(fxMesaContext fxMesa)
_mesa_make_current(fxMesa->glCtx, fxMesa->glBuffer);
fxSetupDDPointers(fxMesa->glCtx);
-
- /* The first time we call MakeCurrent we set the initial viewport size */
- if (fxMesa->glCtx->Viewport.Width == 0)
- _mesa_set_viewport(fxMesa->glCtx, 0, 0, fxMesa->width, fxMesa->height);
}
diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c
index a54bf8fb9c9..e222db951d2 100644
--- a/src/mesa/drivers/glide/fxdd.c
+++ b/src/mesa/drivers/glide/fxdd.c
@@ -43,6 +43,7 @@
#include "image.h"
#include "mtypes.h"
#include "fxdrv.h"
+#include "buffers.h"
#include "enums.h"
#include "extensions.h"
#include "macros.h"
@@ -106,7 +107,7 @@ static void fxDisableColor (fxMesaContext fxMesa)
/* Return buffer size information */
static void
-fxDDBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
+fxDDGetBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
{
GET_CURRENT_CONTEXT(ctx);
if (ctx && FX_CONTEXT(ctx)) {
@@ -121,6 +122,12 @@ fxDDBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
}
}
+static void
+fxDDViewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ /* poll for window size change and realloc software Z/stencil/etc if needed */
+ _mesa_ResizeBuffersMESA();
+}
/* Implements glClearColor() */
static void
@@ -2106,7 +2113,8 @@ fxSetupDDPointers(GLcontext * ctx)
ctx->Driver.ClearColor = fxDDClearColor;
ctx->Driver.Clear = fxDDClear;
ctx->Driver.DrawBuffer = fxDDSetDrawBuffer;
- ctx->Driver.GetBufferSize = fxDDBufferSize;
+ ctx->Driver.GetBufferSize = fxDDGetBufferSize;
+ ctx->Driver.Viewport = fxDDViewport;
switch (fxMesa->colDepth) {
case 15:
ctx->Driver.DrawPixels = fxDDDrawPixels555;
diff --git a/src/mesa/drivers/svga/svgamesa.c b/src/mesa/drivers/svga/svgamesa.c
index 5f636e14afd..980daf30e96 100644
--- a/src/mesa/drivers/svga/svgamesa.c
+++ b/src/mesa/drivers/svga/svgamesa.c
@@ -1,4 +1,4 @@
-/* $Id: svgamesa.c,v 1.23 2002/11/11 18:42:38 brianp Exp $ */
+/* $Id: svgamesa.c,v 1.24 2004/11/27 22:48:00 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -39,6 +39,7 @@
#include <string.h>
#include <vga.h>
#include "GL/svgamesa.h"
+#include "buffers.h"
#include "context.h"
#include "extensions.h"
#include "imports.h"
@@ -212,6 +213,11 @@ static void get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *heigh
*height = SVGAMesa->height = vga_getydim();
}
+static void viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ /* poll for window size change and realloc software Z/stencil/etc if needed */
+ _mesa_ResizeBuffersMESA();
+}
static void set_buffer( GLcontext *ctx, GLframebuffer *colorBuffer,
GLenum buffer )
@@ -258,6 +264,7 @@ static void svgamesa_update_state( GLcontext *ctx, GLuint new_state )
ctx->Driver.GetBufferSize = get_buffer_size;
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
+ ctx->Driver.Viewport = viewport;
/* Software rasterizer pixel paths:
*/
@@ -446,10 +453,8 @@ void SVGAMesaMakeCurrent( SVGAMesaContext ctx )
_mesa_make_current( ctx->gl_ctx, ctx->gl_buffer );
if (ctx->width==0 || ctx->height==0) {
- /* setup initial viewport */
ctx->width = vga_getxdim();
ctx->height = vga_getydim();
- _mesa_set_viewport( ctx->gl_ctx, 0, 0, ctx->width, ctx->height );
}
#endif
}
diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c
index acd5f4a34fb..5d7e260c4b6 100644
--- a/src/mesa/drivers/windows/gdi/wmesa.c
+++ b/src/mesa/drivers/windows/gdi/wmesa.c
@@ -29,6 +29,7 @@
//#include "mesa_extend.h"
#include "glheader.h"
+#include "buffers.h"
#include "colors.h"
#include "context.h"
#include "colormac.h"
@@ -614,7 +615,7 @@ static void set_buffer(GLcontext *ctx, GLframebuffer *colorBuffer,
/* Return characteristics of the output buffer. */
-static void buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
+static void get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
{
/*GET_CURRENT_CONTEXT(ctx);*/
int New_Size;
@@ -658,6 +659,12 @@ static void buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
}
+static void viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ /* poll for window size change and realloc software Z/stencil/etc if needed */
+ _mesa_ResizeBuffersMESA();
+}
+
/**********************************************************************/
/***** Accelerated point, line, polygon rendering *****/
@@ -1094,7 +1101,8 @@ static void SetFunctionPointers( struct dd_function_table *functions )
functions->GetString = get_string;
functions->UpdateState = wmesa_update_state;
functions->ResizeBuffers = _swrast_alloc_buffers;
- functions->GetBufferSize = buffer_size;
+ functions->GetBufferSize = get_buffer_size;
+ functions->Viewport = viewport;
functions->Clear = clear;
@@ -1491,12 +1499,6 @@ void WMesaMakeCurrent( WMesaContext c )
Current = c;
wmesa_update_state(c->gl_ctx, 0);
_mesa_make_current(c->gl_ctx, c->gl_buffer);
- if (Current->gl_ctx->Viewport.Width==0) {
- /* initialize viewport to window size */
- _mesa_Viewport( 0, 0, Current->width, Current->height );
- Current->gl_ctx->Scissor.Width = Current->width;
- Current->gl_ctx->Scissor.Height = Current->height;
- }
if ((c->cColorBits <= 8 ) && (c->rgb_flag == GL_TRUE)){
WMesaPaletteChange(c->hPalHalfTone);
}
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c
index d8f3e22cfc9..4afc81484a0 100644
--- a/src/mesa/drivers/x11/xm_dd.c
+++ b/src/mesa/drivers/x11/xm_dd.c
@@ -25,6 +25,7 @@
#include "glxheader.h"
#include "bufferobj.h"
+#include "buffers.h"
#include "context.h"
#include "colormac.h"
#include "depth.h"
@@ -1203,6 +1204,23 @@ choose_tex_format( GLcontext *ctx, GLint internalFormat,
/**
+ * Called by glViewport.
+ * This is a good time for us to poll the current X window size and adjust
+ * our ancillary (back color, depth, stencil, etc) buffers to match the
+ * current window size. Remember, we have no opportunity to respond to
+ * conventional X Resize/StructureNotify events since the X driver has no
+ * event loop. Thus, we poll.
+ * Note that this trick isn't fool-proof. If the application never calls
+ * glViewport, our notion of the current window size may be incorrect.
+ */
+static void
+xmesa_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ _mesa_ResizeBuffersMESA();
+}
+
+
+/**
* Initialize the device driver function table with the functions
* we implement in this driver.
*/
@@ -1222,6 +1240,7 @@ xmesa_init_driver_functions( XMesaVisual xmvisual,
driver->Enable = enable;
driver->Clear = clear_buffers;
driver->ResizeBuffers = xmesa_resize_buffers;
+ driver->Viewport = xmesa_viewport;
#ifndef XFree86Server
driver->CopyPixels = xmesa_CopyPixels;
if (xmvisual->undithered_pf == PF_8R8G8B &&