From: Marek Olšák Date: Sat, 26 Jun 2010 23:07:34 +0000 (+0200) Subject: r300g: release referenced objects in destroy_context X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=808ad22592b4937e3c7c17793b2f891fb01c5dfb;p=mesa.git r300g: release referenced objects in destroy_context --- diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index b14db16f7cd..c3c4c7491a3 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -36,18 +36,53 @@ #include -static void r300_destroy_context(struct pipe_context* context) +static void r300_release_referenced_objects(struct r300_context *r300) { - struct r300_context* r300 = r300_context(context); + struct pipe_framebuffer_state *fb = + (struct pipe_framebuffer_state*)r300->fb_state.state; + struct r300_textures_state *textures = + (struct r300_textures_state*)r300->textures_state.state; struct r300_query *query, *temp; - struct r300_atom *atom; + unsigned i; + + /* Framebuffer state. */ + for (i = 0; i < fb->nr_cbufs; i++) { + pipe_surface_reference(&fb->cbufs[i], NULL); + } + pipe_surface_reference(&fb->zsbuf, NULL); + + /* Textures. */ + for (i = 0; i < textures->sampler_view_count; i++) + pipe_sampler_view_reference( + (struct pipe_sampler_view**)&textures->sampler_views[i], NULL); + /* The special dummy texture for texkill. */ if (r300->texkill_sampler) { pipe_sampler_view_reference( (struct pipe_sampler_view**)&r300->texkill_sampler, NULL); } + /* The SWTCL VBO. */ + pipe_resource_reference(&r300->vbo, NULL); + + /* Vertex buffers. */ + for (i = 0; i < r300->vertex_buffer_count; i++) { + pipe_resource_reference(&r300->vertex_buffer[i].buffer, NULL); + } + + /* If there are any queries pending or not destroyed, remove them now. */ + foreach_s(query, temp, &r300->query_list) { + remove_from_list(query); + FREE(query); + } +} + +static void r300_destroy_context(struct pipe_context* context) +{ + struct r300_context* r300 = r300_context(context); + struct r300_atom *atom; + util_blitter_destroy(r300->blitter); draw_destroy(r300->draw); @@ -61,17 +96,13 @@ static void r300_destroy_context(struct pipe_context* context) } } - /* If there are any queries pending or not destroyed, remove them now. */ - foreach_s(query, temp, &r300->query_list) { - remove_from_list(query); - FREE(query); - } - u_upload_destroy(r300->upload_vb); u_upload_destroy(r300->upload_ib); translate_cache_destroy(r300->tran.translate_cache); + r300_release_referenced_objects(r300); + FREE(r300->aa_state.state); FREE(r300->blend_color_state.state); FREE(r300->clip_state.state);