zink: remove non-renderpass clear path from zink_clear_texture

this should always be faster

Acked-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17366>
This commit is contained in:
Mike Blumenkrantz 2022-07-06 08:40:50 -04:00 committed by Marge Bot
parent f1f08e3529
commit d53395ad06
1 changed files with 15 additions and 27 deletions

View File

@ -414,8 +414,6 @@ zink_clear_texture(struct pipe_context *pctx,
{ {
struct zink_context *ctx = zink_context(pctx); struct zink_context *ctx = zink_context(pctx);
struct zink_resource *res = zink_resource(pres); struct zink_resource *res = zink_resource(pres);
struct u_rect region = zink_rect_from_box(box);
bool needs_rp = !zink_blit_region_fills(region, u_minify(pres->width0, level), u_minify(pres->height0, level)) || ctx->render_condition_active;
struct pipe_surface *surf = NULL; struct pipe_surface *surf = NULL;
struct pipe_scissor_state scissor = {box->x, box->y, box->x + box->width, box->y + box->height}; struct pipe_scissor_state scissor = {box->x, box->y, box->x + box->width, box->y + box->height};
@ -424,16 +422,11 @@ zink_clear_texture(struct pipe_context *pctx,
util_format_unpack_rgba(pres->format, color.ui, data, 1); util_format_unpack_rgba(pres->format, color.ui, data, 1);
if (!needs_rp) { surf = create_clear_surface(pctx, pres, level, box);
zink_batch_no_rp(ctx); util_blitter_save_framebuffer(ctx->blitter, &ctx->fb_state);
clear_color_no_rp(ctx, res, &color, level, box->z, box->depth); set_clear_fb(pctx, surf, NULL);
} else { pctx->clear(pctx, PIPE_CLEAR_COLOR0, &scissor, &color, 0, 0);
surf = create_clear_surface(pctx, pres, level, box); util_blitter_restore_fb_state(ctx->blitter);
util_blitter_save_framebuffer(ctx->blitter, &ctx->fb_state);
set_clear_fb(pctx, surf, NULL);
pctx->clear(pctx, PIPE_CLEAR_COLOR0, &scissor, &color, 0, 0);
util_blitter_restore_fb_state(ctx->blitter);
}
} else { } else {
float depth = 0.0; float depth = 0.0;
uint8_t stencil = 0; uint8_t stencil = 0;
@ -444,21 +437,16 @@ zink_clear_texture(struct pipe_context *pctx,
if (res->aspect & VK_IMAGE_ASPECT_STENCIL_BIT) if (res->aspect & VK_IMAGE_ASPECT_STENCIL_BIT)
util_format_unpack_s_8uint(pres->format, &stencil, data, 1); util_format_unpack_s_8uint(pres->format, &stencil, data, 1);
if (!needs_rp) { unsigned flags = 0;
zink_batch_no_rp(ctx); if (res->aspect & VK_IMAGE_ASPECT_DEPTH_BIT)
clear_zs_no_rp(ctx, res, res->aspect, depth, stencil, level, box->z, box->depth); flags |= PIPE_CLEAR_DEPTH;
} else { if (res->aspect & VK_IMAGE_ASPECT_STENCIL_BIT)
unsigned flags = 0; flags |= PIPE_CLEAR_STENCIL;
if (res->aspect & VK_IMAGE_ASPECT_DEPTH_BIT) surf = create_clear_surface(pctx, pres, level, box);
flags |= PIPE_CLEAR_DEPTH; util_blitter_save_framebuffer(ctx->blitter, &ctx->fb_state);
if (res->aspect & VK_IMAGE_ASPECT_STENCIL_BIT) set_clear_fb(pctx, NULL, surf);
flags |= PIPE_CLEAR_STENCIL; pctx->clear(pctx, flags, &scissor, NULL, depth, stencil);
surf = create_clear_surface(pctx, pres, level, box); util_blitter_restore_fb_state(ctx->blitter);
util_blitter_save_framebuffer(ctx->blitter, &ctx->fb_state);
set_clear_fb(pctx, NULL, surf);
pctx->clear(pctx, flags, &scissor, NULL, depth, stencil);
util_blitter_restore_fb_state(ctx->blitter);
}
} }
/* this will never destroy the surface */ /* this will never destroy the surface */
pipe_surface_reference(&surf, NULL); pipe_surface_reference(&surf, NULL);