[Mesa-dev] [PATCH 1/3] r600g: Fixed r600_vertex_element leak.
Tilman Sauerbeck
tilman at code-monkey.de
Sat Oct 23 04:33:15 PDT 2010
Signed-off-by: Tilman Sauerbeck <tilman at code-monkey.de>
---
src/gallium/drivers/r600/evergreen_state.c | 13 +++++--------
src/gallium/drivers/r600/r600_pipe.h | 1 -
src/gallium/drivers/r600/r600_state.c | 13 +++++--------
src/gallium/drivers/r600/r600_state_common.c | 1 -
4 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index f394527..8124147 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -561,13 +561,12 @@ static void evergreen_delete_state(struct pipe_context *ctx, void *state)
static void evergreen_delete_vertex_element(struct pipe_context *ctx, void *state)
{
- struct r600_vertex_element *v = (struct r600_vertex_element*)state;
+ struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
- if (v == NULL)
- return;
- if (--v->refcount)
- return;
- free(v);
+ FREE(state);
+
+ if (rctx->vertex_elements == state)
+ rctx->vertex_elements = NULL;
}
static void evergreen_set_clip_state(struct pipe_context *ctx,
@@ -610,10 +609,8 @@ static void evergreen_bind_vertex_elements(struct pipe_context *ctx, void *state
struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
struct r600_vertex_element *v = (struct r600_vertex_element*)state;
- evergreen_delete_vertex_element(ctx, rctx->vertex_elements);
rctx->vertex_elements = v;
if (v) {
- v->refcount++;
// rctx->vs_rebuild = TRUE;
}
}
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
index 11410f1..b27bbba 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -83,7 +83,6 @@ struct r600_pipe_blend {
struct r600_vertex_element
{
unsigned count;
- unsigned refcount;
struct pipe_vertex_element elements[PIPE_MAX_ATTRIBS];
enum pipe_format hw_format[PIPE_MAX_ATTRIBS];
unsigned hw_format_size[PIPE_MAX_ATTRIBS];
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index df2c05e..7100529 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -755,13 +755,12 @@ static void r600_delete_state(struct pipe_context *ctx, void *state)
static void r600_delete_vertex_element(struct pipe_context *ctx, void *state)
{
- struct r600_vertex_element *v = (struct r600_vertex_element*)state;
+ struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
- if (v == NULL)
- return;
- if (--v->refcount)
- return;
- free(v);
+ FREE(state);
+
+ if (rctx->vertex_elements == state)
+ rctx->vertex_elements = NULL;
}
static void r600_set_clip_state(struct pipe_context *ctx,
@@ -804,10 +803,8 @@ static void r600_bind_vertex_elements(struct pipe_context *ctx, void *state)
struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
struct r600_vertex_element *v = (struct r600_vertex_element*)state;
- r600_delete_vertex_element(ctx, rctx->vertex_elements);
rctx->vertex_elements = v;
if (v) {
- v->refcount++;
// rctx->vs_rebuild = TRUE;
}
}
diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
index 722ce32..e127bac 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -118,6 +118,5 @@ void *r600_create_vertex_elements(struct pipe_context *ctx,
align(util_format_get_blocksize(v->hw_format[i]), 4);
}
- v->refcount = 1;
return v;
}
--
1.7.3.1
More information about the mesa-dev
mailing list