zink: split batch state work_count into separate vars

this has better struct packing

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11400>
This commit is contained in:
Mike Blumenkrantz 2021-05-07 09:37:04 -04:00 committed by Marge Bot
parent b85a6b9162
commit e1ba1b5b25
4 changed files with 7 additions and 5 deletions

View File

@ -92,7 +92,7 @@ zink_reset_batch_state(struct zink_context *ctx, struct zink_batch_state *bs)
bs->has_barriers = false;
zink_screen_update_last_finished(screen, bs->fence.batch_id);
bs->fence.batch_id = 0;
bs->work_count[0] = bs->work_count[1] = 0;
bs->draw_count = bs->compute_count = 0;
}
void

View File

@ -56,6 +56,8 @@ batch_ptr_add_usage(struct zink_batch *batch, struct set *s, void *ptr, struct z
struct zink_batch_state {
struct zink_fence fence;
struct pipe_reference reference;
unsigned draw_count;
struct zink_context *ctx;
VkCommandPool cmdpool;
VkCommandBuffer cmdbuf;
@ -66,6 +68,7 @@ struct zink_batch_state {
VkSemaphore sem;
struct util_queue_fence flush_completed;
unsigned compute_count;
struct zink_resource *flush_res;
@ -86,7 +89,6 @@ struct zink_batch_state {
bool is_device_lost;
bool have_timelines;
unsigned work_count[2];
};
struct zink_batch {

View File

@ -2458,7 +2458,7 @@ zink_maybe_flush_or_stall(struct zink_context *ctx)
/* flush anytime our total batch memory usage is potentially >= 50% of total video memory */
if (ctx->batch.state->resource_size >= screen->total_video_mem / 2 ||
/* or if there's >100k draws+computes */
ctx->batch.state->work_count[0] + ctx->batch.state->work_count[1] >= 100000)
ctx->batch.state->draw_count + ctx->batch.state->compute_count >= 100000)
flush_batch(ctx, true);
if (ctx->resource_size >= screen->total_video_mem / 2 || _mesa_hash_table_num_entries(&ctx->batch_states) > 100) {

View File

@ -695,7 +695,7 @@ zink_draw_vbo(struct pipe_context *pctx,
unsigned draw_id = drawid_offset;
bool needs_drawid = ctx->drawid_broken;
batch->state->work_count[0] += num_draws;
batch->state->draw_count += num_draws;
if (dinfo->index_size > 0) {
VkIndexType index_type;
unsigned index_size = dinfo->index_size;
@ -819,7 +819,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->work_count[1]++;
batch->state->compute_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);