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>
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. */