From ebe4a566505554f86ac8aa051bc3c886d8cd4b84 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Thu, 9 Apr 2026 14:02:05 +0200 Subject: [PATCH] panvk: use perf-trilinear when doing anisotropic sampling This should be faster, and matches what the DDK does. Reviewed-by: Marc Alcala Prieto Reviewed-by: Eric R. Smith Part-of: --- src/panfrost/vulkan/panvk_vX_sampler.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/panfrost/vulkan/panvk_vX_sampler.c b/src/panfrost/vulkan/panvk_vX_sampler.c index fdcefa9fb8c..ab6aa444c7b 100644 --- a/src/panfrost/vulkan/panvk_vX_sampler.c +++ b/src/panfrost/vulkan/panvk_vX_sampler.c @@ -18,13 +18,15 @@ #include "vk_ycbcr_conversion.h" static enum mali_mipmap_mode -panvk_translate_sampler_mipmap_mode(VkSamplerMipmapMode mode) +panvk_translate_sampler_mipmap_mode(VkSamplerMipmapMode mode, + bool use_perf_trilinear) { switch (mode) { case VK_SAMPLER_MIPMAP_MODE_NEAREST: return MALI_MIPMAP_MODE_NEAREST; case VK_SAMPLER_MIPMAP_MODE_LINEAR: - return MALI_MIPMAP_MODE_TRILINEAR; + return use_perf_trilinear ? MALI_MIPMAP_MODE_PERFORMANCE_TRILINEAR : + MALI_MIPMAP_MODE_TRILINEAR; default: UNREACHABLE("Invalid mipmap mode"); } @@ -106,11 +108,12 @@ panvk_sampler_fill_desc(const struct VkSamplerCreateInfo *info, VkSamplerReductionMode reduction_mode, VkSamplerCreateFlags flags) { + bool use_aniso = info->anisotropyEnable && info->maxAnisotropy > 1; pan_pack(desc, SAMPLER, cfg) { cfg.magnify_nearest = mag_filter == VK_FILTER_NEAREST; cfg.minify_nearest = min_filter == VK_FILTER_NEAREST; cfg.mipmap_mode = - panvk_translate_sampler_mipmap_mode(info->mipmapMode); + panvk_translate_sampler_mipmap_mode(info->mipmapMode, use_aniso); cfg.normalized_coordinates = !info->unnormalizedCoordinates; cfg.clamp_integer_array_indices = false; @@ -165,7 +168,7 @@ panvk_sampler_fill_desc(const struct VkSamplerCreateInfo *info, cfg.border_color_b = border_color.uint32[2]; cfg.border_color_a = border_color.uint32[3]; - if (info->anisotropyEnable && info->maxAnisotropy > 1) { + if (use_aniso) { cfg.maximum_anisotropy = info->maxAnisotropy; cfg.lod_algorithm = MALI_LOD_ALGORITHM_ANISOTROPIC; }