zink: flush gfx/compute batches when the other pipeline needs resource sync

if compute or gfx use a resource which is already in use by the other pipeline,
we need to ensure tha we flush that pipeline now in order to have commands execute
in the expected order

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8781>
This commit is contained in:
Mike Blumenkrantz 2020-08-12 17:00:09 -04:00 committed by Marge Bot
parent dac99517ff
commit ce6d08a0e7

View file

@ -456,13 +456,15 @@ update_descriptors(struct zink_context *ctx, struct zink_screen *screen, bool is
}
}
unsigned check_flush_id = is_compute ? 0 : ZINK_COMPUTE_BATCH_ID;
bool need_flush = false;
if (num_wds > 0) {
for (int i = 0; i < num_wds; ++i) {
wds[i].dstSet = desc_set;
if (read_desc_resources[i])
zink_batch_reference_resource_rw(batch, read_desc_resources[i], false);
need_flush |= zink_batch_reference_resource_rw(batch, read_desc_resources[i], false) == check_flush_id;
else if (write_desc_resources[i])
zink_batch_reference_resource_rw(batch, write_desc_resources[i], true);
need_flush |= zink_batch_reference_resource_rw(batch, write_desc_resources[i], true) == check_flush_id;
}
vkUpdateDescriptorSets(screen->dev, num_wds, wds, 0, NULL);
for (int i = 0; i < num_surface_refs; i++) {
@ -477,6 +479,17 @@ update_descriptors(struct zink_context *ctx, struct zink_screen *screen, bool is
else
vkCmdBindDescriptorSets(batch->cmdbuf, VK_PIPELINE_BIND_POINT_GRAPHICS,
ctx->curr_program->layout, 0, 1, &desc_set, 0, NULL);
if (!need_flush)
return;
if (is_compute)
/* flush gfx batch */
ctx->base.flush(&ctx->base, NULL, PIPE_FLUSH_HINT_FINISH);
else {
/* flush compute batch */
zink_end_batch(ctx, &ctx->compute_batch);
zink_start_batch(ctx, &ctx->compute_batch);
}
}
static bool