From 58f09f599356757171f9a53576061d6c267c52db Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 13 Oct 2022 12:11:29 -0400 Subject: [PATCH] zink: add a context flag to indicate when blitter is running ...or blitter-like functionality Part-of: --- src/gallium/drivers/zink/zink_blit.c | 2 ++ src/gallium/drivers/zink/zink_clear.c | 11 ++++++++++- src/gallium/drivers/zink/zink_context.c | 2 ++ src/gallium/drivers/zink/zink_render_pass.c | 3 ++- src/gallium/drivers/zink/zink_types.h | 1 + 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/zink/zink_blit.c b/src/gallium/drivers/zink/zink_blit.c index f43a2c38325..135378f4d0a 100644 --- a/src/gallium/drivers/zink/zink_blit.c +++ b/src/gallium/drivers/zink/zink_blit.c @@ -344,6 +344,7 @@ zink_blit(struct pipe_context *pctx, /* this will draw a full-resource quad, so ignore existing data */ if (util_blit_covers_whole_resource(info)) pctx->invalidate_resource(pctx, info->dst.resource); + ctx->blitting = true; zink_blit_begin(ctx, ZINK_BLIT_SAVE_FB | ZINK_BLIT_SAVE_FS | ZINK_BLIT_SAVE_TEXTURES); if (stencil_blit) { @@ -368,6 +369,7 @@ zink_blit(struct pipe_context *pctx, } else { util_blitter_blit(ctx->blitter, info); } + ctx->blitting = false; end: if (needs_present_readback) zink_kopper_present_readback(ctx, src); diff --git a/src/gallium/drivers/zink/zink_clear.c b/src/gallium/drivers/zink/zink_clear.c index ddbb39e27e0..eaebcb3b6fc 100644 --- a/src/gallium/drivers/zink/zink_clear.c +++ b/src/gallium/drivers/zink/zink_clear.c @@ -451,8 +451,10 @@ zink_clear_texture(struct pipe_context *pctx, surf = create_clear_surface(pctx, pres, level, box); util_blitter_save_framebuffer(ctx->blitter, &ctx->fb_state); set_clear_fb(pctx, surf, NULL); + ctx->blitting = true; pctx->clear(pctx, PIPE_CLEAR_COLOR0, &scissor, &color, 0, 0); util_blitter_restore_fb_state(ctx->blitter); + ctx->blitting = false; } else { float depth = 0.0; uint8_t stencil = 0; @@ -470,9 +472,11 @@ zink_clear_texture(struct pipe_context *pctx, flags |= PIPE_CLEAR_STENCIL; surf = create_clear_surface(pctx, pres, level, box); util_blitter_save_framebuffer(ctx->blitter, &ctx->fb_state); + ctx->blitting = true; set_clear_fb(pctx, NULL, surf); pctx->clear(pctx, flags, &scissor, NULL, depth, stencil); util_blitter_restore_fb_state(ctx->blitter); + ctx->blitting = false; } /* this will never destroy the surface */ pipe_surface_reference(&surf, NULL); @@ -538,8 +542,10 @@ zink_clear_render_target(struct pipe_context *pctx, struct pipe_surface *dst, util_blitter_save_framebuffer(ctx->blitter, &ctx->fb_state); set_clear_fb(pctx, dst, NULL); struct pipe_scissor_state scissor = {dstx, dsty, dstx + width, dsty + height}; + ctx->blitting = true; pctx->clear(pctx, PIPE_CLEAR_COLOR0, &scissor, color, 0, 0); util_blitter_restore_fb_state(ctx->blitter); + ctx->blitting = false; if (!render_condition_enabled && render_condition_active) zink_start_conditional_render(ctx); ctx->render_condition_active = render_condition_active; @@ -565,11 +571,14 @@ zink_clear_depth_stencil(struct pipe_context *pctx, struct pipe_surface *dst, if (!cur_attachment) { util_blitter_save_framebuffer(ctx->blitter, &ctx->fb_state); set_clear_fb(pctx, NULL, dst); + ctx->blitting = true; } struct pipe_scissor_state scissor = {dstx, dsty, dstx + width, dsty + height}; pctx->clear(pctx, clear_flags, &scissor, NULL, depth, stencil); - if (!cur_attachment) + if (!cur_attachment) { util_blitter_restore_fb_state(ctx->blitter); + ctx->blitting = false; + } if (!render_condition_enabled && render_condition_active) zink_start_conditional_render(ctx); ctx->render_condition_active = render_condition_active; diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index f81432dc889..6157b494101 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -3612,8 +3612,10 @@ zink_flush(struct pipe_context *pctx, ctx->fbfetch_outputs = 0; ctx->rp_changed = true; } + ctx->blitting = true; /* start rp to do all the clears */ zink_batch_rp(ctx); + ctx->blitting = false; ctx->fbfetch_outputs = fbfetch_outputs; ctx->rp_changed |= fbfetch_outputs > 0; } diff --git a/src/gallium/drivers/zink/zink_render_pass.c b/src/gallium/drivers/zink/zink_render_pass.c index 0367d831bc1..002c8785758 100644 --- a/src/gallium/drivers/zink/zink_render_pass.c +++ b/src/gallium/drivers/zink/zink_render_pass.c @@ -697,11 +697,12 @@ zink_begin_render_pass(struct zink_context *ctx) src_view = ctx->base.create_sampler_view(&ctx->base, src, &src_templ); zink_blit_begin(ctx, ZINK_BLIT_SAVE_FB | ZINK_BLIT_SAVE_FS | ZINK_BLIT_SAVE_TEXTURES); + ctx->blitting = true; util_blitter_blit_generic(ctx->blitter, dst_view, &dstbox, src_view, &dstbox, ctx->fb_state.width, ctx->fb_state.height, PIPE_MASK_RGBAZS, PIPE_TEX_FILTER_NEAREST, NULL, false, false, 0); - + ctx->blitting = false; pipe_sampler_view_reference(&src_view, NULL); csurf->transient_init = true; } diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index e286d37ca44..8dd4c1fbd14 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -1665,6 +1665,7 @@ struct zink_context { bool is_device_lost; bool primitive_restart; + bool blitting : 1; bool vertex_state_changed : 1; bool blend_state_changed : 1; bool sample_mask_changed : 1;