zink: make batch_usage_matches take a batch state param
no functional changes, just some unwinding in some cases Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11399>
This commit is contained in:
committed by
Marge Bot
parent
6e0f552fd2
commit
1108db982e
@@ -547,20 +547,20 @@ zink_batch_reference_resource_rw(struct zink_batch *batch, struct zink_resource
|
||||
zink_get_depth_stencil_resources((struct pipe_resource*)res, NULL, &stencil);
|
||||
|
||||
/* if the resource already has usage of any sort set for this batch, we can skip hashing */
|
||||
if (res->obj->reads.usage != batch->state->fence.batch_id &&
|
||||
res->obj->writes.usage != batch->state->fence.batch_id) {
|
||||
if (!zink_batch_usage_matches(&res->obj->reads, batch->state) &&
|
||||
!zink_batch_usage_matches(&res->obj->writes, batch->state)) {
|
||||
bool found = false;
|
||||
_mesa_set_search_and_add(batch->state->fence.resources, res->obj, &found);
|
||||
if (!found) {
|
||||
pipe_reference(NULL, &res->obj->reference);
|
||||
if (!batch->last_batch_id || !zink_batch_usage_matches(&res->obj->reads, batch->last_batch_id))
|
||||
if (!batch->last_batch_id || res->obj->reads.usage != batch->last_batch_id)
|
||||
/* only add resource usage if it's "new" usage, though this only checks the most recent usage
|
||||
* and not all pending usages
|
||||
*/
|
||||
batch->state->resource_size += res->obj->size;
|
||||
if (stencil) {
|
||||
pipe_reference(NULL, &stencil->obj->reference);
|
||||
if (!batch->last_batch_id || !zink_batch_usage_matches(&stencil->obj->reads, batch->last_batch_id))
|
||||
if (!batch->last_batch_id || stencil->obj->reads.usage != batch->last_batch_id)
|
||||
batch->state->resource_size += stencil->obj->size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,10 +187,9 @@ zink_batch_usage_set(struct zink_batch_usage *u, struct zink_batch_state *bs)
|
||||
}
|
||||
|
||||
static inline bool
|
||||
zink_batch_usage_matches(struct zink_batch_usage *u, uint32_t batch_id)
|
||||
zink_batch_usage_matches(const struct zink_batch_usage *u, const struct zink_batch_state *bs)
|
||||
{
|
||||
uint32_t usage = p_atomic_read(&u->usage);
|
||||
return usage == batch_id;
|
||||
return u->usage == bs->fence.batch_id;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
|
||||
@@ -3146,8 +3146,8 @@ zink_resource_commit(struct pipe_context *pctx, struct pipe_resource *pres, unsi
|
||||
struct zink_screen *screen = zink_screen(pctx->screen);
|
||||
|
||||
/* if any current usage exists, flush the queue */
|
||||
if (zink_batch_usage_matches(&res->obj->reads, ctx->curr_batch) ||
|
||||
zink_batch_usage_matches(&res->obj->writes, ctx->curr_batch))
|
||||
if (res->obj->reads.usage == ctx->curr_batch ||
|
||||
res->obj->writes.usage == ctx->curr_batch)
|
||||
zink_flush_queue(ctx);
|
||||
|
||||
VkBindSparseInfo sparse;
|
||||
|
||||
@@ -825,7 +825,7 @@ init_mem_range(struct zink_screen *screen, struct zink_resource *res, VkDeviceSi
|
||||
bool
|
||||
zink_resource_has_curr_read_usage(struct zink_context *ctx, struct zink_resource *res)
|
||||
{
|
||||
return zink_batch_usage_matches(&res->obj->reads, ctx->curr_batch);
|
||||
return res->obj->reads.usage == ctx->curr_batch;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
|
||||
Reference in New Issue
Block a user