From 453314460835ee78886e980445ce0a3889376018 Mon Sep 17 00:00:00 2001 From: "Eric R. Smith" Date: Tue, 3 Dec 2024 12:08:48 -0400 Subject: [PATCH] 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 Reviewed-by: Boris Brezillon Part-of: --- src/gallium/drivers/panfrost/pan_screen.c | 21 +++++++++++++++++++-- src/panfrost/lib/pan_format.c | 10 +++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index 210b340fb5e..dd024c10190 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -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 diff --git a/src/panfrost/lib/pan_format.c b/src/panfrost/lib/pan_format.c index e488d7c9b3d..81dbd7a92ec 100644 --- a/src/panfrost/lib/pan_format.c +++ b/src/panfrost/lib/pan_format.c @@ -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_),