Fix asserts and check for base image format support in image.mutable tests
authorSlawomir Cygan <slawomir.cygan@intel.com>
Thu, 2 Aug 2018 16:01:57 +0000 (18:01 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 24 Aug 2018 13:26:20 +0000 (09:26 -0400)
This adds a check if base image can be created given the format.

It is required for implementations supporting VK_KHR_maintenance2 or 1.1:
if these are supported, the exisiting VkImageView format support does not
cover base image format support.

Additionally, fix malformed asserts and missign case switches in this test.

Components: Vulkan

Affects: dEQP-VK.image.mutable

VK-GL-CTS Issue: 1295, 1294

Change-Id: I010a8823e2f7fa53a845366e489f071dbdc2f7f2

external/vulkancts/modules/vulkan/image/vktImageMutableTests.cpp

index c833451..29d198f 100644 (file)
@@ -778,7 +778,7 @@ VkImageUsageFlags getImageUsageForTestCase (const CaseDef& caseDef)
                flags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
                break;
        default:
-               DE_ASSERT("Invalid upload method");
+               DE_FATAL("Invalid upload method");
                break;
        }
 
@@ -794,7 +794,7 @@ VkImageUsageFlags getImageUsageForTestCase (const CaseDef& caseDef)
                flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
                break;
        default:
-               DE_ASSERT("Invalid download method");
+               DE_FATAL("Invalid download method");
                break;
        }
 
@@ -965,7 +965,7 @@ void UploadDownloadExecutor::run(Context& context, VkBuffer buffer)
                uploadCopy(context);
                break;
        default:
-               DE_ASSERT("Unsupported upload method");
+               DE_FATAL("Unsupported upload method");
        }
 
        switch (m_caseDef.download)
@@ -980,7 +980,7 @@ void UploadDownloadExecutor::run(Context& context, VkBuffer buffer)
                downloadTexture(context, buffer);
                break;
        default:
-               DE_ASSERT("Unsupported download method");
+               DE_FATAL("Unsupported download method");
        }
 
        endCommandBuffer(m_vk, *m_cmdBuffer);
@@ -1508,8 +1508,14 @@ tcu::TestStatus testMutable (Context& context, const CaseDef caseDef)
        case UPLOAD_STORE:
                viewFormatFeatureFlags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT;
                break;
+       case UPLOAD_CLEAR:
+               viewFormatFeatureFlags |= VK_FORMAT_FEATURE_TRANSFER_DST_BIT;
+               break;
+       case UPLOAD_COPY:
+               viewFormatFeatureFlags |= VK_FORMAT_FEATURE_TRANSFER_DST_BIT;
+               break;
        default:
-               DE_ASSERT("Invalid upload method");
+               DE_FATAL("Invalid upload method");
                break;
        }
        switch (caseDef.download)
@@ -1523,8 +1529,11 @@ tcu::TestStatus testMutable (Context& context, const CaseDef caseDef)
        case DOWNLOAD_LOAD:
                viewFormatFeatureFlags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT;
                break;
+       case DOWNLOAD_COPY:
+               viewFormatFeatureFlags |= VK_FORMAT_FEATURE_TRANSFER_DST_BIT;
+               break;
        default:
-               DE_ASSERT("Invalid download method");
+               DE_FATAL("Invalid download method");
                break;
        }
 
@@ -1538,17 +1547,26 @@ tcu::TestStatus testMutable (Context& context, const CaseDef caseDef)
        if ((viewFormatProps.optimalTilingFeatures & viewFormatFeatureFlags) != viewFormatFeatureFlags)
                TCU_THROW(NotSupportedError, "View format doesn't support upload/download method");
 
+       const bool haveMaintenance2 = isDeviceExtensionSupported(context.getUsedApiVersion(), context.getDeviceExtensions(), "VK_KHR_maintenance2");
+
        // We don't use the base image for anything other than transfer
        // operations so there are no features to check.  However, The Vulkan
        // 1.0 spec does not allow us to create an image view with usage that
        // is not supported by the main format.  With VK_KHR_maintenance2, we
        // can do this via VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR.
        if ((imageFormatProps.optimalTilingFeatures & viewFormatFeatureFlags) != viewFormatFeatureFlags &&
-                !isDeviceExtensionSupported(context.getUsedApiVersion(), context.getDeviceExtensions(), "VK_KHR_maintenance2"))
+               !haveMaintenance2)
        {
                TCU_THROW(NotSupportedError, "Image format doesn't support upload/download method");
        }
 
+       // If no format feature flags are supported, the format itself is not supported,
+       // and images of that format cannot be created.
+       if (imageFormatProps.optimalTilingFeatures == 0)
+       {
+               TCU_THROW(NotSupportedError, "Base image format is not supported");
+       }
+
        // Create a color buffer for host-inspection of results
        // For the Copy download method, this is the target of the download, for other
        // download methods, pixel data will be copied to this buffer from the download