Extend image tests to support formats with no formats
authorGraeme Leese <gleese@broadcom.com>
Tue, 6 Jul 2021 13:12:43 +0000 (14:12 +0100)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 16 Jul 2021 08:20:52 +0000 (08:20 +0000)
Unless the test actually needs a SPIR-V format token, allow testing of
Vulkan formats for which there is no corresponding SPIR-V token. At the
moment this functionality is not used, but tests will soon be added that
exercise it.

Components: Framework, Vulkan
Affects (trivially): dEQP-VK.image.*

Change-Id: I11e16b6951ca40444131fa1e8d5e7bce6b075f85

external/vulkancts/framework/vulkan/vkImageUtil.cpp
external/vulkancts/framework/vulkan/vkImageUtil.hpp
external/vulkancts/modules/vulkan/image/vktImageLoadStoreTests.cpp

index ca4b6b0..13df81e 100644 (file)
@@ -358,6 +358,12 @@ const std::map<VkFormat, std::string> spirvFormats = {
        { VK_FORMAT_R64_UINT,                                   "R64ui"                 },
 };
 
+bool hasSpirvFormat(VkFormat fmt)
+{
+       auto iter = spirvFormats.find(fmt);
+       return (iter != spirvFormats.end());
+}
+
 const std::string getSpirvFormat(VkFormat fmt)
 {
        auto iter = spirvFormats.find(fmt);
index e8d7b4d..48d6959 100644 (file)
@@ -81,6 +81,7 @@ deUint32                                      getBlockSizeInBytes                     (const VkFormat compressedFormat);
 deUint32                                       getBlockWidth                           (const VkFormat compressedFormat);
 deUint32                                       getBlockHeight                          (const VkFormat compressedFormat);
 
+bool                                           hasSpirvFormat                          (VkFormat fmt);
 const std::string                      getSpirvFormat                          (VkFormat fmt);
 
 const deUint32 BUFFER_IMAGE_COPY_OFFSET_GRANULARITY = 4u;
index 3b5f984..aec847d 100644 (file)
@@ -563,7 +563,6 @@ void StoreTest::initPrograms (SourceCollections& programCollection) const
        const std::string texelCoordStr = (dimension == 1 ? "gx" : dimension == 2 ? "ivec2(gx, gy)" : dimension == 3 ? "ivec3(gx, gy, gz)" : "");
 
        const ImageType usedImageType = (m_singleLayerBind ? getImageTypeForSingleLayer(m_texture.type()) : m_texture.type());
-       const std::string formatQualifierStr = getShaderImageFormatQualifier(mapVkFormat(m_format));
        const std::string imageTypeStr = getShaderImageType(mapVkFormat(m_format), usedImageType);
 
        std::ostringstream src;
@@ -571,7 +570,10 @@ void StoreTest::initPrograms (SourceCollections& programCollection) const
                << "\n"
                << "layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;\n";
        if (m_declareImageFormatInShader)
+       {
+               const std::string formatQualifierStr = getShaderImageFormatQualifier(mapVkFormat(m_format));
                src << "layout (binding = 0, " << formatQualifierStr << ") writeonly uniform " << imageTypeStr << " u_image;\n";
+       }
        else
                src << "layout (binding = 0) writeonly uniform " << imageTypeStr << " u_image;\n";
 
@@ -2549,17 +2551,21 @@ tcu::TestCaseGroup* createImageStoreTests (tcu::TestContext& testCtx)
 
                for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_formats); ++formatNdx)
                {
-                       groupWithFormatByImageViewType->addChild(new StoreTest(testCtx, getFormatShortString(s_formats[formatNdx]), "", texture, s_formats[formatNdx]));
+                       const bool hasSpirvFmt = hasSpirvFormat(s_formats[formatNdx]);
+
+                       if (hasSpirvFmt)
+                               groupWithFormatByImageViewType->addChild(new StoreTest(testCtx, getFormatShortString(s_formats[formatNdx]), "", texture, s_formats[formatNdx]));
                        groupWithoutFormatByImageViewType->addChild(new StoreTest(testCtx, getFormatShortString(s_formats[formatNdx]), "", texture, s_formats[formatNdx], 0));
 
-                       if (isLayered)
+                       if (isLayered && hasSpirvFmt)
                                groupWithFormatByImageViewType->addChild(new StoreTest(testCtx, getFormatShortString(s_formats[formatNdx]) + "_single_layer", "",
                                                                                                                 texture, s_formats[formatNdx],
                                                                                                                 StoreTest::FLAG_SINGLE_LAYER_BIND | StoreTest::FLAG_DECLARE_IMAGE_FORMAT_IN_SHADER));
 
                        if (texture.type() == IMAGE_TYPE_BUFFER)
                        {
-                               groupWithFormatByImageViewType->addChild(new StoreTest(testCtx, getFormatShortString(s_formats[formatNdx]) + "_minalign", "", texture, s_formats[formatNdx], StoreTest::FLAG_MINALIGN | StoreTest::FLAG_DECLARE_IMAGE_FORMAT_IN_SHADER));
+                               if (hasSpirvFmt)
+                                       groupWithFormatByImageViewType->addChild(new StoreTest(testCtx, getFormatShortString(s_formats[formatNdx]) + "_minalign", "", texture, s_formats[formatNdx], StoreTest::FLAG_MINALIGN | StoreTest::FLAG_DECLARE_IMAGE_FORMAT_IN_SHADER));
                                groupWithoutFormatByImageViewType->addChild(new StoreTest(testCtx, getFormatShortString(s_formats[formatNdx]) + "_minalign", "", texture, s_formats[formatNdx], StoreTest::FLAG_MINALIGN));
                        }
                }
@@ -2589,6 +2595,11 @@ tcu::TestCaseGroup* createImageLoadStoreTests (tcu::TestContext& testCtx)
 
                for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_formats); ++formatNdx)
                {
+                       // These tests always require a SPIR-V format for the write image, even if the read
+                       // image is being used without a format.
+                       if (!hasSpirvFormat(s_formats[formatNdx]))
+                               continue;
+
                        groupWithFormatByImageViewType->addChild(new LoadStoreTest(testCtx, getFormatShortString(s_formats[formatNdx]), "", texture, s_formats[formatNdx], s_formats[formatNdx]));
                        groupWithoutFormatByImageViewType->addChild(new LoadStoreTest(testCtx, getFormatShortString(s_formats[formatNdx]), "", texture, s_formats[formatNdx], s_formats[formatNdx], 0));
 
@@ -2653,6 +2664,11 @@ tcu::TestCaseGroup* createImageLoadStoreLodAMDTests (tcu::TestContext& testCtx)
 
                for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_formats); ++formatNdx)
                {
+                       // These tests always require a SPIR-V format for the write image, even if the read
+                       // image is being used without a format.
+                       if (!hasSpirvFormat(s_formats[formatNdx]))
+                               continue;
+
                        groupWithFormatByImageViewType->addChild(new LoadStoreTest(testCtx, getFormatShortString(s_formats[formatNdx]), "", texture, s_formats[formatNdx], s_formats[formatNdx], LoadStoreTest::FLAG_DECLARE_IMAGE_FORMAT_IN_SHADER, DE_TRUE));
                        groupWithoutFormatByImageViewType->addChild(new LoadStoreTest(testCtx, getFormatShortString(s_formats[formatNdx]), "", texture, s_formats[formatNdx], s_formats[formatNdx], 0, DE_TRUE));
 
@@ -2684,6 +2700,9 @@ tcu::TestCaseGroup* createImageFormatReinterpretTests (tcu::TestContext& testCtx
                for (int imageFormatNdx = 0; imageFormatNdx < DE_LENGTH_OF_ARRAY(s_formats); ++imageFormatNdx)
                for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_formats); ++formatNdx)
                {
+                       if (!hasSpirvFormat(s_formats[formatNdx]))
+                               continue;
+
                        const std::string caseName = getFormatShortString(s_formats[imageFormatNdx]) + "_" + getFormatShortString(s_formats[formatNdx]);
                        if (imageFormatNdx != formatNdx && formatsAreCompatible(s_formats[imageFormatNdx], s_formats[formatNdx]))
                                groupByImageViewType->addChild(new LoadStoreTest(testCtx, caseName, "", texture, s_formats[formatNdx], s_formats[imageFormatNdx]));
@@ -2807,6 +2826,9 @@ tcu::TestCaseGroup* createImageExtendOperandsTests(tcu::TestContext& testCtx)
                                        if (relaxedPrecision && !relaxedOK(readFormat))
                                                continue;
 
+                                       if (!hasSpirvFormat(readFormat) || !hasSpirvFormat(writeFormat))
+                                               continue;
+
                                        matchGroup->addChild(new ImageExtendOperandTest(testCtx, precisionName, texture, readFormat, writeFormat, mismatched, relaxedPrecision, testType.testType));
                                }