diff --git a/src/gallium/drivers/zink/zink_clear.c b/src/gallium/drivers/zink/zink_clear.c index e6927b13c3f..1ce1d039b73 100644 --- a/src/gallium/drivers/zink/zink_clear.c +++ b/src/gallium/drivers/zink/zink_clear.c @@ -530,48 +530,20 @@ zink_clear_depth_stencil(struct pipe_context *pctx, struct pipe_surface *dst, bool render_condition_enabled) { struct zink_context *ctx = zink_context(pctx); - struct zink_resource *res = zink_resource(dst->texture); - struct u_rect rect = {dstx, dstx + width, dsty, dsty + height}; - bool needs_rp = !zink_blit_region_fills(rect, dst->texture->width0, dst->texture->height0); - needs_rp |= check_3d_layers(dst); - bool cur_attachment = zink_csurface(ctx->fb_state.zsbuf) == zink_csurface(dst); bool render_condition_active = ctx->render_condition_active; - if (cur_attachment) { //current depth attachment - struct pipe_scissor_state scissor = {dstx, dsty, dstx + width, dsty + height}; - if (!render_condition_enabled && render_condition_active) { - zink_stop_conditional_render(ctx); - ctx->render_condition_active = false; - } - unsigned orig_width = ctx->fb_state.width, orig_height = ctx->fb_state.height; - bool fb_changed = !zink_blit_region_fills(rect, ctx->fb_state.width, ctx->fb_state.height); - if (fb_changed) { - ctx->fb_state.width = dstx + width; - ctx->fb_state.height = dsty + height; - ctx->fb_changed = true; - zink_batch_no_rp(ctx); - } - zink_clear(pctx, clear_flags, &scissor, NULL, depth, stencil); - zink_batch_rp(ctx); - if (fb_changed) { - ctx->fb_state.width = orig_width; - ctx->fb_state.height = orig_height; - ctx->fb_changed = true; - zink_batch_no_rp(ctx); - } - } else { - if (needs_rp) { - zink_blit_begin(ctx, ZINK_BLIT_SAVE_FB | ZINK_BLIT_SAVE_FS | (render_condition_enabled ? 0 : ZINK_BLIT_NO_COND_RENDER)); - util_blitter_clear_depth_stencil(ctx->blitter, dst, clear_flags, depth, stencil, dstx, dsty, width, height); - } else { - VkImageAspectFlags aspects = 0; - if (clear_flags & PIPE_CLEAR_DEPTH) - aspects |= VK_IMAGE_ASPECT_DEPTH_BIT; - if (clear_flags & PIPE_CLEAR_STENCIL) - aspects |= VK_IMAGE_ASPECT_STENCIL_BIT; - for (unsigned i = 0; i < res->base.b.last_level; i++) - clear_zs_no_rp(ctx, res, aspects, depth, stencil, i, 0, res->base.b.array_size); - } + if (!render_condition_enabled && render_condition_active) { + zink_stop_conditional_render(ctx); + ctx->render_condition_active = false; } + bool cur_attachment = zink_csurface(ctx->fb_state.zsbuf) == zink_csurface(dst); + if (!cur_attachment) { + util_blitter_save_framebuffer(ctx->blitter, &ctx->fb_state); + set_clear_fb(pctx, NULL, dst); + } + struct pipe_scissor_state scissor = {dstx, dsty, dstx + width, dsty + height}; + pctx->clear(pctx, clear_flags, &scissor, NULL, depth, stencil); + if (!cur_attachment) + util_blitter_restore_fb_state(ctx->blitter); if (!render_condition_enabled && render_condition_active) zink_start_conditional_render(ctx); ctx->render_condition_active = render_condition_active;