Mesa (staging/21.3): zink: fix waiting on current batch id

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Feb 2 21:21:47 UTC 2022


Module: Mesa
Branch: staging/21.3
Commit: 05110a7860ec1953634e14915078c7b826e5d792
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=05110a7860ec1953634e14915078c7b826e5d792

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Tue Jan 18 17:40:56 2022 -0500

zink: fix waiting on current batch id

- the current batch id is always 0
- there is always a current batch
- a batch id can only be set at the time of submit

thus when passing 0 to wait on the current batch, the submit must complete
so that there is a batch id, and this must occur before the timeline wait
path or else the timeline wait does nothing

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14693>
(cherry picked from commit 3a0888c62fa3ebcce0494e3e07451fa9aa26b9df)

---

 .pick_status.json                       |  2 +-
 src/gallium/drivers/zink/zink_context.c | 14 +++++++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index bd36a2bd570..b46dc4d9e92 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1633,7 +1633,7 @@
         "description": "zink: fix waiting on current batch id",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 9bb924f1a5d..f7ebf827056 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -3094,11 +3094,15 @@ zink_fence_wait(struct pipe_context *pctx)
 void
 zink_wait_on_batch(struct zink_context *ctx, uint32_t batch_id)
 {
-   struct zink_batch_state *bs = ctx->batch.state;
-   assert(bs);
-   if (!batch_id || bs->fence.batch_id == batch_id)
+   struct zink_batch_state *bs;
+   if (!batch_id) {
       /* not submitted yet */
       flush_batch(ctx, true);
+      bs = zink_batch_state(ctx->last_fence);
+      assert(bs);
+      batch_id = bs->fence.batch_id;
+   }
+   assert(batch_id);
    if (ctx->have_timelines) {
       if (!zink_screen_timeline_wait(zink_screen(ctx->base.screen), batch_id, UINT64_MAX))
          check_device_lost(ctx);
@@ -3107,8 +3111,8 @@ zink_wait_on_batch(struct zink_context *ctx, uint32_t batch_id)
    simple_mtx_lock(&ctx->batch_mtx);
    struct zink_fence *fence;
 
-   assert(batch_id || ctx->last_fence);
-   if (ctx->last_fence && (!batch_id || batch_id == zink_batch_state(ctx->last_fence)->fence.batch_id))
+   assert(ctx->last_fence);
+   if (batch_id == zink_batch_state(ctx->last_fence)->fence.batch_id)
       fence = ctx->last_fence;
    else {
       for (bs = ctx->batch_states; bs; bs = bs->next) {



More information about the mesa-commit mailing list