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@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12010>
This commit is contained in:
Mike Blumenkrantz 2021-05-21 17:27:43 -04:00 committed by Marge Bot
parent 48473ec967
commit 9460c350b1
3 changed files with 9 additions and 11 deletions

View file

@ -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;

View file

@ -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
};

View file

@ -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);
}