[Mesa-dev] [PATCH] r600g/compute: Stop leaking CL kernel bytecode/resources

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


Tested on CEDAR

v2: fix indentation

Signed-off-by: Aaron Watry <awatry at gmail.com>
---
 src/gallium/drivers/r600/evergreen_compute.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c
index 510d9a3..61446f6 100644
--- a/src/gallium/drivers/r600/evergreen_compute.c
+++ b/src/gallium/drivers/r600/evergreen_compute.c
@@ -238,7 +238,18 @@ void evergreen_delete_compute_state(struct pipe_context *ctx, void* state)
 	if (!shader)
 		return;
 
-	FREE(shader->kernels);
+	if (shader->kernels) {
+		for (int i = 0; i < shader->num_kernels; i++) {
+			if (shader->kernels[i].code_bo) {
+				pipe_resource_reference(
+					(struct pipe_resource**) &shader->kernels[i].code_bo,
+					NULL
+				);
+			}
+			FREE(shader->kernels[i].bc.bytecode);
+		}
+		FREE(shader->kernels);
+	}
 
 	if (shader->ctx){
 		struct pipe_framebuffer_state *fb_state = &shader->ctx->framebuffer.state;
-- 
1.9.1



More information about the mesa-dev mailing list