From e4f5908a57601a275f44c01c7b7cee9b7acb66d3 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 31 Mar 2025 17:44:44 +0200 Subject: [PATCH] panvk: check for texture-compression support We currently just assume that textureCompressionETC2 and textureCompressionASTC_LDR are always supported. And while that's true for all the G52s, G610s abd G310s we've seen out in the wild, it's not guaranteed to be true. An SoC vendor might disable support for one of these formats. So let's check properly, just for good measure. Fixes: d970fe2e9d6 ("panfrost: Add a Vulkan driver for Midgard/Bifrost GPUs") Reviewed-by: Eric R. Smith Part-of: (cherry picked from commit e4786cf971539f05a72318e1d121e9818d71e14e) --- .pick_status.json | 2 +- src/panfrost/vulkan/panvk_physical_device.c | 30 +++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index e08a313d9f3..2fd18f1f195 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -174,7 +174,7 @@ "description": "panvk: check for texture-compression support", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "d970fe2e9d6a8e9997a0ce212146d62013b3b455", "notes": null diff --git a/src/panfrost/vulkan/panvk_physical_device.c b/src/panfrost/vulkan/panvk_physical_device.c index dc3b371c3b0..05be006ad16 100644 --- a/src/panfrost/vulkan/panvk_physical_device.c +++ b/src/panfrost/vulkan/panvk_physical_device.c @@ -253,6 +253,32 @@ get_device_extensions(const struct panvk_physical_device *device, }; } +static bool +has_compressed_formats(const struct panvk_physical_device *physical_device, + const uint32_t required_formats) +{ + uint32_t supported_compr_fmts = + panfrost_query_compressed_formats(&physical_device->kmod.props); + + return (supported_compr_fmts & required_formats) == required_formats; +} + +static bool +has_texture_compression_etc2(const struct panvk_physical_device *physical_device) +{ + return has_compressed_formats(physical_device, + BITFIELD_BIT(MALI_ETC2_RGB8) | + BITFIELD_BIT(MALI_ETC2_RGB8A1) | BITFIELD_BIT(MALI_ETC2_RGBA8) | + BITFIELD_BIT(MALI_ETC2_R11_UNORM) | BITFIELD_BIT(MALI_ETC2_R11_SNORM) | + BITFIELD_BIT(MALI_ETC2_RG11_UNORM) | BITFIELD_BIT(MALI_ETC2_RG11_SNORM)); +} + +static bool +has_texture_compression_astc_ldr(const struct panvk_physical_device *physical_device) +{ + return has_compressed_formats(physical_device, BITFIELD_BIT(MALI_ASTC_2D_LDR)); +} + static void get_features(const struct panvk_physical_device *device, struct vk_features *features) @@ -273,8 +299,8 @@ get_features(const struct panvk_physical_device *device, .largePoints = true, .occlusionQueryPrecise = true, .samplerAnisotropy = true, - .textureCompressionETC2 = true, - .textureCompressionASTC_LDR = true, + .textureCompressionETC2 = has_texture_compression_etc2(device), + .textureCompressionASTC_LDR = has_texture_compression_astc_ldr(device), .fragmentStoresAndAtomics = arch >= 10, .shaderUniformBufferArrayDynamicIndexing = true, .shaderSampledImageArrayDynamicIndexing = true,