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 <jasuarez@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15693>
This commit is contained in:
Juan A. Suarez Romero 2022-04-13 19:42:37 +02:00 committed by Marge Bot
parent e6bcb8ad15
commit 21bfbc74ee

View file

@ -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)