Commit 031d9a73 authored by Kenneth Graunke's avatar Kenneth Graunke
Browse files

iris: implement threaded context callbacks for resource busy checking

This allows u_threaded_context to reuse idle buffers, map them
asynchronously, and avoid reallocating them unnecessarily.

See commit 2fad90dc in radeonsi.
parent f791fe40
Pipeline #745054 waiting for manual action with stages
......@@ -1025,8 +1025,10 @@ _iris_batch_flush(struct iris_batch *batch, const char *file, int line)
struct iris_context *ice = batch->ice;
/* If a fence signals we need to flush it. */
if (iris_batch_bytes_used(batch) == 0 && !batch->contains_fence_signal)
if (iris_batch_bytes_used(batch) == 0 && !batch->contains_fence_signal) {
tc_driver_internal_flush_notify(ice->thrctx);
return;
}
iris_measure_batch_end(ice, batch);
......@@ -1077,6 +1079,8 @@ _iris_batch_flush(struct iris_batch *batch, const char *file, int line)
util_dynarray_clear(&batch->exec_fences);
tc_driver_internal_flush_notify(ice->thrctx);
if (INTEL_DEBUG(DEBUG_SYNC)) {
dbg_printf("waiting for idle\n");
iris_bo_wait_rendering(batch->bo); /* if execbuf failed; this is a nop */
......
......@@ -212,6 +212,15 @@ iris_flush_dirty_dmabufs(struct iris_context *ice)
clear_dirty_dmabuf_set(ice);
}
static bool
iris_tc_is_resource_busy(struct pipe_screen *pscreen,
struct pipe_resource *prsc,
unsigned usage)
{
struct iris_resource *res = (void *) prsc;
return iris_bo_busy(res->bo);
}
/**
* Destroy a context, freeing any associated memory.
*/
......@@ -386,8 +395,13 @@ iris_create_context(struct pipe_screen *pscreen, void *priv, unsigned flags)
if (flags & PIPE_CONTEXT_COMPUTE_ONLY)
return ctx;
struct threaded_context_options tc_options = {
.is_resource_busy = iris_tc_is_resource_busy,
.driver_calls_flush_notify = true,
};
return threaded_context_create(ctx, &screen->transfer_pool,
iris_replace_buffer_storage,
NULL, /* TODO: asynchronous flushes? */
&tc_options,
&ice->thrctx);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment