Mesa (master): zink: rename 'has_draw' flag on batches and set it when the batch is used

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Feb 23 00:29:05 UTC 2021


Module: Mesa
Branch: master
Commit: 60726ed0d314ac928739249d7f825a753e1ad0c0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=60726ed0d314ac928739249d7f825a753e1ad0c0

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Tue Sep 29 15:05:28 2020 -0400

zink: rename 'has_draw' flag on batches and set it when the batch is used

this lets us add some tracking later for handling no-op fencing

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9190>

---

 src/gallium/drivers/zink/zink_batch.c   | 7 ++++++-
 src/gallium/drivers/zink/zink_batch.h   | 3 +--
 src/gallium/drivers/zink/zink_context.c | 6 +++---
 src/gallium/drivers/zink/zink_draw.c    | 4 ++--
 src/gallium/drivers/zink/zink_query.c   | 3 +++
 5 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c
index 943537f2c35..2cfd4c5744b 100644
--- a/src/gallium/drivers/zink/zink_batch.c
+++ b/src/gallium/drivers/zink/zink_batch.c
@@ -76,7 +76,7 @@ reset_batch(struct zink_context *ctx, struct zink_batch *batch)
 
    if (vkResetCommandPool(screen->dev, batch->cmdpool, 0) != VK_SUCCESS)
       fprintf(stderr, "vkResetCommandPool failed\n");
-   batch->has_draw = false;
+   batch->has_work = false;
 }
 
 void
@@ -188,6 +188,8 @@ zink_batch_reference_resource_rw(struct zink_batch *batch, struct zink_resource
 
    if (stencil)
       stencil->batch_uses[batch->batch_id] |= mask;
+
+   batch->has_work = true;
    return batch_to_flush;
 }
 
@@ -200,6 +202,7 @@ zink_batch_reference_sampler_view(struct zink_batch *batch,
       entry = _mesa_set_add(batch->sampler_views, sv);
       pipe_reference(NULL, &sv->base.reference);
    }
+   batch->has_work = true;
 }
 
 void
@@ -211,6 +214,7 @@ zink_batch_reference_program(struct zink_batch *batch,
       entry = _mesa_set_add(batch->programs, prog);
       pipe_reference(NULL, prog);
    }
+   batch->has_work = true;
 }
 
 void
@@ -223,4 +227,5 @@ zink_batch_reference_surface(struct zink_batch *batch,
       entry = _mesa_set_add(batch->surfaces, surf);
       pipe_reference(NULL, &surf->reference);
    }
+   batch->has_work = true;
 }
diff --git a/src/gallium/drivers/zink/zink_batch.h b/src/gallium/drivers/zink/zink_batch.h
index 402378b223f..3d95c6d466e 100644
--- a/src/gallium/drivers/zink/zink_batch.h
+++ b/src/gallium/drivers/zink/zink_batch.h
@@ -61,8 +61,7 @@ struct zink_batch {
    struct util_dynarray zombie_samplers;
 
    struct set *active_queries; /* zink_query objects which were active at some point in this batch */
-
-   bool has_draw;
+   bool has_work;
    bool in_rp; //renderpass is currently active
 };
 
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 12f9039e0ec..5f5d0b7473d 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1319,7 +1319,7 @@ static void
 zink_texture_barrier(struct pipe_context *pctx, unsigned flags)
 {
    struct zink_context *ctx = zink_context(pctx);
-   if (zink_curr_batch(ctx)->has_draw)
+   if (zink_curr_batch(ctx)->has_work)
       pctx->flush(pctx, NULL, 0);
    zink_flush_compute(ctx);
 }
@@ -1438,7 +1438,7 @@ zink_memory_barrier(struct pipe_context *pctx, unsigned flags)
    b.dstAccessMask = dflags;
 
    struct zink_batch *batch = zink_curr_batch(ctx);
-   if (batch->has_draw) {
+   if (batch->has_work) {
       zink_end_render_pass(ctx, batch);
 
       /* this should be the only call needed */
@@ -1446,7 +1446,7 @@ zink_memory_barrier(struct pipe_context *pctx, unsigned flags)
       flush_batch(ctx);
    }
    batch = &ctx->compute_batch;
-   if (batch->has_draw) {
+   if (batch->has_work) {
       /* this should be the only call needed */
       vkCmdPipelineBarrier(batch->cmdbuf, src, dst, 0, 0, &b, 0, NULL, 0, NULL);
       zink_end_batch(ctx, batch);
diff --git a/src/gallium/drivers/zink/zink_draw.c b/src/gallium/drivers/zink/zink_draw.c
index 9c8ffd2db3b..808d7976f4f 100644
--- a/src/gallium/drivers/zink/zink_draw.c
+++ b/src/gallium/drivers/zink/zink_draw.c
@@ -919,7 +919,7 @@ zink_draw_vbo(struct pipe_context *pctx,
       }
       screen->vk_CmdEndTransformFeedbackEXT(batch->cmdbuf, 0, ctx->num_so_targets, counter_buffers, counter_buffer_offsets);
    }
-   batch->has_draw = true;
+   batch->has_work = true;
 }
 
 void
@@ -945,5 +945,5 @@ zink_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info)
       zink_batch_reference_resource_rw(batch, zink_resource(info->indirect), false);
    } else
       vkCmdDispatch(batch->cmdbuf, info->grid[0], info->grid[1], info->grid[2]);
-   batch->has_draw = true;
+   batch->has_work = true;
 }
diff --git a/src/gallium/drivers/zink/zink_query.c b/src/gallium/drivers/zink/zink_query.c
index 0058d06c33b..1903e238348 100644
--- a/src/gallium/drivers/zink/zink_query.c
+++ b/src/gallium/drivers/zink/zink_query.c
@@ -203,6 +203,7 @@ zink_create_query(struct pipe_context *pctx,
       }
    }
    struct zink_batch *batch = get_batch_for_query(zink_context(pctx), query, true);
+   batch->has_work = true;
    vkCmdResetQueryPool(batch->cmdbuf, query->query_pool, 0, query->num_queries);
    if (query->type == PIPE_QUERY_PRIMITIVES_GENERATED)
       vkCmdResetQueryPool(batch->cmdbuf, query->xfb_query_pool[0], 0, query->num_queries);
@@ -506,6 +507,7 @@ begin_query(struct zink_context *ctx, struct zink_batch *batch, struct zink_quer
       reset_pool(ctx, batch, q);
    assert(q->curr_query < q->num_queries);
    q->active = true;
+   batch->has_work = true;
    if (q->type == PIPE_QUERY_TIME_ELAPSED)
       vkCmdWriteTimestamp(batch->cmdbuf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, q->query_pool, q->curr_query++);
    /* ignore the rest of begin_query for timestamps */
@@ -569,6 +571,7 @@ static void
 end_query(struct zink_context *ctx, struct zink_batch *batch, struct zink_query *q)
 {
    struct zink_screen *screen = zink_screen(ctx->base.screen);
+   batch->has_work = true;
    q->active = q->type == PIPE_QUERY_TIMESTAMP;
    if (is_time_query(q)) {
       vkCmdWriteTimestamp(batch->cmdbuf, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,



More information about the mesa-commit mailing list