Simplify support checking and fix typos in messages
authorGraeme Leese <gleese@broadcom.com>
Tue, 7 May 2019 12:41:46 +0000 (13:41 +0100)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Wed, 8 May 2019 07:29:13 +0000 (03:29 -0400)
The code for checking format support was duplicated for source and
destination formats and there were several typos in the various error
messages.

Components: Vulkan
Affects: dEQP-VK.ycbcr.copy.*

Change-Id: I1cc02a5aa66f521e5a152f608f39456e24c4ccb8

external/vulkancts/modules/vulkan/ycbcr/vktYCbCrCopyTests.cpp

index f121fb517da70387cc87e80372b6534b7abf58d3..ad74baed49817d0e696119ae0f5f77ccc346bbe0 100644 (file)
@@ -93,26 +93,23 @@ struct TestConfig
        ImageConfig     dst;
 };
 
-void checkSupport (Context& context, const TestConfig config)
+void checkFormatSupport(Context& context, const ImageConfig& config)
 {
-       if (!de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), string("VK_KHR_sampler_ycbcr_conversion")))
-               TCU_THROW(NotSupportedError, "Extension VK_KHR_sampler_ycbcr_conversion not supported");
-
        try
        {
-               const vk::VkFormatProperties    properties      (vk::getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), config.src.format));
-               const vk::VkFormatFeatureFlags  features        (config.src.tiling == vk::VK_IMAGE_TILING_OPTIMAL
+               const vk::VkFormatProperties    properties      (vk::getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), config.format));
+               const vk::VkFormatFeatureFlags  features        (config.tiling == vk::VK_IMAGE_TILING_OPTIMAL
                                                                                                        ? properties.optimalTilingFeatures
                                                                                                        : properties.linearTilingFeatures);
 
                if ((features & vk::VK_FORMAT_FEATURE_TRANSFER_SRC_BIT) == 0
                        && (features & vk::VK_FORMAT_FEATURE_TRANSFER_DST_BIT) == 0)
                {
-                       TCU_THROW(NotSupportedError, "Source format doesn't support copies");
+                       TCU_THROW(NotSupportedError, "Format doesn't support copies");
                }
 
-               if (config.src.disjoint && ((features & vk::VK_FORMAT_FEATURE_DISJOINT_BIT) == 0))
-                       TCU_THROW(NotSupportedError, "Format doesn'tsupport  disjoint planes");
+               if (config.disjoint && ((features & vk::VK_FORMAT_FEATURE_DISJOINT_BIT) == 0))
+                       TCU_THROW(NotSupportedError, "Format doesn't support disjoint planes");
        }
        catch (const vk::Error& err)
        {
@@ -121,30 +118,15 @@ void checkSupport (Context& context, const TestConfig config)
 
                throw;
        }
+}
 
-       try
-       {
-               const vk::VkFormatProperties    properties      (vk::getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), config.dst.format));
-               const vk::VkFormatFeatureFlags  features        (config.dst.tiling == vk::VK_IMAGE_TILING_OPTIMAL
-                                                                                                       ? properties.optimalTilingFeatures
-                                                                                                       : properties.linearTilingFeatures);
-
-               if ((features & vk::VK_FORMAT_FEATURE_TRANSFER_SRC_BIT) == 0
-                       && (features & vk::VK_FORMAT_FEATURE_TRANSFER_DST_BIT) == 0)
-               {
-                       TCU_THROW(NotSupportedError, "Source format doesn't support copies");
-               }
-
-               if (config.dst.disjoint && ((features & vk::VK_FORMAT_FEATURE_DISJOINT_BIT) == 0))
-                       TCU_THROW(NotSupportedError, "Format doesn't disjoint planes");
-       }
-       catch (const vk::Error& err)
-       {
-               if (err.getError() == vk::VK_ERROR_FORMAT_NOT_SUPPORTED)
-                       TCU_THROW(NotSupportedError, "Format not supported");
+void checkSupport (Context& context, const TestConfig config)
+{
+       if (!de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), string("VK_KHR_sampler_ycbcr_conversion")))
+               TCU_THROW(NotSupportedError, "Extension VK_KHR_sampler_ycbcr_conversion not supported");
 
-               throw;
-       }
+       checkFormatSupport(context, config.src);
+       checkFormatSupport(context, config.dst);
 }
 
 vk::Move<vk::VkImage> createImage (const vk::DeviceInterface&  vkd,