[Mesa-dev] [PATCH 1/2] st/mesa: don't unreference user attribs up front.
Brian Paul
brianp at vmware.com
Thu Feb 9 14:45:58 PST 2012
On 02/09/2012 12:44 PM, Dave Airlie wrote:
> From: Dave Airlie<airlied at redhat.com>
>
> postpone unreferences until end of function, as the ones in use will
> get naturally dereferenced.
>
> Signed-off-by: Dave Airlie<airlied at redhat.com>
> ---
> src/mesa/state_tracker/st_draw.c | 9 ++++++---
> 1 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
> index c0554cf..c4b2cac 100644
> --- a/src/mesa/state_tracker/st_draw.c
> +++ b/src/mesa/state_tracker/st_draw.c
> @@ -905,6 +905,7 @@ st_validate_varrays(struct gl_context *ctx,
> unsigned num_vbuffers, num_velements;
> GLuint attr;
> unsigned i;
> + unsigned old_num_user_attribs;
>
> /* must get these after state validation! */
> vp = st->vp;
> @@ -913,9 +914,7 @@ st_validate_varrays(struct gl_context *ctx,
> memset(velements, 0, sizeof(struct pipe_vertex_element) * vpv->num_inputs);
>
> /* Unreference any user vertex buffers. */
> - for (i = 0; i< st->num_user_attribs; i++) {
> - pipe_resource_reference(&st->user_attrib[i].buffer, NULL);
> - }
> + old_num_user_attribs = st->num_user_attribs;
> st->num_user_attribs = 0;
>
> /*
> @@ -954,6 +953,10 @@ st_validate_varrays(struct gl_context *ctx,
> assert(!vbuffer[attr].buffer);
> }
>
> + for (i = old_num_user_attribs; i< st->num_user_attribs; i++) {
> + pipe_resource_reference(&st->user_attrib[i].buffer, NULL);
> + }
> +
> return GL_TRUE;
> }
>
Both pathces look good.
Reviewed-by: Brian Paul <brianp at vmware.com>
More information about the mesa-dev
mailing list