Mesa (main): zink: merge draw_count and compute_count, move to batch struct
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jul 27 00:35:24 UTC 2021
Module: Mesa
Branch: main
Commit: 9460c350b1b594f4808034eb902debd7eeb2e88c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9460c350b1b594f4808034eb902debd7eeb2e88c
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Fri May 21 17:27:43 2021 -0400
zink: merge draw_count and compute_count, move to batch struct
one fewer deref and now it's a single counter
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12010>
---
src/gallium/drivers/zink/zink_batch.c | 2 +-
src/gallium/drivers/zink/zink_batch.h | 4 ++--
src/gallium/drivers/zink/zink_draw.cpp | 14 ++++++--------
3 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c
index 276997f8d14..0b8373cd88d 100644
--- a/src/gallium/drivers/zink/zink_batch.c
+++ b/src/gallium/drivers/zink/zink_batch.c
@@ -101,7 +101,6 @@ zink_reset_batch_state(struct zink_context *ctx, struct zink_batch_state *bs)
bs->submit_count++;
bs->fence.batch_id = 0;
bs->usage.usage = 0;
- bs->draw_count = bs->compute_count = 0;
}
void
@@ -565,6 +564,7 @@ zink_end_batch(struct zink_context *ctx, struct zink_batch *batch)
if (_mesa_hash_table_num_entries(&ctx->batch_states) > 50)
ctx->oom_flush = true;
}
+ batch->work_count = 0;
if (screen->device_lost)
return;
diff --git a/src/gallium/drivers/zink/zink_batch.h b/src/gallium/drivers/zink/zink_batch.h
index af5aba1c27e..fb929bb7f0c 100644
--- a/src/gallium/drivers/zink/zink_batch.h
+++ b/src/gallium/drivers/zink/zink_batch.h
@@ -63,7 +63,6 @@ batch_ptr_add_usage(struct zink_batch *batch, struct set *s, void *ptr);
struct zink_batch_state {
struct zink_fence fence;
struct pipe_reference reference;
- unsigned draw_count;
struct zink_batch_usage usage;
struct zink_context *ctx;
@@ -75,7 +74,6 @@ struct zink_batch_state {
VkSemaphore sem;
struct util_queue_fence flush_completed;
- unsigned compute_count;
struct pipe_resource *flush_res;
@@ -109,6 +107,8 @@ struct zink_batch {
struct zink_batch_usage *last_batch_usage;
+ unsigned work_count;
+
bool has_work;
bool in_rp; //renderpass is currently active
};
diff --git a/src/gallium/drivers/zink/zink_draw.cpp b/src/gallium/drivers/zink/zink_draw.cpp
index 5e86f17f245..9afcf8b999b 100644
--- a/src/gallium/drivers/zink/zink_draw.cpp
+++ b/src/gallium/drivers/zink/zink_draw.cpp
@@ -420,7 +420,7 @@ zink_draw_vbo(struct pipe_context *pctx,
bool mode_changed = ctx->gfx_pipeline_state.mode != dinfo->mode;
bool reads_drawid = ctx->shader_reads_drawid;
bool reads_basevertex = ctx->shader_reads_basevertex;
- unsigned draw_count = ctx->batch.state->draw_count;
+ unsigned work_count = ctx->batch.work_count;
enum pipe_prim_type mode = dinfo->mode;
update_barriers(ctx, false);
@@ -690,7 +690,7 @@ zink_draw_vbo(struct pipe_context *pctx,
}
bool needs_drawid = reads_drawid && ctx->drawid_broken;
- draw_count += num_draws;
+ work_count += num_draws;
if (index_size > 0) {
if (dindirect && dindirect->buffer) {
assert(num_draws == 1);
@@ -752,10 +752,9 @@ zink_draw_vbo(struct pipe_context *pctx,
screen->vk.CmdEndTransformFeedbackEXT(batch->state->cmdbuf, 0, ctx->num_so_targets, counter_buffers, counter_buffer_offsets);
}
batch->has_work = true;
- ctx->batch.state->draw_count = draw_count;
+ ctx->batch.work_count = work_count;
/* flush if there's >100k draws */
- if (unlikely(ctx->batch.state->resource_size >= screen->total_video_mem / 2 ||
- draw_count >= 100000))
+ if (unlikely(work_count >= 100000))
pctx->flush(pctx, NULL, PIPE_FLUSH_ASYNC);
}
@@ -800,7 +799,7 @@ zink_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info)
offsetof(struct zink_cs_push_constant, work_dim), sizeof(uint32_t),
&info->work_dim);
- batch->state->compute_count++;
+ batch->work_count++;
if (info->indirect) {
vkCmdDispatchIndirect(batch->state->cmdbuf, zink_resource(info->indirect)->obj->buffer, info->indirect_offset);
zink_batch_reference_resource_rw(batch, zink_resource(info->indirect), false);
@@ -808,8 +807,7 @@ zink_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info)
vkCmdDispatch(batch->state->cmdbuf, info->grid[0], info->grid[1], info->grid[2]);
batch->has_work = true;
/* flush if there's >100k computes */
- if (unlikely(ctx->batch.state->resource_size >= zink_screen(ctx->base.screen)->total_video_mem / 2 ||
- ctx->batch.state->compute_count >= 100000))
+ if (unlikely(ctx->batch.work_count >= 100000))
pctx->flush(pctx, NULL, PIPE_FLUSH_ASYNC);
}
More information about the mesa-commit
mailing list