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>
{
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) {
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;
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;