diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index 40e35540554..7a693bf1c29 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -426,11 +426,18 @@ agx_bind_sampler_states(struct pipe_context *pctx, { struct agx_context *ctx = agx_context(pctx); - ctx->stage[shader].sampler_count = states ? count : 0; ctx->stage[shader].dirty = ~0; - memcpy(&ctx->stage[shader].samplers[start], states, - sizeof(struct agx_sampler_state *) * count); + for (unsigned i = 0; i < count; i++) { + unsigned p = start + i; + ctx->stage[shader].samplers[p] = states ? states[i] : NULL; + if (ctx->stage[shader].samplers[p]) + ctx->stage[shader].valid_samplers |= BITFIELD_BIT(p); + else + ctx->stage[shader].valid_samplers &= ~BITFIELD_BIT(p); + } + + ctx->stage[shader].sampler_count = util_last_bit(ctx->stage[shader].valid_samplers); } /* Channels agree for RGBA but are weird for force 0/1 */ diff --git a/src/gallium/drivers/asahi/agx_state.h b/src/gallium/drivers/asahi/agx_state.h index 78668951b76..4fc59a8213d 100644 --- a/src/gallium/drivers/asahi/agx_state.h +++ b/src/gallium/drivers/asahi/agx_state.h @@ -87,6 +87,7 @@ struct agx_stage { struct agx_sampler_view *textures[PIPE_MAX_SHADER_SAMPLER_VIEWS]; unsigned sampler_count, texture_count; + uint32_t valid_samplers; }; struct agx_batch {