From: Alyssa Rosenzweig Date: Sun, 23 Jun 2019 18:05:10 +0000 (-0700) Subject: panfrost: Use dedicated u_blitter context for wallpapers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7005c0d83b7d33158cabf204a00f6f80f984cdaa;p=mesa.git panfrost: Use dedicated u_blitter context for wallpapers 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 --- diff --git a/src/gallium/drivers/panfrost/pan_blit.c b/src/gallium/drivers/panfrost/pan_blit.c index 1e50448a67d..c98e08e8a0b 100644 --- a/src/gallium/drivers/panfrost/pan_blit.c +++ b/src/gallium/drivers/panfrost/pan_blit.c @@ -31,29 +31,31 @@ #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); } diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index d19ce10a88c..0160452d208 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -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! */ diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index 41999b5fed5..ca6f8deef33 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -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;