From 4690ecd15f1d2b422d14ba131edb59955f5734dd Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sat, 9 Dec 2023 21:00:46 -0400 Subject: [PATCH] asahi: fix set_sampler_views Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/asahi/agx_state.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index 24198ce4aec..cd25a16fba9 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -846,9 +846,6 @@ agx_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader, count = 0; for (i = 0; i < count; ++i) { - if (views[i]) - new_nr = i + 1; - if (take_ownership) { pipe_sampler_view_reference( (struct pipe_sampler_view **)&ctx->stage[shader].textures[i], NULL); @@ -860,10 +857,17 @@ agx_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader, } } - for (; i < ctx->stage[shader].texture_count; i++) { + for (; i < count + unbind_num_trailing_slots; i++) { pipe_sampler_view_reference( (struct pipe_sampler_view **)&ctx->stage[shader].textures[i], NULL); } + + for (unsigned t = 0; t < MAX2(ctx->stage[shader].texture_count, count); + ++t) { + if (ctx->stage[shader].textures[t]) + new_nr = t + 1; + } + ctx->stage[shader].texture_count = new_nr; ctx->stage[shader].dirty |= AGX_STAGE_DIRTY_IMAGE; }