diff options
author | Chia-I Wu <[email protected]> | 2013-06-04 16:20:05 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2013-06-07 11:28:21 +0800 |
commit | 09f62a13fcddd237e7a3aef6185377f9a585a332 (patch) | |
tree | 0a7ffa01d5575872b001a8eaab82a7cd34d43bd3 /src | |
parent | 7cbf0a410e565b6a02c4b45f73364d3537780105 (diff) |
ilo: clean up states upon context destroy
We need to unreference resources that we referenced.
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/ilo/ilo_state.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c index a2ec664c304..3b9e8cb1495 100644 --- a/src/gallium/drivers/ilo/ilo_state.c +++ b/src/gallium/drivers/ilo/ilo_state.c @@ -1115,4 +1115,42 @@ ilo_init_states(struct ilo_context *ilo) void ilo_cleanup_states(struct ilo_context *ilo) { + unsigned i, sh; + + for (i = 0; i < Elements(ilo->vb.states); i++) { + if (ilo->vb.enabled_mask & (1 << i)) + pipe_resource_reference(&ilo->vb.states[i].buffer, NULL); + } + + pipe_resource_reference(&ilo->ib.state.buffer, NULL); + + for (i = 0; i < ilo->so.count; i++) + pipe_so_target_reference(&ilo->so.states[i], NULL); + + for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) { + for (i = 0; i < ilo->view[sh].count; i++) { + struct pipe_sampler_view *view = ilo->view[sh].states[i]; + pipe_sampler_view_reference(&view, NULL); + } + + for (i = 0; i < Elements(ilo->cbuf[sh].cso); i++) { + struct ilo_cbuf_cso *cbuf = &ilo->cbuf[sh].cso[i]; + pipe_resource_reference(&cbuf->resource, NULL); + } + } + + for (i = 0; i < ilo->resource.count; i++) + pipe_surface_reference(&ilo->resource.states[i], NULL); + + for (i = 0; i < ilo->fb.state.nr_cbufs; i++) + pipe_surface_reference(&ilo->fb.state.cbufs[i], NULL); + + if (ilo->fb.state.zsbuf) + pipe_surface_reference(&ilo->fb.state.zsbuf, NULL); + + for (i = 0; i < ilo->cs_resource.count; i++) + pipe_surface_reference(&ilo->cs_resource.states[i], NULL); + + for (i = 0; i < ilo->global_binding.count; i++) + pipe_resource_reference(&ilo->global_binding.resources[i], NULL); } |