panfrost: Use dedicated u_blitter context for wallpapers
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Sun, 23 Jun 2019 18:05:10 +0000 (11:05 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 25 Jun 2019 20:39:17 +0000 (13:39 -0700)
The main ctx->blitter instance should be reserved for blits originated
from Gallium (like mipmap generation). Since wallpapering is
conceptually different -- wallpaper blits can be triggered by Gallium
blits -- the blitter pipes must be separate to avoid potential u_blitter
recursion.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_blit.c
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_context.h

index 1e50448a67def3a1615554534dadd88d7ba5b79d..c98e08e8a0b0502dd17895ee221c6dcf3476fd4e 100644 (file)
 #include "util/u_format.h"
 
 static void
-panfrost_blitter_save(struct panfrost_context *ctx)
+panfrost_blitter_save(
+                struct panfrost_context *ctx,
+                struct blitter_context *blitter)
 {
 
-        util_blitter_save_vertex_buffer_slot(ctx->blitter, ctx->vertex_buffers);
-        util_blitter_save_vertex_elements(ctx->blitter, ctx->vertex);
-        util_blitter_save_vertex_shader(ctx->blitter, ctx->vs);
-        util_blitter_save_rasterizer(ctx->blitter, ctx->rasterizer);
-        util_blitter_save_viewport(ctx->blitter, &ctx->pipe_viewport);
-        util_blitter_save_scissor(ctx->blitter, &ctx->scissor);
-        util_blitter_save_fragment_shader(ctx->blitter, ctx->fs);
-        util_blitter_save_blend(ctx->blitter, ctx->blend);
-        util_blitter_save_depth_stencil_alpha(ctx->blitter, ctx->depth_stencil);
-        util_blitter_save_stencil_ref(ctx->blitter, &ctx->stencil_ref);
-       util_blitter_save_so_targets(ctx->blitter, 0, NULL);
+        util_blitter_save_vertex_buffer_slot(blitter, ctx->vertex_buffers);
+        util_blitter_save_vertex_elements(blitter, ctx->vertex);
+        util_blitter_save_vertex_shader(blitter, ctx->vs);
+        util_blitter_save_rasterizer(blitter, ctx->rasterizer);
+        util_blitter_save_viewport(blitter, &ctx->pipe_viewport);
+        util_blitter_save_scissor(blitter, &ctx->scissor);
+        util_blitter_save_fragment_shader(blitter, ctx->fs);
+        util_blitter_save_blend(blitter, ctx->blend);
+        util_blitter_save_depth_stencil_alpha(blitter, ctx->depth_stencil);
+        util_blitter_save_stencil_ref(blitter, &ctx->stencil_ref);
+       util_blitter_save_so_targets(blitter, 0, NULL);
 
        /* For later */
-//        util_blitter_save_sample_mask(ctx->blitter, ctx->sample_mask);
+//        util_blitter_save_sample_mask(blitter, ctx->sample_mask);
 
-        util_blitter_save_framebuffer(ctx->blitter, &ctx->pipe_framebuffer);
-        util_blitter_save_fragment_sampler_states(ctx->blitter,
+        util_blitter_save_framebuffer(blitter, &ctx->pipe_framebuffer);
+        util_blitter_save_fragment_sampler_states(blitter,
                                                  ctx->sampler_count[PIPE_SHADER_FRAGMENT],
                                                  (void **)(&ctx->samplers[PIPE_SHADER_FRAGMENT]));
-        util_blitter_save_fragment_sampler_views(ctx->blitter,
+        util_blitter_save_fragment_sampler_views(blitter,
                                                 ctx->sampler_view_count[PIPE_SHADER_FRAGMENT],
                                                 (struct pipe_sampler_view **)&ctx->sampler_views[PIPE_SHADER_FRAGMENT]);
 }
@@ -73,7 +75,7 @@ panfrost_u_blitter_blit(struct pipe_context *pipe,
 
         /* TODO: Scissor */
 
-        panfrost_blitter_save(ctx);
+        panfrost_blitter_save(ctx, ctx->blitter);
         util_blitter_blit(ctx->blitter, info);
 
         return true;
@@ -105,7 +107,7 @@ panfrost_blit_wallpaper(struct panfrost_context *ctx)
 {
         struct pipe_blit_info binfo = { };
 
-        panfrost_blitter_save(ctx);
+        panfrost_blitter_save(ctx, ctx->blitter_wallpaper);
 
        binfo.src.resource = binfo.dst.resource = ctx->pipe_framebuffer.cbufs[0]->texture;
        binfo.src.level = binfo.dst.level = 0;
@@ -122,6 +124,6 @@ panfrost_blit_wallpaper(struct panfrost_context *ctx)
        binfo.filter = PIPE_TEX_FILTER_LINEAR;
        binfo.scissor_enable = FALSE;
 
-       util_blitter_blit(ctx->blitter, &binfo);
+       util_blitter_blit(ctx->blitter_wallpaper, &binfo);
 }
 
index d19ce10a88c3edd74e096763ca3b7294acb6d773..0160452d20887e5de78f36b88012675a53827acb 100644 (file)
@@ -2549,6 +2549,9 @@ panfrost_destroy(struct pipe_context *pipe)
         if (panfrost->blitter)
                 util_blitter_destroy(panfrost->blitter);
 
+        if (panfrost->blitter_wallpaper)
+                util_blitter_destroy(panfrost->blitter_wallpaper);
+
         panfrost_drm_free_slab(screen, &panfrost->scratchpad);
         panfrost_drm_free_slab(screen, &panfrost->varying_mem);
         panfrost_drm_free_slab(screen, &panfrost->shaders);
@@ -2822,7 +2825,10 @@ panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
         ctx->primconvert = util_primconvert_create(gallium, ctx->draw_modes);
 
         ctx->blitter = util_blitter_create(gallium);
+        ctx->blitter_wallpaper = util_blitter_create(gallium);
+
         assert(ctx->blitter);
+        assert(ctx->blitter_wallpaper);
 
         /* Prepare for render! */
 
index 41999b5fed5a740cf9468907f68ca2bf4178eaf7..ca6f8deef3379e120d1c4e308e22e2e28922cfc4 100644 (file)
@@ -183,6 +183,14 @@ struct panfrost_context {
 
         struct primconvert_context *primconvert;
         struct blitter_context *blitter;
+
+        /* Blitting the wallpaper (the old contents of the framebuffer back to
+         * itself) uses a dedicated u_blitter instance versus general blit()
+         * callbacks from Gallium, as the blit() callback can trigger
+         * wallpapering without Gallium realising, which in turns u_blitter
+         * errors due to unsupported reucrsion */
+
+        struct blitter_context *blitter_wallpaper;
         struct panfrost_job *wallpaper_batch;
 
         struct panfrost_blend_state *blend;