turnip: implement VK_EXT_sampler_filter_minmax
authorJonathan Marek <jonathan@marek.ca>
Mon, 20 Apr 2020 21:54:36 +0000 (17:54 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 22 Apr 2020 20:12:14 +0000 (20:12 +0000)
Passes dEQP-VK.pipeline.sampler.view_type.*

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4662>

src/freedreno/registers/a6xx.xml
src/freedreno/vulkan/tu_device.c
src/freedreno/vulkan/tu_extensions.py
src/freedreno/vulkan/tu_formats.c

index 5d6ddcf1785099e62534f1172b7130223526cef3..2402395fa5171a25c55291ab3d53fcd47ebee221 100644 (file)
@@ -3307,6 +3307,12 @@ to upconvert to 32b float internally?
                <value name="A6XX_TEX_ANISO_8" value="3"/>
                <value name="A6XX_TEX_ANISO_16" value="4"/>
        </enum>
+       <enum name="a6xx_reduction_mode">
+               <value name="A6XX_REDUCTION_MODE_AVERAGE" value="0"/>
+               <value name="A6XX_REDUCTION_MODE_MIN" value="1"/>
+               <value name="A6XX_REDUCTION_MODE_MAX" value="2"/>
+       </enum>
+
        <reg32 offset="0" name="0">
                <bitfield name="MIPFILTER_LINEAR_NEAR" pos="0" type="boolean"/>
                <bitfield name="XY_MAG" low="1" high="2" type="a6xx_tex_filter"/>
@@ -3326,7 +3332,8 @@ to upconvert to 32b float internally?
                <bitfield name="MIN_LOD" low="20" high="31" type="ufixed" radix="8"/>
        </reg32>
        <reg32 offset="2" name="2">
-               <bitfield name="BCOLOR_OFFSET" low="0" high="31"/>
+               <bitfield name="REDUCTION_MODE" low="0" high="1" type="a6xx_reduction_mode"/>
+               <bitfield name="BCOLOR_OFFSET" low="7" high="31" shr="7"/>
        </reg32>
        <reg32 offset="3" name="3"/>
 </domain>
index da8d8ed6a1daffc039ea99e314d0cacdbbb6f3c7..85b1385499f61a8d77ea5c91a2cbdb24fb900cda 100644 (file)
@@ -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?
     */
index e003ea7025285393ca47901ff16c89649f5434d6..f838a6b08009d0e5ad1e7871b0f08c91b1797174 100644 (file)
@@ -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),
index 3195baca6c4ed369bb9ce4db1fb2adbcf387a563..24f7f246e367eb25c47bc79804b4f63c59e84bb4 100644 (file)
@@ -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)