Commit 5f613822 authored by Mike Blumenkrantz's avatar Mike Blumenkrantz 🏋 Committed by Marge Bot
Browse files

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: a8e047e8

 ("zink: discard pending clears during blit/copy if we'll overwrite the data")
Reviewed-by: default avatarDave Airlie <airlied@redhat.com>
Part-of: <mesa/mesa!11307>
parent df402eb8
......@@ -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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment