util_queue_fence_destroy(&bs->flush_completed);
+ cnd_destroy(&bs->usage.flush);
+ mtx_destroy(&bs->usage.mtx);
+
if (bs->fence.fence)
vkDestroyFence(screen->dev, bs->fence.fence, NULL);
util_dynarray_init(&bs->zombie_samplers, NULL);
util_dynarray_init(&bs->persistent_resources, NULL);
+ cnd_init(&bs->usage.flush);
+ mtx_init(&bs->usage.mtx, mtx_plain);
+
if (!screen->batch_descriptor_init(screen, bs))
goto fail;
bs->is_device_lost = true;
}
bs->submit_count++;
+ cnd_broadcast(&bs->usage.flush);
+
p_atomic_set(&bs->fence.submitted, true);
}
{
if (!zink_batch_usage_exists(u))
return;
+ if (zink_batch_usage_is_unflushed(u)) {
+ if (likely(u == &ctx->batch.state->usage))
+ ctx->base.flush(&ctx->base, NULL, PIPE_FLUSH_HINT_FINISH);
+ else { //multi-context
+ mtx_lock(&u->mtx);
+ cnd_wait(&u->flush, &u->mtx);
+ mtx_unlock(&u->mtx);
+ }
+ }
zink_wait_on_batch(ctx, u->usage);
}
struct zink_resource *staging_res = zink_resource(trans->staging_res);
if (usage & PIPE_MAP_READ) {
+ /* force multi-context sync */
+ if (zink_batch_usage_is_unflushed(res->obj->writes))
+ zink_batch_usage_wait(ctx, res->obj->writes);
zink_transfer_copy_bufimage(ctx, staging_res, res, trans);
/* need to wait for rendering to finish */
zink_fence_wait(pctx);