Commit 340df53d authored by Kenneth Graunke's avatar Kenneth Graunke

iris: Fix resource tracking for CS thread ID buffer

Today, we stream the compute shader thread IDs simply because they're
(annoyingly) relative to dynamic state base address.  We could upload
them once at compile time, but we'd need a separate non-streaming
uploader for IRIS_MEMZONE_DYNAMIC, and I'm not sure it's worth it.

stream_state pins the buffer for use in the current batch, but also
returns a reference to the pipe_resource.  We dropped this reference
on the floor, leaking a reference basically every time we dispatched
a compute shader after switching to a new one.

The reason it returns a reference is so that we can hold on to it and
re-pin it in iris_restore_compute_saved_bos, which we were also failing
to do.  So if we actually filled up a batch with repeated dispatches to
the same compute shader, and flushed, then continued dispatching, we
would fail to pin it and likely GPU hang.
parent 16d33495
......@@ -712,6 +712,7 @@ struct iris_context {
struct pipe_resource *scissor;
struct pipe_resource *blend;
struct pipe_resource *index_buffer;
struct pipe_resource *cs_thread_ids;
} last_res;
/** Records the size of variable-length state for INTEL_DEBUG=bat */
......@@ -4369,6 +4369,10 @@ iris_restore_compute_saved_bos(struct iris_context *ice,
struct iris_bo *bo = iris_resource_bo(shader->assembly.res);
iris_use_pinned_bo(batch, bo, false);
struct iris_bo *curbe_bo =
iris_use_pinned_bo(batch, curbe_bo, false);
struct brw_stage_prog_data *prog_data = shader->prog_data;
if (prog_data->total_scratch > 0) {
......@@ -5507,9 +5511,9 @@ iris_upload_compute_state(struct iris_context *ice,
assert(cs_prog_data->push.cross_thread.dwords == 0 &&
cs_prog_data->push.per_thread.dwords == 1 &&
cs_prog_data->base.param[0] == BRW_PARAM_BUILTIN_SUBGROUP_ID);
struct pipe_resource *curbe_data_res = NULL;
uint32_t *curbe_data_map =
stream_state(batch, ice->state.dynamic_uploader, &curbe_data_res,
stream_state(batch, ice->state.dynamic_uploader,
ALIGN(cs_prog_data->, 64), 64,
......@@ -5653,6 +5657,7 @@ iris_destroy_state(struct iris_context *ice)
pipe_resource_reference(&ice->state.last_res.scissor, NULL);
pipe_resource_reference(&ice->state.last_res.blend, NULL);
pipe_resource_reference(&ice->state.last_res.index_buffer, NULL);
pipe_resource_reference(&ice->state.last_res.cs_thread_ids, NULL);
/* ------------------------------------------------------------------- */
Markdown is supported
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