From 3e9ac50d3764bf72aeca4364b8ff214ec2c3a163 Mon Sep 17 00:00:00 2001 From: "Eric R. Smith" Date: Thu, 4 Apr 2024 17:22:15 -0300 Subject: [PATCH] gallium: handle copy_image of depth textures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit copy_image calls blit now for multisampled images, including depth. But blit explicitly uses only PIPE_MASK_RGBA, so it is incapable of copying depth buffers. This patch checks the destination format and uses PIPE_MASK_ZS if it is a depth or stencil. Ideally we would simply use PIPE_MASK_RGBAZS always, but not all drivers actually handle getting this mask (they probably should, but that's another story). The change to copy_image was in 5027b5aa2, so in some sense this patch "fixes" that. In fact though the issue wasn't in the copy_image change, it was always latent in blit(). Fixes: 5027b5aa28f ("gallium: stop calling resource_copy_region for multisampled copy_image") Signed-off-by: Eric R. Smith Reviewed-by: Erik Faye-Lund Reviewed-by: Marek Olšák Part-of: (cherry picked from commit 0cb852050d668c6f5d9dbb8b35e970d23ad6bd9a) --- .pick_status.json | 2 +- src/mesa/state_tracker/st_cb_copyimage.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index ae7760326b2..b3025f42a80 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1084,7 +1084,7 @@ "description": "gallium: handle copy_image of depth textures", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "5027b5aa28fb9395b1acff57336d2862753bba17", "notes": null diff --git a/src/mesa/state_tracker/st_cb_copyimage.c b/src/mesa/state_tracker/st_cb_copyimage.c index 2bf95a66358..f3ab37fcbdc 100644 --- a/src/mesa/state_tracker/st_cb_copyimage.c +++ b/src/mesa/state_tracker/st_cb_copyimage.c @@ -282,7 +282,10 @@ blit(struct pipe_context *pipe, blit.src.box = *src_box; u_box_3d(dstx, dsty, dstz, src_box->width, src_box->height, src_box->depth, &blit.dst.box); - blit.mask = PIPE_MASK_RGBA; + if (util_format_is_depth_or_stencil(dst_format)) + blit.mask = PIPE_MASK_ZS; + else + blit.mask = PIPE_MASK_RGBA; blit.filter = PIPE_TEX_FILTER_NEAREST; pipe->blit(pipe, &blit);