diff options
Diffstat (limited to 'src/mesa/main/shared.c')
-rw-r--r-- | src/mesa/main/shared.c | 88 |
1 files changed, 59 insertions, 29 deletions
diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c index 2cce47e2268..a2f0f8d398c 100644 --- a/src/mesa/main/shared.c +++ b/src/mesa/main/shared.c @@ -334,46 +334,73 @@ free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared) /* * Free display lists */ - _mesa_HashDeleteAll(shared->DisplayList, delete_displaylist_cb, ctx); - _mesa_DeleteHashTable(shared->DisplayList); - _mesa_HashDeleteAll(shared->BitmapAtlas, delete_bitmap_atlas_cb, ctx); - _mesa_DeleteHashTable(shared->BitmapAtlas); + if (shared->DisplayList) { + _mesa_HashDeleteAll(shared->DisplayList, delete_displaylist_cb, ctx); + _mesa_DeleteHashTable(shared->DisplayList); + } + + if (shared->BitmapAtlas) { + _mesa_HashDeleteAll(shared->BitmapAtlas, delete_bitmap_atlas_cb, ctx); + _mesa_DeleteHashTable(shared->BitmapAtlas); + } - _mesa_HashWalk(shared->ShaderObjects, free_shader_program_data_cb, ctx); - _mesa_HashDeleteAll(shared->ShaderObjects, delete_shader_cb, ctx); - _mesa_DeleteHashTable(shared->ShaderObjects); + if (shared->ShaderObjects) { + _mesa_HashWalk(shared->ShaderObjects, free_shader_program_data_cb, ctx); + _mesa_HashDeleteAll(shared->ShaderObjects, delete_shader_cb, ctx); + _mesa_DeleteHashTable(shared->ShaderObjects); + } - _mesa_HashDeleteAll(shared->Programs, delete_program_cb, ctx); - _mesa_DeleteHashTable(shared->Programs); + if (shared->Programs) { + _mesa_HashDeleteAll(shared->Programs, delete_program_cb, ctx); + _mesa_DeleteHashTable(shared->Programs); + } - _mesa_reference_program(ctx, &shared->DefaultVertexProgram, NULL); - _mesa_reference_program(ctx, &shared->DefaultFragmentProgram, NULL); + if (shared->DefaultVertexProgram) + _mesa_reference_program(ctx, &shared->DefaultVertexProgram, NULL); - _mesa_HashDeleteAll(shared->ATIShaders, delete_fragshader_cb, ctx); - _mesa_DeleteHashTable(shared->ATIShaders); - _mesa_delete_ati_fragment_shader(ctx, shared->DefaultFragmentShader); + if (shared->DefaultFragmentProgram) + _mesa_reference_program(ctx, &shared->DefaultFragmentProgram, NULL); - _mesa_HashDeleteAll(shared->BufferObjects, delete_bufferobj_cb, ctx); - _mesa_DeleteHashTable(shared->BufferObjects); + if (shared->DefaultFragmentShader) + _mesa_delete_ati_fragment_shader(ctx, shared->DefaultFragmentShader); - _mesa_HashDeleteAll(shared->FrameBuffers, delete_framebuffer_cb, ctx); - _mesa_DeleteHashTable(shared->FrameBuffers); - _mesa_HashDeleteAll(shared->RenderBuffers, delete_renderbuffer_cb, ctx); - _mesa_DeleteHashTable(shared->RenderBuffers); + if (shared->ATIShaders) { + _mesa_HashDeleteAll(shared->ATIShaders, delete_fragshader_cb, ctx); + _mesa_DeleteHashTable(shared->ATIShaders); + } - _mesa_reference_buffer_object(ctx, &shared->NullBufferObj, NULL); + if (shared->BufferObjects) { + _mesa_HashDeleteAll(shared->BufferObjects, delete_bufferobj_cb, ctx); + _mesa_DeleteHashTable(shared->BufferObjects); + } - { - struct set_entry *entry; + if (shared->FrameBuffers) { + _mesa_HashDeleteAll(shared->FrameBuffers, delete_framebuffer_cb, ctx); + _mesa_DeleteHashTable(shared->FrameBuffers); + } + + if (shared->RenderBuffers) { + _mesa_HashDeleteAll(shared->RenderBuffers, delete_renderbuffer_cb, ctx); + _mesa_DeleteHashTable(shared->RenderBuffers); + } + + if (shared->NullBufferObj) + _mesa_reference_buffer_object(ctx, &shared->NullBufferObj, NULL); + if (shared->SyncObjects) { + struct set_entry *entry; set_foreach(shared->SyncObjects, entry) { _mesa_unref_sync_object(ctx, (struct gl_sync_object *) entry->key, 1); } + + _mesa_set_destroy(shared->SyncObjects, NULL); } - _mesa_set_destroy(shared->SyncObjects, NULL); - _mesa_HashDeleteAll(shared->SamplerObjects, delete_sampler_object_cb, ctx); - _mesa_DeleteHashTable(shared->SamplerObjects); + if (shared->SamplerObjects) { + _mesa_HashDeleteAll(shared->SamplerObjects, delete_sampler_object_cb, + ctx); + _mesa_DeleteHashTable(shared->SamplerObjects); + } /* * Free texture objects (after FBOs since some textures might have @@ -382,12 +409,15 @@ free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared) assert(ctx->Driver.DeleteTexture); /* the default textures */ for (i = 0; i < NUM_TEXTURE_TARGETS; i++) { - ctx->Driver.DeleteTexture(ctx, shared->DefaultTex[i]); + if (shared->DefaultTex[i]) + ctx->Driver.DeleteTexture(ctx, shared->DefaultTex[i]); } /* all other textures */ - _mesa_HashDeleteAll(shared->TexObjects, delete_texture_cb, ctx); - _mesa_DeleteHashTable(shared->TexObjects); + if (shared->TexObjects) { + _mesa_HashDeleteAll(shared->TexObjects, delete_texture_cb, ctx); + _mesa_DeleteHashTable(shared->TexObjects); + } _mesa_free_shared_handles(shared); |