panvk: Allow compressed formats

Compressed formats were disabled because of the different layout for
u_interleaved(compressed), where the 16x16 texel tile model for
non-compressed is replaced by a 4x4 block tile. This prevents us from
creating RGBA views of compressed images, which break copies.

The simple option is to keep compressed images linear. The more complex
one would be to patch coordinates/frag-coords on the shader side when
we're dealing with a compressed texture/color-attachment, but given
we're using vk_meta for copies, it's not something we can easily do,
so let's go for the first option and see if we want to revisit it
later.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29451>
This commit is contained in:
Boris Brezillon 2024-05-28 09:09:43 +02:00 committed by Marge Bot
parent 4a30a28653
commit 213e895da0

View file

@ -919,28 +919,49 @@ panvk_DestroyDevice(VkDevice _device, const VkAllocationCallbacks *pAllocator)
panvk_arch_dispatch(arch, destroy_device, device, pAllocator);
}
static bool
format_is_supported(struct panvk_physical_device *physical_device,
const struct panfrost_format fmt)
{
/* If the format ID is zero, it's not supported. */
if (!fmt.hw)
return false;
/* Compressed formats (ID < 32) are optional. We need to check against
* the supported formats reported by the GPU. */
unsigned idx = MALI_EXTRACT_INDEX(fmt.hw);
if (MALI_EXTRACT_TYPE(idx) == MALI_FORMAT_COMPRESSED) {
uint32_t supported_compr_fmts =
panfrost_query_compressed_formats(&physical_device->kmod.props);
assert(idx < 32);
if (!(BITFIELD_BIT(idx) & supported_compr_fmts))
return false;
}
return true;
}
static void
get_format_properties(struct panvk_physical_device *physical_device,
VkFormat format, VkFormatProperties *out_properties)
{
VkFormatFeatureFlags tex = 0, buffer = 0;
enum pipe_format pfmt = vk_format_to_pipe_format(format);
if (pfmt == PIPE_FORMAT_NONE)
goto end;
const struct panfrost_format fmt = physical_device->formats.all[pfmt];
if (!pfmt || !fmt.hw)
if (!format_is_supported(physical_device, fmt))
goto end;
/* 3byte formats are not supported by the buffer <-> image copy helpers. */
if (util_format_get_blocksize(pfmt) == 3)
goto end;
/* We don't support compressed formats yet: this is causing trouble when
* doing a vkCmdCopyImage() between a compressed and a non-compressed format
* on a tiled/AFBC resource.
*/
if (util_format_is_compressed(pfmt))
goto end;
buffer |=
VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT;