From c552b5fd1d106adc04f62fcbe71d650a9a17f7e0 Mon Sep 17 00:00:00 2001 From: Jonathan Marek Date: Mon, 20 Apr 2020 17:54:36 -0400 Subject: [PATCH] turnip: implement VK_EXT_sampler_filter_minmax Passes dEQP-VK.pipeline.sampler.view_type.* Signed-off-by: Jonathan Marek Part-of: --- src/freedreno/registers/a6xx.xml | 9 ++++++++- src/freedreno/vulkan/tu_device.c | 15 +++++++++++++++ src/freedreno/vulkan/tu_extensions.py | 1 + src/freedreno/vulkan/tu_formats.c | 3 ++- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/freedreno/registers/a6xx.xml b/src/freedreno/registers/a6xx.xml index 5d6ddcf1785..2402395fa51 100644 --- a/src/freedreno/registers/a6xx.xml +++ b/src/freedreno/registers/a6xx.xml @@ -3307,6 +3307,12 @@ to upconvert to 32b float internally? + + + + + + @@ -3326,7 +3332,8 @@ to upconvert to 32b float internally? - + + diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index da8d8ed6a1d..85b1385499f 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -943,6 +943,13 @@ tu_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, properties->variableSampleLocations = true; break; } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES: { + VkPhysicalDeviceSamplerFilterMinmaxProperties *properties = + (VkPhysicalDeviceSamplerFilterMinmaxProperties *)ext; + properties->filterMinmaxImageComponentMapping = true; + properties->filterMinmaxSingleComponentFormats = true; + break; + } default: break; @@ -2112,6 +2119,9 @@ tu_init_sampler(struct tu_device *device, struct tu_sampler *sampler, const VkSamplerCreateInfo *pCreateInfo) { + const struct VkSamplerReductionModeCreateInfo *reduction = + vk_find_struct_const(pCreateInfo->pNext, SAMPLER_REDUCTION_MODE_CREATE_INFO); + unsigned aniso = pCreateInfo->anisotropyEnable ? util_last_bit(MIN2((uint32_t)pCreateInfo->maxAnisotropy >> 1, 8)) : 0; bool miplinear = (pCreateInfo->mipmapMode == VK_SAMPLER_MIPMAP_MODE_LINEAR); @@ -2141,6 +2151,11 @@ tu_init_sampler(struct tu_device *device, sizeof(struct bcolor_entry)); sampler->descriptor[3] = 0; + if (reduction) { + /* note: vulkan enum matches hw */ + sampler->descriptor[2] |= A6XX_TEX_SAMP_2_REDUCTION_MODE(reduction->reductionMode); + } + /* TODO: * A6XX_TEX_SAMP_1_MIPFILTER_LINEAR_FAR disables mipmapping, but vk has no NONE mipfilter? */ diff --git a/src/freedreno/vulkan/tu_extensions.py b/src/freedreno/vulkan/tu_extensions.py index e003ea70252..f838a6b0800 100644 --- a/src/freedreno/vulkan/tu_extensions.py +++ b/src/freedreno/vulkan/tu_extensions.py @@ -78,6 +78,7 @@ EXTENSIONS = [ Extension('VK_EXT_external_memory_dma_buf', 1, True), Extension('VK_EXT_image_drm_format_modifier', 1, False), Extension('VK_EXT_sample_locations', 1, 'device->gpu_id == 650'), + Extension('VK_EXT_sampler_filter_minmax', 1, True), Extension('VK_EXT_transform_feedback', 1, True), Extension('VK_ANDROID_native_buffer', 1, True), Extension('VK_KHR_external_semaphore_fd', 1, True), diff --git a/src/freedreno/vulkan/tu_formats.c b/src/freedreno/vulkan/tu_formats.c index 3195baca6c4..24f7f246e36 100644 --- a/src/freedreno/vulkan/tu_formats.c +++ b/src/freedreno/vulkan/tu_formats.c @@ -382,7 +382,8 @@ tu_physical_device_get_format_properties( optimal |= VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | - VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT; + VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT | + VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT; buffer |= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT; if (physical_device->supported_extensions.EXT_filter_cubic) -- 2.30.2