X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fvbo%2Fvbo_save.c;h=9757c3d9f61cd4dc96bd0468091acf84925c3f47;hb=0756dc876c01a3d07da34e2da1899b340b0fb819;hp=0a5b7054005db24010691b7a0579d6d947c02567;hpb=fd12b37dbada6f945a94b93ecf332d0b6a8eef06;p=mesa.git diff --git a/src/mesa/vbo/vbo_save.c b/src/mesa/vbo/vbo_save.c index 0a5b7054005..9757c3d9f61 100644 --- a/src/mesa/vbo/vbo_save.c +++ b/src/mesa/vbo/vbo_save.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.3 + * Version: 7.2 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 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"), @@ -26,23 +26,43 @@ */ -#include "mtypes.h" -#include "dlist.h" -#include "vtxfmt.h" -#include "imports.h" +#include "main/mtypes.h" +#include "main/bufferobj.h" +#include "main/dlist.h" +#include "main/vtxfmt.h" +#include "main/imports.h" #include "vbo_context.h" +static void vbo_save_callback_init( GLcontext *ctx ) +{ + ctx->Driver.NewList = vbo_save_NewList; + ctx->Driver.EndList = vbo_save_EndList; + ctx->Driver.SaveFlushVertices = vbo_save_SaveFlushVertices; + ctx->Driver.BeginCallList = vbo_save_BeginCallList; + ctx->Driver.EndCallList = vbo_save_EndCallList; + ctx->Driver.NotifySaveBegin = vbo_save_NotifyBegin; +} + + + void vbo_save_init( GLcontext *ctx ) { - struct vbo_save_context *save = &vbo_context(ctx)->save; + struct vbo_context *vbo = vbo_context(ctx); + struct vbo_save_context *save = &vbo->save; save->ctx = ctx; vbo_save_api_init( save ); - vbo_save_wakeup(ctx); + vbo_save_callback_init(ctx); + + { + struct gl_client_array *arrays = save->arrays; + memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0])); + memcpy(arrays + 16, vbo->generic_currval, 16 * sizeof(arrays[0])); + } ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN; } @@ -50,6 +70,26 @@ void vbo_save_init( GLcontext *ctx ) void vbo_save_destroy( GLcontext *ctx ) { + struct vbo_context *vbo = vbo_context(ctx); + struct vbo_save_context *save = &vbo->save; + GLuint i; + + if (save->prim_store) { + if ( --save->prim_store->refcount == 0 ) { + FREE( save->prim_store ); + save->prim_store = NULL; + } + if ( --save->vertex_store->refcount == 0 ) { + _mesa_reference_buffer_object(ctx, + &save->vertex_store->bufferobj, NULL); + FREE( save->vertex_store ); + save->vertex_store = NULL; + } + } + + for (i = 0; i < VBO_ATTRIB_MAX; i++) { + _mesa_reference_buffer_object(ctx, &save->arrays[i].BufferObj, NULL); + } } @@ -68,27 +108,3 @@ void vbo_save_fallback( GLcontext *ctx, GLboolean fallback ) } -/* I don't see any reason to swap this code out on fallbacks. It - * wouldn't really mean anything to do so anyway as the old lists are - * still around from pre-fallback. Instead, the above code ensures - * that vertices are routed back through immediate mode dispatch on - * fallback. - * - * The below can be moved into init or removed: - */ -void vbo_save_wakeup( GLcontext *ctx ) -{ - ctx->Driver.NewList = vbo_save_NewList; - ctx->Driver.EndList = vbo_save_EndList; - ctx->Driver.SaveFlushVertices = vbo_save_SaveFlushVertices; - ctx->Driver.BeginCallList = vbo_save_BeginCallList; - ctx->Driver.EndCallList = vbo_save_EndCallList; - ctx->Driver.NotifySaveBegin = vbo_save_NotifyBegin; - - /* Assume we haven't been getting state updates either: - */ - vbo_save_invalidate_state( ctx, ~0 ); -} - - -