asahi: unbind samplers and fix sampler_count if state is NULL
When states is NULL, unbind samplers (to avoid dangling pointers) and set sampler_count to the highest non-null samplers[] entry instead of setting it to 0. This is ported from a similar fix in panfrost: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20285 Signed-off-by: Iago López Galeiras <iaguis@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20306>
This commit is contained in:
committed by
Marge Bot
parent
687a82d2d3
commit
5f2171625b
@@ -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 */
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user