zink: add helper for applying/discarding clears based on a rect
this lets us test whether we're going to overwrite a scissored clear region in order to correctly no-op it Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9206>
This commit is contained in:
committed by
Marge Bot
parent
a48bf14b44
commit
031e3e68ee
@@ -525,3 +525,46 @@ zink_clear_apply_conditionals(struct zink_context *ctx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
fb_clears_apply_or_discard_internal(struct zink_context *ctx, struct pipe_resource *pres, struct u_rect region, bool discard_only, int i)
|
||||
{
|
||||
struct zink_framebuffer_clear *fb_clear = &ctx->fb_clears[i];
|
||||
if (fb_clear->enabled) {
|
||||
if (zink_blit_region_fills(region, pres->width0, pres->height0)) {
|
||||
/* we know we can skip these */
|
||||
zink_fb_clears_discard(ctx, pres);
|
||||
return;
|
||||
}
|
||||
for (int j = 0; j < zink_fb_clear_count(fb_clear); j++) {
|
||||
struct zink_framebuffer_clear_data *clear = zink_fb_clear_element(fb_clear, j);
|
||||
struct u_rect scissor = {clear->scissor.minx, clear->scissor.maxx,
|
||||
clear->scissor.miny, clear->scissor.maxy};
|
||||
if (!clear->has_scissor || zink_blit_region_covers(region, scissor)) {
|
||||
/* this is a clear that isn't fully covered by our pending write */
|
||||
if (!discard_only)
|
||||
fb_clears_apply_internal(ctx, pres, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* if we haven't already returned, then we know we can discard */
|
||||
zink_fb_clears_discard(ctx, pres);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
zink_fb_clears_apply_or_discard(struct zink_context *ctx, struct pipe_resource *pres, struct u_rect region, bool discard_only)
|
||||
{
|
||||
if (zink_resource(pres)->aspect == VK_IMAGE_ASPECT_COLOR_BIT) {
|
||||
for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
|
||||
if (ctx->fb_state.cbufs[i] && ctx->fb_state.cbufs[i]->texture == pres) {
|
||||
fb_clears_apply_or_discard_internal(ctx, pres, region, discard_only, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (ctx->fb_clears[PIPE_MAX_COLOR_BUFS].enabled && ctx->fb_state.zsbuf && ctx->fb_state.zsbuf->texture == pres) {
|
||||
fb_clears_apply_or_discard_internal(ctx, pres, region, discard_only, PIPE_MAX_COLOR_BUFS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,6 +340,9 @@ zink_fb_clears_apply(struct zink_context *ctx, struct pipe_resource *pres);
|
||||
void
|
||||
zink_fb_clears_discard(struct zink_context *ctx, struct pipe_resource *pres);
|
||||
|
||||
void
|
||||
zink_fb_clears_apply_or_discard(struct zink_context *ctx, struct pipe_resource *pres, struct u_rect region, bool discard_only);
|
||||
|
||||
void
|
||||
zink_draw_vbo(struct pipe_context *pctx,
|
||||
const struct pipe_draw_info *dinfo,
|
||||
|
||||
Reference in New Issue
Block a user