dEQP-VK: Merge ConvertTestCase with SpvAsmComputeShaderCase
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 14 Mar 2017 21:40:58 +0000 (14:40 -0700)
committerPyry Haulos <phaulos@google.com>
Thu, 16 Mar 2017 22:26:33 +0000 (18:26 -0400)
The only thing ConvertTestCase was providing over SpvAsmComputeShaderCase
was the ability to specify a set of features required by the test case.
However, this is something that's useful in general if we want to be
able to use int16, int64, or float64 in any of the other compute tests.

Change-Id: I870b8245de94afdb1067d2e538621d1b2230fc51

external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmComputeShaderCase.cpp
external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmComputeShaderCase.hpp
external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmInstructionTests.cpp

index 852fff1..e1bee62 100644 (file)
@@ -246,18 +246,20 @@ namespace SpirVAssembly
 class SpvAsmComputeShaderInstance : public TestInstance
 {
 public:
-                                                               SpvAsmComputeShaderInstance     (Context& ctx, const ComputeShaderSpec& spec);
+                                                               SpvAsmComputeShaderInstance     (Context& ctx, const ComputeShaderSpec& spec, const ComputeTestFeatures features);
        tcu::TestStatus                         iterate                                         (void);
 
 private:
        const ComputeShaderSpec&        m_shaderSpec;
+       const ComputeTestFeatures       m_features;
 };
 
 // ComputeShaderTestCase implementations
 
-SpvAsmComputeShaderCase::SpvAsmComputeShaderCase (tcu::TestContext& testCtx, const char* name, const char* description, const ComputeShaderSpec& spec)
+SpvAsmComputeShaderCase::SpvAsmComputeShaderCase (tcu::TestContext& testCtx, const char* name, const char* description, const ComputeShaderSpec& spec, const ComputeTestFeatures features)
        : TestCase              (testCtx, name, description)
        , m_shaderSpec  (spec)
+       , m_features    (features)
 {
 }
 
@@ -268,23 +270,35 @@ void SpvAsmComputeShaderCase::initPrograms (SourceCollections& programCollection
 
 TestInstance* SpvAsmComputeShaderCase::createInstance (Context& ctx) const
 {
-       return new SpvAsmComputeShaderInstance(ctx, m_shaderSpec);
+       return new SpvAsmComputeShaderInstance(ctx, m_shaderSpec, m_features);
 }
 
 // ComputeShaderTestInstance implementations
 
-SpvAsmComputeShaderInstance::SpvAsmComputeShaderInstance (Context& ctx, const ComputeShaderSpec& spec)
+SpvAsmComputeShaderInstance::SpvAsmComputeShaderInstance (Context& ctx, const ComputeShaderSpec& spec, const ComputeTestFeatures features)
        : TestInstance  (ctx)
        , m_shaderSpec  (spec)
+       , m_features    (features)
 {
 }
 
 tcu::TestStatus SpvAsmComputeShaderInstance::iterate (void)
 {
+       const VkPhysicalDeviceFeatures&         features = m_context.getDeviceFeatures();
        const DeviceInterface&                          vkdi                            = m_context.getDeviceInterface();
        const VkDevice&                                         device                          = m_context.getDevice();
        Allocator&                                                      allocator                       = m_context.getDefaultAllocator();
 
+       if ((m_features == COMPUTE_TEST_USES_INT16 || m_features == COMPUTE_TEST_USES_INT16_INT64) && !features.shaderInt16)
+       {
+               throw tcu::NotSupportedError("shaderInt16 feature is not supported");
+       }
+
+       if ((m_features == COMPUTE_TEST_USES_INT64 || m_features == COMPUTE_TEST_USES_INT16_INT64) && !features.shaderInt64)
+       {
+               throw tcu::NotSupportedError("shaderInt64 feature is not supported");
+       }
+
        vector<AllocationSp>                            inputAllocs;
        vector<AllocationSp>                            outputAllocs;
        vector<BufferHandleSp>                          inputBuffers;
@@ -396,49 +410,5 @@ tcu::TestStatus SpvAsmComputeShaderInstance::iterate (void)
        return tcu::TestStatus::pass("Output match with expected");
 }
 
-class ConvertTestInstance : public SpvAsmComputeShaderInstance
-{
-public:
-                                               ConvertTestInstance     (Context& ctx, const ComputeShaderSpec& spec, const ConvertTestFeatures features);
-       tcu::TestStatus         iterate                         (void);
-private:
-       const ConvertTestFeatures       m_features;
-};
-
-ConvertTestInstance::ConvertTestInstance (Context& ctx, const ComputeShaderSpec& spec, const ConvertTestFeatures features)
-       : SpvAsmComputeShaderInstance   (ctx, spec)
-       , m_features                                    (features)
-{
-}
-
-tcu::TestStatus ConvertTestInstance::iterate (void)
-{
-       const VkPhysicalDeviceFeatures&         features = m_context.getDeviceFeatures();
-
-       if ((m_features == CONVERT_TEST_USES_INT16 || m_features == CONVERT_TEST_USES_INT16_INT64) && !features.shaderInt16)
-       {
-               throw tcu::NotSupportedError("shaderInt16 feature is not supported");
-       }
-
-       if ((m_features == CONVERT_TEST_USES_INT64 || m_features == CONVERT_TEST_USES_INT16_INT64) && !features.shaderInt64)
-       {
-               throw tcu::NotSupportedError("shaderInt64 feature is not supported");
-       }
-
-       return SpvAsmComputeShaderInstance::iterate();
-}
-
-ConvertTestCase::ConvertTestCase (tcu::TestContext& testCtx, const char* name, const char* description, const ComputeShaderSpec& spec, const ConvertTestFeatures features)
-       : SpvAsmComputeShaderCase       (testCtx, name, description, spec)
-       , m_shaderSpec                          (spec)
-       , m_features                            (features)
-{
-}
-
-TestInstance* ConvertTestCase::createInstance (Context& ctx) const
-{
-       return new ConvertTestInstance(ctx, m_shaderSpec, m_features);
-}
-
 } // SpirVAssembly
 } // vkt
index bd70ffc..50c69e9 100644 (file)
@@ -33,32 +33,24 @@ namespace vkt
 namespace SpirVAssembly
 {
 
+enum ComputeTestFeatures
+{
+       COMPUTE_TEST_USES_NONE,
+       COMPUTE_TEST_USES_INT16,
+       COMPUTE_TEST_USES_INT64,
+       COMPUTE_TEST_USES_INT16_INT64,
+};
+
 class SpvAsmComputeShaderCase : public TestCase
 {
 public:
-                                               SpvAsmComputeShaderCase (tcu::TestContext& testCtx, const char* name, const char* description, const ComputeShaderSpec& spec);
+                                               SpvAsmComputeShaderCase (tcu::TestContext& testCtx, const char* name, const char* description, const ComputeShaderSpec& spec, const ComputeTestFeatures features = COMPUTE_TEST_USES_NONE);
        void                            initPrograms                    (vk::SourceCollections& programCollection) const;
        TestInstance*           createInstance                  (Context& ctx) const;
 
 private:
        ComputeShaderSpec       m_shaderSpec;
-};
-
-enum ConvertTestFeatures
-{
-       CONVERT_TEST_USES_INT16,
-       CONVERT_TEST_USES_INT64,
-       CONVERT_TEST_USES_INT16_INT64,
-};
-
-class ConvertTestCase : public SpvAsmComputeShaderCase
-{
-public:
-                                               ConvertTestCase (tcu::TestContext& testCtx, const char* name, const char* description, const ComputeShaderSpec& spec, const ConvertTestFeatures features);
-       TestInstance*           createInstance  (Context& ctx) const;
-private:
-       ComputeShaderSpec                       m_shaderSpec;
-       const ConvertTestFeatures       m_features;
+       const ComputeTestFeatures       m_features;
 };
 
 } // SpirVAssembly
index 01806b2..f6c9a68 100644 (file)
@@ -6164,22 +6164,22 @@ bool usesInt64 (IntegerType from, IntegerType to)
                        || to == INTEGER_TYPE_SIGNED_64 || to == INTEGER_TYPE_UNSIGNED_64);
 }
 
-ConvertTestFeatures getUsedFeatures (IntegerType from, IntegerType to)
+ComputeTestFeatures getConversionUsedFeatures (IntegerType from, IntegerType to)
 {
        if (usesInt16(from, to))
        {
                if (usesInt64(from, to))
                {
-                       return CONVERT_TEST_USES_INT16_INT64;
+                       return COMPUTE_TEST_USES_INT16_INT64;
                }
                else
                {
-                       return CONVERT_TEST_USES_INT16;
+                       return COMPUTE_TEST_USES_INT16;
                }
        }
        else
        {
-               return CONVERT_TEST_USES_INT64;
+               return COMPUTE_TEST_USES_INT64;
        }
 }
 
@@ -6188,7 +6188,7 @@ struct ConvertCase
        ConvertCase (IntegerType from, IntegerType to, deInt64 number)
        : m_fromType            (from)
        , m_toType                      (to)
-       , m_features            (getUsedFeatures(from, to))
+       , m_features            (getConversionUsedFeatures(from, to))
        , m_name                        (getTestName(from, to))
        , m_inputBuffer         (getBuffer(from, number))
        , m_outputBuffer        (getBuffer(to, number))
@@ -6196,15 +6196,15 @@ struct ConvertCase
                m_asmTypes["inputType"]         = getAsmTypeDeclaration(from);
                m_asmTypes["outputType"]        = getAsmTypeDeclaration(to);
 
-               if (m_features == CONVERT_TEST_USES_INT16)
+               if (m_features == COMPUTE_TEST_USES_INT16)
                {
                        m_asmTypes["int_capabilities"] = "OpCapability Int16\n";
                }
-               else if (m_features == CONVERT_TEST_USES_INT64)
+               else if (m_features == COMPUTE_TEST_USES_INT64)
                {
                        m_asmTypes["int_capabilities"] = "OpCapability Int64\n";
                }
-               else if (m_features == CONVERT_TEST_USES_INT16_INT64)
+               else if (m_features == COMPUTE_TEST_USES_INT16_INT64)
                {
                        m_asmTypes["int_capabilities"] = string("OpCapability Int16\n") +
                                                                                                        "OpCapability Int64\n";
@@ -6217,7 +6217,7 @@ struct ConvertCase
 
        IntegerType                             m_fromType;
        IntegerType                             m_toType;
-       ConvertTestFeatures             m_features;
+       ComputeTestFeatures             m_features;
        string                                  m_name;
        map<string, string>             m_asmTypes;
        BufferSp                                m_inputBuffer;
@@ -6328,7 +6328,7 @@ tcu::TestCaseGroup* createSConvertTests (tcu::TestContext& testCtx)
                spec.outputs.push_back(test->m_outputBuffer);
                spec.numWorkGroups = IVec3(1, 1, 1);
 
-               group->addChild(new ConvertTestCase(testCtx, test->m_name.c_str(), "Convert integers with OpSConvert.", spec, test->m_features));
+               group->addChild(new SpvAsmComputeShaderCase(testCtx, test->m_name.c_str(), "Convert integers with OpSConvert.", spec, test->m_features));
        }
 
        return group.release();
@@ -6366,7 +6366,7 @@ tcu::TestCaseGroup* createUConvertTests (tcu::TestContext& testCtx)
                spec.outputs.push_back(test->m_outputBuffer);
                spec.numWorkGroups = IVec3(1, 1, 1);
 
-               group->addChild(new ConvertTestCase(testCtx, test->m_name.c_str(), "Convert integers with OpUConvert.", spec, test->m_features));
+               group->addChild(new SpvAsmComputeShaderCase(testCtx, test->m_name.c_str(), "Convert integers with OpUConvert.", spec, test->m_features));
        }
        return group.release();
 }