zink: improve handling of buffer rebinds using tc info

tc rebind info can't distinguish between buffers bound multiple times
in a given bind point (e.g., for multiple vertex buffers), so ensure all
rebinds are processed and the global rebind isn't triggered if multiple rebinds
are processed for a given buffer

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12934>
This commit is contained in:
Mike Blumenkrantz 2021-09-15 20:27:09 -04:00 committed by Marge Bot
parent 9dbf1ba21d
commit c32bcb9a8c
1 changed files with 12 additions and 7 deletions

View File

@ -3298,7 +3298,7 @@ rebind_ibo(struct zink_context *ctx, enum pipe_shader_type shader, unsigned slot
}
static unsigned
rebind_buffer(struct zink_context *ctx, struct zink_resource *res, const uint32_t rebind_mask, const unsigned expected_num_rebinds)
rebind_buffer(struct zink_context *ctx, struct zink_resource *res, uint32_t rebind_mask, const unsigned expected_num_rebinds)
{
unsigned num_rebinds = 0;
bool has_write = false;
@ -3313,8 +3313,9 @@ rebind_buffer(struct zink_context *ctx, struct zink_resource *res, const uint32_
}
}
}
rebind_mask &= ~BITFIELD_BIT(TC_BINDING_STREAMOUT_BUFFER);
}
if (num_rebinds && expected_num_rebinds == num_rebinds)
if (num_rebinds && expected_num_rebinds >= num_rebinds && !rebind_mask)
goto end;
if ((rebind_mask & BITFIELD_BIT(TC_BINDING_VERTEX_BUFFER)) || (!rebind_mask && res->vbo_bind_mask)) {
@ -3324,9 +3325,10 @@ rebind_buffer(struct zink_context *ctx, struct zink_resource *res, const uint32_
set_vertex_buffer_clamped(ctx, slot);
num_rebinds++;
}
rebind_mask &= ~BITFIELD_BIT(TC_BINDING_VERTEX_BUFFER);
ctx->vertex_buffers_dirty = true;
}
if (num_rebinds && expected_num_rebinds == num_rebinds)
if (num_rebinds && expected_num_rebinds >= num_rebinds && !rebind_mask)
goto end;
const uint32_t ubo_mask = rebind_mask ?
@ -3341,7 +3343,8 @@ rebind_buffer(struct zink_context *ctx, struct zink_resource *res, const uint32_
num_rebinds++;
}
}
if (num_rebinds && expected_num_rebinds == num_rebinds)
rebind_mask &= ~BITFIELD_RANGE(TC_BINDING_UBO_VS, PIPE_SHADER_TYPES);
if (num_rebinds && expected_num_rebinds >= num_rebinds && !rebind_mask)
goto end;
const unsigned ssbo_mask = rebind_mask ?
@ -3357,7 +3360,8 @@ rebind_buffer(struct zink_context *ctx, struct zink_resource *res, const uint32_
num_rebinds++;
}
}
if (num_rebinds && expected_num_rebinds == num_rebinds)
rebind_mask &= ~BITFIELD_RANGE(TC_BINDING_SSBO_VS, PIPE_SHADER_TYPES);
if (num_rebinds && expected_num_rebinds >= num_rebinds && !rebind_mask)
goto end;
const unsigned sampler_mask = rebind_mask ?
rebind_mask & BITFIELD_RANGE(TC_BINDING_SAMPLERVIEW_VS, PIPE_SHADER_TYPES) :
@ -3371,7 +3375,8 @@ rebind_buffer(struct zink_context *ctx, struct zink_resource *res, const uint32_
num_rebinds++;
}
}
if (num_rebinds && expected_num_rebinds == num_rebinds)
rebind_mask &= ~BITFIELD_RANGE(TC_BINDING_SAMPLERVIEW_VS, PIPE_SHADER_TYPES);
if (num_rebinds && expected_num_rebinds >= num_rebinds && !rebind_mask)
goto end;
const unsigned image_mask = rebind_mask ?
@ -3516,7 +3521,7 @@ zink_context_replace_buffer_storage(struct pipe_context *pctx, struct pipe_resou
d->obj = s->obj;
/* force counter buffer reset */
d->so_valid = false;
if (num_rebinds && rebind_buffer(ctx, d, rebind_mask, num_rebinds) != num_rebinds)
if (num_rebinds && rebind_buffer(ctx, d, rebind_mask, num_rebinds) < num_rebinds)
ctx->buffer_rebind_counter = p_atomic_inc_return(&screen->buffer_rebind_counter);
}