Mesa (master): zink: optimize the remaining read cases of applying pending clear calls
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Feb 24 02:08:20 UTC 2021
Module: Mesa
Branch: master
Commit: 3c4bc68a05996058e4d346fe6580d93d3c0cb6d8
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3c4bc68a05996058e4d346fe6580d93d3c0cb6d8
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Thu Sep 17 16:32:54 2020 -0400
zink: optimize the remaining read cases of applying pending clear calls
we have src regions for all the blit/copy/map calls, so we can use those to
verify whether we actually need to apply the clears now or if we can keep
sitting on them a while longer
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9206>
---
src/gallium/drivers/zink/zink_blit.c | 4 ++--
src/gallium/drivers/zink/zink_context.c | 2 +-
src/gallium/drivers/zink/zink_resource.c | 7 ++++++-
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_blit.c b/src/gallium/drivers/zink/zink_blit.c
index b358b26d3b3..4d6bdcf35af 100644
--- a/src/gallium/drivers/zink/zink_blit.c
+++ b/src/gallium/drivers/zink/zink_blit.c
@@ -39,7 +39,7 @@ blit_resolve(struct zink_context *ctx, const struct pipe_blit_info *info)
info->dst.box.x, info->dst.box.x + info->dst.box.width);
zink_fb_clears_apply_or_discard(ctx, info->dst.resource, zink_rect_from_box(&info->dst.box), false);
- zink_fb_clears_apply(ctx, info->src.resource);
+ zink_fb_clears_apply_region(ctx, info->src.resource, zink_rect_from_box(&info->src.box));
struct zink_batch *batch = zink_batch_no_rp(ctx);
zink_batch_reference_resource_rw(batch, src, false);
@@ -121,7 +121,7 @@ blit_native(struct zink_context *ctx, const struct pipe_blit_info *info)
return false;
zink_fb_clears_apply_or_discard(ctx, info->dst.resource, zink_rect_from_box(&info->dst.box), false);
- zink_fb_clears_apply(ctx, info->src.resource);
+ zink_fb_clears_apply_region(ctx, info->src.resource, zink_rect_from_box(&info->src.box));
struct zink_batch *batch = zink_batch_no_rp(ctx);
zink_batch_reference_resource_rw(batch, src, false);
zink_batch_reference_resource_rw(batch, dst, true);
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 0e5938186a9..3d7ed3584eb 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1592,7 +1592,7 @@ zink_resource_copy_region(struct pipe_context *pctx,
unreachable("planar formats not yet handled");
zink_fb_clears_apply_or_discard(ctx, pdst, (struct u_rect){dstx, dstx + src_box->width, dsty, dsty + src_box->height}, false);
- zink_fb_clears_apply(ctx, psrc);
+ zink_fb_clears_apply_region(ctx, psrc, zink_rect_from_box(src_box));
region.srcSubresource.aspectMask = src->aspect;
region.srcSubresource.mipLevel = src_level;
diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index 2ec1f84a9b1..a1830429af9 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -619,7 +619,12 @@ zink_transfer_map(struct pipe_context *pctx,
if (usage & PIPE_MAP_WRITE)
util_range_add(&res->base, &res->valid_buffer_range, box->x, box->x + box->width);
} else {
- zink_fb_clears_apply(ctx, pres);
+ if (usage & PIPE_MAP_WRITE && !(usage & PIPE_MAP_READ))
+ /* this is like a blit, so we can potentially dump some clears or maybe we have to */
+ zink_fb_clears_apply_or_discard(ctx, pres, zink_rect_from_box(box), false);
+ else if (usage & PIPE_MAP_READ)
+ /* if the map region intersects with any clears then we have to apply them */
+ zink_fb_clears_apply_region(ctx, pres, zink_rect_from_box(box));
if (res->optimal_tiling || !res->host_visible) {
enum pipe_format format = pres->format;
if (usage & PIPE_MAP_DEPTH_ONLY)
More information about the mesa-commit
mailing list