Cell: generalize the batch buffer code for vertex buffers...
[mesa.git] / src / mesa / vbo / vbo_save.c
index e7f46879639c4eea88c92ca07dfb4d14212836b4..8dd87141c0c27ec84c813f73d3f27dd8575d0510 100644 (file)
  */
 
 
-#include "mtypes.h"
-#include "dlist.h"
-#include "vtxfmt.h"
-#include "imports.h"
+#include "main/mtypes.h"
+#include "main/dlist.h"
+#include "main/vtxfmt.h"
+#include "main/imports.h"
 
 #include "vbo_context.h"
 
@@ -69,6 +69,21 @@ 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;
+   if (save->prim_store) {
+      if ( --save->prim_store->refcount == 0 ) {
+         FREE( save->prim_store );
+         save->prim_store = NULL;
+      }
+      if ( --save->vertex_store->refcount == 0 ) {
+         if (save->vertex_store->bufferobj)
+            ctx->Driver.DeleteBuffer( ctx, save->vertex_store->bufferobj );
+
+         FREE( save->vertex_store );
+         save->vertex_store = NULL;
+      }
+   }
 }