Check for linear filtering support in pipeline.sampler tests
authorPyry Haulos <phaulos@google.com>
Thu, 21 Jan 2016 19:04:23 +0000 (11:04 -0800)
committerPyry Haulos <phaulos@google.com>
Fri, 22 Jan 2016 20:38:40 +0000 (12:38 -0800)
Fixes #243

Change-Id: I294dc93afc6c7a46e9d29bcb63a549e4565103c9

external/vulkancts/modules/vulkan/pipeline/vktPipelineImageSamplingInstance.cpp
external/vulkancts/modules/vulkan/pipeline/vktPipelineImageUtil.cpp
external/vulkancts/modules/vulkan/pipeline/vktPipelineImageUtil.hpp

index dbf142ea29a43388200432ad6cead937962388b2..35f9167516ac53020c4f6db42128bf42ce8d0efe 100644 (file)
@@ -371,6 +371,12 @@ ImageSamplingInstance::ImageSamplingInstance (Context&                                                     context,
        if (!isSupportedSamplableFormat(context.getInstanceInterface(), context.getPhysicalDevice(), imageFormat))
                throw tcu::NotSupportedError(std::string("Unsupported format for sampling: ") + getFormatName(imageFormat));
 
+       if ((samplerParams.minFilter == VK_FILTER_LINEAR ||
+                samplerParams.magFilter == VK_FILTER_LINEAR ||
+                samplerParams.mipmapMode == VK_SAMPLER_MIPMAP_MODE_LINEAR) &&
+               !isLinearFilteringSupported(context.getInstanceInterface(), context.getPhysicalDevice(), imageFormat, VK_IMAGE_TILING_OPTIMAL))
+               throw tcu::NotSupportedError(std::string("Unsupported format for linear filtering: ") + getFormatName(imageFormat));
+
        // Create texture image, view and sampler
        {
                VkImageCreateFlags                      imageFlags                      = 0u;
index b873a29e446399449c7d6e01f80e244c8b219fed..b18b317179c50c127c0b2958fdb1967b19477614 100644 (file)
@@ -113,6 +113,39 @@ bool isSupportedSamplableFormat (const InstanceInterface& instanceInterface, VkP
        return (formatProps.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0u;
 }
 
+// \todo [2016-01-21 pyry] Update this to just rely on vkDefs.hpp once
+//                                                CTS has been updated to 1.0.2.
+enum
+{
+       VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT = 0x00001000,
+};
+
+bool isLinearFilteringSupported (const InstanceInterface& vki, VkPhysicalDevice physicalDevice, VkFormat format, VkImageTiling tiling)
+{
+       const VkFormatProperties        formatProperties        = getPhysicalDeviceFormatProperties(vki, physicalDevice, format);
+       const VkFormatFeatureFlags      formatFeatures          = tiling == VK_IMAGE_TILING_LINEAR
+                                                                                                       ? formatProperties.linearTilingFeatures
+                                                                                                       : formatProperties.optimalTilingFeatures;
+
+       switch (format)
+       {
+               case VK_FORMAT_R32_SFLOAT:
+               case VK_FORMAT_R32G32_SFLOAT:
+               case VK_FORMAT_R32G32B32_SFLOAT:
+               case VK_FORMAT_R32G32B32A32_SFLOAT:
+               case VK_FORMAT_R64_SFLOAT:
+               case VK_FORMAT_R64G64_SFLOAT:
+               case VK_FORMAT_R64G64B64_SFLOAT:
+               case VK_FORMAT_R64G64B64A64_SFLOAT:
+                       return (formatFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT) != 0;
+
+               default:
+                       // \todo [2016-01-21 pyry] Check for all formats once drivers have been updated to 1.0.2
+                       //                                                 and we have tests to verify format properties.
+                       return true;
+       }
+}
+
 VkBorderColor getFormatBorderColor (BorderColor color, VkFormat format)
 {
        if (!isCompressedFormat(format) && (isIntFormat(format) || isUintFormat(format)))
index 3c2c24d68afa23720955ff5ff14a35a2c2b7cc9a..17af27a132d7c8bd333389ffb767086a6e8e97f9 100644 (file)
@@ -60,9 +60,13 @@ enum BorderColor
        BORDER_COLOR_COUNT
 };
 
-bool                                                   isSupportedSamplableFormat      (const vk::InstanceInterface& instanceInterface,
-                                                                                                                        vk::VkPhysicalDevice device,
-                                                                                                                        vk::VkFormat format);
+bool                                                   isSupportedSamplableFormat      (const vk::InstanceInterface&   instanceInterface,
+                                                                                                                        vk::VkPhysicalDevice                   device,
+                                                                                                                        vk::VkFormat                                   format);
+bool                                                   isLinearFilteringSupported      (const vk::InstanceInterface&   instanceInterface,
+                                                                                                                        vk::VkPhysicalDevice                   device,
+                                                                                                                        vk::VkFormat                                   format,
+                                                                                                                        vk::VkImageTiling                              tiling);
 
 vk::VkBorderColor                              getFormatBorderColor            (BorderColor color, vk::VkFormat format);