[Impeller] Use linear sampling to sample from AHB textures in Vulkan. (flutter/engine#54233)
Fixes https://github.com/flutter/flutter/issues/152579 This now matches Skia OpenGL behavior with SurfaceTexture. 
This commit is contained in:
@@ -146,6 +146,10 @@ static std::shared_ptr<YUVConversionVK> CreateYUVConversion(
|
||||
const auto& ahb_format =
|
||||
ahb_props.get<vk::AndroidHardwareBufferFormatPropertiesANDROID>();
|
||||
|
||||
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<YUVConversionVK> 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) {
|
||||
|
||||
@@ -55,27 +55,18 @@ static vk::UniqueSampler CreateSampler(
|
||||
sampler_chain.get<vk::SamplerYcbcrConversionInfo>().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
|
||||
|
||||
Reference in New Issue
Block a user