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@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9190>
This commit is contained in:
Mike Blumenkrantz 2020-09-29 15:05:28 -04:00 committed by Marge Bot
parent 90bcb91cd5
commit 60726ed0d3
5 changed files with 15 additions and 8 deletions

View file

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

View file

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

View file

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

View file

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

View file

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