iris: add a iris_context reference to iris_batch
authorMark Janes <markjanes@swizzler.org>
Wed, 28 Oct 2020 21:13:48 +0000 (14:13 -0700)
committerMark Janes <markjanes@swizzler.org>
Tue, 2 Feb 2021 01:24:57 +0000 (17:24 -0800)
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 <kenneth@whitecape.org>

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7354>

src/gallium/drivers/iris/iris_batch.c
src/gallium/drivers/iris/iris_batch.h
src/gallium/drivers/iris/iris_context.c
src/gallium/drivers/iris/iris_state.c

index 5f885f5..70f40be 100644 (file)
@@ -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,
index 76927eb..302ebd5 100644 (file)
@@ -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;
index 391e0d1..80b666d 100644 (file)
@@ -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");
index 882b112..33c5b2c 100644 (file)
@@ -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;