zink: flag ssbo buffer resources as having pending writes on batch

ssbos are the only descriptor type we support (so far) that allows writes
during the draw, so we have to ensure that we set the right flag on the batch
reference to handle sync if the buffer is later read from

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8330>
This commit is contained in:
Mike Blumenkrantz 2020-08-04 14:57:06 -04:00 committed by Marge Bot
parent d0d1888af0
commit e79d905f5a
3 changed files with 9 additions and 1 deletions

View File

@ -583,6 +583,10 @@ zink_set_shader_buffers(struct pipe_context *pctx,
{
struct zink_context *ctx = zink_context(pctx);
unsigned modified_bits = u_bit_consecutive(start_slot, count);
ctx->writable_ssbos &= ~modified_bits;
ctx->writable_ssbos |= writable_bitmask << start_slot;
for (unsigned i = 0; i < count; i++) {
struct pipe_shader_buffer *ssbo = &ctx->ssbos[p_stage][start_slot + i];
if (buffers && buffers[i].buffer) {

View File

@ -92,6 +92,7 @@ struct zink_context {
struct pipe_constant_buffer ubos[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
struct pipe_shader_buffer ssbos[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_BUFFERS];
uint32_t writable_ssbos;
struct pipe_framebuffer_state fb_state;
struct zink_vertex_elements_state *element_state;

View File

@ -356,7 +356,10 @@ zink_draw_vbo(struct pipe_context *pctx,
assert(ctx->ssbos[i][index].buffer_size <= screen->info.props.limits.maxStorageBufferRange);
assert(ctx->ssbos[i][index].buffer);
struct zink_resource *res = zink_resource(ctx->ssbos[i][index].buffer);
write_desc_resources[num_wds] = res;
if (ctx->writable_ssbos & (1 << index))
write_desc_resources[num_wds] = res;
else
read_desc_resources[num_wds] = res;
buffer_infos[num_buffer_info].buffer = res->buffer;
buffer_infos[num_buffer_info].offset = ctx->ssbos[i][index].buffer_offset;
buffer_infos[num_buffer_info].range = ctx->ssbos[i][index].buffer_size;