From 87978c39334045b6e998e62f7353c4c98e588f53 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Tue, 11 Apr 2023 12:48:44 -0700 Subject: [PATCH] freedreno/a6xx: Allow z24s8 format casts Allow UBWC format casts between z24s8/x24s8/z24x8. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8816 Signed-off-by: Rob Clark Part-of: --- .../drivers/freedreno/a6xx/fd6_resource.cc | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_resource.cc b/src/gallium/drivers/freedreno/a6xx/fd6_resource.cc index 5a0a3a6f328..a1befce7b35 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_resource.cc +++ b/src/gallium/drivers/freedreno/a6xx/fd6_resource.cc @@ -118,6 +118,20 @@ is_norm(enum pipe_format format) return desc->is_snorm || desc->is_unorm; } +static bool +is_z24s8(enum pipe_format format) +{ + switch (format) { + case PIPE_FORMAT_Z24_UNORM_S8_UINT: + case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_X24S8_UINT: + case PIPE_FORMAT_Z24_UNORM_S8_UINT_AS_R8G8B8A8: + return true; + default: + return false; + } +} + static bool valid_format_cast(struct fd_resource *rsc, enum pipe_format format) { @@ -125,6 +139,13 @@ valid_format_cast(struct fd_resource *rsc, enum pipe_format format) if (format == PIPE_FORMAT_Z24_UNORM_S8_UINT_AS_R8G8B8A8) return true; + /* If we support z24s8 ubwc then allow casts between the various + * permutations of z24s8: + */ + if (fd_screen(rsc->b.b.screen)->info->a6xx.has_z24uint_s8uint && + (is_z24s8(format) == is_z24s8(rsc->b.b.format))) + return true; + /* For some color values (just "solid white") compression metadata maps to * different pixel values for uint/sint vs unorm/snorm, so we can't reliably * "cast" u/snorm to u/sint and visa versa: