Fix VK_KHR_shader_clock feature checks
authorRicardo Garcia <rgarcia@igalia.com>
Fri, 8 Oct 2021 07:50:00 +0000 (09:50 +0200)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Thu, 28 Oct 2021 21:46:23 +0000 (21:46 +0000)
The shader clock tests were not checking if the implementation supported
64-bit integers for tests that required the feature and they were
checking supported features at test instance creation time instead of
the specific checkSupport method for test cases.

Affected tests:
dEQP-VK.glsl.shader_clock.*

Components: Vulkan
VK-GL-CTS issue: 3187

Change-Id: I0dc86a4fae619c0d27628d97f0ac11c5def5ff4f

external/vulkancts/modules/vulkan/shaderexecutor/vktShaderClockTests.cpp

index e89f07a..60b1de3 100644 (file)
@@ -94,12 +94,10 @@ using namespace vk;
 class ShaderClockTestInstance : public TestInstance
 {
 public:
-       ShaderClockTestInstance(Context& context, bool realtimeTest, const ShaderSpec& shaderSpec, glu::ShaderType shaderType)
+       ShaderClockTestInstance(Context& context, const ShaderSpec& shaderSpec, glu::ShaderType shaderType)
                : TestInstance(context)
-               , m_realtime_test(realtimeTest)
                , m_executor(createExecutor(m_context, shaderType, shaderSpec))
        {
-               checkSupported();
        }
 
        virtual tcu::TestStatus iterate(void)
@@ -120,34 +118,12 @@ public:
        }
 
 private:
-       void checkSupported(void)
-       {
-               m_context.requireDeviceFunctionality("VK_KHR_shader_clock");
-
-               VkPhysicalDeviceShaderClockFeaturesKHR shaderClockFeatures;
-               shaderClockFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CLOCK_FEATURES_KHR;
-               shaderClockFeatures.pNext = DE_NULL;
-
-               VkPhysicalDeviceFeatures2 features;
-               features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
-               features.pNext = &shaderClockFeatures;
-
-               m_context.getInstanceInterface().getPhysicalDeviceFeatures2(m_context.getPhysicalDevice(), &features);
-
-               if (m_realtime_test && !shaderClockFeatures.shaderDeviceClock)
-                       TCU_THROW(NotSupportedError, "Shader device clock is not supported");
-
-               if (!m_realtime_test && !shaderClockFeatures.shaderSubgroupClock)
-                       TCU_THROW(NotSupportedError, "Shader subgroup clock is not supported");
-       }
-
        bool validateOutput(std::vector<deUint64>& outputs)
        {
                // The shader will write a 1 in the output if the clock did not increase
                return (outputs.size() == deUint64(std::count(std::begin(outputs), std::end(outputs), 0)));
        }
 
-       const bool                                                      m_realtime_test;
        de::UniquePtr<ShaderExecutor>           m_executor;
 };
 
@@ -163,16 +139,33 @@ public:
                initShaderSpec();
        }
 
-       TestInstance* createInstance(Context& ctx) const
+       TestInstance* createInstance (Context& ctx) const override
        {
-               return new ShaderClockTestInstance(ctx, (m_operation.testClockType == DEVICE), m_shaderSpec, m_shaderType);
+               return new ShaderClockTestInstance(ctx, m_shaderSpec, m_shaderType);
        }
 
-       void initPrograms(vk::SourceCollections& programCollection) const
+       void initPrograms (vk::SourceCollections& programCollection) const override
        {
                generateSources(m_shaderType, m_shaderSpec, programCollection);
        }
 
+       void checkSupport (Context& context) const override
+       {
+               context.requireDeviceFunctionality("VK_KHR_shader_clock");
+
+               if (m_operation.testBitType == BIT_64)
+                       context.requireDeviceCoreFeature(DEVICE_CORE_FEATURE_SHADER_INT64);
+
+               const auto&     shaderClockFeatures     = context.getShaderClockFeatures();
+               const auto      realTimeTest            = (m_operation.testClockType == DEVICE);
+
+               if (realTimeTest && !shaderClockFeatures.shaderDeviceClock)
+                       TCU_THROW(NotSupportedError, "Shader device clock is not supported");
+
+               if (!realTimeTest && !shaderClockFeatures.shaderSubgroupClock)
+                       TCU_THROW(NotSupportedError, "Shader subgroup clock is not supported");
+       }
+
 private:
        void initShaderSpec()
        {