From: Tomeu Vizoso Date: Thu, 12 Dec 2019 07:43:12 +0000 (+0100) Subject: panfrost: Hold a reference to sampler views X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5dfe41239c321ff1b6af6ce261caefe99be6b675;p=mesa.git panfrost: Hold a reference to sampler views Before we were just copying, but we need to hold a reference as well. Signed-off-by: Tomeu Vizoso Reviewed-by: Alyssa Rosenzweig --- diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 3b65034b8f8..069a517e0db 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -2213,17 +2213,23 @@ panfrost_set_sampler_views( struct pipe_sampler_view **views) { struct panfrost_context *ctx = pan_context(pctx); + unsigned new_nr = 0; + unsigned i; assert(start_slot == 0); - unsigned new_nr = 0; - for (unsigned i = 0; i < num_views; ++i) { + for (i = 0; i < num_views; ++i) { if (views[i]) new_nr = i + 1; + pipe_sampler_view_reference((struct pipe_sampler_view **)&ctx->sampler_views[shader][i], + views[i]); } + for (; i < ctx->sampler_view_count[shader]; i++) { + pipe_sampler_view_reference((struct pipe_sampler_view **)&ctx->sampler_views[shader][i], + NULL); + } ctx->sampler_view_count[shader] = new_nr; - memcpy(ctx->sampler_views[shader], views, num_views * sizeof (void *)); ctx->dirty |= PAN_DIRTY_TEXTURES; }