17117f1b4Smrg/* 27117f1b4Smrg * Mesa 3-D graphics library 37117f1b4Smrg * 4c1f859d4Smrg * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 57117f1b4Smrg * 67117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a 77117f1b4Smrg * copy of this software and associated documentation files (the "Software"), 87117f1b4Smrg * to deal in the Software without restriction, including without limitation 97117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 107117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the 117117f1b4Smrg * Software is furnished to do so, subject to the following conditions: 127117f1b4Smrg * 137117f1b4Smrg * The above copyright notice and this permission notice shall be included 147117f1b4Smrg * in all copies or substantial portions of the Software. 157117f1b4Smrg * 167117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 177117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 187117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE. 237117f1b4Smrg * 247117f1b4Smrg * Authors: 25af69d88dSmrg * Keith Whitwell <keithw@vmware.com> 267117f1b4Smrg */ 277117f1b4Smrg 287117f1b4Smrg 2901e04c3fSmrg#include "main/arrayobj.h" 30c1f859d4Smrg#include "main/bufferobj.h" 317117f1b4Smrg 3201e04c3fSmrg#include "vbo_private.h" 337117f1b4Smrg 347117f1b4Smrg 35af69d88dSmrg/** 36af69d88dSmrg * Called at context creation time. 37af69d88dSmrg */ 383464ebd5Sriastradhvoid vbo_save_init( struct gl_context *ctx ) 397117f1b4Smrg{ 407117f1b4Smrg struct vbo_context *vbo = vbo_context(ctx); 417117f1b4Smrg struct vbo_save_context *save = &vbo->save; 427117f1b4Smrg 437117f1b4Smrg vbo_save_api_init( save ); 447117f1b4Smrg 4501e04c3fSmrg for (gl_vertex_processing_mode vpm = VP_MODE_FF; vpm < VP_MODE_MAX; ++vpm) 4601e04c3fSmrg save->VAO[vpm] = NULL; 474a49301eSmrg 4801e04c3fSmrg save->no_current_update = false; 497117f1b4Smrg 50af69d88dSmrg ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END; 517117f1b4Smrg} 527117f1b4Smrg 537117f1b4Smrg 543464ebd5Sriastradhvoid vbo_save_destroy( struct gl_context *ctx ) 557117f1b4Smrg{ 567117f1b4Smrg struct vbo_context *vbo = vbo_context(ctx); 577117f1b4Smrg struct vbo_save_context *save = &vbo->save; 5801e04c3fSmrg 5901e04c3fSmrg for (gl_vertex_processing_mode vpm = VP_MODE_FF; vpm < VP_MODE_MAX; ++vpm) 6001e04c3fSmrg _mesa_reference_vao(ctx, &save->VAO[vpm], NULL); 61c1f859d4Smrg 627117f1b4Smrg if (save->prim_store) { 637ec681f3Smrg free(save->prim_store->prims); 647ec681f3Smrg free(save->prim_store); 657ec681f3Smrg save->prim_store = NULL; 667117f1b4Smrg } 6701e04c3fSmrg if (save->vertex_store) { 687ec681f3Smrg free(save->vertex_store->buffer_in_ram); 6901e04c3fSmrg free(save->vertex_store); 7001e04c3fSmrg save->vertex_store = NULL; 71c1f859d4Smrg } 727ec681f3Smrg 737ec681f3Smrg if (save->copied.buffer) 747ec681f3Smrg free(save->copied.buffer); 757ec681f3Smrg 767ec681f3Smrg _mesa_reference_buffer_object(ctx, &save->current_bo, NULL); 777117f1b4Smrg} 78