v3d: reinterpret stencil data as uint texture in stencil blit path
authorJuan A. Suarez Romero <jasuarez@igalia.com>
Tue, 5 Jan 2021 12:05:20 +0000 (13:05 +0100)
committerJuan A. Suárez <jasuarez@igalia.com>
Thu, 7 Jan 2021 16:09:31 +0000 (16:09 +0000)
There is a path to blit stencil buffers reinterpreting the stencil data
as an RGBA8888 or R8 float texture.

This works fine except for the case when the stencil buffer is
multisampled, and the blit operation needs to resolve it: an average of
the samples is done, which is incorrect, as only one sample must be
used.

This can be observed n the piglit test
`ext_framebuffer_multisample-unaligned-blit 2 stencil downsample -auto
-fbo`, specifically in the triangles border.

To avoid this averaging, let's reinterpret the stencil data as RGBA8888
or R8 uint texture.

Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8361>

src/gallium/drivers/v3d/v3d_blit.c

index 51ed8a3..325f6a7 100644 (file)
@@ -124,16 +124,16 @@ v3d_stencil_blit(struct pipe_context *ctx, const struct pipe_blit_info *info)
 
         if (src->separate_stencil) {
                 src = src->separate_stencil;
-                src_format = PIPE_FORMAT_R8_UNORM;
+                src_format = PIPE_FORMAT_R8_UINT;
         } else {
-                src_format = PIPE_FORMAT_RGBA8888_UNORM;
+                src_format = PIPE_FORMAT_RGBA8888_UINT;
         }
 
         if (dst->separate_stencil) {
                 dst = dst->separate_stencil;
-                dst_format = PIPE_FORMAT_R8_UNORM;
+                dst_format = PIPE_FORMAT_R8_UINT;
         } else {
-                dst_format = PIPE_FORMAT_RGBA8888_UNORM;
+                dst_format = PIPE_FORMAT_RGBA8888_UINT;
         }
 
         /* Initialize the surface. */