summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2002-06-17 23:36:31 +0000
committerBrian Paul <[email protected]>2002-06-17 23:36:31 +0000
commit85d816028a2472e0378afda65e7ab6f7ff4d76b4 (patch)
tree5e5a6d079d835e4410374970db44eaacc99d102b
parentd373819b8cfd0d4d44eaf495dd3ff90d8481572b (diff)
Port glXCopyContext bug from 4.0 branch.
-rw-r--r--src/mesa/main/attrib.c53
-rw-r--r--src/mesa/main/context.c81
-rw-r--r--src/mesa/main/texobj.c39
-rw-r--r--src/mesa/main/texobj.h7
-rw-r--r--src/mesa/main/texstate.c64
-rw-r--r--src/mesa/main/texstate.h10
6 files changed, 183 insertions, 71 deletions
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index fb5fbc8b704..c9ec11311f3 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1,4 +1,4 @@
-/* $Id: attrib.c,v 1.68 2002/06/15 03:03:06 brianp Exp $ */
+/* $Id: attrib.c,v 1.69 2002/06/17 23:36:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -72,42 +72,6 @@ new_attrib_node( GLbitfield kind )
}
-
-/*
- * Copy texture object state from one texture object to another.
- */
-static void
-copy_texobj_state( struct gl_texture_object *dest,
- const struct gl_texture_object *src )
-{
- dest->Name = src->Name;
- /*dest->Target = src->Target*/
- dest->Priority = src->Priority;
- dest->BorderColor[0] = src->BorderColor[0];
- dest->BorderColor[1] = src->BorderColor[1];
- dest->BorderColor[2] = src->BorderColor[2];
- dest->BorderColor[3] = src->BorderColor[3];
- dest->WrapS = src->WrapS;
- dest->WrapT = src->WrapT;
- dest->WrapR = src->WrapR;
- dest->MinFilter = src->MinFilter;
- dest->MagFilter = src->MagFilter;
- dest->MinLod = src->MinLod;
- dest->MaxLod = src->MaxLod;
- dest->BaseLevel = src->BaseLevel;
- dest->MaxLevel = src->MaxLevel;
- dest->MaxAnisotropy = src->MaxAnisotropy;
- dest->CompareFlag = src->CompareFlag;
- dest->CompareOperator = src->CompareOperator;
- dest->ShadowAmbient = src->ShadowAmbient;
- dest->_MaxLevel = src->_MaxLevel;
- dest->_MaxLambda = src->_MaxLambda;
- dest->Palette = src->Palette;
- dest->Complete = src->Complete;
-}
-
-
-
void
_mesa_PushAttrib(GLbitfield mask)
{
@@ -387,11 +351,16 @@ _mesa_PushAttrib(GLbitfield mask)
MEMCPY( attr, &ctx->Texture, sizeof(struct gl_texture_attrib) );
/* copy state of the currently bound texture objects */
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
- copy_texobj_state(&attr->Unit[u].Saved1D, attr->Unit[u].Current1D);
- copy_texobj_state(&attr->Unit[u].Saved2D, attr->Unit[u].Current2D);
- copy_texobj_state(&attr->Unit[u].Saved3D, attr->Unit[u].Current3D);
- copy_texobj_state(&attr->Unit[u].SavedCubeMap, attr->Unit[u].CurrentCubeMap);
- copy_texobj_state(&attr->Unit[u].SavedRect, attr->Unit[u].CurrentRect);
+ _mesa_copy_texture_object(&attr->Unit[u].Saved1D,
+ attr->Unit[u].Current1D);
+ _mesa_copy_texture_object(&attr->Unit[u].Saved2D,
+ attr->Unit[u].Current2D);
+ _mesa_copy_texture_object(&attr->Unit[u].Saved3D,
+ attr->Unit[u].Current3D);
+ _mesa_copy_texture_object(&attr->Unit[u].SavedCubeMap,
+ attr->Unit[u].CurrentCubeMap);
+ _mesa_copy_texture_object(&attr->Unit[u].SavedRect,
+ attr->Unit[u].CurrentRect);
}
newnode = new_attrib_node( GL_TEXTURE_BIT );
newnode->data = attr;
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 6fc70b545a9..c8c6b99b243 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.169 2002/06/16 01:10:41 brianp Exp $ */
+/* $Id: context.c,v 1.170 2002/06/17 23:36:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -49,6 +49,7 @@
#include "state.h"
#include "teximage.h"
#include "texobj.h"
+#include "texstate.h"
#include "mtypes.h"
#include "varray.h"
#include "vpstate.h"
@@ -461,6 +462,8 @@ _mesa_initialize_framebuffer( GLframebuffer *buffer,
assert(buffer);
assert(visual);
+ BZERO(buffer, sizeof(GLframebuffer));
+
/* sanity checks */
if (softwareDepth ) {
assert(visual->depthBits > 0);
@@ -1978,72 +1981,104 @@ void
_mesa_copy_context( const GLcontext *src, GLcontext *dst, GLuint mask )
{
if (mask & GL_ACCUM_BUFFER_BIT) {
- MEMCPY( &dst->Accum, &src->Accum, sizeof(struct gl_accum_attrib) );
+ /* OK to memcpy */
+ dst->Accum = src->Accum;
}
if (mask & GL_COLOR_BUFFER_BIT) {
- MEMCPY( &dst->Color, &src->Color, sizeof(struct gl_colorbuffer_attrib) );
+ /* OK to memcpy */
+ dst->Color = src->Color;
}
if (mask & GL_CURRENT_BIT) {
- MEMCPY( &dst->Current, &src->Current, sizeof(struct gl_current_attrib) );
+ /* OK to memcpy */
+ dst->Current = src->Current;
}
if (mask & GL_DEPTH_BUFFER_BIT) {
- MEMCPY( &dst->Depth, &src->Depth, sizeof(struct gl_depthbuffer_attrib) );
+ /* OK to memcpy */
+ dst->Depth = src->Depth;
}
if (mask & GL_ENABLE_BIT) {
/* no op */
}
if (mask & GL_EVAL_BIT) {
- MEMCPY( &dst->Eval, &src->Eval, sizeof(struct gl_eval_attrib) );
+ /* OK to memcpy */
+ dst->Eval = src->Eval;
}
if (mask & GL_FOG_BIT) {
- MEMCPY( &dst->Fog, &src->Fog, sizeof(struct gl_fog_attrib) );
+ /* OK to memcpy */
+ dst->Fog = src->Fog;
}
if (mask & GL_HINT_BIT) {
- MEMCPY( &dst->Hint, &src->Hint, sizeof(struct gl_hint_attrib) );
+ /* OK to memcpy */
+ dst->Hint = src->Hint;
}
if (mask & GL_LIGHTING_BIT) {
- MEMCPY( &dst->Light, &src->Light, sizeof(struct gl_light_attrib) );
- /* gl_reinit_light_attrib( &dst->Light ); */
+ GLuint i;
+ /* begin with memcpy */
+ MEMCPY( &dst->Light, &src->Light, sizeof(struct gl_light) );
+ /* fixup linked lists to prevent pointer insanity */
+ make_empty_list( &(dst->Light.EnabledList) );
+ for (i = 0; i < MAX_LIGHTS; i++) {
+ if (dst->Light.Light[i].Enabled) {
+ insert_at_tail(&(dst->Light.EnabledList), &(dst->Light.Light[i]));
+ }
+ }
}
if (mask & GL_LINE_BIT) {
- MEMCPY( &dst->Line, &src->Line, sizeof(struct gl_line_attrib) );
+ /* OK to memcpy */
+ dst->Line = src->Line;
}
if (mask & GL_LIST_BIT) {
- MEMCPY( &dst->List, &src->List, sizeof(struct gl_list_attrib) );
+ /* OK to memcpy */
+ dst->List = src->List;
}
if (mask & GL_PIXEL_MODE_BIT) {
- MEMCPY( &dst->Pixel, &src->Pixel, sizeof(struct gl_pixel_attrib) );
+ /* OK to memcpy */
+ dst->Pixel = src->Pixel;
}
if (mask & GL_POINT_BIT) {
- MEMCPY( &dst->Point, &src->Point, sizeof(struct gl_point_attrib) );
+ /* OK to memcpy */
+ dst->Point = src->Point;
}
if (mask & GL_POLYGON_BIT) {
- MEMCPY( &dst->Polygon, &src->Polygon, sizeof(struct gl_polygon_attrib) );
+ /* OK to memcpy */
+ dst->Polygon = src->Polygon;
}
if (mask & GL_POLYGON_STIPPLE_BIT) {
/* Use loop instead of MEMCPY due to problem with Portland Group's
* C compiler. Reported by John Stone.
*/
- int i;
- for (i=0;i<32;i++) {
+ GLuint i;
+ for (i = 0; i < 32; i++) {
dst->PolygonStipple[i] = src->PolygonStipple[i];
}
}
if (mask & GL_SCISSOR_BIT) {
- MEMCPY( &dst->Scissor, &src->Scissor, sizeof(struct gl_scissor_attrib) );
+ /* OK to memcpy */
+ dst->Scissor = src->Scissor;
}
if (mask & GL_STENCIL_BUFFER_BIT) {
- MEMCPY( &dst->Stencil, &src->Stencil, sizeof(struct gl_stencil_attrib) );
+ /* OK to memcpy */
+ dst->Stencil = src->Stencil;
}
if (mask & GL_TEXTURE_BIT) {
- MEMCPY( &dst->Texture, &src->Texture, sizeof(struct gl_texture_attrib) );
+ /* Cannot memcpy because of pointers */
+ _mesa_copy_texture_state(src, dst);
}
if (mask & GL_TRANSFORM_BIT) {
- MEMCPY( &dst->Transform, &src->Transform, sizeof(struct gl_transform_attrib) );
+ /* OK to memcpy */
+ dst->Transform = src->Transform;
}
if (mask & GL_VIEWPORT_BIT) {
- MEMCPY( &dst->Viewport, &src->Viewport, sizeof(struct gl_viewport_attrib) );
+ /* Cannot use memcpy, because of pointers in GLmatrix _WindowMap */
+ dst->Viewport.X = src->Viewport.X;
+ dst->Viewport.Y = src->Viewport.Y;
+ dst->Viewport.Width = src->Viewport.Width;
+ dst->Viewport.Height = src->Viewport.Height;
+ dst->Viewport.Near = src->Viewport.Near;
+ dst->Viewport.Far = src->Viewport.Far;
+ _math_matrix_copy(&dst->Viewport._WindowMap, &src->Viewport._WindowMap);
}
+
/* XXX FIXME: Call callbacks?
*/
dst->NewState = _NEW_ALL;
@@ -2134,7 +2169,7 @@ _mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
newCtx->DrawBuffer = drawBuffer;
newCtx->ReadBuffer = readBuffer;
newCtx->NewState |= _NEW_BUFFERS;
- /* _mesa_update_state( newCtx ); */
+ /* _mesa_update_state( newCtx ); */
}
/* This is only for T&L - a bit out of place, or misnamed (BP) */
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index f41bc13a171..7d4b402d28e 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1,4 +1,4 @@
-/* $Id: texobj.c,v 1.55 2002/06/15 03:03:09 brianp Exp $ */
+/* $Id: texobj.c,v 1.56 2002/06/17 23:36:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -176,6 +176,43 @@ void _mesa_free_texture_object( struct gl_shared_state *shared,
/*
+ * Copy texture object state from one texture object to another.
+ */
+void
+_mesa_copy_texture_object( struct gl_texture_object *dest,
+ const struct gl_texture_object *src )
+{
+ dest->Name = src->Name;
+ dest->Priority = src->Priority;
+ dest->BorderColor[0] = src->BorderColor[0];
+ dest->BorderColor[1] = src->BorderColor[1];
+ dest->BorderColor[2] = src->BorderColor[2];
+ dest->BorderColor[3] = src->BorderColor[3];
+ dest->WrapS = src->WrapS;
+ dest->WrapT = src->WrapT;
+ dest->WrapR = src->WrapR;
+ dest->MinFilter = src->MinFilter;
+ dest->MagFilter = src->MagFilter;
+ dest->MinLod = src->MinLod;
+ dest->MaxLod = src->MaxLod;
+ dest->BaseLevel = src->BaseLevel;
+ dest->MaxLevel = src->MaxLevel;
+ dest->MaxAnisotropy = src->MaxAnisotropy;
+ dest->CompareFlag = src->CompareFlag;
+ dest->CompareOperator = src->CompareOperator;
+ dest->ShadowAmbient = src->ShadowAmbient;
+ dest->CompareMode = src->CompareMode;
+ dest->CompareFunc = src->CompareFunc;
+ dest->DepthMode = src->DepthMode;
+ dest->_MaxLevel = src->_MaxLevel;
+ dest->_MaxLambda = src->_MaxLambda;
+ dest->GenerateMipmap = src->GenerateMipmap;
+ dest->Palette = src->Palette;
+ dest->Complete = src->Complete;
+}
+
+
+/*
* Report why a texture object is incomplete. (for debug only)
*/
#if 0
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index 3257dc761fc..050caff23fd 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -1,4 +1,4 @@
-/* $Id: texobj.h,v 1.7 2002/06/15 03:03:09 brianp Exp $ */
+/* $Id: texobj.h,v 1.8 2002/06/17 23:36:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -48,6 +48,11 @@ _mesa_free_texture_object( struct gl_shared_state *shared,
extern void
+_mesa_copy_texture_object( struct gl_texture_object *dest,
+ const struct gl_texture_object *src );
+
+
+extern void
_mesa_test_texobj_completeness( const GLcontext *ctx,
struct gl_texture_object *t );
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 2284499bf3d..8f4f3631ea7 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -1,4 +1,4 @@
-/* $Id: texstate.c,v 1.75 2002/06/15 03:03:09 brianp Exp $ */
+/* $Id: texstate.c,v 1.76 2002/06/17 23:36:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -56,6 +56,68 @@
+void
+_mesa_copy_texture_state( const GLcontext *src, GLcontext *dst )
+{
+ GLuint i;
+
+ ASSERT(src);
+ ASSERT(dst);
+
+ dst->Texture.CurrentUnit = src->Texture.CurrentUnit;
+ dst->Texture._GenFlags = src->Texture._GenFlags;
+ dst->Texture._TexGenEnabled = src->Texture._TexGenEnabled;
+ dst->Texture._TexMatEnabled = src->Texture._TexMatEnabled;
+ dst->Texture.SharedPalette = src->Texture.SharedPalette;
+
+ /* per-unit state */
+ for (i = 0; i < src->Const.MaxTextureUnits; i++) {
+ dst->Texture.Unit[i].Enabled = src->Texture.Unit[i].Enabled;
+ dst->Texture.Unit[i].EnvMode = src->Texture.Unit[i].EnvMode;
+ COPY_4V(dst->Texture.Unit[i].EnvColor, src->Texture.Unit[i].EnvColor);
+ dst->Texture.Unit[i].TexGenEnabled = src->Texture.Unit[i].TexGenEnabled;
+ dst->Texture.Unit[i].GenModeS = src->Texture.Unit[i].GenModeS;
+ dst->Texture.Unit[i].GenModeT = src->Texture.Unit[i].GenModeT;
+ dst->Texture.Unit[i].GenModeR = src->Texture.Unit[i].GenModeR;
+ dst->Texture.Unit[i].GenModeQ = src->Texture.Unit[i].GenModeQ;
+ dst->Texture.Unit[i]._GenBitS = src->Texture.Unit[i]._GenBitS;
+ dst->Texture.Unit[i]._GenBitT = src->Texture.Unit[i]._GenBitT;
+ dst->Texture.Unit[i]._GenBitR = src->Texture.Unit[i]._GenBitR;
+ dst->Texture.Unit[i]._GenBitQ = src->Texture.Unit[i]._GenBitQ;
+ dst->Texture.Unit[i]._GenFlags = src->Texture.Unit[i]._GenFlags;
+ COPY_4V(dst->Texture.Unit[i].ObjectPlaneS, src->Texture.Unit[i].ObjectPlaneS);
+ COPY_4V(dst->Texture.Unit[i].ObjectPlaneT, src->Texture.Unit[i].ObjectPlaneT);
+ COPY_4V(dst->Texture.Unit[i].ObjectPlaneR, src->Texture.Unit[i].ObjectPlaneR);
+ COPY_4V(dst->Texture.Unit[i].ObjectPlaneQ, src->Texture.Unit[i].ObjectPlaneQ);
+ COPY_4V(dst->Texture.Unit[i].EyePlaneS, src->Texture.Unit[i].EyePlaneS);
+ COPY_4V(dst->Texture.Unit[i].EyePlaneT, src->Texture.Unit[i].EyePlaneT);
+ COPY_4V(dst->Texture.Unit[i].EyePlaneR, src->Texture.Unit[i].EyePlaneR);
+ COPY_4V(dst->Texture.Unit[i].EyePlaneQ, src->Texture.Unit[i].EyePlaneQ);
+ dst->Texture.Unit[i].LodBias = src->Texture.Unit[i].LodBias;
+
+ /* GL_EXT_texture_env_combine */
+ dst->Texture.Unit[i].CombineModeRGB = src->Texture.Unit[i].CombineModeRGB;
+ dst->Texture.Unit[i].CombineModeA = src->Texture.Unit[i].CombineModeA;
+ COPY_3V(dst->Texture.Unit[i].CombineSourceRGB, src->Texture.Unit[i].CombineSourceRGB);
+ COPY_3V(dst->Texture.Unit[i].CombineSourceA, src->Texture.Unit[i].CombineSourceA);
+ COPY_3V(dst->Texture.Unit[i].CombineOperandRGB, src->Texture.Unit[i].CombineOperandRGB);
+ COPY_3V(dst->Texture.Unit[i].CombineOperandA, src->Texture.Unit[i].CombineOperandA);
+ dst->Texture.Unit[i].CombineScaleShiftRGB = src->Texture.Unit[i].CombineScaleShiftRGB;
+ dst->Texture.Unit[i].CombineScaleShiftA = src->Texture.Unit[i].CombineScaleShiftA;
+
+ /* texture object state */
+ _mesa_copy_texture_object(dst->Texture.Unit[i].Current1D,
+ src->Texture.Unit[i].Current1D);
+ _mesa_copy_texture_object(dst->Texture.Unit[i].Current2D,
+ src->Texture.Unit[i].Current2D);
+ _mesa_copy_texture_object(dst->Texture.Unit[i].Current3D,
+ src->Texture.Unit[i].Current3D);
+ _mesa_copy_texture_object(dst->Texture.Unit[i].CurrentCubeMap,
+ src->Texture.Unit[i].CurrentCubeMap);
+ }
+}
+
+
/**********************************************************************/
/* Texture Environment */
/**********************************************************************/
diff --git a/src/mesa/main/texstate.h b/src/mesa/main/texstate.h
index 542fde574c4..6950b211298 100644
--- a/src/mesa/main/texstate.h
+++ b/src/mesa/main/texstate.h
@@ -1,10 +1,10 @@
-/* $Id: texstate.h,v 1.8 2001/06/18 17:26:08 brianp Exp $ */
+/* $Id: texstate.h,v 1.9 2002/06/17 23:36:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 4.1
*
- * 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"),
@@ -32,6 +32,10 @@
#include "mtypes.h"
+extern void
+_mesa_copy_texture_state( const GLcontext *src, GLcontext *dst );
+
+
/*** Called from API ***/
extern void