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

Aaron Watry awatry at gmail.com
Thu Aug 21 12:39:21 PDT 2014


Walk the array of cbufs backwards and free all of them.

v2: Change to C-style comments and fix indentation

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 38b78c7..510d9a3 100644
--- a/src/gallium/drivers/r600/evergreen_compute.c
+++ b/src/gallium/drivers/r600/evergreen_compute.c
@@ -240,6 +240,15 @@ void evergreen_delete_compute_state(struct pipe_context *ctx, void* state)
 
 	FREE(shader->kernels);
 
+	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--;
+		}
+	}
+
 #ifdef HAVE_OPENCL
 	if (shader->llvm_ctx){
 		LLVMContextDispose(shader->llvm_ctx);
-- 
1.9.1



More information about the mesa-dev mailing list