From: Mike Blumenkrantz Date: Fri, 12 May 2023 16:26:52 +0000 (-0400) Subject: zink: track/check submit info on resource batch usage X-Git-Tag: upstream/23.3.3~8293 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db12b881c7fdbbe534b21b9d169db0a905c2c704;p=platform%2Fupstream%2Fmesa.git 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: --- diff --git a/src/gallium/drivers/zink/zink_bo.h b/src/gallium/drivers/zink/zink_bo.h index cbd2966..70c6ef1 100644 --- a/src/gallium/drivers/zink/zink_bo.h +++ b/src/gallium/drivers/zink/zink_bo.h @@ -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 diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index c5eec03..25b131b 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -550,6 +550,7 @@ struct zink_batch_usage { }; struct zink_bo_usage { + uint32_t submit_count; struct zink_batch_usage *u; };