Check if display is available for Vulkan.
authorSai Kiran Korwar <skirank@nvidia.com>
Wed, 19 Feb 2020 08:53:39 +0000 (14:23 +0530)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 27 Feb 2020 11:20:13 +0000 (06:20 -0500)
If the display is already being used by native windowing system,
then it may not be available to Vulkan, which may cause the test
to fail.
To account for this, check if any windowing system is already present
and running and then report the test to be unsupported.
Since the extension is meant to support direct rendering to display,
avoid running it when a windowing system is present.

Components: Vulkan

VK-GL-CTS issue: #2230

Affects:
dEQP-VK.wsi.display_control.swapchain_counter

Change-Id: I7fd00b417021e4a2ef017b742e529f5a3917a056
(cherry picked from commit 5318e8023d181def3d6affe446ab251f9898737e)

external/vulkancts/modules/vulkan/wsi/vktWsiDisplayControlTests.cpp

index 5967b4c..77ee36b 100644 (file)
@@ -94,7 +94,8 @@ deUint32 chooseQueueFamilyIndex (const InstanceInterface& vki, VkPhysicalDevice
        return 0;
 }
 
-Move<VkDevice> createDevice (const PlatformInterface&          vkp,
+Move<VkDevice> createDevice (const vk::Platform&               platform,
+                                                        const PlatformInterface&               vkp,
                                                         const VkInstance                               instance,
                                                         const InstanceInterface&               vki,
                                                         VkPhysicalDevice                               physicalDevice,
@@ -104,6 +105,7 @@ Move<VkDevice> createDevice (const PlatformInterface&               vkp,
                                                         const VkAllocationCallbacks*   pAllocator = DE_NULL)
 {
        const float queuePriorities[] = { 1.0f };
+       bool displayAvailable = true;
        const VkDeviceQueueCreateInfo queueInfos[] =
        {
                {
@@ -145,6 +147,19 @@ Move<VkDevice> createDevice (const PlatformInterface&              vkp,
                        TCU_THROW(NotSupportedError, (string(ext) + " is not supported").c_str());
        }
 
+       for (int typeNdx = 0; typeNdx < vk::wsi::TYPE_LAST; ++typeNdx)
+       {
+               vk::wsi::Type   wsiType = (vk::wsi::Type)typeNdx;
+               if (platform.hasDisplay(wsiType))
+               {
+                       displayAvailable = false;
+                       break;
+               }
+       }
+
+       if (!displayAvailable)
+               TCU_THROW(NotSupportedError, "Display is unavailable as windowing system has access");
+
        return createCustomDevice(validationEnabled, vkp, instance, vki, physicalDevice, &deviceParams, pAllocator);
 }
 
@@ -700,7 +715,7 @@ SwapchainCounterTestInstance::SwapchainCounterTestInstance (Context& context)
 
        , m_queueFamilyIndex            (chooseQueueFamilyIndex(m_vki, m_physicalDevice, m_surface))
        , m_deviceExtensions            (enumerateDeviceExtensionProperties(m_vki, m_physicalDevice, DE_NULL))
-       , m_device                                      (createDevice(m_vkp, m_instance, m_vki, m_physicalDevice, m_deviceExtensions, m_queueFamilyIndex, context.getTestContext().getCommandLine().isValidationEnabled()))
+       , m_device                                      (createDevice(context.getTestContext().getPlatform().getVulkanPlatform(), m_vkp, m_instance, m_vki, m_physicalDevice, m_deviceExtensions, m_queueFamilyIndex, context.getTestContext().getCommandLine().isValidationEnabled()))
        , m_vkd                                         (m_vkp, m_instance, *m_device)
        , m_queue                                       (getDeviceQueue(m_vkd, *m_device, m_queueFamilyIndex, 0u))