zink: track/check submit info on resource batch usage

resources use a private refcount to avoid overhead from atomics on
descriptor binds, but this has the side effect of evading batch usage,
meaning that the usage may not be properly removed once the batch state
is reset, which will cause issues with detecting whether usage exists
for a given resource

to fix this, the mechanism for tc fence disambiguation can be reused,
namely adding the batch state's submit count to the usage info and
then using that to add a second set of comparisons such that it becomes
possible to check both whether the batch usage for a resource matches
a given batch AND whether the batch usage is the current state of the
batch

affects:
KHR-GLES3.copy_tex_image_conversions.required.cubemap_posy_cubemap_negz

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23035>
This commit is contained in:
Mike Blumenkrantz 2023-05-12 12:26:52 -04:00 committed by Marge Bot
parent 5e1943db7f
commit db12b881c7
2 changed files with 12 additions and 8 deletions

View file

@ -145,22 +145,22 @@ zink_bo_commit(struct zink_screen *screen, struct zink_resource *res, unsigned l
static inline bool
zink_bo_has_unflushed_usage(const struct zink_bo *bo)
{
return zink_batch_usage_is_unflushed(bo->reads.u) ||
zink_batch_usage_is_unflushed(bo->writes.u);
return (zink_batch_usage_is_unflushed(bo->reads.u) && bo->reads.submit_count == bo->reads.u->submit_count) ||
(zink_batch_usage_is_unflushed(bo->writes.u) && bo->writes.submit_count == bo->writes.u->submit_count);
}
static inline bool
zink_bo_has_usage(const struct zink_bo *bo)
{
return zink_batch_usage_exists(bo->reads.u) ||
zink_batch_usage_exists(bo->writes.u);
return (zink_batch_usage_exists(bo->reads.u) && bo->reads.submit_count == bo->reads.u->submit_count) ||
(zink_batch_usage_exists(bo->writes.u) && bo->writes.submit_count == bo->writes.u->submit_count);
}
static inline bool
zink_bo_usage_matches(const struct zink_bo *bo, const struct zink_batch_state *bs)
{
return zink_batch_usage_matches(bo->reads.u, bs) ||
zink_batch_usage_matches(bo->writes.u, bs);
return (zink_batch_usage_matches(bo->reads.u, bs) && bo->reads.submit_count == bo->reads.u->submit_count) ||
(zink_batch_usage_matches(bo->writes.u, bs) && bo->writes.submit_count == bo->writes.u->submit_count);
}
static inline bool
@ -204,10 +204,13 @@ zink_bo_usage_try_wait(struct zink_context *ctx, struct zink_bo *bo, enum zink_r
static inline void
zink_bo_usage_set(struct zink_bo *bo, struct zink_batch_state *bs, bool write)
{
if (write)
if (write) {
zink_batch_usage_set(&bo->writes.u, bs);
else
bo->writes.submit_count = bs->usage.submit_count;
} else {
zink_batch_usage_set(&bo->reads.u, bs);
bo->reads.submit_count = bs->usage.submit_count;
}
}
static inline bool

View file

@ -550,6 +550,7 @@ struct zink_batch_usage {
};
struct zink_bo_usage {
uint32_t submit_count;
struct zink_batch_usage *u;
};