zink: break out fb clear apply into helper function

we'll be reusing this shortly...

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9206>
This commit is contained in:
Mike Blumenkrantz 2020-09-17 09:50:46 -04:00 committed by Marge Bot
parent f6cf5a64cc
commit a48bf14b44
1 changed files with 56 additions and 45 deletions

View File

@ -412,14 +412,14 @@ zink_fb_clear_needs_explicit(struct zink_framebuffer_clear *fb_clear)
return clear->has_scissor || clear->conditional;
}
void
zink_fb_clears_apply(struct zink_context *ctx, struct pipe_resource *pres)
static void
fb_clears_apply_internal(struct zink_context *ctx, struct pipe_resource *pres, int i)
{
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) {
struct zink_framebuffer_clear *fb_clear = &ctx->fb_clears[i];
if (fb_clear->enabled) {
if (!fb_clear->enabled)
return;
if (zink_resource(pres)->aspect == VK_IMAGE_ASPECT_COLOR_BIT) {
assert(!zink_curr_batch(ctx)->in_rp);
if (zink_fb_clear_needs_explicit(fb_clear) || !check_3d_layers(ctx->fb_state.cbufs[i]))
/* this will automatically trigger all the clears */
@ -442,13 +442,8 @@ zink_fb_clears_apply(struct zink_context *ctx, struct pipe_resource *pres)
psurf->u.tex.last_layer - psurf->u.tex.first_layer + 1);
}
zink_fb_clear_reset(&ctx->fb_clears[i]);
}
return;
}
}
} else {
struct zink_framebuffer_clear *fb_clear = &ctx->fb_clears[PIPE_MAX_COLOR_BUFS];
if (fb_clear->enabled && ctx->fb_state.zsbuf && ctx->fb_state.zsbuf->texture == pres) {
assert(!zink_curr_batch(ctx)->in_rp);
if (zink_fb_clear_needs_explicit(fb_clear) || !check_3d_layers(ctx->fb_state.zsbuf))
/* this will automatically trigger all the clears */
@ -464,8 +459,24 @@ zink_fb_clears_apply(struct zink_context *ctx, struct pipe_resource *pres)
clear_zs_no_rp(ctx, zink_resource(pres), aspects, clear->zs.depth, clear->zs.stencil,
psurf->u.tex.level, psurf->u.tex.first_layer,
psurf->u.tex.last_layer - psurf->u.tex.first_layer + 1);
}
}
zink_fb_clear_reset(fb_clear);
}
void
zink_fb_clears_apply(struct zink_context *ctx, struct pipe_resource *pres)
{
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_internal(ctx, pres, i);
return;
}
}
} else {
if (ctx->fb_state.zsbuf && ctx->fb_state.zsbuf->texture == pres) {
fb_clears_apply_internal(ctx, pres, PIPE_MAX_COLOR_BUFS);
}
}
}
@ -506,7 +517,7 @@ zink_clear_apply_conditionals(struct zink_context *ctx)
else
surf = ctx->fb_state.zsbuf;
if (surf)
zink_fb_clears_apply(ctx, surf->texture);
fb_clears_apply_internal(ctx, surf->texture, i);
else
zink_fb_clear_reset(&ctx->fb_clears[i]);
break;