diff --git a/engine/src/flutter/impeller/renderer/backend/vulkan/android/ahb_texture_source_vk.cc b/engine/src/flutter/impeller/renderer/backend/vulkan/android/ahb_texture_source_vk.cc index c6d0197bac..fb4c37b894 100644 --- a/engine/src/flutter/impeller/renderer/backend/vulkan/android/ahb_texture_source_vk.cc +++ b/engine/src/flutter/impeller/renderer/backend/vulkan/android/ahb_texture_source_vk.cc @@ -146,6 +146,10 @@ static std::shared_ptr CreateYUVConversion( const auto& ahb_format = ahb_props.get(); + const bool supports_linear_filtering = + !!(ahb_format.formatFeatures & + vk::FormatFeatureFlagBits::eSampledImageYcbcrConversionLinearFilter); + auto& conversion_info = conversion_chain.get(); conversion_info.format = ahb_format.format; @@ -154,12 +158,8 @@ static std::shared_ptr CreateYUVConversion( conversion_info.components = ahb_format.samplerYcbcrConversionComponents; conversion_info.xChromaOffset = ahb_format.suggestedXChromaOffset; conversion_info.yChromaOffset = ahb_format.suggestedYChromaOffset; - // If the potential format features of the sampler Y′CBCR conversion do not - // support VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT, - // chromaFilter must not be VK_FILTER_LINEAR. - // - // Since we are not checking, let's just default to a safe value. - conversion_info.chromaFilter = vk::Filter::eNearest; + conversion_info.chromaFilter = + supports_linear_filtering ? vk::Filter::eLinear : vk::Filter::eNearest; conversion_info.forceExplicitReconstruction = false; if (conversion_info.format == vk::Format::eUndefined) { diff --git a/engine/src/flutter/impeller/renderer/backend/vulkan/sampler_vk.cc b/engine/src/flutter/impeller/renderer/backend/vulkan/sampler_vk.cc index 2d7bfe1c01..836f9bdd24 100644 --- a/engine/src/flutter/impeller/renderer/backend/vulkan/sampler_vk.cc +++ b/engine/src/flutter/impeller/renderer/backend/vulkan/sampler_vk.cc @@ -55,27 +55,18 @@ static vk::UniqueSampler CreateSampler( sampler_chain.get().conversion = yuv_conversion->GetConversion(); - // - // TL;DR: When using YUV conversion, our samplers are somewhat hobbled and - // not all options configurable in Impeller (especially the linear - // filtering which is by far the most used form of filtering) can be - // supported. Switch to safe defaults. - // // Spec: If sampler Y'CBCR conversion is enabled and the potential format // features of the sampler Y'CBCR conversion do not support or enable // separate reconstruction filters, minFilter and magFilter must be equal to // the sampler Y'CBCR conversion's chromaFilter. // - // Thing is, we don't enable separate reconstruction filters. By the time we - // are here, we also don't have access to the descriptor used to create this - // conversion. So we don't yet know what the chromaFilter is. But eNearest - // is a safe bet since the `AndroidHardwareBufferTextureSourceVK` defaults - // to that safe value. So just use that. + // We don't enable separate reconstruction filters. So, just do what the + // spec. says and use the conversions chromaFilter. // // See the validation VUID-VkSamplerCreateInfo-minFilter-01645 for more. // - sampler_info.magFilter = vk::Filter::eNearest; - sampler_info.minFilter = vk::Filter::eNearest; + sampler_info.minFilter = sampler_info.magFilter = + yuv_conversion->GetDescriptor().get().chromaFilter; // Spec: If sampler Y′CBCR conversion is enabled, addressModeU, // addressModeV, and addressModeW must be