zink: add a context flag to indicate when blitter is running
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Thu, 13 Oct 2022 16:11:29 +0000 (12:11 -0400)
committerMarge Bot <emma+marge@anholt.net>
Sat, 29 Oct 2022 20:19:51 +0000 (20:19 +0000)
...or blitter-like functionality

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19077>

src/gallium/drivers/zink/zink_blit.c
src/gallium/drivers/zink/zink_clear.c
src/gallium/drivers/zink/zink_context.c
src/gallium/drivers/zink/zink_render_pass.c
src/gallium/drivers/zink/zink_types.h

index f43a2c3..135378f 100644 (file)
@@ -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);
index ddbb39e..eaebcb3 100644 (file)
@@ -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;
index f81432d..6157b49 100644 (file)
@@ -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;
    }
index 0367d83..002c878 100644 (file)
@@ -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;
       }
index e286d37..8dd4c1f 100644 (file)
@@ -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;