panfrost: apply DEPTH_STENCIL flag consistently

We were inconsistent over the usage of PAN_BIND_DEPTH_STENCIL, putting
it on some stencil only formats but not others. Apply it to all
stencil formats. However, we also need to change is_format_supported
to ignore S8_UINT (at least for GLES), because the hardware is a little
weird with that format and the gallium driver gets confused by it.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32462>
This commit is contained in:
Eric R. Smith 2024-12-03 12:08:48 -04:00 committed by Marge Bot
parent b6ade2714c
commit 4533144608
2 changed files with 24 additions and 7 deletions

View file

@ -616,8 +616,8 @@ panfrost_is_format_supported(struct pipe_screen *screen,
/* Check we support the format with the given bind */
unsigned pan_bind_flags = pipe_to_pan_bind_flags(bind);
struct panfrost_format fmt = dev->formats[format];
unsigned fmt_bind_flags = fmt.bind;
/* Also check that compressed texture formats are supported on this
* particular chip. They may not be depending on system integration
@ -630,7 +630,24 @@ panfrost_is_format_supported(struct pipe_screen *screen,
if (!supported)
return false;
return MALI_EXTRACT_INDEX(fmt.hw) && ((pan_bind_flags & ~fmt.bind) == 0);
if (bind & PIPE_BIND_DEPTH_STENCIL) {
/* On panfrost, S8_UINT is actually stored as X8S8_UINT, which
* causes us headaches when we try to bind it as DEPTH_STENCIL;
* the gallium driver doesn't handle this correctly. So reject
* it for now.
*/
switch (format) {
case PIPE_FORMAT_S8_UINT:
fmt_bind_flags &= ~PAN_BIND_DEPTH_STENCIL;
break;
default:
/* no other special handling required yet */
break;
}
}
return MALI_EXTRACT_INDEX(fmt.hw) &&
((pan_bind_flags & ~fmt_bind_flags) == 0);
}
static void

View file

@ -491,7 +491,7 @@ const struct panfrost_format GENX(panfrost_pipe_format)[PIPE_FORMAT_COUNT] = {
FMT(Z32_FLOAT_S8X24_UINT, RG32F, RRRR, L, _T_Z),
FMT(X32_S8X24_UINT, X32_S8X24, GGGG, L, _T_Z),
FMT(X24S8_UINT, RGBA8UI, AAAA, L, _T_Z),
FMT(S8_UINT, R8UI, RRRR, L, _T__),
FMT(S8_UINT, R8UI, RRRR, L, _T_Z),
FMT(A8_UNORM, R8_UNORM, 000R, L, VTR_),
FMT(L8A8_UNORM, RG8_UNORM, RRRG, L, VTR_),
@ -524,9 +524,9 @@ const struct panfrost_format GENX(panfrost_pipe_format)[PIPE_FORMAT_COUNT] = {
* we want stencil in the red channel, so we use the GRBA swizzles.
*/
FMT(Z32_FLOAT_S8X24_UINT, R32F, GRBA, L, _T_Z),
FMT(X32_S8X24_UINT, S8, GRBA, L, _T__),
FMT(X32_S8X24_UINT, S8, GRBA, L, _T_Z),
FMT(X24S8_UINT, S8, GRBA, L, _T_Z),
FMT(S8_UINT, S8, GRBA, L, _T__),
FMT(S8_UINT, S8, GRBA, L, _T_Z),
/* similarly, the interchange format is RGBA8, but we only
actually store 1 component in memory here */
@ -534,9 +534,9 @@ const struct panfrost_format GENX(panfrost_pipe_format)[PIPE_FORMAT_COUNT] = {
#else
/* Specify real formats on Bifrost */
FMT(Z32_FLOAT_S8X24_UINT, Z32_X32, RGBA, L, _T_Z),
FMT(X32_S8X24_UINT, X32_S8X24, GRBA, L, _T__),
FMT(X32_S8X24_UINT, X32_S8X24, GRBA, L, _T_Z),
FMT(X24S8_UINT, X24S8, GRBA, L, _T_Z),
FMT(S8_UINT, S8, GRBA, L, _T__),
FMT(S8_UINT, S8, GRBA, L, _T_Z),
/* Obsolete formats removed in Valhall */
FMT(A8_UNORM, A8_UNORM, 000A, L, VTR_),