Add contextSupports functions
authorArkadiusz Sarwa <arkadiusz.sarwa@mobica.com>
Mon, 9 Oct 2017 15:13:48 +0000 (17:13 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 10 Nov 2017 11:14:36 +0000 (06:14 -0500)
Components: Vulkan

VK-GL-CTS issue: 727

Change-Id: Ic2912106268402eb61c2a7aa4d487a2c3c7755e3

external/vulkancts/modules/vulkan/draw/vktDrawShaderDrawParametersTests.cpp
external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmLoopDepInfTests.cpp
external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmLoopDepLenTests.cpp
external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.cpp
external/vulkancts/modules/vulkan/vktTestCase.cpp
external/vulkancts/modules/vulkan/vktTestCase.hpp

index 2e2e8df..2c4a46d 100644 (file)
@@ -114,7 +114,7 @@ DrawTest::DrawTest (Context &context, TestSpec testSpec)
                        TCU_THROW(NotSupportedError, "Missing extension: VK_KHR_shader_draw_parameters");
 
                // Shader draw parameters is part of Vulkan 1.1 but is optional
-               if (context.getUsedApiVersion() >= VK_API_VERSION_1_1)
+               if ( context.contextSupports(vk::ApiVersion(1, 1, 0)) )
                {
                        // Check if shader draw parameters is supported on the physical device.
                        vk::VkPhysicalDeviceShaderDrawParameterFeatures drawParameters =
index b988eac..4bf87f4 100644 (file)
@@ -209,7 +209,7 @@ void SpvAsmLoopControlDependencyInfiniteCase::initPrograms (SourceCollections& p
 
 TestInstance* SpvAsmLoopControlDependencyInfiniteCase::createInstance (Context& context) const
 {
-       if (context.getUsedApiVersion() < VK_API_VERSION_1_1)
+       if (context.contextSupports(vk::ApiVersion(1, 1, 0)))
                TCU_THROW(NotSupportedError, "SPIR-V higher than 1.3 is required for this test to run");
 
        return new SpvAsmLoopControlDependencyInfiniteInstance(context);
index f9f3306..01700a1 100644 (file)
@@ -224,7 +224,7 @@ void SpvAsmLoopControlDependencyLengthCase::initPrograms (SourceCollections& pro
 
 TestInstance* SpvAsmLoopControlDependencyLengthCase::createInstance (Context& context) const
 {
-       if (context.getUsedApiVersion() < VK_API_VERSION_1_1)
+       if (context.contextSupports(vk::ApiVersion(1, 1, 0)))
                TCU_THROW(NotSupportedError, "SPIR-V higher than 1.3 is required for this test to run");
 
        return new SpvAsmLoopControlDependencyLengthInstance(context);
index f8aeb30..11490d7 100644 (file)
@@ -821,7 +821,7 @@ std::string vkt::subgroups::getVertShaderForStage(vk::VkShaderStageFlags stage)
 
 bool vkt::subgroups::isSubgroupSupported(Context& context)
 {
-       return context.getUsedApiVersion() < VK_API_VERSION_1_1 ? false : true;
+       return context.contextSupports(vk::ApiVersion(1, 1, 0));
 }
 
 bool vkt::subgroups::areSubgroupOperationsSupportedForStage(
index 576e2f3..29940f0 100644 (file)
@@ -30,7 +30,6 @@
 #include "vkMemUtil.hpp"
 #include "vkPlatform.hpp"
 #include "vkDebugReportUtil.hpp"
-#include "vkApiVersion.hpp"
 
 #include "tcuCommandLine.hpp"
 
@@ -425,6 +424,12 @@ deUint32                                                           Context::getUniversalQueueFamilyIndex   (void) const { return m_de
 vk::VkQueue                                                            Context::getUniversalQueue                              (void) const { return m_device->getUniversalQueue();                    }
 vk::Allocator&                                                 Context::getDefaultAllocator                    (void) const { return *m_allocator;                                                             }
 deUint32                                                               Context::getUsedApiVersion                              (void) const { return m_device->getUsedApiVersion();                    }
+bool                                                                   Context::contextSupports                                (const deUint32 majorNum, const deUint32 minorNum, const deUint32 patchNum) const
+                                                                                                                                                                                       { return m_device->getUsedApiVersion() >= VK_MAKE_VERSION(majorNum, minorNum, patchNum); }
+bool                                                                   Context::contextSupports                                (const ApiVersion version) const
+                                                                                                                                                                                       { return m_device->getUsedApiVersion() >= pack(version); }
+bool                                                                   Context::contextSupports                                (const deUint32 requiredApiVersionBits) const
+                                                                                                                                                                                       { return m_device->getUsedApiVersion() >= requiredApiVersionBits; }
 
 // TestCase
 
index 7d5c46c..ce02791 100644 (file)
@@ -28,6 +28,7 @@
 #include "vkDefs.hpp"
 #include "deUniquePtr.hpp"
 #include "vkPrograms.hpp"
+#include "vkApiVersion.hpp"
 
 namespace glu
 {
@@ -79,6 +80,9 @@ public:
        deUint32                                                                        getUsedApiVersion                               (void) const;
 
        vk::Allocator&                                                          getDefaultAllocator                             (void) const;
+       bool                                                                            contextSupports                                 (const deUint32 majorNum, const deUint32 minorNum, const deUint32 patchNum) const;
+       bool                                                                            contextSupports                                 (const vk::ApiVersion version) const;
+       bool                                                                            contextSupports                                 (const deUint32 requiredApiVersionBits) const;
 
 protected:
        tcu::TestContext&                                                       m_testCtx;
@@ -93,7 +97,6 @@ private:
        Context&                                                                        operator=                                               (const Context&); // Not allowed
 };
 
-
 class TestInstance;
 
 class TestCase : public tcu::TestCase