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

Aaron Watry awatry at gmail.com
Thu Aug 21 09:06:44 PDT 2014


Tested on CEDAR

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 dcb7183..71a9218 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