From a852378a6289d154364dde440f89a39bbfc33e2d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sun, 19 Nov 2000 23:10:25 +0000 Subject: Replaced Texture.CurrentD[] with separate Texture.Current1/2/3D vars. Completely removed the dirty texture object list. Set texObj->Complete to GL_FALSE to indicate dirty. Made point/line/triangle/quad SWvertex parameters const. Minor code clean-ups. --- src/mesa/main/attrib.c | 37 +++++------ src/mesa/main/colortab.c | 32 +++++----- src/mesa/main/context.c | 89 ++++++++++++++++---------- src/mesa/main/get.c | 26 ++++---- src/mesa/main/state.c | 153 ++++++++++++++++++++++---------------------- src/mesa/main/state.h | 5 +- src/mesa/main/teximage.c | 56 ++++++++--------- src/mesa/main/texobj.c | 160 +++++++++++++++++++++++++++-------------------- src/mesa/main/texobj.h | 15 ++--- src/mesa/main/texstate.c | 71 ++------------------- src/mesa/main/texstate.h | 17 +---- 11 files changed, 313 insertions(+), 348 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index b6c5174def..155af4cbbc 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1,4 +1,4 @@ -/* $Id: attrib.c,v 1.34 2000/11/16 21:05:34 keithw Exp $ */ +/* $Id: attrib.c,v 1.35 2000/11/19 23:10:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -350,17 +350,18 @@ _mesa_PushAttrib(GLbitfield mask) GLuint u; /* Take care of texture object reference counters */ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - ctx->Texture.Unit[u].CurrentD[1]->RefCount++; - ctx->Texture.Unit[u].CurrentD[2]->RefCount++; - ctx->Texture.Unit[u].CurrentD[3]->RefCount++; + ctx->Texture.Unit[u].Current1D->RefCount++; + ctx->Texture.Unit[u].Current2D->RefCount++; + ctx->Texture.Unit[u].Current3D->RefCount++; + ctx->Texture.Unit[u].CurrentCubeMap->RefCount++; } attr = MALLOC_STRUCT( gl_texture_attrib ); 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].CurrentD[1]); - copy_texobj_state(&attr->Unit[u].Saved2D, attr->Unit[u].CurrentD[2]); - copy_texobj_state(&attr->Unit[u].Saved3D, attr->Unit[u].CurrentD[3]); + 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); } newnode = new_attrib_node( GL_TEXTURE_BIT ); @@ -811,29 +812,29 @@ _mesa_PopAttrib(void) { GLuint u; for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - ctx->Texture.Unit[u].CurrentD[1]->RefCount--; - ctx->Texture.Unit[u].CurrentD[2]->RefCount--; - ctx->Texture.Unit[u].CurrentD[3]->RefCount--; + ctx->Texture.Unit[u].Current1D->RefCount--; + ctx->Texture.Unit[u].Current2D->RefCount--; + ctx->Texture.Unit[u].Current3D->RefCount--; + ctx->Texture.Unit[u].CurrentCubeMap->RefCount--; } MEMCPY( &ctx->Texture, attr->data, sizeof(struct gl_texture_attrib) ); ctx->NewState |= _NEW_TEXTURE; /* restore state of the currently bound texture objects */ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - copy_texobj_state( ctx->Texture.Unit[u].CurrentD[1], + copy_texobj_state( ctx->Texture.Unit[u].Current1D, &(ctx->Texture.Unit[u].Saved1D) ); - copy_texobj_state( ctx->Texture.Unit[u].CurrentD[2], + copy_texobj_state( ctx->Texture.Unit[u].Current2D, &(ctx->Texture.Unit[u].Saved2D) ); - copy_texobj_state( ctx->Texture.Unit[u].CurrentD[3], + copy_texobj_state( ctx->Texture.Unit[u].Current3D, &(ctx->Texture.Unit[u].Saved3D) ); copy_texobj_state( ctx->Texture.Unit[u].CurrentCubeMap, &(ctx->Texture.Unit[u].SavedCubeMap) ); - gl_put_texobj_on_dirty_list( ctx, ctx->Texture.Unit[u].CurrentD[1] ); - gl_put_texobj_on_dirty_list( ctx, ctx->Texture.Unit[u].CurrentD[2] ); - gl_put_texobj_on_dirty_list( ctx, ctx->Texture.Unit[u].CurrentD[3] ); - gl_put_texobj_on_dirty_list( ctx, ctx->Texture.Unit[u].CurrentCubeMap ); - + ctx->Texture.Unit[u].Current1D->Complete = GL_FALSE; + ctx->Texture.Unit[u].Current2D->Complete = GL_FALSE; + ctx->Texture.Unit[u].Current3D->Complete = GL_FALSE; + ctx->Texture.Unit[u].CurrentCubeMap->Complete = GL_FALSE; } } break; diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c index 64ba6670d7..12c8dbbde7 100644 --- a/src/mesa/main/colortab.c +++ b/src/mesa/main/colortab.c @@ -1,4 +1,4 @@ -/* $Id: colortab.c,v 1.26 2000/11/10 17:45:15 brianp Exp $ */ +/* $Id: colortab.c,v 1.27 2000/11/19 23:10:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -217,15 +217,15 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat, switch (target) { case GL_TEXTURE_1D: - texObj = texUnit->CurrentD[1]; + texObj = texUnit->Current1D; table = &texObj->Palette; break; case GL_TEXTURE_2D: - texObj = texUnit->CurrentD[2]; + texObj = texUnit->Current2D; table = &texObj->Palette; break; case GL_TEXTURE_3D: - texObj = texUnit->CurrentD[3]; + texObj = texUnit->Current3D; table = &texObj->Palette; break; case GL_PROXY_TEXTURE_1D: @@ -458,15 +458,15 @@ _mesa_ColorSubTable( GLenum target, GLsizei start, switch (target) { case GL_TEXTURE_1D: - texObj = texUnit->CurrentD[1]; + texObj = texUnit->Current1D; table = &texObj->Palette; break; case GL_TEXTURE_2D: - texObj = texUnit->CurrentD[2]; + texObj = texUnit->Current2D; table = &texObj->Palette; break; case GL_TEXTURE_3D: - texObj = texUnit->CurrentD[3]; + texObj = texUnit->Current3D; table = &texObj->Palette; break; case GL_SHARED_TEXTURE_PALETTE_EXT: @@ -687,13 +687,13 @@ _mesa_GetColorTable( GLenum target, GLenum format, switch (target) { case GL_TEXTURE_1D: - table = &texUnit->CurrentD[1]->Palette; + table = &texUnit->Current1D->Palette; break; case GL_TEXTURE_2D: - table = &texUnit->CurrentD[2]->Palette; + table = &texUnit->Current2D->Palette; break; case GL_TEXTURE_3D: - table = &texUnit->CurrentD[3]->Palette; + table = &texUnit->Current3D->Palette; break; case GL_SHARED_TEXTURE_PALETTE_EXT: table = &ctx->Texture.Palette; @@ -950,13 +950,13 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) switch (target) { case GL_TEXTURE_1D: - table = &texUnit->CurrentD[1]->Palette; + table = &texUnit->Current1D->Palette; break; case GL_TEXTURE_2D: - table = &texUnit->CurrentD[2]->Palette; + table = &texUnit->Current2D->Palette; break; case GL_TEXTURE_3D: - table = &texUnit->CurrentD[3]->Palette; + table = &texUnit->Current3D->Palette; break; case GL_PROXY_TEXTURE_1D: table = &ctx->Texture.Proxy1D->Palette; @@ -1081,13 +1081,13 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) switch (target) { case GL_TEXTURE_1D: - table = &texUnit->CurrentD[1]->Palette; + table = &texUnit->Current1D->Palette; break; case GL_TEXTURE_2D: - table = &texUnit->CurrentD[2]->Palette; + table = &texUnit->Current2D->Palette; break; case GL_TEXTURE_3D: - table = &texUnit->CurrentD[3]->Palette; + table = &texUnit->Current3D->Palette; break; case GL_PROXY_TEXTURE_1D: table = &ctx->Texture.Proxy1D->Palette; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index c0e75e9298..83c64cc321 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1,4 +1,4 @@ -/* $Id: context.c,v 1.106 2000/11/16 21:05:34 keithw Exp $ */ +/* $Id: context.c,v 1.107 2000/11/19 23:10:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -479,7 +479,6 @@ one_time_init( void ) static struct gl_shared_state * alloc_shared_state( void ) { - GLuint d; struct gl_shared_state *ss; GLboolean outOfMemory; @@ -494,16 +493,32 @@ alloc_shared_state( void ) /* Default Texture objects */ outOfMemory = GL_FALSE; - for (d = 1 ; d <= 3 ; d++) { - ss->DefaultD[d] = gl_alloc_texture_object(ss, 0, d); - if (!ss->DefaultD[d]) { - outOfMemory = GL_TRUE; - break; - } - ss->DefaultD[d]->RefCount++; /* don't free if not in use */ + + ss->Default1D = _mesa_alloc_texture_object(ss, 0, 1); + if (!ss->Default1D) { + outOfMemory = GL_TRUE; + } + else { + ss->Default1D->RefCount++; } - ss->DefaultCubeMap = gl_alloc_texture_object(ss, 0, 6); + ss->Default2D = _mesa_alloc_texture_object(ss, 0, 2); + if (!ss->Default2D) { + outOfMemory = GL_TRUE; + } + else { + ss->Default2D->RefCount++; + } + + ss->Default3D = _mesa_alloc_texture_object(ss, 0, 3); + if (!ss->Default3D) { + outOfMemory = GL_TRUE; + } + else { + ss->Default1D->RefCount++; + } + + ss->DefaultCubeMap = _mesa_alloc_texture_object(ss, 0, 6); if (!ss->DefaultCubeMap) { outOfMemory = GL_TRUE; } @@ -517,14 +532,14 @@ alloc_shared_state( void ) _mesa_DeleteHashTable(ss->DisplayList); if (ss->TexObjects) _mesa_DeleteHashTable(ss->TexObjects); - if (ss->DefaultD[1]) - gl_free_texture_object(ss, ss->DefaultD[1]); - if (ss->DefaultD[2]) - gl_free_texture_object(ss, ss->DefaultD[2]); - if (ss->DefaultD[3]) - gl_free_texture_object(ss, ss->DefaultD[3]); + if (ss->Default1D) + _mesa_free_texture_object(ss, ss->Default1D); + if (ss->Default2D) + _mesa_free_texture_object(ss, ss->Default2D); + if (ss->Default3D) + _mesa_free_texture_object(ss, ss->Default3D); if (ss->DefaultCubeMap) - gl_free_texture_object(ss, ss->DefaultCubeMap); + _mesa_free_texture_object(ss, ss->DefaultCubeMap); FREE(ss); return NULL; } @@ -558,7 +573,7 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) if (ctx->Driver.DeleteTexture) (*ctx->Driver.DeleteTexture)( ctx, ss->TexObjectList ); /* this function removes from linked list too! */ - gl_free_texture_object(ss, ss->TexObjectList); + _mesa_free_texture_object(ss, ss->TexObjectList); } _mesa_DeleteHashTable(ss->TexObjects); @@ -668,9 +683,9 @@ init_texture_unit( GLcontext *ctx, GLuint unit ) ASSIGN_4V( texUnit->EyePlaneR, 0.0, 0.0, 0.0, 0.0 ); ASSIGN_4V( texUnit->EyePlaneQ, 0.0, 0.0, 0.0, 0.0 ); - texUnit->CurrentD[1] = ctx->Shared->DefaultD[1]; - texUnit->CurrentD[2] = ctx->Shared->DefaultD[2]; - texUnit->CurrentD[3] = ctx->Shared->DefaultD[3]; + texUnit->Current1D = ctx->Shared->Default1D; + texUnit->Current2D = ctx->Shared->Default2D; + texUnit->Current3D = ctx->Shared->Default3D; texUnit->CurrentCubeMap = ctx->Shared->DefaultCubeMap; } @@ -1352,21 +1367,29 @@ alloc_proxy_textures( GLcontext *ctx ) GLboolean out_of_memory; GLint i; - ctx->Texture.Proxy1D = gl_alloc_texture_object(NULL, 0, 1); + ctx->Texture.Proxy1D = _mesa_alloc_texture_object(NULL, 0, 1); if (!ctx->Texture.Proxy1D) { return GL_FALSE; } - ctx->Texture.Proxy2D = gl_alloc_texture_object(NULL, 0, 2); + ctx->Texture.Proxy2D = _mesa_alloc_texture_object(NULL, 0, 2); if (!ctx->Texture.Proxy2D) { - gl_free_texture_object(NULL, ctx->Texture.Proxy1D); + _mesa_free_texture_object(NULL, ctx->Texture.Proxy1D); return GL_FALSE; } - ctx->Texture.Proxy3D = gl_alloc_texture_object(NULL, 0, 3); + ctx->Texture.Proxy3D = _mesa_alloc_texture_object(NULL, 0, 3); if (!ctx->Texture.Proxy3D) { - gl_free_texture_object(NULL, ctx->Texture.Proxy1D); - gl_free_texture_object(NULL, ctx->Texture.Proxy2D); + _mesa_free_texture_object(NULL, ctx->Texture.Proxy1D); + _mesa_free_texture_object(NULL, ctx->Texture.Proxy2D); + return GL_FALSE; + } + + ctx->Texture.ProxyCubeMap = _mesa_alloc_texture_object(NULL, 0, 6); + if (!ctx->Texture.ProxyCubeMap) { + _mesa_free_texture_object(NULL, ctx->Texture.Proxy1D); + _mesa_free_texture_object(NULL, ctx->Texture.Proxy2D); + _mesa_free_texture_object(NULL, ctx->Texture.Proxy3D); return GL_FALSE; } @@ -1393,9 +1416,9 @@ alloc_proxy_textures( GLcontext *ctx ) _mesa_free_texture_image(ctx->Texture.Proxy3D->Image[i]); } } - gl_free_texture_object(NULL, ctx->Texture.Proxy1D); - gl_free_texture_object(NULL, ctx->Texture.Proxy2D); - gl_free_texture_object(NULL, ctx->Texture.Proxy3D); + _mesa_free_texture_object(NULL, ctx->Texture.Proxy1D); + _mesa_free_texture_object(NULL, ctx->Texture.Proxy2D); + _mesa_free_texture_object(NULL, ctx->Texture.Proxy3D); return GL_FALSE; } else { @@ -1609,9 +1632,9 @@ _mesa_free_context_data( GLcontext *ctx ) FREE( ctx->_ShineTabList ); /* Free proxy texture objects */ - gl_free_texture_object( NULL, ctx->Texture.Proxy1D ); - gl_free_texture_object( NULL, ctx->Texture.Proxy2D ); - gl_free_texture_object( NULL, ctx->Texture.Proxy3D ); + _mesa_free_texture_object( NULL, ctx->Texture.Proxy1D ); + _mesa_free_texture_object( NULL, ctx->Texture.Proxy2D ); + _mesa_free_texture_object( NULL, ctx->Texture.Proxy3D ); /* Free evaluator data */ if (ctx->EvalMap.Map1Vertex3.Points) diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 980269d854..b373f70107 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1,4 +1,4 @@ -/* $Id: get.c,v 1.41 2000/11/16 21:05:35 keithw Exp $ */ +/* $Id: get.c,v 1.42 2000/11/19 23:10:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -811,13 +811,13 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) *params = _mesa_IsEnabled(GL_TEXTURE_3D); break; case GL_TEXTURE_BINDING_1D: - *params = INT_TO_BOOL(textureUnit->CurrentD[1]->Name); + *params = INT_TO_BOOL(textureUnit->Current1D->Name); break; case GL_TEXTURE_BINDING_2D: - *params = INT_TO_BOOL(textureUnit->CurrentD[2]->Name); + *params = INT_TO_BOOL(textureUnit->Current2D->Name); break; case GL_TEXTURE_BINDING_3D: - *params = INT_TO_BOOL(textureUnit->CurrentD[3]->Name); + *params = INT_TO_BOOL(textureUnit->Current3D->Name); break; case GL_TEXTURE_ENV_COLOR: { @@ -2009,13 +2009,13 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) *params = _mesa_IsEnabled(GL_TEXTURE_3D) ? 1.0 : 0.0; break; case GL_TEXTURE_BINDING_1D: - *params = (GLdouble) textureUnit->CurrentD[1]->Name; + *params = (GLdouble) textureUnit->Current1D->Name; break; case GL_TEXTURE_BINDING_2D: - *params = (GLdouble) textureUnit->CurrentD[2]->Name; + *params = (GLdouble) textureUnit->Current2D->Name; break; case GL_TEXTURE_BINDING_3D: - *params = (GLdouble) textureUnit->CurrentD[3]->Name; + *params = (GLdouble) textureUnit->Current3D->Name; break; case GL_TEXTURE_ENV_COLOR: params[0] = (GLdouble) textureUnit->EnvColor[0]; @@ -3210,13 +3210,13 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) *params = _mesa_IsEnabled(GL_TEXTURE_3D) ? 1.0 : 0.0; break; case GL_TEXTURE_BINDING_1D: - *params = (GLfloat) textureUnit->CurrentD[1]->Name; + *params = (GLfloat) textureUnit->Current1D->Name; break; case GL_TEXTURE_BINDING_2D: - *params = (GLfloat) textureUnit->CurrentD[2]->Name; + *params = (GLfloat) textureUnit->Current2D->Name; break; case GL_TEXTURE_BINDING_3D: - *params = (GLfloat) textureUnit->CurrentD[2]->Name; + *params = (GLfloat) textureUnit->Current2D->Name; break; case GL_TEXTURE_ENV_COLOR: params[0] = textureUnit->EnvColor[0]; @@ -4383,13 +4383,13 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) *params = _mesa_IsEnabled(GL_TEXTURE_3D) ? 1 : 0; break; case GL_TEXTURE_BINDING_1D: - *params = textureUnit->CurrentD[1]->Name; + *params = textureUnit->Current1D->Name; break; case GL_TEXTURE_BINDING_2D: - *params = textureUnit->CurrentD[2]->Name; + *params = textureUnit->Current2D->Name; break; case GL_TEXTURE_BINDING_3D: - *params = textureUnit->CurrentD[3]->Name; + *params = textureUnit->Current3D->Name; break; case GL_TEXTURE_ENV_COLOR: params[0] = FLOAT_TO_INT( textureUnit->EnvColor[0] ); diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index d1dde8c88e..2439655143 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -1,4 +1,4 @@ -/* $Id: state.c,v 1.45 2000/11/16 21:05:35 keithw Exp $ */ +/* $Id: state.c,v 1.46 2000/11/19 23:10:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -692,7 +692,7 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) static void -_mesa_update_polygon( GLcontext *ctx ) +update_polygon( GLcontext *ctx ) { ctx->_TriangleCaps &= ~DD_TRI_CULL_FRONT_BACK; @@ -726,7 +726,7 @@ _mesa_update_polygon( GLcontext *ctx ) } static void -_mesa_calculate_model_project_matrix( GLcontext *ctx ) +calculate_model_project_matrix( GLcontext *ctx ) { if (!ctx->_NeedEyeCoords) { _math_matrix_mul_matrix( &ctx->_ModelProjectMatrix, @@ -738,7 +738,7 @@ _mesa_calculate_model_project_matrix( GLcontext *ctx ) } static void -_mesa_update_modelview_scale( GLcontext *ctx ) +update_modelview_scale( GLcontext *ctx ) { ctx->_ModelViewInvScale = 1.0F; if (ctx->ModelView.flags & (MAT_FLAG_UNIFORM_SCALE | @@ -759,34 +759,32 @@ _mesa_update_modelview_scale( GLcontext *ctx ) /* Bring uptodate any state that relies on _NeedEyeCoords. */ static void -_mesa_update_tnl_spaces( GLcontext *ctx, GLuint oldneedeyecoords ) +update_tnl_spaces( GLcontext *ctx, GLuint oldneedeyecoords ) { /* Check if the truth-value interpretations of the bitfields have * changed: */ - if ((oldneedeyecoords == 0) != (ctx->_NeedEyeCoords == 0)) - { + if ((oldneedeyecoords == 0) != (ctx->_NeedEyeCoords == 0)) { /* Recalculate all state that depends on _NeedEyeCoords. */ - _mesa_update_modelview_scale(ctx); - _mesa_calculate_model_project_matrix(ctx); + update_modelview_scale(ctx); + calculate_model_project_matrix(ctx); gl_compute_light_positions( ctx ); if (ctx->Driver.LightingSpaceChange) ctx->Driver.LightingSpaceChange( ctx ); } - else - { + else { GLuint new_state = ctx->NewState; /* Recalculate that same state if and only if it has been * invalidated by other statechanges. */ if (new_state & _NEW_MODELVIEW) - _mesa_update_modelview_scale(ctx); + update_modelview_scale(ctx); if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION)) - _mesa_calculate_model_project_matrix(ctx); + calculate_model_project_matrix(ctx); if (new_state & (_NEW_LIGHT|_NEW_MODELVIEW)) gl_compute_light_positions( ctx ); @@ -795,7 +793,7 @@ _mesa_update_tnl_spaces( GLcontext *ctx, GLuint oldneedeyecoords ) static void -_mesa_update_drawbuffer( GLcontext *ctx ) +update_drawbuffer( GLcontext *ctx ) { ctx->DrawBuffer->_Xmin = 0; ctx->DrawBuffer->_Ymin = 0; @@ -824,7 +822,7 @@ _mesa_update_drawbuffer( GLcontext *ctx ) * uptodate across changes to the Transform attributes. */ static void -_mesa_update_projection( GLcontext *ctx ) +update_projection( GLcontext *ctx ) { _math_matrix_analyze( &ctx->ProjectionMatrix ); @@ -845,6 +843,61 @@ _mesa_update_projection( GLcontext *ctx ) +/* + * Return a bitmask of IMAGE_*_BIT flags which to indicate which + * pixel transfer operations are enabled. + */ +static void +update_image_transfer_state(GLcontext *ctx) +{ + GLuint mask = 0; + + if (ctx->Pixel.RedScale != 1.0F || ctx->Pixel.RedBias != 0.0F || + ctx->Pixel.GreenScale != 1.0F || ctx->Pixel.GreenBias != 0.0F || + ctx->Pixel.BlueScale != 1.0F || ctx->Pixel.BlueBias != 0.0F || + ctx->Pixel.AlphaScale != 1.0F || ctx->Pixel.AlphaBias != 0.0F) + mask |= IMAGE_SCALE_BIAS_BIT; + + if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) + mask |= IMAGE_SHIFT_OFFSET_BIT; + + if (ctx->Pixel.MapColorFlag) + mask |= IMAGE_MAP_COLOR_BIT; + + if (ctx->Pixel.ColorTableEnabled) + mask |= IMAGE_COLOR_TABLE_BIT; + + if (ctx->Pixel.Convolution1DEnabled || + ctx->Pixel.Convolution2DEnabled || + ctx->Pixel.Separable2DEnabled) + mask |= IMAGE_CONVOLUTION_BIT; + + if (ctx->Pixel.PostConvolutionColorTableEnabled) + mask |= IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT; + + if (ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.PostColorMatrixScale[0] != 1.0F || + ctx->Pixel.PostColorMatrixBias[0] != 0.0F || + ctx->Pixel.PostColorMatrixScale[1] != 1.0F || + ctx->Pixel.PostColorMatrixBias[1] != 0.0F || + ctx->Pixel.PostColorMatrixScale[2] != 1.0F || + ctx->Pixel.PostColorMatrixBias[2] != 0.0F || + ctx->Pixel.PostColorMatrixScale[3] != 1.0F || + ctx->Pixel.PostColorMatrixBias[3] != 0.0F) + mask |= IMAGE_COLOR_MATRIX_BIT; + + if (ctx->Pixel.PostColorMatrixColorTableEnabled) + mask |= IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT; + + if (ctx->Pixel.HistogramEnabled) + mask |= IMAGE_HISTOGRAM_BIT; + + if (ctx->Pixel.MinMaxEnabled) + mask |= IMAGE_MIN_MAX_BIT; + + ctx->_ImageTransferState = mask; +} + /* * If ctx->NewState is non-zero then this function MUST be called before @@ -871,7 +924,7 @@ void gl_update_state( GLcontext *ctx ) _math_matrix_analyze( &ctx->ModelView ); if (new_state & _NEW_PROJECTION) - _mesa_update_projection( ctx ); + update_projection( ctx ); if (new_state & _NEW_TEXTURE_MATRIX) _mesa_update_texture_matrices( ctx ); @@ -882,18 +935,18 @@ void gl_update_state( GLcontext *ctx ) /* References ColorMatrix.type (derived above). */ if (new_state & (_NEW_PIXEL|_NEW_COLOR_MATRIX)) - _mesa_update_image_transfer_state(ctx); + update_image_transfer_state(ctx); /* Contributes to NeedEyeCoords, NeedNormals. */ if (new_state & _NEW_TEXTURE) - _mesa_update_textures( ctx ); + _mesa_update_texture_state( ctx ); if (new_state & (_NEW_BUFFERS|_NEW_SCISSOR)) - _mesa_update_drawbuffer( ctx ); + update_drawbuffer( ctx ); if (new_state & _NEW_POLYGON) - _mesa_update_polygon( ctx ); + update_polygon( ctx ); /* Contributes to NeedEyeCoords, NeedNormals. */ @@ -924,7 +977,7 @@ void gl_update_state( GLcontext *ctx ) _TNL_NEW_NORMAL_TRANSFORM | _NEW_LIGHT | _TNL_NEW_NEED_EYE_COORDS)) - _mesa_update_tnl_spaces( ctx, oldneedeyecoords ); + update_tnl_spaces( ctx, oldneedeyecoords ); /* * Here the driver sets up all the ctx->Driver function pointers @@ -935,61 +988,3 @@ void gl_update_state( GLcontext *ctx ) ctx->Driver.UpdateState(ctx); ctx->NewState = 0; } - - - - -/* - * Return a bitmask of IMAGE_*_BIT flags which to indicate which - * pixel transfer operations are enabled. - */ -void -_mesa_update_image_transfer_state(GLcontext *ctx) -{ - GLuint mask = 0; - - if (ctx->Pixel.RedScale != 1.0F || ctx->Pixel.RedBias != 0.0F || - ctx->Pixel.GreenScale != 1.0F || ctx->Pixel.GreenBias != 0.0F || - ctx->Pixel.BlueScale != 1.0F || ctx->Pixel.BlueBias != 0.0F || - ctx->Pixel.AlphaScale != 1.0F || ctx->Pixel.AlphaBias != 0.0F) - mask |= IMAGE_SCALE_BIAS_BIT; - - if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) - mask |= IMAGE_SHIFT_OFFSET_BIT; - - if (ctx->Pixel.MapColorFlag) - mask |= IMAGE_MAP_COLOR_BIT; - - if (ctx->Pixel.ColorTableEnabled) - mask |= IMAGE_COLOR_TABLE_BIT; - - if (ctx->Pixel.Convolution1DEnabled || - ctx->Pixel.Convolution2DEnabled || - ctx->Pixel.Separable2DEnabled) - mask |= IMAGE_CONVOLUTION_BIT; - - if (ctx->Pixel.PostConvolutionColorTableEnabled) - mask |= IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT; - - if (ctx->ColorMatrix.type != MATRIX_IDENTITY || - ctx->Pixel.PostColorMatrixScale[0] != 1.0F || - ctx->Pixel.PostColorMatrixBias[0] != 0.0F || - ctx->Pixel.PostColorMatrixScale[1] != 1.0F || - ctx->Pixel.PostColorMatrixBias[1] != 0.0F || - ctx->Pixel.PostColorMatrixScale[2] != 1.0F || - ctx->Pixel.PostColorMatrixBias[2] != 0.0F || - ctx->Pixel.PostColorMatrixScale[3] != 1.0F || - ctx->Pixel.PostColorMatrixBias[3] != 0.0F) - mask |= IMAGE_COLOR_MATRIX_BIT; - - if (ctx->Pixel.PostColorMatrixColorTableEnabled) - mask |= IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT; - - if (ctx->Pixel.HistogramEnabled) - mask |= IMAGE_HISTOGRAM_BIT; - - if (ctx->Pixel.MinMaxEnabled) - mask |= IMAGE_MIN_MAX_BIT; - - ctx->_ImageTransferState = mask; -} diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h index 640c21dc7c..cd1a78f226 100644 --- a/src/mesa/main/state.h +++ b/src/mesa/main/state.h @@ -1,4 +1,4 @@ -/* $Id: state.h,v 1.3 2000/08/21 14:22:24 brianp Exp $ */ +/* $Id: state.h,v 1.4 2000/11/19 23:10:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -46,8 +46,5 @@ gl_print_state( const char *msg, GLuint state ); extern void gl_print_enable_flags( const char *msg, GLuint flags ); -extern void -_mesa_update_image_transfer_state(GLcontext *ctx); - #endif diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 0eab5dfa50..6ef5554b6f 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1,4 +1,4 @@ -/* $Id: teximage.c,v 1.62 2000/11/13 15:25:26 brianp Exp $ */ +/* $Id: teximage.c,v 1.63 2000/11/19 23:10:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -544,15 +544,15 @@ _mesa_select_tex_object(GLcontext *ctx, const struct gl_texture_unit *texUnit, { switch (target) { case GL_TEXTURE_1D: - return texUnit->CurrentD[1]; + return texUnit->Current1D; case GL_PROXY_TEXTURE_1D: return ctx->Texture.Proxy1D; case GL_TEXTURE_2D: - return texUnit->CurrentD[2]; + return texUnit->Current2D; case GL_PROXY_TEXTURE_2D: return ctx->Texture.Proxy2D; case GL_TEXTURE_3D: - return texUnit->CurrentD[3]; + return texUnit->Current3D; case GL_PROXY_TEXTURE_3D: return ctx->Texture.Proxy3D; case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: @@ -584,15 +584,15 @@ _mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit, ASSERT(texUnit); switch (target) { case GL_TEXTURE_1D: - return texUnit->CurrentD[1]->Image[level]; + return texUnit->Current1D->Image[level]; case GL_PROXY_TEXTURE_1D: return ctx->Texture.Proxy1D->Image[level]; case GL_TEXTURE_2D: - return texUnit->CurrentD[2]->Image[level]; + return texUnit->Current2D->Image[level]; case GL_PROXY_TEXTURE_2D: return ctx->Texture.Proxy2D->Image[level]; case GL_TEXTURE_3D: - return texUnit->CurrentD[3]->Image[level]; + return texUnit->Current3D->Image[level]; case GL_PROXY_TEXTURE_3D: return ctx->Texture.Proxy3D->Image[level]; case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: @@ -1247,7 +1247,7 @@ subtexture_error_check( GLcontext *ctx, GLuint dimensions, return GL_TRUE; } - destTex = texUnit->CurrentD[2]->Image[level]; + destTex = texUnit->Current2D->Image[level]; if (!destTex) { gl_error(ctx, GL_INVALID_OPERATION, "glTexSubImage2D"); return GL_TRUE; @@ -1442,7 +1442,7 @@ copytexsubimage_error_check( GLcontext *ctx, GLuint dimensions, return GL_TRUE; } - teximage = texUnit->CurrentD[dimensions]->Image[level]; + teximage = _mesa_select_tex_image(ctx, texUnit, target, level); if (!teximage) { char message[100]; sprintf(message, "glCopyTexSubImage%dD(undefined texture)", dimensions); @@ -1639,7 +1639,7 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, } texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - texObj = texUnit->CurrentD[1]; + texObj = texUnit->Current1D; texImage = texObj->Image[level]; if (!texImage) { @@ -1700,7 +1700,7 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, } /* state update */ - gl_put_texobj_on_dirty_list( ctx, texObj ); + texObj->Complete = GL_FALSE; ctx->NewState |= _NEW_TEXTURE; } else if (target == GL_PROXY_TEXTURE_1D) { @@ -1839,7 +1839,7 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, } /* state update */ - gl_put_texobj_on_dirty_list( ctx, texObj ); + texObj->Complete = GL_FALSE; ctx->NewState |= _NEW_TEXTURE; } else if (target == GL_PROXY_TEXTURE_2D) { @@ -1911,7 +1911,7 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, } texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - texObj = texUnit->CurrentD[3]; + texObj = texUnit->Current3D; texImage = texObj->Image[level]; if (!texImage) { @@ -1973,7 +1973,7 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, } /* state update */ - gl_put_texobj_on_dirty_list( ctx, texObj ); + texObj->Complete = GL_FALSE; ctx->NewState |= _NEW_TEXTURE; } else if (target == GL_PROXY_TEXTURE_3D) { @@ -2403,7 +2403,7 @@ _mesa_TexSubImage1D( GLenum target, GLint level, } texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - texObj = texUnit->CurrentD[1]; + texObj = texUnit->Current1D; texImage = texObj->Image[level]; assert(texImage); @@ -2544,7 +2544,7 @@ _mesa_TexSubImage3D( GLenum target, GLint level, } texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - texObj = texUnit->CurrentD[3]; + texObj = texUnit->Current3D; texImage = texObj->Image[level]; assert(texImage); @@ -2741,7 +2741,7 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level, GLchan *image; texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - teximage = texUnit->CurrentD[1]->Image[level]; + teximage = texUnit->Current1D->Image[level]; assert(teximage); /* get image from frame buffer */ @@ -2788,7 +2788,7 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level, GLchan *image; texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - teximage = texUnit->CurrentD[2]->Image[level]; + teximage = texUnit->Current2D->Image[level]; assert(teximage); /* get image from frame buffer */ @@ -2835,7 +2835,7 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level, GLchan *image; texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - teximage = texUnit->CurrentD[3]->Image[level]; + teximage = texUnit->Current3D->Image[level]; assert(teximage); /* get image from frame buffer */ @@ -2893,7 +2893,7 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level, } texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - texObj = texUnit->CurrentD[1]; + texObj = texUnit->Current1D; texImage = texObj->Image[level]; if (!texImage) { @@ -2954,7 +2954,7 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level, } /* state update */ - gl_put_texobj_on_dirty_list( ctx, texObj ); + texObj->Complete = GL_FALSE; ctx->NewState |= _NEW_TEXTURE; } else if (target == GL_PROXY_TEXTURE_1D) { @@ -3023,7 +3023,7 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level, } texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - texObj = texUnit->CurrentD[2]; + texObj = texUnit->Current2D; texImage = texObj->Image[level]; if (!texImage) { @@ -3089,7 +3089,7 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level, } /* state update */ - gl_put_texobj_on_dirty_list( ctx, texObj ); + texObj->Complete = GL_FALSE; ctx->NewState |= _NEW_TEXTURE; } else if (target == GL_PROXY_TEXTURE_2D) { @@ -3155,7 +3155,7 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level, } texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - texObj = texUnit->CurrentD[3]; + texObj = texUnit->Current3D; texImage = texObj->Image[level]; if (!texImage) { @@ -3218,7 +3218,7 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level, } /* state update */ - gl_put_texobj_on_dirty_list( ctx, texObj ); + texObj->Complete = GL_FALSE; ctx->NewState |= _NEW_TEXTURE; } else if (target == GL_PROXY_TEXTURE_3D) { @@ -3377,11 +3377,11 @@ _mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img) switch (target) { case GL_TEXTURE_1D: - texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentD[1]; + texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current1D; texImage = texObj->Image[level]; break; case GL_TEXTURE_2D: - texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentD[2]; + texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current2D; texImage = texObj->Image[level]; break; case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: @@ -3409,7 +3409,7 @@ _mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img) texImage = texObj->NegZ[level]; break; case GL_TEXTURE_3D: - texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentD[3]; + texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current3D; texImage = texObj->Image[level]; break; default: diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 18f942fa8e..f0372237ca 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -1,4 +1,4 @@ -/* $Id: texobj.c,v 1.33 2000/11/11 20:23:47 brianp Exp $ */ +/* $Id: texobj.c,v 1.34 2000/11/19 23:10:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -50,11 +50,12 @@ * Input: shared - the shared GL state structure to contain the texture object * name - integer name for the texture object * dimensions - either 1, 2, 3 or 6 (cube map) + * zero is ok for the sake of GenTextures() * Return: pointer to new texture object */ struct gl_texture_object * -gl_alloc_texture_object( struct gl_shared_state *shared, GLuint name, - GLuint dimensions) +_mesa_alloc_texture_object( struct gl_shared_state *shared, GLuint name, + GLuint dimensions) { struct gl_texture_object *obj; @@ -103,19 +104,13 @@ gl_alloc_texture_object( struct gl_shared_state *shared, GLuint name, * Input: shared - the shared GL state to which the object belongs * t - the texture object to delete */ -void gl_free_texture_object( struct gl_shared_state *shared, - struct gl_texture_object *t ) +void _mesa_free_texture_object( struct gl_shared_state *shared, + struct gl_texture_object *t ) { struct gl_texture_object *tprev, *tcurr; assert(t); - /* Remove t from dirty list so we don't touch free'd memory later. - * Test for shared since Proxy texture aren't in global linked list. - */ - if (shared) - gl_remove_texobj_from_dirty_list( shared, t ); - /* unlink t from the linked list */ if (shared) { _glthread_LOCK_MUTEX(shared->Mutex); @@ -144,7 +139,7 @@ void gl_free_texture_object( struct gl_shared_state *shared, _mesa_free_colortable_data(&t->Palette); - /* free texture images */ + /* free the texture images */ { GLuint i; for (i=0;iComplete flag will be set to GL_TRUE or GL_FALSE accordingly. */ void @@ -180,7 +180,7 @@ _mesa_test_texobj_completeness( const GLcontext *ctx, t->Complete = GL_TRUE; /* be optimistic */ - /* Always need level zero image */ + /* Always need the base level image */ if (!t->Image[baseLevel]) { incomplete(t, "Image[baseLevel] == NULL"); t->Complete = GL_FALSE; @@ -207,7 +207,7 @@ _mesa_test_texobj_completeness( const GLcontext *ctx, if (t->Dimensions == 6) { - /* make sure all six level 0 images are same size */ + /* make sure that all six cube map level 0 images are the same size */ const GLint w = t->Image[baseLevel]->Width2; const GLint h = t->Image[baseLevel]->Height2; if (!t->NegX[baseLevel] || @@ -444,7 +444,7 @@ _mesa_GenTextures( GLsizei n, GLuint *texName ) for (i=0;iShared, name, dims); + (void) _mesa_alloc_texture_object(ctx->Shared, name, dims); } _glthread_UNLOCK_MUTEX(GenTexturesLock); @@ -467,36 +467,42 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *texName) return; for (i=0;i0) { - t = (struct gl_texture_object *) + if (texName[i] > 0) { + struct gl_texture_object *delObj = (struct gl_texture_object *) _mesa_HashLookup(ctx->Shared->TexObjects, texName[i]); - if (t) { + if (delObj) { /* First check if this texture is currently bound. * If so, unbind it and decrement the reference count. */ GLuint u; for (u = 0; u < MAX_TEXTURE_UNITS; u++) { struct gl_texture_unit *unit = &ctx->Texture.Unit[u]; - GLuint d; - for (d = 1 ; d <= 3 ; d++) { - if (unit->CurrentD[d] == t) { - unit->CurrentD[d] = ctx->Shared->DefaultD[d]; - ctx->Shared->DefaultD[d]->RefCount++; - t->RefCount--; - ASSERT( t->RefCount >= 0 ); - ctx->NewState |= _NEW_TEXTURE; - } - } + if (delObj == unit->Current1D) { + unit->Current1D = ctx->Shared->Default1D; + ctx->Shared->Default1D->RefCount++; + } + else if (delObj == unit->Current2D) { + unit->Current2D = ctx->Shared->Default2D; + ctx->Shared->Default2D->RefCount++; + } + else if (delObj == unit->Current3D) { + unit->Current3D = ctx->Shared->Default3D; + ctx->Shared->Default3D->RefCount++; + } + else if (delObj == unit->CurrentCubeMap) { + unit->CurrentCubeMap = ctx->Shared->DefaultCubeMap; + ctx->Shared->DefaultCubeMap->RefCount++; + } } + ctx->NewState |= _NEW_TEXTURE; /* Decrement reference count and delete if zero */ - t->RefCount--; - ASSERT( t->RefCount >= 0 ); - if (t->RefCount == 0) { + delObj->RefCount--; + ASSERT( delObj->RefCount >= 0 ); + if (delObj->RefCount == 0) { if (ctx->Driver.DeleteTexture) - (*ctx->Driver.DeleteTexture)( ctx, t ); - gl_free_texture_object(ctx->Shared, t); + (*ctx->Driver.DeleteTexture)( ctx, delObj ); + _mesa_free_texture_object(ctx->Shared, delObj); } } } @@ -516,7 +522,7 @@ _mesa_BindTexture( GLenum target, GLuint texName ) struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; struct gl_texture_object *oldTexObj; struct gl_texture_object *newTexObj; - GLuint dim; + GLuint targetDim; if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) fprintf(stderr, "glBindTexture %s %d\n", @@ -526,20 +532,20 @@ _mesa_BindTexture( GLenum target, GLuint texName ) switch (target) { case GL_TEXTURE_1D: - dim = 1; - oldTexObj = texUnit->CurrentD[1]; + targetDim = 1; + oldTexObj = texUnit->Current1D; break; case GL_TEXTURE_2D: - dim = 2; - oldTexObj = texUnit->CurrentD[2]; + targetDim = 2; + oldTexObj = texUnit->Current2D; break; case GL_TEXTURE_3D: - dim = 3; - oldTexObj = texUnit->CurrentD[3]; + targetDim = 3; + oldTexObj = texUnit->Current3D; break; case GL_TEXTURE_CUBE_MAP_ARB: if (ctx->Extensions.ARB_texture_cube_map) { - dim = 6; + targetDim = 6; oldTexObj = texUnit->CurrentCubeMap; break; } @@ -550,42 +556,65 @@ _mesa_BindTexture( GLenum target, GLuint texName ) } if (oldTexObj->Name == texName) - return; + return; /* rebinding the same texture- no change */ + /* + * Get pointer to new texture object (newTexObj) + */ if (texName == 0) { - if (target == GL_TEXTURE_CUBE_MAP_ARB) - newTexObj = ctx->Shared->DefaultCubeMap; - else - newTexObj = ctx->Shared->DefaultD[dim]; + /* newTexObj = a default texture object */ + switch (target) { + case GL_TEXTURE_1D: + newTexObj = ctx->Shared->Default1D; + break; + case GL_TEXTURE_2D: + newTexObj = ctx->Shared->Default2D; + break; + case GL_TEXTURE_3D: + newTexObj = ctx->Shared->Default3D; + break; + case GL_TEXTURE_CUBE_MAP_ARB: + newTexObj = ctx->Shared->DefaultCubeMap; + break; + default: + ; /* Bad targets are caught above */ + } } else { - struct _mesa_HashTable *hash = ctx->Shared->TexObjects; + /* non-default texture object */ + const struct _mesa_HashTable *hash = ctx->Shared->TexObjects; newTexObj = (struct gl_texture_object *) _mesa_HashLookup(hash, texName); - - if (!newTexObj) - newTexObj = gl_alloc_texture_object(ctx->Shared, texName, dim); - - if (newTexObj->Dimensions != dim) { - if (newTexObj->Dimensions) { + if (newTexObj) { + /* error checking */ + if (newTexObj->Dimensions > 0 && newTexObj->Dimensions != targetDim) { /* the named texture object's dimensions don't match the target */ - gl_error( ctx, GL_INVALID_OPERATION, "glBindTexture" ); - return; - } - newTexObj->Dimensions = dim; + gl_error( ctx, GL_INVALID_OPERATION, "glBindTexture" ); + return; + } } + else { + /* if this is a new texture id, allocate a texture object now */ + newTexObj = _mesa_alloc_texture_object(ctx->Shared, texName, targetDim); + if (!newTexObj) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glBindTexture"); + return; + } + } + newTexObj->Dimensions = targetDim; } newTexObj->RefCount++; + /* do the actual binding */ switch (target) { case GL_TEXTURE_1D: - texUnit->CurrentD[1] = newTexObj; + texUnit->Current1D = newTexObj; break; case GL_TEXTURE_2D: - texUnit->CurrentD[2] = newTexObj; + texUnit->Current2D = newTexObj; break; case GL_TEXTURE_3D: - texUnit->CurrentD[3] = newTexObj; + texUnit->Current3D = newTexObj; break; case GL_TEXTURE_CUBE_MAP_ARB: texUnit->CurrentCubeMap = newTexObj; @@ -594,11 +623,6 @@ _mesa_BindTexture( GLenum target, GLuint texName ) gl_problem(ctx, "bad target in BindTexture"); } - /* If we've changed the CurrentD[123] texture object then update the - * ctx->Texture.Current pointer to point to the new texture object. - */ - texUnit->_Current = texUnit->CurrentD[texUnit->_CurrentDimension]; - ctx->NewState |= _NEW_TEXTURE; /* Pass BindTexture call to device driver */ @@ -612,7 +636,7 @@ _mesa_BindTexture( GLenum target, GLuint texName ) if (ctx->Driver.DeleteTexture) { (*ctx->Driver.DeleteTexture)( ctx, oldTexObj ); } - gl_free_texture_object(ctx->Shared, oldTexObj); + _mesa_free_texture_object(ctx->Shared, oldTexObj); } } } diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h index 52bf621be8..c6948398b1 100644 --- a/src/mesa/main/texobj.h +++ b/src/mesa/main/texobj.h @@ -1,10 +1,10 @@ -/* $Id: texobj.h,v 1.3 2000/05/23 17:14:49 brianp Exp $ */ +/* $Id: texobj.h,v 1.4 2000/11/19 23:10:25 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.3 + * Version: 3.5 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -38,12 +38,13 @@ */ extern struct gl_texture_object * -gl_alloc_texture_object( struct gl_shared_state *shared, GLuint name, - GLuint dimensions ); +_mesa_alloc_texture_object( struct gl_shared_state *shared, GLuint name, + GLuint dimensions ); -extern void gl_free_texture_object( struct gl_shared_state *shared, - struct gl_texture_object *t ); +extern void +_mesa_free_texture_object( struct gl_shared_state *shared, + struct gl_texture_object *t ); extern void diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 0e33e683de..a99325672c 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -1,4 +1,4 @@ -/* $Id: texstate.c,v 1.22 2000/11/16 21:05:35 keithw Exp $ */ +/* $Id: texstate.c,v 1.23 2000/11/19 23:10:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -616,13 +616,13 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) switch (target) { case GL_TEXTURE_1D: - texObj = texUnit->CurrentD[1]; + texObj = texUnit->Current1D; break; case GL_TEXTURE_2D: - texObj = texUnit->CurrentD[2]; + texObj = texUnit->Current2D; break; case GL_TEXTURE_3D_EXT: - texObj = texUnit->CurrentD[3]; + texObj = texUnit->Current3D; break; case GL_TEXTURE_CUBE_MAP_ARB: if (ctx->Extensions.ARB_texture_cube_map) { @@ -737,7 +737,7 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) } ctx->NewState |= _NEW_TEXTURE; - gl_put_texobj_on_dirty_list( ctx, texObj ); + texObj->Complete = GL_FALSE; if (ctx->Driver.TexParameter) { (*ctx->Driver.TexParameter)( ctx, target, texObj, pname, params ); @@ -1613,64 +1613,3 @@ _mesa_ClientActiveTextureARB( GLenum target ) gl_error(ctx, GL_INVALID_OPERATION, "glActiveTextureARB(target)"); } } - - - -/* - * Put the given texture object into the list of dirty texture objects. - * When a texture object is dirty we have to reexamine it for completeness - * and perhaps choose a different texture sampling function. - */ -void gl_put_texobj_on_dirty_list( GLcontext *ctx, struct gl_texture_object *t ) -{ - ASSERT(ctx); - ASSERT(t); - /* Only insert if not already in the dirty list. - * The Dirty flag is only set iff the texture object is in the dirty list. - */ - if (!t->Dirty) { - ASSERT(t->NextDirty == NULL); - t->Dirty = GL_TRUE; - t->NextDirty = ctx->Shared->DirtyTexObjList; - ctx->Shared->DirtyTexObjList = t; - } -#ifdef DEBUG - else { - /* make sure t is in the list */ - struct gl_texture_object *obj = ctx->Shared->DirtyTexObjList; - while (obj) { - if (obj == t) { - return; - } - obj = obj->NextDirty; - } - gl_problem(ctx, "Error in gl_put_texobj_on_dirty_list"); - } -#endif -} - - -/* - * Remove a texture object from the dirty texture list. - */ -void gl_remove_texobj_from_dirty_list( struct gl_shared_state *shared, - struct gl_texture_object *tObj ) -{ - struct gl_texture_object *t, *prev = NULL; - ASSERT(shared); - ASSERT(tObj); - for (t = shared->DirtyTexObjList; t; t = t->NextDirty) { - if (t == tObj) { - if (prev) { - prev->NextDirty = t->NextDirty; - } - else { - shared->DirtyTexObjList = t->NextDirty; - } - return; - } - prev = t; - } -} - - diff --git a/src/mesa/main/texstate.h b/src/mesa/main/texstate.h index 9954a0a126..d9dd060abd 100644 --- a/src/mesa/main/texstate.h +++ b/src/mesa/main/texstate.h @@ -1,4 +1,4 @@ -/* $Id: texstate.h,v 1.3 2000/11/16 21:05:35 keithw Exp $ */ +/* $Id: texstate.h,v 1.4 2000/11/19 23:10:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -127,20 +127,5 @@ extern void _mesa_ClientActiveTextureARB( GLenum target ); - -/*** Internal functions ***/ - -extern void -gl_put_texobj_on_dirty_list( GLcontext *ctx, struct gl_texture_object *t ); - -#ifdef VMS -#define gl_remove_texobj_from_dirty_list gl_remove_texobj_from_dirty_lis -#endif -extern void -gl_remove_texobj_from_dirty_list( struct gl_shared_state *shared, - struct gl_texture_object *tObj ); - - - #endif -- cgit v1.2.3