From 21bfbc74eea000b9768371a12f5edc20bed715ae Mon Sep 17 00:00:00 2001 From: "Juan A. Suarez Romero" Date: Wed, 13 Apr 2022 19:42:37 +0200 Subject: [PATCH] v3d: use surface format defined on pipe_blit When trying to perform a TLB-based blit, we need to create a surface out of the src and dst resources. But instead of using the same formats as the resources, we need to use the format that is passed through pipe_blit_info. This was making some cases to use the render-based blit instead of the TLB-based blit, which is more performant. Signed-off-by: Juan A. Suarez Romero Reviewed-by: Iago Toral Quiroga Part-of: --- src/gallium/drivers/v3d/v3d_blit.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/v3d/v3d_blit.c b/src/gallium/drivers/v3d/v3d_blit.c index 00bf21fb885..84bc5fc5263 100644 --- a/src/gallium/drivers/v3d/v3d_blit.c +++ b/src/gallium/drivers/v3d/v3d_blit.c @@ -391,12 +391,13 @@ v3d_tfu_blit(struct pipe_context *pctx, struct pipe_blit_info *info) static struct pipe_surface * v3d_get_blit_surface(struct pipe_context *pctx, struct pipe_resource *prsc, + enum pipe_format format, unsigned level, int16_t layer) { struct pipe_surface tmpl; - tmpl.format = prsc->format; + tmpl.format = format; tmpl.u.tex.level = level; tmpl.u.tex.first_layer = layer; tmpl.u.tex.last_layer = layer; @@ -439,14 +440,14 @@ v3d_tlb_blit(struct pipe_context *pctx, struct pipe_blit_info *info) return; if (is_color_blit && - util_format_is_depth_or_stencil(info->dst.resource->format)) + util_format_is_depth_or_stencil(info->dst.format)) return; - if (!v3d_rt_format_supported(&screen->devinfo, info->src.resource->format)) + if (!v3d_rt_format_supported(&screen->devinfo, info->src.format)) return; - if (v3d_get_rt_format(&screen->devinfo, info->src.resource->format) != - v3d_get_rt_format(&screen->devinfo, info->dst.resource->format)) + if (v3d_get_rt_format(&screen->devinfo, info->src.format) != + v3d_get_rt_format(&screen->devinfo, info->dst.format)) return; bool msaa = (info->src.resource->nr_samples > 1 || @@ -455,15 +456,15 @@ v3d_tlb_blit(struct pipe_context *pctx, struct pipe_blit_info *info) info->dst.resource->nr_samples < 2); if (is_msaa_resolve && - !v3d_format_supports_tlb_msaa_resolve(&screen->devinfo, info->src.resource->format)) + !v3d_format_supports_tlb_msaa_resolve(&screen->devinfo, info->src.format)) return; v3d_flush_jobs_writing_resource(v3d, info->src.resource, V3D_FLUSH_DEFAULT, false); struct pipe_surface *dst_surf = - v3d_get_blit_surface(pctx, info->dst.resource, info->dst.level, info->dst.box.z); + v3d_get_blit_surface(pctx, info->dst.resource, info->dst.format, info->dst.level, info->dst.box.z); struct pipe_surface *src_surf = - v3d_get_blit_surface(pctx, info->src.resource, info->src.level, info->src.box.z); + v3d_get_blit_surface(pctx, info->src.resource, info->src.format, info->src.level, info->src.box.z); struct pipe_surface *surfaces[V3D_MAX_DRAW_BUFFERS] = { 0 }; if (is_color_blit)