Clean up Win32 platform code
authorPyry Haulos <phaulos@google.com>
Mon, 21 Mar 2016 18:58:17 +0000 (11:58 -0700)
committerPyry Haulos <phaulos@google.com>
Mon, 21 Mar 2016 18:58:17 +0000 (11:58 -0700)
 * Move generic Win32 code to "win32" namespace

 * Move WGLContextFactory to wgl namespace (tcu::wgl::ContextFactory).

 * Move Vulkan platform implementation to tcuWin32VulkanPlatform.(c|h)pp.

Change-Id: Ie5d3945c54d6f696104270150c809638f16e18a1

12 files changed:
framework/platform/CMakeLists.txt
framework/platform/win32/tcuWGL.cpp
framework/platform/win32/tcuWGLContextFactory.cpp
framework/platform/win32/tcuWGLContextFactory.hpp
framework/platform/win32/tcuWin32EGLNativeDisplayFactory.cpp
framework/platform/win32/tcuWin32EGLNativeDisplayFactory.hpp
framework/platform/win32/tcuWin32Platform.cpp
framework/platform/win32/tcuWin32Platform.hpp
framework/platform/win32/tcuWin32VulkanPlatform.cpp [new file with mode: 0644]
framework/platform/win32/tcuWin32VulkanPlatform.hpp [new file with mode: 0644]
framework/platform/win32/tcuWin32Window.cpp
framework/platform/win32/tcuWin32Window.hpp

index 0bbc1f6..5716c23 100644 (file)
@@ -3,25 +3,22 @@
 # Target file may define TCUTIL_PLATFORM_SRCS
 if (NOT DEFINED TCUTIL_PLATFORM_SRCS)
        if (DE_OS_IS_WIN32)
-                       set(TCUTIL_PLATFORM_SRCS
-                               win32/tcuWin32Platform.hpp
-                               win32/tcuWin32Platform.cpp
-                               win32/tcuWGLContextFactory.hpp
-                               win32/tcuWGLContextFactory.cpp
-                               win32/tcuWGL.hpp
-                               win32/tcuWGL.cpp
-                               win32/tcuWin32API.h
-                               win32/tcuWin32Window.cpp
-                               win32/tcuWin32Window.hpp
+               set(TCUTIL_PLATFORM_SRCS
+                       win32/tcuWin32Platform.hpp
+                       win32/tcuWin32Platform.cpp
+                       win32/tcuWGLContextFactory.hpp
+                       win32/tcuWGLContextFactory.cpp
+                       win32/tcuWGL.hpp
+                       win32/tcuWGL.cpp
+                       win32/tcuWin32API.h
+                       win32/tcuWin32Window.cpp
+                       win32/tcuWin32Window.hpp
+                       win32/tcuWin32EGLNativeDisplayFactory.hpp
+                       win32/tcuWin32EGLNativeDisplayFactory.cpp
+                       win32/tcuWin32VulkanPlatform.hpp
+                       win32/tcuWin32VulkanPlatform.cpp
                        )
 
-               if (DEQP_SUPPORT_EGL)
-                       set(TCUTIL_PLATFORM_SRCS
-                               ${TCUTIL_PLATFORM_SRCS}
-                               win32/tcuWin32EGLNativeDisplayFactory.hpp
-                               win32/tcuWin32EGLNativeDisplayFactory.cpp
-                               )
-               endif()
        elseif ((DE_OS_IS_UNIX OR DE_OS_IS_OSX) AND DEQP_USE_X11)
                set(TCUTIL_PLATFORM_SRCS
                        X11/tcuX11.cpp
@@ -107,10 +104,8 @@ target_link_libraries(tcutil-platform tcutil ${TCUTIL_PLATFORM_LIBS})
 # Always link to glutil as some platforms such as Win32 always support GL
 target_link_libraries(tcutil-platform glutil)
 
-# Link to eglutil if platform supports EGL
-if (DEQP_SUPPORT_EGL)
-       target_link_libraries(tcutil-platform eglutil eglwrapper)
-endif ()
+# Always link to eglutil
+target_link_libraries(tcutil-platform eglutil)
 
 # X11 libraries
 if (DEQP_USE_X11)
index d77cf78..740b430 100644 (file)
@@ -186,7 +186,7 @@ Library::Library (HINSTANCE instance)
        : m_library("opengl32.dll")
 {
        // Temporary 1x1 window for creating context
-       Win32Window tmpWindow(instance, 1, 1);
+       win32::Window tmpWindow(instance, 1, 1);
 
        // Load WGL core.
        m_functions.createContext               = (wglCreateContextFunc)                m_library.getFunction("wglCreateContext");
index 253c632..145a55c 100644 (file)
@@ -34,6 +34,8 @@ using std::vector;
 
 namespace tcu
 {
+namespace wgl
+{
 namespace
 {
 
@@ -77,7 +79,7 @@ private:
 
        glu::ContextType                                m_contextType;
 
-       Win32Window                                             m_window;
+       win32::Window                                   m_window;
        wgl::Context*                                   m_context;
 
        tcu::RenderTarget                               m_renderTarget;
@@ -151,16 +153,17 @@ void WGLContext::postIterate (void)
 
 } // anonymous
 
-WGLContextFactory::WGLContextFactory (HINSTANCE instance)
+ContextFactory::ContextFactory (HINSTANCE instance)
        : glu::ContextFactory   ("wgl", "Windows WGL OpenGL context")
        , m_instance                    (instance)
        , m_wglCore                             (instance)
 {
 }
 
-glu::RenderContext* WGLContextFactory::createContext (const glu::RenderConfig& config, const tcu::CommandLine&) const
+glu::RenderContext* ContextFactory::createContext (const glu::RenderConfig& config, const tcu::CommandLine&) const
 {
        return new WGLContext(m_instance, m_wglCore, config);
 }
 
+} // wgl
 } // tcu
index 804b74b..b3301e1 100644 (file)
 
 namespace tcu
 {
+namespace wgl
+{
 
-class WGLContextFactory : public glu::ContextFactory
+class ContextFactory : public glu::ContextFactory
 {
 public:
-                                                               WGLContextFactory       (HINSTANCE instance);
-       virtual glu::RenderContext*     createContext           (const glu::RenderConfig& config, const tcu::CommandLine& cmdLine) const;
+                                                               ContextFactory  (HINSTANCE instance);
+       virtual glu::RenderContext*     createContext   (const glu::RenderConfig& config, const tcu::CommandLine& cmdLine) const;
 
 private:
-       HINSTANCE                                       m_instance;
-       wgl::Core                                       m_wglCore;
+       const HINSTANCE                         m_instance;
+       Core                                            m_wglCore;
 };
 
+} // wgl
 } // tcu
 
 #endif // _TCUWGLCONTEXTFACTORY_HPP
index 5cd61e8..9c55196 100644 (file)
@@ -40,6 +40,8 @@ DE_STATIC_ASSERT(sizeof(eglw::EGLNativeWindowType) == sizeof(HWND));
 
 namespace tcu
 {
+namespace win32
+{
 namespace
 {
 
@@ -127,7 +129,7 @@ public:
        virtual void                                    readScreenPixels                (tcu::TextureLevel* dst) const;
 
 private:
-       Win32Window                                             m_window;
+       win32::Window                                   m_window;
        eglu::WindowParams::Visibility  m_curVisibility;
        deUint64                                                m_setVisibleTime;               //!< Time window was set visible.
 };
@@ -378,7 +380,7 @@ void NativeWindow::readScreenPixels (tcu::TextureLevel* dst) const
 
 } // anonymous
 
-Win32EGLNativeDisplayFactory::Win32EGLNativeDisplayFactory (HINSTANCE instance)
+EGLNativeDisplayFactory::EGLNativeDisplayFactory (HINSTANCE instance)
        : eglu::NativeDisplayFactory    ("win32", "Native Win32 Display", DISPLAY_CAPABILITIES)
        , m_instance                                    (instance)
 {
@@ -386,14 +388,15 @@ Win32EGLNativeDisplayFactory::Win32EGLNativeDisplayFactory (HINSTANCE instance)
        m_nativePixmapRegistry.registerFactory(new NativePixmapFactory());
 }
 
-Win32EGLNativeDisplayFactory::~Win32EGLNativeDisplayFactory (void)
+EGLNativeDisplayFactory::~EGLNativeDisplayFactory (void)
 {
 }
 
-eglu::NativeDisplay* Win32EGLNativeDisplayFactory::createDisplay (const EGLAttrib* attribList) const
+eglu::NativeDisplay* EGLNativeDisplayFactory::createDisplay (const EGLAttrib* attribList) const
 {
        DE_UNREF(attribList);
        return new NativeDisplay();
 }
 
+} // win32
 } // tcu
index 78e1000..52b4550 100644 (file)
 
 namespace tcu
 {
+namespace win32
+{
 
-class Win32EGLNativeDisplayFactory : public eglu::NativeDisplayFactory
+class EGLNativeDisplayFactory : public eglu::NativeDisplayFactory
 {
 public:
-                                                                       Win32EGLNativeDisplayFactory    (HINSTANCE instance);
-       virtual                                                 ~Win32EGLNativeDisplayFactory   (void);
+                                                                       EGLNativeDisplayFactory         (HINSTANCE instance);
+       virtual                                                 ~EGLNativeDisplayFactory        (void);
 
-       virtual eglu::NativeDisplay*    createDisplay                                   (const eglw::EGLAttrib* attribList) const;
+       virtual eglu::NativeDisplay*    createDisplay                           (const eglw::EGLAttrib* attribList) const;
 
 private:
        const HINSTANCE                                 m_instance;
 };
 
+} // win32
 } // tcu
 
 #endif // _TCUWIN32EGLNATIVEDISPLAYFACTORY_HPP
index 60dd095..0517c60 100644 (file)
@@ -2,7 +2,7 @@
  * drawElements Quality Program Tester Core
  * ----------------------------------------
  *
- * Copyright 2014 The Android Open Source Project
+ * Copyright 2016 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * \brief Win32 platform port.
  *//*--------------------------------------------------------------------*/
 
-// \todo [2016-01-22 pyry] GetVersionEx() used by getOSInfo() is deprecated.
-//                                                Find a way to get version info without using deprecated APIs.
-#pragma warning(disable : 4996)
-
 #include "tcuWin32Platform.hpp"
-#include "tcuWin32Window.hpp"
 #include "tcuWGLContextFactory.hpp"
-#include "tcuFunctionLibrary.hpp"
-#include "tcuFormatUtil.hpp"
-
-#include "vkWsiPlatform.hpp"
-#include "tcuVector.hpp"
-
-#include "deUniquePtr.hpp"
-#include "deMemory.h"
-
-#if defined(DEQP_SUPPORT_EGL)
-#      include "tcuWin32EGLNativeDisplayFactory.hpp"
-#      include "egluGLContextFactory.hpp"
-#endif
+#include "tcuWin32EGLNativeDisplayFactory.hpp"
+#include "egluGLContextFactory.hpp"
 
 namespace tcu
 {
-
-// \todo [2016-02-23 pyry] Move vulkan platform implementation out
-
-using de::MovePtr;
-using de::UniquePtr;
-
-DE_STATIC_ASSERT(sizeof(vk::pt::Win32InstanceHandle)   == sizeof(HINSTANCE));
-DE_STATIC_ASSERT(sizeof(vk::pt::Win32WindowHandle)             == sizeof(HWND));
-
-class VulkanWindow : public vk::wsi::Win32WindowInterface
-{
-public:
-       VulkanWindow (MovePtr<Win32Window> window)
-               : vk::wsi::Win32WindowInterface (vk::pt::Win32WindowHandle(window->getHandle()))
-               , m_window                                              (window)
-       {
-       }
-
-       void resize (const UVec2& newSize)
-       {
-               m_window->setSize((int)newSize.x(), (int)newSize.y());
-       }
-
-private:
-       UniquePtr<Win32Window>  m_window;
-};
-
-class VulkanDisplay : public vk::wsi::Win32DisplayInterface
-{
-public:
-       VulkanDisplay (HINSTANCE instance)
-               : vk::wsi::Win32DisplayInterface        (vk::pt::Win32InstanceHandle(instance))
-       {
-       }
-
-       vk::wsi::Window* createWindow (const Maybe<UVec2>& initialSize) const
-       {
-               const HINSTANCE instance        = (HINSTANCE)m_native.internal;
-               const deUint32  width           = !initialSize ? 400 : initialSize->x();
-               const deUint32  height          = !initialSize ? 300 : initialSize->y();
-
-               return new VulkanWindow(MovePtr<Win32Window>(new Win32Window(instance, (int)width, (int)height)));
-       }
-};
-
-class VulkanLibrary : public vk::Library
-{
-public:
-       VulkanLibrary (void)
-               : m_library     ("vulkan-1.dll")
-               , m_driver      (m_library)
-       {
-       }
-
-       const vk::PlatformInterface& getPlatformInterface (void) const
-       {
-               return m_driver;
-       }
-
-private:
-       const tcu::DynamicFunctionLibrary       m_library;
-       const vk::PlatformDriver                        m_driver;
-};
-
-Win32VulkanPlatform::Win32VulkanPlatform (HINSTANCE instance)
-       : m_instance(instance)
-{
-}
-
-Win32VulkanPlatform::~Win32VulkanPlatform (void)
-{
-}
-
-vk::Library* Win32VulkanPlatform::createLibrary (void) const
-{
-       return new VulkanLibrary();
-}
-
-const char* getProductTypeName (WORD productType)
-{
-       switch (productType)
-       {
-               case VER_NT_DOMAIN_CONTROLLER:  return "Windows Server (domain controller)";
-               case VER_NT_SERVER:                             return "Windows Server";
-               case VER_NT_WORKSTATION:                return "Windows NT";
-               default:                                                return DE_NULL;
-       }
-}
-
-static void getOSInfo (std::ostream& dst)
-{
-       OSVERSIONINFOEX osInfo;
-
-       deMemset(&osInfo, 0, sizeof(osInfo));
-       osInfo.dwOSVersionInfoSize = (DWORD)sizeof(osInfo);
-
-       GetVersionEx((OSVERSIONINFO*)&osInfo);
-
-       {
-               const char* const       productName     = getProductTypeName(osInfo.wProductType);
-
-               if (productName)
-                       dst << productName;
-               else
-                       dst << "unknown product " << tcu::toHex(osInfo.wProductType);
-       }
-
-       dst << " " << osInfo.dwMajorVersion << "." << osInfo.dwMinorVersion
-               << ", service pack " << osInfo.wServicePackMajor << "." << osInfo.wServicePackMinor
-               << ", build " << osInfo.dwBuildNumber;
-}
-
-const char* getProcessorArchitectureName (WORD arch)
-{
-       switch (arch)
-       {
-               case PROCESSOR_ARCHITECTURE_AMD64:              return "AMD64";
-               case PROCESSOR_ARCHITECTURE_ARM:                return "ARM";
-               case PROCESSOR_ARCHITECTURE_IA64:               return "IA64";
-               case PROCESSOR_ARCHITECTURE_INTEL:              return "INTEL";
-               case PROCESSOR_ARCHITECTURE_UNKNOWN:    return "UNKNOWN";
-               default:                                                                return DE_NULL;
-       }
-}
-
-static void getProcessorInfo (std::ostream& dst)
+namespace win32
 {
-       SYSTEM_INFO     sysInfo;
-
-       deMemset(&sysInfo, 0, sizeof(sysInfo));
-       GetSystemInfo(&sysInfo);
-
-       dst << "arch ";
-       {
-               const char* const       archName        = getProcessorArchitectureName(sysInfo.wProcessorArchitecture);
-
-               if (archName)
-                       dst << archName;
-               else
-                       dst << tcu::toHex(sysInfo.wProcessorArchitecture);
-       }
-
-       dst << ", level " << tcu::toHex(sysInfo.wProcessorLevel) << ", revision " << tcu::toHex(sysInfo.wProcessorRevision);
-}
-
-void Win32VulkanPlatform::describePlatform (std::ostream& dst) const
-{
-       dst << "OS: ";
-       getOSInfo(dst);
-       dst << "\n";
-
-       dst << "CPU: ";
-       getProcessorInfo(dst);
-       dst << "\n";
-}
-
-vk::wsi::Display* Win32VulkanPlatform::createWsiDisplay (vk::wsi::Type wsiType) const
-{
-       if (wsiType != vk::wsi::TYPE_WIN32)
-               TCU_THROW(NotSupportedError, "WSI type not supported");
-
-       return new VulkanDisplay(m_instance);
-}
 
-Win32Platform::Win32Platform (void)
+Platform::Platform (void)
        : m_instance            (GetModuleHandle(NULL))
        , m_vulkanPlatform      (m_instance)
 {
@@ -216,11 +39,11 @@ Win32Platform::Win32Platform (void)
        SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS);
 
        {
-               WGLContextFactory* factory = DE_NULL;
+               wgl::ContextFactory* factory = DE_NULL;
 
                try
                {
-                       factory = new WGLContextFactory(m_instance);
+                       factory = new wgl::ContextFactory(m_instance);
                }
                catch (const std::exception& e)
                {
@@ -241,17 +64,15 @@ Win32Platform::Win32Platform (void)
                }
        }
 
-#if defined(DEQP_SUPPORT_EGL)
-       m_nativeDisplayFactoryRegistry.registerFactory(new Win32EGLNativeDisplayFactory(m_instance));
+       m_nativeDisplayFactoryRegistry.registerFactory(new win32::EGLNativeDisplayFactory(m_instance));
        m_contextFactoryRegistry.registerFactory(new eglu::GLContextFactory(m_nativeDisplayFactoryRegistry));
-#endif
 }
 
-Win32Platform::~Win32Platform (void)
+Platform::~Platform (void)
 {
 }
 
-bool Win32Platform::processEvents (void)
+bool Platform::processEvents (void)
 {
        MSG msg;
        while (PeekMessage(&msg, (HWND)-1, 0, 0, PM_REMOVE))
@@ -263,10 +84,11 @@ bool Win32Platform::processEvents (void)
        return true;
 }
 
+} // win32
 } // tcu
 
 // Create platform
 tcu::Platform* createPlatform (void)
 {
-       return new tcu::Win32Platform();
+       return new tcu::win32::Platform();
 }
index 1abcc7c..e45b6cc 100644 (file)
@@ -4,7 +4,7 @@
  * drawElements Quality Program Tester Core
  * ----------------------------------------
  *
- * Copyright 2014 The Android Open Source Project
+ * Copyright 2016 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include "tcuDefs.hpp"
 #include "tcuPlatform.hpp"
 #include "gluPlatform.hpp"
-#include "vkPlatform.hpp"
+#include "egluPlatform.hpp"
+#include "tcuWin32VulkanPlatform.hpp"
 #include "tcuWin32API.h"
 
-#if defined(DEQP_SUPPORT_EGL)
-#      include "egluPlatform.hpp"
-#endif
-
 namespace tcu
 {
-
-class Win32VulkanPlatform : public vk::Platform
+namespace win32
 {
-public:
-                                               Win32VulkanPlatform             (HINSTANCE instance);
-                                               ~Win32VulkanPlatform    (void);
-
-       vk::Library*            createLibrary                   (void) const;
-       void                            describePlatform                (std::ostream& dst) const;
-       vk::wsi::Display*       createWsiDisplay                (vk::wsi::Type wsiType) const;
-
-private:
-       const HINSTANCE         m_instance;
-};
 
-class Win32Platform : public tcu::Platform, private glu::Platform
-#if defined(DEQP_SUPPORT_EGL)
-       , private eglu::Platform
-#endif
+class Platform : public tcu::Platform, private glu::Platform, private eglu::Platform
 {
 public:
-                                                               Win32Platform           (void);
-                                                               ~Win32Platform          (void);
+                                                               Platform                        (void);
+                                                               ~Platform                       (void);
 
        bool                                            processEvents           (void);
 
        const glu::Platform&            getGLPlatform           (void) const { return static_cast<const glu::Platform&>(*this); }
 
-#if defined(DEQP_SUPPORT_EGL)
        const eglu::Platform&           getEGLPlatform          (void) const { return static_cast<const eglu::Platform&>(*this);}
-#endif
 
        const vk::Platform&                     getVulkanPlatform       (void) const { return m_vulkanPlatform;                                                 }
 
 private:
        const HINSTANCE                         m_instance;
-       const Win32VulkanPlatform       m_vulkanPlatform;
+       const VulkanPlatform            m_vulkanPlatform;
 };
 
+} // win32
 } // tcu
 
 #endif // _TCUWIN32PLATFORM_HPP
diff --git a/framework/platform/win32/tcuWin32VulkanPlatform.cpp b/framework/platform/win32/tcuWin32VulkanPlatform.cpp
new file mode 100644 (file)
index 0000000..9d33be2
--- /dev/null
@@ -0,0 +1,207 @@
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program Tester Core
+ * ----------------------------------------
+ *
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Win32 Vulkan platform
+ *//*--------------------------------------------------------------------*/
+
+// \todo [2016-01-22 pyry] GetVersionEx() used by getOSInfo() is deprecated.
+//                                                Find a way to get version info without using deprecated APIs.
+#pragma warning(disable : 4996)
+
+#include "tcuWin32VulkanPlatform.hpp"
+#include "tcuWin32Window.hpp"
+
+#include "tcuFormatUtil.hpp"
+#include "tcuFunctionLibrary.hpp"
+#include "tcuVector.hpp"
+
+#include "vkWsiPlatform.hpp"
+
+#include "deUniquePtr.hpp"
+#include "deMemory.h"
+
+namespace tcu
+{
+namespace win32
+{
+
+using de::MovePtr;
+using de::UniquePtr;
+
+DE_STATIC_ASSERT(sizeof(vk::pt::Win32InstanceHandle)   == sizeof(HINSTANCE));
+DE_STATIC_ASSERT(sizeof(vk::pt::Win32WindowHandle)             == sizeof(HWND));
+
+class VulkanWindow : public vk::wsi::Win32WindowInterface
+{
+public:
+       VulkanWindow (MovePtr<win32::Window> window)
+               : vk::wsi::Win32WindowInterface (vk::pt::Win32WindowHandle(window->getHandle()))
+               , m_window                                              (window)
+       {
+       }
+
+       void resize (const UVec2& newSize)
+       {
+               m_window->setSize((int)newSize.x(), (int)newSize.y());
+       }
+
+private:
+       UniquePtr<win32::Window>        m_window;
+};
+
+class VulkanDisplay : public vk::wsi::Win32DisplayInterface
+{
+public:
+       VulkanDisplay (HINSTANCE instance)
+               : vk::wsi::Win32DisplayInterface        (vk::pt::Win32InstanceHandle(instance))
+       {
+       }
+
+       vk::wsi::Window* createWindow (const Maybe<UVec2>& initialSize) const
+       {
+               const HINSTANCE instance        = (HINSTANCE)m_native.internal;
+               const deUint32  width           = !initialSize ? 400 : initialSize->x();
+               const deUint32  height          = !initialSize ? 300 : initialSize->y();
+
+               return new VulkanWindow(MovePtr<win32::Window>(new win32::Window(instance, (int)width, (int)height)));
+       }
+};
+
+class VulkanLibrary : public vk::Library
+{
+public:
+       VulkanLibrary (void)
+               : m_library     ("vulkan-1.dll")
+               , m_driver      (m_library)
+       {
+       }
+
+       const vk::PlatformInterface& getPlatformInterface (void) const
+       {
+               return m_driver;
+       }
+
+private:
+       const tcu::DynamicFunctionLibrary       m_library;
+       const vk::PlatformDriver                        m_driver;
+};
+
+VulkanPlatform::VulkanPlatform (HINSTANCE instance)
+       : m_instance(instance)
+{
+}
+
+VulkanPlatform::~VulkanPlatform (void)
+{
+}
+
+vk::Library* VulkanPlatform::createLibrary (void) const
+{
+       return new VulkanLibrary();
+}
+
+const char* getProductTypeName (WORD productType)
+{
+       switch (productType)
+       {
+               case VER_NT_DOMAIN_CONTROLLER:  return "Windows Server (domain controller)";
+               case VER_NT_SERVER:                             return "Windows Server";
+               case VER_NT_WORKSTATION:                return "Windows NT";
+               default:                                                return DE_NULL;
+       }
+}
+
+static void getOSInfo (std::ostream& dst)
+{
+       OSVERSIONINFOEX osInfo;
+
+       deMemset(&osInfo, 0, sizeof(osInfo));
+       osInfo.dwOSVersionInfoSize = (DWORD)sizeof(osInfo);
+
+       GetVersionEx((OSVERSIONINFO*)&osInfo);
+
+       {
+               const char* const       productName     = getProductTypeName(osInfo.wProductType);
+
+               if (productName)
+                       dst << productName;
+               else
+                       dst << "unknown product " << tcu::toHex(osInfo.wProductType);
+       }
+
+       dst << " " << osInfo.dwMajorVersion << "." << osInfo.dwMinorVersion
+               << ", service pack " << osInfo.wServicePackMajor << "." << osInfo.wServicePackMinor
+               << ", build " << osInfo.dwBuildNumber;
+}
+
+const char* getProcessorArchitectureName (WORD arch)
+{
+       switch (arch)
+       {
+               case PROCESSOR_ARCHITECTURE_AMD64:              return "AMD64";
+               case PROCESSOR_ARCHITECTURE_ARM:                return "ARM";
+               case PROCESSOR_ARCHITECTURE_IA64:               return "IA64";
+               case PROCESSOR_ARCHITECTURE_INTEL:              return "INTEL";
+               case PROCESSOR_ARCHITECTURE_UNKNOWN:    return "UNKNOWN";
+               default:                                                                return DE_NULL;
+       }
+}
+
+static void getProcessorInfo (std::ostream& dst)
+{
+       SYSTEM_INFO     sysInfo;
+
+       deMemset(&sysInfo, 0, sizeof(sysInfo));
+       GetSystemInfo(&sysInfo);
+
+       dst << "arch ";
+       {
+               const char* const       archName        = getProcessorArchitectureName(sysInfo.wProcessorArchitecture);
+
+               if (archName)
+                       dst << archName;
+               else
+                       dst << tcu::toHex(sysInfo.wProcessorArchitecture);
+       }
+
+       dst << ", level " << tcu::toHex(sysInfo.wProcessorLevel) << ", revision " << tcu::toHex(sysInfo.wProcessorRevision);
+}
+
+void VulkanPlatform::describePlatform (std::ostream& dst) const
+{
+       dst << "OS: ";
+       getOSInfo(dst);
+       dst << "\n";
+
+       dst << "CPU: ";
+       getProcessorInfo(dst);
+       dst << "\n";
+}
+
+vk::wsi::Display* VulkanPlatform::createWsiDisplay (vk::wsi::Type wsiType) const
+{
+       if (wsiType != vk::wsi::TYPE_WIN32)
+               TCU_THROW(NotSupportedError, "WSI type not supported");
+
+       return new VulkanDisplay(m_instance);
+}
+
+} // win32
+} // tcu
diff --git a/framework/platform/win32/tcuWin32VulkanPlatform.hpp b/framework/platform/win32/tcuWin32VulkanPlatform.hpp
new file mode 100644 (file)
index 0000000..d015abc
--- /dev/null
@@ -0,0 +1,52 @@
+#ifndef _TCUWIN32VULKANPLATFORM_HPP
+#define _TCUWIN32VULKANPLATFORM_HPP
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program Tester Core
+ * ----------------------------------------
+ *
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Win32 Vulkan platform
+ *//*--------------------------------------------------------------------*/
+
+#include "tcuDefs.hpp"
+#include "vkPlatform.hpp"
+#include "tcuWin32API.h"
+
+namespace tcu
+{
+namespace win32
+{
+
+class VulkanPlatform : public vk::Platform
+{
+public:
+                                               VulkanPlatform          (HINSTANCE instance);
+                                               ~VulkanPlatform         (void);
+
+       vk::Library*            createLibrary           (void) const;
+       void                            describePlatform        (std::ostream& dst) const;
+       vk::wsi::Display*       createWsiDisplay        (vk::wsi::Type wsiType) const;
+
+private:
+       const HINSTANCE         m_instance;
+};
+
+} // win32
+} // tcu
+
+#endif // _TCUWIN32VULKANPLATFORM_HPP
index 4e674e8..2ab4336 100644 (file)
@@ -2,7 +2,7 @@
  * drawElements Quality Program Tester Core
  * ----------------------------------------
  *
- * Copyright 2014 The Android Open Source Project
+ * Copyright 2016 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 namespace tcu
 {
+namespace win32
+{
 
-static LRESULT CALLBACK win32WindowProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+static LRESULT CALLBACK windowProcCallback (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
-       Win32Window* window = reinterpret_cast<Win32Window*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
+       Window* window = reinterpret_cast<Window*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
        if (window)
                return window->windowProc(uMsg, wParam, lParam);
        else
                return DefWindowProc(hWnd, uMsg, wParam, lParam);
 }
 
-Win32Window::Win32Window (HINSTANCE instance, int width, int height)
-       : m_window              (DE_NULL)
+Window::Window (HINSTANCE instance, int width, int height)
+       : m_window      (DE_NULL)
 {
        try
        {
@@ -47,7 +49,7 @@ Win32Window::Win32Window (HINSTANCE instance, int width, int height)
                        WNDCLASS wndClass;
                        memset(&wndClass, 0, sizeof(wndClass));
                        wndClass.style                  = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
-                       wndClass.lpfnWndProc    = win32WindowProc;
+                       wndClass.lpfnWndProc    = windowProcCallback;
                        wndClass.cbClsExtra             = 0;
                        wndClass.cbWndExtra             = 0;
                        wndClass.hInstance              = instance;
@@ -83,7 +85,7 @@ Win32Window::Win32Window (HINSTANCE instance, int width, int height)
        }
 }
 
-Win32Window::~Win32Window (void)
+Window::~Window (void)
 {
        if (m_window)
        {
@@ -94,12 +96,12 @@ Win32Window::~Win32Window (void)
        DestroyWindow(m_window);
 }
 
-void Win32Window::setVisible (bool visible)
+void Window::setVisible (bool visible)
 {
        ShowWindow(m_window, visible ? SW_SHOW : SW_HIDE);
 }
 
-void Win32Window::setSize (int width, int height)
+void Window::setSize (int width, int height)
 {
        RECT rc;
 
@@ -117,7 +119,7 @@ void Win32Window::setSize (int width, int height)
                TCU_THROW(TestError, "SetWindowPos() failed");
 }
 
-IVec2 Win32Window::getSize (void) const
+IVec2 Window::getSize (void) const
 {
        RECT rc;
        if (!GetClientRect(m_window, &rc))
@@ -127,14 +129,14 @@ IVec2 Win32Window::getSize (void) const
                                 rc.bottom - rc.top);
 }
 
-void Win32Window::processEvents (void)
+void Window::processEvents (void)
 {
        MSG msg;
        while (PeekMessage(&msg, m_window, 0, 0, PM_REMOVE))
                DispatchMessage(&msg);
 }
 
-LRESULT Win32Window::windowProc (UINT uMsg, WPARAM wParam, LPARAM lParam)
+LRESULT Window::windowProc (UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
        switch (uMsg)
        {
@@ -157,4 +159,5 @@ LRESULT Win32Window::windowProc (UINT uMsg, WPARAM wParam, LPARAM lParam)
        }
 }
 
+} // win32
 } // tcu
index 65aec4e..93a90fe 100644 (file)
@@ -4,7 +4,7 @@
  * drawElements Quality Program Tester Core
  * ----------------------------------------
  *
- * Copyright 2014 The Android Open Source Project
+ * Copyright 2016 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 namespace tcu
 {
+namespace win32
+{
 
-class Win32Window
+class Window
 {
 public:
-                                                       Win32Window                             (HINSTANCE instance, int width, int height);
-                                                       ~Win32Window                    (void);
+                               Window                          (HINSTANCE instance, int width, int height);
+                               ~Window                         (void);
 
-       void                                    setVisible                              (bool visible);
-       void                                    setSize                                 (int width, int height);
+       void            setVisible                      (bool visible);
+       void            setSize                         (int width, int height);
 
-       LRESULT                                 windowProc                              (UINT uMsg, WPARAM wParam, LPARAM lParam);
-       void                                    processEvents                   (void);
+       LRESULT         windowProc                      (UINT uMsg, WPARAM wParam, LPARAM lParam);
+       void            processEvents           (void);
 
-       IVec2                                   getSize                                 (void) const;
-       HWND                                    getHandle                               (void) const { return m_window;                 }
-       HDC                                             getDeviceContext                (void) const { return GetDC(m_window);  }
+       IVec2           getSize                         (void) const;
+       HWND            getHandle                       (void) const { return m_window;                 }
+       HDC                     getDeviceContext        (void) const { return GetDC(m_window);  }
 
 private:
-       HWND                                    m_window;
+                               Window                          (const Window&);
+       Window          operator=                       (const Window&);
+
+       HWND            m_window;
 };
 
+} // win32
 } // tcu
 
 #endif // _TCUWIN32WINDOW_HPP