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

Aaron Watry awatry at gmail.com
Thu Nov 13 15:43:10 PST 2014


v3: Rebase and add #if guards
v2: fix indentation

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

diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c
index 4334743..5389f96 100644
--- a/src/gallium/drivers/r600/evergreen_compute.c
+++ b/src/gallium/drivers/r600/evergreen_compute.c
@@ -252,6 +252,25 @@ void evergreen_delete_compute_state(struct pipe_context *ctx, void* state)
 	if (!shader)
 		return;
 
+#if HAVE_OPENCL
+#if HAVE_LLVM < 0x0306
+	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);
+			shader->kernels[i].bc.bytecode = NULL;
+		}
+		FREE(shader->kernels);
+		shader->kernels = NULL;
+	}
+#endif
+#endif
+
 	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--){
-- 
2.1.0



More information about the mesa-dev mailing list