From b338bb70e0df3839718315140f217d173cc6d460 Mon Sep 17 00:00:00 2001 From: Mark Janes Date: Wed, 28 Oct 2020 14:13:48 -0700 Subject: [PATCH] iris: add a iris_context reference to iris_batch This eliminates the need to use container_of in error handling code. INTEL_MEASURE will need to access the iris context from each batch. suggested-by: Kenneth Graunke Acked-by: Kenneth Graunke Part-of: --- src/gallium/drivers/iris/iris_batch.c | 1 + src/gallium/drivers/iris/iris_batch.h | 1 + src/gallium/drivers/iris/iris_context.c | 8 +------- src/gallium/drivers/iris/iris_state.c | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/iris/iris_batch.c b/src/gallium/drivers/iris/iris_batch.c index 5f885f5..70f40be 100644 --- a/src/gallium/drivers/iris/iris_batch.c +++ b/src/gallium/drivers/iris/iris_batch.c @@ -180,6 +180,7 @@ iris_init_batch(struct iris_context *ice, batch->reset = &ice->reset; batch->state_sizes = ice->state.sizes; batch->name = name; + batch->ice = ice; batch->fine_fences.uploader = u_upload_create(&ice->ctx, 4096, PIPE_BIND_CUSTOM, diff --git a/src/gallium/drivers/iris/iris_batch.h b/src/gallium/drivers/iris/iris_batch.h index 76927eb..302ebd5 100644 --- a/src/gallium/drivers/iris/iris_batch.h +++ b/src/gallium/drivers/iris/iris_batch.h @@ -58,6 +58,7 @@ enum iris_batch_name { #define IRIS_BATCH_COUNT 2 struct iris_batch { + struct iris_context *ice; struct iris_screen *screen; struct pipe_debug_callback *dbg; struct pipe_device_reset_callback *reset; diff --git a/src/gallium/drivers/iris/iris_context.c b/src/gallium/drivers/iris/iris_context.c index 391e0d1..80b666d 100644 --- a/src/gallium/drivers/iris/iris_context.c +++ b/src/gallium/drivers/iris/iris_context.c @@ -78,17 +78,11 @@ iris_lost_context_state(struct iris_batch *batch) * we do need to inform the context of batch catastrophe. We know the * batch is one of our context's, so hackily claw our way back. */ - struct iris_context *ice = NULL; + struct iris_context *ice = batch->ice; if (batch->name == IRIS_BATCH_RENDER) { - ice = container_of(batch, struct iris_context, batches[IRIS_BATCH_RENDER]); - assert(&ice->batches[IRIS_BATCH_RENDER] == batch); - batch->screen->vtbl.init_render_context(batch); } else if (batch->name == IRIS_BATCH_COMPUTE) { - ice = container_of(batch, struct iris_context, batches[IRIS_BATCH_COMPUTE]); - assert(&ice->batches[IRIS_BATCH_COMPUTE] == batch); - batch->screen->vtbl.init_compute_context(batch); } else { unreachable("unhandled batch reset"); diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index 882b112..33c5b2c 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -812,7 +812,7 @@ iris_upload_slice_hashing_state(struct iris_batch *batch) if (subslices_delta == 0) return; - struct iris_context *ice = container_of(batch, struct iris_context, batches[IRIS_BATCH_RENDER]); + struct iris_context *ice = batch->ice; assert(&ice->batches[IRIS_BATCH_RENDER] == batch); unsigned size = GENX(SLICE_HASH_TABLE_length) * 4; -- 2.7.4