r600g: Fixed r600_vertex_element leak.
authorTilman Sauerbeck <tilman@code-monkey.de>
Sat, 23 Oct 2010 11:33:15 +0000 (13:33 +0200)
committerDave Airlie <airlied@redhat.com>
Sun, 24 Oct 2010 02:44:56 +0000 (12:44 +1000)
Signed-off-by: Tilman Sauerbeck <tilman@code-monkey.de>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_state_common.c

index f394527edfd983d2f6d8daece0f2a5e234f7214f..81241478ab2957995758e439fbe7691aa32dba97 100644 (file)
@@ -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;
        }
 }
index 11410f17c75e51ddb771b8bc6c6bac40fcbd4b17..b27bbbac8c1df4a26cd3f67769e2256a6d0645a1 100644 (file)
@@ -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];
index df2c05ea1390bd7a24735f1e40d254ac198d8426..710052976463665babad92828a869be2ad7c476b 100644 (file)
@@ -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;
        }
 }
index 722ce32263eeeddeb22ff94a828ae6199ae2c050..e127bac7797f912689df6140861063aabf08effb 100644 (file)
@@ -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;
 }