void
zink_batch_reset_all(struct zink_context *ctx)
{
+ simple_mtx_lock(&ctx->batch_mtx);
hash_table_foreach(&ctx->batch_states, entry) {
struct zink_batch_state *bs = entry->data;
zink_reset_batch_state(ctx, bs);
_mesa_hash_table_remove(&ctx->batch_states, entry);
util_dynarray_append(&ctx->free_batch_states, struct zink_batch_state *, bs);
}
+ simple_mtx_unlock(&ctx->batch_mtx);
}
void
{
struct zink_batch_state *bs = NULL;
+ simple_mtx_lock(&ctx->batch_mtx);
if (util_dynarray_num_elements(&ctx->free_batch_states, struct zink_batch_state*))
bs = util_dynarray_pop(&ctx->free_batch_states, struct zink_batch_state*);
if (!bs) {
_mesa_hash_table_remove(&ctx->batch_states, he);
}
}
+ simple_mtx_unlock(&ctx->batch_mtx);
if (bs)
zink_reset_batch_state(ctx, bs);
else {
ctx->reset.reset(ctx->reset.data, PIPE_GUILTY_CONTEXT_RESET);
}
}
-
+ simple_mtx_lock(&ctx->batch_mtx);
ctx->last_fence = &batch->state->fence;
_mesa_hash_table_insert_pre_hashed(&ctx->batch_states, batch->state->fence.batch_id, (void*)(uintptr_t)batch->state->fence.batch_id, batch->state);
+ simple_mtx_unlock(&ctx->batch_mtx);
ctx->resource_size += batch->state->resource_size;
}
for (unsigned i = 0; i < ARRAY_SIZE(ctx->null_buffers); i++)
pipe_resource_reference(&ctx->null_buffers[i], NULL);
+ simple_mtx_destroy(&ctx->batch_mtx);
struct zink_fence *fence = zink_fence(&ctx->batch.state);
zink_clear_batch_state(ctx, ctx->batch.state);
zink_fence_reference(screen, &fence, NULL);
/* not submitted yet */
flush_batch(ctx);
+ simple_mtx_lock(&ctx->batch_mtx);
struct zink_fence *fence;
assert(batch_id || ctx->last_fence);
struct hash_entry *he = _mesa_hash_table_search_pre_hashed(&ctx->batch_states, batch_id, (void*)(uintptr_t)batch_id);
if (!he) {
util_dynarray_foreach(&ctx->free_batch_states, struct zink_batch_state*, bs) {
- if ((*bs)->fence.batch_id == batch_id)
+ if ((*bs)->fence.batch_id == batch_id) {
+ simple_mtx_unlock(&ctx->batch_mtx);
return;
+ }
}
- if (ctx->last_fence && ctx->last_fence->batch_id > batch_id)
+ if (ctx->last_fence && ctx->last_fence->batch_id > batch_id) {
/* already completed */
+ simple_mtx_unlock(&ctx->batch_mtx);
return;
+ }
unreachable("should've found batch state");
}
fence = he->data;
}
assert(fence);
ctx->base.screen->fence_finish(ctx->base.screen, &ctx->base, (struct pipe_fence_handle*)fence, PIPE_TIMEOUT_INFINITE);
+ simple_mtx_unlock(&ctx->batch_mtx);
}
static void
goto fail;
vkGetDeviceQueue(screen->dev, screen->gfx_queue, 0, &ctx->queue);
+ simple_mtx_init(&ctx->batch_mtx, mtx_plain);
ctx->program_cache = _mesa_hash_table_create(NULL,
hash_gfx_program,