Check if CTS has platform display for wsi-type
authorygole <ygole@nvidia.com>
Tue, 15 Jan 2019 13:49:31 +0000 (19:19 +0530)
committerYogesh Gole <ygole@nvidia.com>
Mon, 25 Feb 2019 14:45:51 +0000 (09:45 -0500)
Vulkan driver can expose multiple VK_KHR_{platform}_surface extensions
and it's app responsibility to create platform display then create the
surface and pass it to vkCreate{platform}SurfaceKHR. But if CTS does
not have display for requested wsi type and extension is exposed, CTS
reports it as failure.

To fix this, if function createWsiDisplay fails then check whether CTS
has platform display available for requested wsi-type and if it does
then only report this as failure otherwise report it as unsupported.

Affects: dEQP-VK.wsi.*

Components: Vulkan, Framework

VK-GL-CTS issue: 1558

Change-Id: I41aabc2e77cfc6e730b5a95dde746d8ea8152d2b
(cherry picked from commit b7efacd7b320d2b2c3b8b75cf98c9979b5a29fe9)

23 files changed:
external/vulkancts/framework/vulkan/vkPlatform.cpp
external/vulkancts/framework/vulkan/vkPlatform.hpp
external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemWsiSwapchainTests.cpp
external/vulkancts/modules/vulkan/wsi/vktWsiColorSpaceTests.cpp
external/vulkancts/modules/vulkan/wsi/vktWsiDisplayTimingTests.cpp
external/vulkancts/modules/vulkan/wsi/vktWsiIncrementalPresentTests.cpp
external/vulkancts/modules/vulkan/wsi/vktWsiSharedPresentableImageTests.cpp
external/vulkancts/modules/vulkan/wsi/vktWsiSurfaceTests.cpp
external/vulkancts/modules/vulkan/wsi/vktWsiSwapchainTests.cpp
framework/platform/android/tcuAndroidPlatform.cpp
framework/platform/android/tcuAndroidPlatform.hpp
framework/platform/lnx/X11/tcuLnxX11.cpp
framework/platform/lnx/X11/tcuLnxX11.hpp
framework/platform/lnx/X11/tcuLnxX11Xcb.cpp
framework/platform/lnx/X11/tcuLnxX11Xcb.hpp
framework/platform/lnx/tcuLnxVulkanPlatform.cpp
framework/platform/lnx/tcuLnxVulkanPlatform.hpp
framework/platform/lnx/wayland/tcuLnxWayland.cpp
framework/platform/lnx/wayland/tcuLnxWayland.hpp
framework/platform/osx/tcuOSXVulkanPlatform.cpp
framework/platform/osx/tcuOSXVulkanPlatform.hpp
framework/platform/win32/tcuWin32VulkanPlatform.cpp
framework/platform/win32/tcuWin32VulkanPlatform.hpp

index 8ceb805..d2266f4 100644 (file)
@@ -78,6 +78,11 @@ wsi::Display* Platform::createWsiDisplay (wsi::Type) const
        TCU_THROW(NotSupportedError, "WSI not supported");
 }
 
+bool Platform::hasDisplay (wsi::Type) const
+{
+       return false;
+}
+
 void Platform::describePlatform (std::ostream& dst) const
 {
        dst << "vk::Platform::describePlatform() not implemented";
index 40159a7..1ec1f26 100644 (file)
@@ -141,6 +141,7 @@ public:
        virtual Library*                createLibrary           (void) const = 0;
 
        virtual wsi::Display*   createWsiDisplay        (wsi::Type wsiType) const;
+       virtual bool                    hasDisplay      (wsi::Type wsiType) const;
 
        virtual void                    getMemoryLimits         (PlatformMemoryLimits& limits) const = 0;
        virtual void                    describePlatform        (std::ostream& dst) const;
index 509851f..b53979f 100644 (file)
@@ -115,7 +115,8 @@ de::MovePtr<vk::wsi::Display> createDisplay (const vk::Platform&    platform,
        }
        catch (const tcu::NotSupportedError& e)
        {
-               if (isExtensionSupported(supportedExtensions, vk::RequiredExtension(getExtensionName(wsiType))))
+               if (isExtensionSupported(supportedExtensions, vk::RequiredExtension(getExtensionName(wsiType))) &&
+                   platform.hasDisplay(wsiType))
                {
                        // If VK_KHR_{platform}_surface was supported, vk::Platform implementation
                        // must support creating native display & window for that WSI type.
index ca87f61..d2f65cc 100644 (file)
@@ -261,7 +261,8 @@ MovePtr<Display> createDisplay (const vk::Platform& platform,
        }
        catch (const tcu::NotSupportedError& e)
        {
-               if (isExtensionSupported(supportedExtensions, RequiredExtension(getExtensionName(wsiType))))
+               if (isExtensionSupported(supportedExtensions, RequiredExtension(getExtensionName(wsiType))) &&
+                   platform.hasDisplay(wsiType))
                {
                        // If VK_KHR_{platform}_surface was supported, vk::Platform implementation
                        // must support creating native display & window for that WSI type.
index 2a6045c..f67a818 100644 (file)
@@ -192,7 +192,8 @@ de::MovePtr<vk::wsi::Display> createDisplay (const vk::Platform&    platform,
        }
        catch (const tcu::NotSupportedError& e)
        {
-               if (isExtensionSupported(supportedExtensions, vk::RequiredExtension(getExtensionName(wsiType))))
+               if (isExtensionSupported(supportedExtensions, vk::RequiredExtension(getExtensionName(wsiType))) &&
+                   platform.hasDisplay(wsiType))
                {
                        // If VK_KHR_{platform}_surface was supported, vk::Platform implementation
                        // must support creating native display & window for that WSI type.
index c367554..9b851b2 100644 (file)
@@ -194,7 +194,8 @@ de::MovePtr<vk::wsi::Display> createDisplay (const vk::Platform&    platform,
        }
        catch (const tcu::NotSupportedError& e)
        {
-               if (isExtensionSupported(supportedExtensions, vk::RequiredExtension(getExtensionName(wsiType))))
+               if (isExtensionSupported(supportedExtensions, vk::RequiredExtension(getExtensionName(wsiType))) &&
+                   platform.hasDisplay(wsiType))
                {
                        // If VK_KHR_{platform}_surface was supported, vk::Platform implementation
                        // must support creating native display & window for that WSI type.
index cf1eb7d..bc7c3de 100644 (file)
@@ -200,7 +200,8 @@ de::MovePtr<vk::wsi::Display> createDisplay (const vk::Platform&    platform,
        }
        catch (const tcu::NotSupportedError& e)
        {
-               if (isExtensionSupported(supportedExtensions, vk::RequiredExtension(getExtensionName(wsiType))))
+               if (isExtensionSupported(supportedExtensions, vk::RequiredExtension(getExtensionName(wsiType))) &&
+                   platform.hasDisplay(wsiType))
                {
                        // If VK_KHR_{platform}_surface was supported, vk::Platform implementation
                        // must support creating native display & window for that WSI type.
index d978573..aab4da2 100644 (file)
@@ -238,7 +238,8 @@ MovePtr<Display> createDisplay (const vk::Platform& platform,
        }
        catch (const tcu::NotSupportedError& e)
        {
-               if (isExtensionSupported(supportedExtensions, RequiredExtension(getExtensionName(wsiType))))
+               if (isExtensionSupported(supportedExtensions, RequiredExtension(getExtensionName(wsiType))) &&
+                   platform.hasDisplay(wsiType))
                {
                        // If VK_KHR_{platform}_surface was supported, vk::Platform implementation
                        // must support creating native display & window for that WSI type.
index 951aa25..cb5fe91 100644 (file)
@@ -258,7 +258,8 @@ MovePtr<Display> createDisplay (const vk::Platform& platform,
        }
        catch (const tcu::NotSupportedError& e)
        {
-               if (isExtensionSupported(supportedExtensions, RequiredExtension(getExtensionName(wsiType))))
+               if (isExtensionSupported(supportedExtensions, RequiredExtension(getExtensionName(wsiType))) &&
+                   platform.hasDisplay(wsiType))
                {
                        // If VK_KHR_{platform}_surface was supported, vk::Platform implementation
                        // must support creating native display & window for that WSI type.
index 2aa0920..8556bb0 100644 (file)
@@ -347,5 +347,13 @@ vk::wsi::Display* Platform::createWsiDisplay (vk::wsi::Type wsiType) const
                TCU_THROW(NotSupportedError, "WSI type not supported on Android");
 }
 
+bool Platform::hasDisplay (vk::wsi::Type wsiType) const
+{
+       if (wsiType == vk::wsi::TYPE_ANDROID)
+               return true;
+
+       return false;
+}
+
 } // Android
 } // tcu
index 1798777..a10cef8 100644 (file)
@@ -55,6 +55,7 @@ public:
        void                                                    describePlatform        (std::ostream& dst) const;
        void                                                    getMemoryLimits         (vk::PlatformMemoryLimits& limits) const;
        vk::wsi::Display*                               createWsiDisplay        (vk::wsi::Type wsiType) const;
+       bool                                            hasDisplay              (vk::wsi::Type wsiType) const;
 
 private:
        NativeActivity&                                 m_activity;
index 1a60860..7f2fe59 100644 (file)
@@ -52,6 +52,24 @@ WindowBase::~WindowBase (void)
 {
 }
 
+XlibDisplay::DisplayState XlibDisplay::s_displayState = XlibDisplay::DISPLAY_STATE_UNKNOWN;
+
+bool XlibDisplay::hasDisplay (const char* name)
+{
+       if (s_displayState == DISPLAY_STATE_UNKNOWN)
+       {
+               XInitThreads();
+               Display *display = XOpenDisplay((char*)name);
+               if (display)
+               {
+                       s_displayState = DISPLAY_STATE_AVAILABLE;
+                       XCloseDisplay(display);
+               } else
+                       s_displayState = DISPLAY_STATE_UNAVAILABLE;
+       }
+       return s_displayState == DISPLAY_STATE_AVAILABLE ? true : false;
+}
+
 XlibDisplay::XlibDisplay (EventState& eventState, const char* name)
        : DisplayBase   (eventState)
 {
index 10d7fc0..b6abe1b 100644 (file)
@@ -47,6 +47,13 @@ public:
        virtual                 ~DisplayBase    (void);
        virtual void    processEvents   (void) = 0;
 
+       enum DisplayState
+       {
+               DISPLAY_STATE_UNKNOWN = -1,
+               DISPLAY_STATE_UNAVAILABLE,
+               DISPLAY_STATE_AVAILABLE
+       };
+
 protected:
        EventState&             m_eventState;
 
@@ -90,6 +97,9 @@ public:
        bool                    getVisualInfo   (VisualID visualID, XVisualInfo& dst);
        void                    processEvents   (void);
        void                    processEvent    (XEvent& event);
+       static bool             hasDisplay      (const char* name);
+
+       static DisplayState     s_displayState;
 
 protected:
        ::Display*              m_display;
index de87b0c..2820cbc 100644 (file)
@@ -31,6 +31,23 @@ namespace lnx
 namespace x11
 {
 
+XcbDisplay::DisplayState XcbDisplay::s_displayState = XcbDisplay::DISPLAY_STATE_UNKNOWN;
+
+bool XcbDisplay::hasDisplay (const char* name)
+{
+       if (s_displayState == DISPLAY_STATE_UNKNOWN)
+       {
+               xcb_connection_t *connection = xcb_connect(name, NULL);
+               if (connection)
+               {
+                       s_displayState = DISPLAY_STATE_AVAILABLE;
+                       xcb_disconnect(connection);
+               } else
+                       s_displayState = DISPLAY_STATE_UNAVAILABLE;
+       }
+       return s_displayState == DISPLAY_STATE_AVAILABLE ? true : false;
+}
+
 XcbDisplay::XcbDisplay (EventState& platform, const char* name)
        : DisplayBase   (platform)
 {
index c00c413..0d5472f 100644 (file)
@@ -43,7 +43,9 @@ public:
        xcb_connection_t*       getConnection   (void) { return m_connection;   }
 
        void                            processEvents   (void);
+       static bool                     hasDisplay      (const char* name);
 
+       static DisplayState     s_displayState;
 protected:
        xcb_screen_t*           m_screen;
        xcb_connection_t*       m_connection;
index 642af34..b933dad 100644 (file)
@@ -40,10 +40,12 @@ using de::UniquePtr;
 #      if defined (DEQP_SUPPORT_XCB)
 #              include "tcuLnxX11Xcb.hpp"
 #      endif // DEQP_SUPPORT_XCB
+#      define X11_DISPLAY ""
 #endif // DEQP_SUPPORT_X11
 
 #if defined (DEQP_SUPPORT_WAYLAND)
 #      include "tcuLnxWayland.hpp"
+#      define WAYLAND_DISPLAY DE_NULL
 #endif // DEQP_SUPPORT_WAYLAND
 
 namespace tcu
@@ -211,17 +213,17 @@ vk::wsi::Display* VulkanPlatform::createWsiDisplay (vk::wsi::Type wsiType) const
        {
 #if defined (DEQP_SUPPORT_X11)
        case vk::wsi::TYPE_XLIB:
-               return new VulkanDisplayXlib(MovePtr<x11::DisplayBase>(new x11::XlibDisplay(m_eventState,"")));
+               return new VulkanDisplayXlib(MovePtr<x11::DisplayBase>(new x11::XlibDisplay(m_eventState,X11_DISPLAY)));
                break;
 #endif // DEQP_SUPPORT_X11
 #if defined (DEQP_SUPPORT_XCB)
        case vk::wsi::TYPE_XCB:
-               return new VulkanDisplayXcb(MovePtr<x11::DisplayBase>(new x11::XcbDisplay(m_eventState,"")));
+               return new VulkanDisplayXcb(MovePtr<x11::DisplayBase>(new x11::XcbDisplay(m_eventState,X11_DISPLAY)));
                break;
 #endif // DEQP_SUPPORT_XCB
 #if defined (DEQP_SUPPORT_WAYLAND)
        case vk::wsi::TYPE_WAYLAND:
-               return new VulkanDisplayWayland(MovePtr<wayland::Display>(new wayland::Display(m_eventState, DE_NULL)));
+               return new VulkanDisplayWayland(MovePtr<wayland::Display>(new wayland::Display(m_eventState, WAYLAND_DISPLAY)));
                break;
 #endif // DEQP_SUPPORT_WAYLAND
 
@@ -230,7 +232,27 @@ vk::wsi::Display* VulkanPlatform::createWsiDisplay (vk::wsi::Type wsiType) const
 
        };
 }
+bool VulkanPlatform::hasDisplay (vk::wsi::Type wsiType) const
+{
+       switch(wsiType)
+       {
+#if defined (DEQP_SUPPORT_X11)
+       case vk::wsi::TYPE_XLIB:
+               return x11::XlibDisplay::hasDisplay(X11_DISPLAY);
+#endif // DEQP_SUPPORT_X11
+#if defined (DEQP_SUPPORT_XCB)
+       case vk::wsi::TYPE_XCB:
+               return x11::XcbDisplay::hasDisplay(X11_DISPLAY);
+#endif // DEQP_SUPPORT_XCB
+#if defined (DEQP_SUPPORT_WAYLAND)
+       case vk::wsi::TYPE_WAYLAND:
+               return wayland::Display::hasDisplay(WAYLAND_DISPLAY);
+#endif // DEQP_SUPPORT_WAYLAND
+       default:
+               return false;
 
+       };
+}
 vk::Library* VulkanPlatform::createLibrary (void) const
 {
        return new VulkanLibrary();
index b025f55..6d4c2e9 100644 (file)
@@ -39,6 +39,7 @@ public:
                                                VulkanPlatform          (EventState& eventState);
        vk::wsi::Display*       createWsiDisplay        (vk::wsi::Type wsiType) const;
        vk::Library*            createLibrary           (void) const;
+       bool                            hasDisplay              (vk::wsi::Type wsiType) const;
        void                            describePlatform        (std::ostream& dst) const;
        void                            getMemoryLimits         (vk::PlatformMemoryLimits& limits) const;
 
index 6d12543..bea6835 100644 (file)
@@ -42,6 +42,8 @@ const struct wl_registry_listener Display::s_registryListener =
        Display::handleGlobalRemove
 };
 
+Display::DisplayState Display::s_displayState = Display::DISPLAY_STATE_UNKNOWN;
+
 const struct wl_shell_surface_listener Window::s_shellSurfaceListener =
 {
        Window::handlePing,
@@ -68,6 +70,21 @@ void Display::handleGlobalRemove (void* data, struct wl_registry* registry, uint
        DE_UNREF(name);
 }
 
+bool Display::hasDisplay (const char* name)
+{
+       if (s_displayState == DISPLAY_STATE_UNKNOWN)
+       {
+               struct wl_display *display = wl_display_connect(name);
+               if (display)
+               {
+                       s_displayState = DISPLAY_STATE_AVAILABLE;
+                       wl_display_disconnect(display);
+               } else
+                       s_displayState = DISPLAY_STATE_UNAVAILABLE;
+       }
+       return s_displayState == DISPLAY_STATE_AVAILABLE ? true : false;
+}
+
 Display::Display (EventState& eventState, const char* name)
        : m_eventState  (eventState)
        , m_display             (DE_NULL)
index b5d1f9e..b7c540a 100644 (file)
@@ -51,6 +51,15 @@ public:
        struct wl_shell*                getShell                                (void) { return m_shell;                }
 
        void                                    processEvents                   (void);
+       static bool                             hasDisplay                      (const char* name);
+
+       enum DisplayState
+       {
+               DISPLAY_STATE_UNKNOWN = -1,
+               DISPLAY_STATE_UNAVAILABLE,
+               DISPLAY_STATE_AVAILABLE
+       };
+       static DisplayState             s_displayState;
 
 protected:
        EventState&                             m_eventState;
index b1fde87..61822dd 100644 (file)
@@ -108,6 +108,13 @@ vk::wsi::Display* VulkanPlatform::createWsiDisplay (vk::wsi::Type wsiType) const
        return new VulkanDisplay();
 }
 
+bool VulkanPlatform::hasDisplay (vk::wsi::Type wsiType)  const
+{
+       if (wsiType != vk::wsi::TYPE_MACOS)
+               return false;
+
+       return true;
+}
 vk::Library* VulkanPlatform::createLibrary (void) const
 {
        return new VulkanLibrary();
index f288425..5044d5b 100644 (file)
@@ -38,6 +38,7 @@ public:
                                                VulkanPlatform          ();
        vk::wsi::Display*       createWsiDisplay        (vk::wsi::Type wsiType) const;
        vk::Library*            createLibrary           (void) const;
+       bool                            hasDisplay              (vk::wsi::Type wsiType) const;
        void                            describePlatform        (std::ostream& dst) const;
        void                            getMemoryLimits         (vk::PlatformMemoryLimits& limits) const;
 };
index 78edfac..a72a36e 100644 (file)
@@ -294,5 +294,13 @@ vk::wsi::Display* VulkanPlatform::createWsiDisplay (vk::wsi::Type wsiType) const
        return new VulkanDisplay(m_instance);
 }
 
+bool VulkanPlatform::hasDisplay (vk::wsi::Type wsiType)  const
+{
+       if (wsiType != vk::wsi::TYPE_WIN32)
+               return false;
+
+       return true;
+}
+
 } // win32
 } // tcu
index 26d9fb4..4fb7f81 100644 (file)
@@ -40,6 +40,7 @@ public:
 
        vk::Library*            createLibrary           (void) const;
        vk::wsi::Display*       createWsiDisplay        (vk::wsi::Type wsiType) const;
+       bool                            hasDisplay      (vk::wsi::Type wsiType) const;
 
        void                            getMemoryLimits         (vk::PlatformMemoryLimits& limits) const;
        void                            describePlatform        (std::ostream& dst) const;