[Mesa-dev] [PATCH 1/4] r600g/compute: Don't leak cbufs in compute state

Michel Dänzer michel at daenzer.net
Thu Nov 13 18:49:33 PST 2014


On 14.11.2014 08:43, Aaron Watry wrote:
> Walk the array of cbufs backwards and free all of them.
> 
> v3: Rebase on top of changes since Aug 2014
> 
> Signed-off-by: Aaron Watry <awatry at gmail.com>
> ---
>   src/gallium/drivers/r600/evergreen_compute.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c
> index 90fdd79..4334743 100644
> --- a/src/gallium/drivers/r600/evergreen_compute.c
> +++ b/src/gallium/drivers/r600/evergreen_compute.c
> @@ -252,6 +252,15 @@ void evergreen_delete_compute_state(struct pipe_context *ctx, void* state)
>   	if (!shader)
>   		return;
>   
> +	if (shader->ctx){
> +		struct pipe_framebuffer_state *fb_state = &shader->ctx->framebuffer.state;
> +		for (int i = fb_state->nr_cbufs - 1; fb_state->nr_cbufs > 0 ; i--){
> +			shader->ctx->b.b.surface_destroy(ctx, fb_state->cbufs[i]);
> +			fb_state->cbufs[i] = NULL;
> +			fb_state->nr_cbufs--;
> +		}
> +	}

I think this is the wrong place to do this. It's the state tracker's responsibility to set an empty framebuffer state, so that the driver can unreference the surfaces of the previous framebuffer state.


-- 
Earthling Michel Dänzer            |                  http://www.amd.com
Libre software enthusiast          |                Mesa and X developer


More information about the mesa-dev mailing list