Mesa (master): r600g: Also clear bc data when we're destroying a shader.

Dave Airlie airlied at kemper.freedesktop.org
Sun Oct 24 03:01:46 UTC 2010


Module: Mesa
Branch: master
Commit: f4a2c62af56ce10e43688e8283f8defeb05cef1a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f4a2c62af56ce10e43688e8283f8defeb05cef1a

Author: Tilman Sauerbeck <tilman at code-monkey.de>
Date:   Sat Oct 23 13:33:22 2010 +0200

r600g: Also clear bc data when we're destroying a shader.

[airlied: remove unused vars]

Signed-off-by: Tilman Sauerbeck <tilman at code-monkey.de>
Signed-off-by: Dave Airlie <airlied at redhat.com>

---

 src/gallium/drivers/r600/r600_asm.c    |   36 ++++++++++++++++++++++++++++++++
 src/gallium/drivers/r600/r600_asm.h    |    1 +
 src/gallium/drivers/r600/r600_shader.c |    3 +-
 3 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_asm.c b/src/gallium/drivers/r600/r600_asm.c
index d13da0e..a71d95f 100644
--- a/src/gallium/drivers/r600/r600_asm.c
+++ b/src/gallium/drivers/r600/r600_asm.c
@@ -871,3 +871,39 @@ int r600_bc_build(struct r600_bc *bc)
 	}
 	return 0;
 }
+
+void r600_bc_clear(struct r600_bc *bc)
+{
+	struct r600_bc_cf *cf, *next_cf;
+
+	free(bc->bytecode);
+	bc->bytecode = NULL;
+
+	LIST_FOR_EACH_ENTRY_SAFE(cf, next_cf, &bc->cf, list) {
+		struct r600_bc_alu *alu, *next_alu;
+		struct r600_bc_tex *tex, *next_tex;
+		struct r600_bc_tex *vtx, *next_vtx;
+
+		LIST_FOR_EACH_ENTRY_SAFE(alu, next_alu, &cf->alu, list) {
+			free(alu);
+		}
+
+		LIST_INITHEAD(&cf->alu);
+
+		LIST_FOR_EACH_ENTRY_SAFE(tex, next_tex, &cf->tex, list) {
+			free(tex);
+		}
+
+		LIST_INITHEAD(&cf->tex);
+
+		LIST_FOR_EACH_ENTRY_SAFE(vtx, next_vtx, &cf->vtx, list) {
+			free(vtx);
+		}
+
+		LIST_INITHEAD(&cf->vtx);
+
+		free(cf);
+	}
+
+	LIST_INITHEAD(&cf->list);
+}
diff --git a/src/gallium/drivers/r600/r600_asm.h b/src/gallium/drivers/r600/r600_asm.h
index bebc7c1..97d08ee 100644
--- a/src/gallium/drivers/r600/r600_asm.h
+++ b/src/gallium/drivers/r600/r600_asm.h
@@ -185,6 +185,7 @@ int eg_bc_cf_build(struct r600_bc *bc, struct r600_bc_cf *cf);
 
 /* r600_asm.c */
 int r600_bc_init(struct r600_bc *bc, enum radeon_family family);
+void r600_bc_clear(struct r600_bc *bc);
 int r600_bc_add_alu(struct r600_bc *bc, const struct r600_bc_alu *alu);
 int r600_bc_add_literal(struct r600_bc *bc, const u32 *value);
 int r600_bc_add_vtx(struct r600_bc *bc, const struct r600_bc_vtx *vtx);
diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index a4e052c..4106587 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -342,10 +342,11 @@ void
 r600_pipe_shader_destroy(struct pipe_context *ctx, struct r600_pipe_shader *shader)
 {
 	struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
-	struct r600_bc_cf *cf, *next_cf;
 
 	r600_bo_reference(rctx->radeon, &shader->bo, NULL);
 
+	r600_bc_clear(&shader->shader.bc);
+
 	/* FIXME: is there more stuff to free? */
 }
 




More information about the mesa-commit mailing list