dEQP-VK: check against the proper VkFormatProperties member
authorAndres Gomez <agomez@igalia.com>
Thu, 8 Jun 2017 11:39:02 +0000 (14:39 +0300)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Sun, 18 Jun 2017 11:23:53 +0000 (07:23 -0400)
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT and
VK_FORMAT_FEATURE_TRANSFER_[SRC|DST]_BIT_KHR are flag values of the
VkFormatFeatureFlagBits enum that can only be hold and checked against
the linearTilingFeatures or optimalTilingFeatures members of the
VkFormatProperties struct but not the bufferFeatures member.

From the VulkanĀ® 1.0.51, with the VK_KHR_maintenance1 extension,
section 32.3.2 docs for VkFormatProperties:

   "* linearTilingFeatures is a bitmask of VkFormatFeatureFlagBits
      specifying features supported by images created with a tiling
      parameter of VK_IMAGE_TILING_LINEAR.

    * optimalTilingFeatures is a bitmask of VkFormatFeatureFlagBits
      specifying features supported by images created with a tiling
      parameter of VK_IMAGE_TILING_OPTIMAL.

    * bufferFeatures is a bitmask of VkFormatFeatureFlagBits
      specifying features supported by buffers."

    ...

    Bits which can be set in the VkFormatProperties features
    linearTilingFeatures, optimalTilingFeatures, and bufferFeatures
    are:

    typedef enum VkFormatFeatureFlagBits {

    ...

      VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT = 0x00000080,

    ...

      VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR = 0x00004000,
      VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR = 0x00008000,

    ...

    } VkFormatFeatureFlagBits;

    ...

    The following bits may be set in linearTilingFeatures and
    optimalTilingFeatures, specifying that the features are supported
    by images or image views created with the queried
    vkGetPhysicalDeviceFormatProperties::format:

    ...

    * VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT specifies that an image
      view can be used as a framebuffer color attachment and as an
      input attachment."

    ...

    * VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR specifies that an image
      can be used as a source image for copy commands.

    * VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR specifies that an image
      can be used as a destination image for copy commands and clear
      commands."

Affects:

dEQP-VK.spirv_assembly.instruction.graphics.16bit_storage.input_output_*

VK-GL-CTS issue: 483
Components: Vulkan

Change-Id: I89d21dbba2794429973830b0368259cf0cc24312

external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmGraphicsShaderTestUtil.cpp

index a1092fb..8acc544 100644 (file)
@@ -183,15 +183,31 @@ VkBufferUsageFlagBits getMatchingBufferUsageFlagBit(VkDescriptorType dType)
        return (VkBufferUsageFlagBits)0;
 }
 
-static void requireFormatUsageSupport(const InstanceInterface& vki, VkPhysicalDevice physicalDevice, VkFormat format, VkImageUsageFlags requiredUsageFlags)
+static void requireFormatUsageSupport(const InstanceInterface& vki, VkPhysicalDevice physicalDevice, VkFormat format, VkImageTiling imageTiling, VkImageUsageFlags requiredUsageFlags)
 {
-       VkFormatProperties      properties;
+       VkFormatProperties              properties;
+       VkFormatFeatureFlags    tilingFeatures  = 0;
 
        vki.getPhysicalDeviceFormatProperties(physicalDevice, format, &properties);
 
+       switch (imageTiling)
+       {
+               case VK_IMAGE_TILING_LINEAR:
+                       tilingFeatures = properties.linearTilingFeatures;
+                       break;
+
+               case VK_IMAGE_TILING_OPTIMAL:
+                       tilingFeatures = properties.optimalTilingFeatures;
+                       break;
+
+               default:
+                       DE_ASSERT(false);
+                       break;
+       }
+
        if ((requiredUsageFlags & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) != 0)
        {
-               if ((properties.bufferFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) == 0)
+               if ((tilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) == 0)
                        TCU_THROW(NotSupportedError, "Image format cannot be used as color attachment");
                requiredUsageFlags ^= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
        }
@@ -199,7 +215,7 @@ static void requireFormatUsageSupport(const InstanceInterface& vki, VkPhysicalDe
 
        if ((requiredUsageFlags & VK_IMAGE_USAGE_TRANSFER_SRC_BIT) != 0)
        {
-               if ((properties.bufferFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR) == 0)
+               if ((tilingFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR) == 0)
                        TCU_THROW(NotSupportedError, "Image format cannot be used as transfer source");
                requiredUsageFlags ^= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
        }
@@ -2320,7 +2336,7 @@ TestStatus runAndVerifyDefaultPipeline (Context& context, InstanceContext instan
                imageParams.format              = instance.interfaces.getOutputType().getVkFormat();
 
                // Check the usage bits on the given image format are supported.
-               requireFormatUsageSupport(vkInstance, vkPhysicalDevice, imageParams.format, imageParams.usage);
+               requireFormatUsageSupport(vkInstance, vkPhysicalDevice, imageParams.format, imageParams.tiling, imageParams.usage);
 
                fragOutputImage                 = createImage(vk, *vkDevice, &imageParams);
                fragOutputImageMemory   = allocator.allocate(getImageMemoryRequirements(vk, *vkDevice, *fragOutputImage), MemoryRequirement::Any);