From 5f61382280dc4a82528bce31a8df2c8eed052386 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 10 Jun 2021 15:52:18 -0400 Subject: [PATCH] zink: use scissor region for discarding clears during blit ensure that clears aren't being mistakenly discarded or applied due to scissor region being ignored and full surface geometry being used Fixes: a8e047e8f4a ("zink: discard pending clears during blit/copy if we'll overwrite the data") Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_blit.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/zink/zink_blit.c b/src/gallium/drivers/zink/zink_blit.c index 3ea9ac7..9de8e56 100644 --- a/src/gallium/drivers/zink/zink_blit.c +++ b/src/gallium/drivers/zink/zink_blit.c @@ -8,6 +8,17 @@ #include "util/u_surface.h" #include "util/format/u_format.h" +static void +apply_dst_clears(struct zink_context *ctx, const struct pipe_blit_info *info, bool discard_only) +{ + if (info->scissor_enable) { + struct u_rect rect = { info->scissor.minx, info->scissor.maxx, + info->scissor.miny, info->scissor.maxy }; + zink_fb_clears_apply_or_discard(ctx, info->dst.resource, rect, discard_only); + } else + zink_fb_clears_apply_or_discard(ctx, info->dst.resource, zink_rect_from_box(&info->dst.box), discard_only); +} + static bool blit_resolve(struct zink_context *ctx, const struct pipe_blit_info *info) { @@ -38,7 +49,7 @@ blit_resolve(struct zink_context *ctx, const struct pipe_blit_info *info) util_range_add(info->dst.resource, &dst->valid_buffer_range, 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); + apply_dst_clears(ctx, info, false); 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); @@ -143,7 +154,7 @@ blit_native(struct zink_context *ctx, const struct pipe_blit_info *info) VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT)) return false; - zink_fb_clears_apply_or_discard(ctx, info->dst.resource, zink_rect_from_box(&info->dst.box), false); + apply_dst_clears(ctx, info, false); 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); @@ -276,7 +287,10 @@ zink_blit(struct pipe_context *pctx, return; } - zink_fb_clears_apply_or_discard(ctx, info->dst.resource, zink_rect_from_box(&info->dst.box), true); + /* this is discard_only because we're about to start a renderpass that will + * flush all pending clears anyway + */ + apply_dst_clears(ctx, info, true); if (info->dst.resource->target == PIPE_BUFFER) util_range_add(info->dst.resource, &dst->valid_buffer_range, -- 2.7.4