X11/tcuX11.hpp
X11/tcuX11Platform.hpp
X11/tcuX11Platform.cpp
+ X11/tcuX11VulkanPlatform.hpp
+ X11/tcuX11VulkanPlatform.cpp
)
+ if (DEQP_USE_XCB)
+ set(TCUTIL_PLATFORM_SRCS
+ ${TCUTIL_PLATFORM_SRCS}
+ X11/tcuX11Xcb.hpp
+ X11/tcuX11Xcb.cpp
+ )
+ endif()
if (DEQP_SUPPORT_EGL)
set(TCUTIL_PLATFORM_SRCS
${TCUTIL_PLATFORM_SRCS}
if (DEQP_USE_X11)
find_package(X11 REQUIRED)
target_link_libraries(tcutil-platform ${X11_LIBRARIES})
+ if (DEQP_USE_XCB)
+ find_package(XCB REQUIRED)
+ target_link_libraries(tcutil-platform ${XCB_LIBRARIES})
+ add_definitions(-DDEQP_SUPPORT_XCB=1)
+ endif ()
if (DEQP_SUPPORT_GLX)
# GLX functions don't currently have wrappers, so link directly to libGL.
target_link_libraries(tcutil-platform GL)
namespace x11
{
-enum
-{
- DEFAULT_WINDOW_WIDTH = 400,
- DEFAULT_WINDOW_HEIGHT = 300
-};
-
EventState::EventState (void)
: m_quit(false)
{
return m_quit;
}
-Display::Display (EventState& eventState, const char* name)
- : m_eventState (eventState)
- , m_display (DE_NULL)
- , m_deleteAtom (DE_NULL)
+DisplayBase::DisplayBase (EventState& platform)
+ : m_eventState (platform)
+{
+}
+
+DisplayBase::~DisplayBase (void)
+{
+}
+
+WindowBase::WindowBase ()
+ : m_visible (false)
+{
+}
+
+WindowBase::~WindowBase (void)
+{
+}
+
+XlibDisplay::XlibDisplay (EventState& eventState, const char* name)
+ : DisplayBase (eventState)
{
m_display = XOpenDisplay((char*)name); // Won't modify argument string.
if (!m_display)
m_deleteAtom = XInternAtom(m_display, "WM_DELETE_WINDOW", False);
}
-Display::~Display (void)
+XlibDisplay::~XlibDisplay (void)
{
XCloseDisplay(m_display);
}
-void Display::processEvents (void)
+void XlibDisplay::processEvents (void)
{
XEvent event;
}
}
-bool Display::getVisualInfo (VisualID visualID, XVisualInfo& dst)
+bool XlibDisplay::getVisualInfo (VisualID visualID, XVisualInfo& dst)
{
XVisualInfo query;
query.visualid = visualID;
return succ;
}
-::Visual* Display::getVisual (VisualID visualID)
+::Visual* XlibDisplay::getVisual (VisualID visualID)
{
XVisualInfo info;
return DE_NULL;
}
-Window::Window (Display& display, int width, int height, ::Visual* visual)
- : m_display (display)
+XlibWindow::XlibWindow (XlibDisplay& display, int width, int height, ::Visual* visual)
+ : WindowBase ()
+ , m_display (display)
, m_colormap (None)
, m_window (None)
- , m_visible (false)
{
XSetWindowAttributes swa;
::Display* const dpy = m_display.getXDisplay();
Atom deleteAtom = m_display.getDeleteAtom();
XSetWMProtocols(dpy, m_window, &deleteAtom, 1);
+ XSync(dpy,false);
}
-void Window::setVisibility (bool visible)
+void XlibWindow::setVisibility (bool visible)
{
::Display* dpy = m_display.getXDisplay();
int eventType = None;
m_visible = visible;
}
-void Window::getDimensions (int* width, int* height) const
+void XlibWindow::getDimensions (int* width, int* height) const
{
int x, y;
::Window root;
*height = static_cast<int>(height_);
}
-void Window::setDimensions (int width, int height)
+void XlibWindow::setDimensions (int width, int height)
{
- const unsigned int mask = CWWidth | CWHeight;
+ const unsigned int mask = CWWidth | CWHeight;
XWindowChanges changes;
- changes.width = width;
- changes.height = height;
-
- XConfigureWindow(m_display.getXDisplay(), m_window, mask, &changes);
+ ::Display* dpy = m_display.getXDisplay();
+ XEvent myevent;
+ changes.width = width;
+ changes.height = height;
+ XConfigureWindow(dpy, m_window, mask, &changes);
+ XFlush(dpy);
+
+ for(;;)
+ {
+ XNextEvent(dpy, &myevent);
+ if (myevent.type == ConfigureNotify)
+ break;
+ }
}
-void Window::processEvents (void)
+void XlibWindow::processEvents (void)
{
// A bit of a hack, since we don't really handle all the events.
m_display.processEvents();
}
-Window::~Window (void)
+XlibWindow::~XlibWindow (void)
{
XDestroyWindow(m_display.getXDisplay(), m_window);
if (m_colormap != None)
{
namespace x11
{
+enum
+{
+ DEFAULT_WINDOW_WIDTH = 400,
+ DEFAULT_WINDOW_HEIGHT = 300
+};
class EventState
{
public:
- EventState (void);
- virtual ~EventState (void);
+ EventState (void);
+ virtual ~EventState (void);
+ void setQuitFlag (bool quit);
+ bool getQuitFlag (void);
+
+protected:
+ de::Mutex m_mutex;
+ bool m_quit;
+
+private:
+ EventState (const EventState&);
+ EventState& operator= (const EventState&);
+};
- void setQuitFlag (bool quit);
- bool getQuitFlag (void);
+class DisplayBase
+{
+public:
+ DisplayBase (EventState& platform);
+ virtual ~DisplayBase (void);
+ virtual void processEvents (void) = 0;
protected:
- de::Mutex m_mutex;
- bool m_quit;
+ EventState& m_eventState;
private:
- EventState (const EventState&);
- EventState& operator= (const EventState&);
+ DisplayBase (const DisplayBase&);
+ DisplayBase& operator= (const DisplayBase&);
};
-class Display
+class WindowBase
{
public:
- Display (EventState& platform, const char* name);
- virtual ~Display (void);
+ WindowBase (void);
+ virtual ~WindowBase (void);
- ::Display* getXDisplay (void) { return m_display; }
- Atom getDeleteAtom (void) { return m_deleteAtom; }
+ virtual void setVisibility (bool visible) = 0;
- ::Visual* getVisual (VisualID visualID);
- bool getVisualInfo (VisualID visualID, XVisualInfo& dst);
- void processEvents (void);
+ virtual void processEvents (void) = 0;
+ virtual DisplayBase& getDisplay (void) = 0;
+
+ virtual void getDimensions (int* width, int* height) const = 0;
+ virtual void setDimensions (int width, int height) = 0;
protected:
- EventState& m_eventState;
- ::Display* m_display;
- Atom m_deleteAtom;
+ bool m_visible;
private:
- Display (const Display&);
- Display& operator= (const Display&);
+ WindowBase (const WindowBase&);
+ WindowBase& operator= (const WindowBase&);
};
-class Window
+class XlibDisplay : public DisplayBase
{
public:
- Window (Display& display, int width, int height,
- ::Visual* visual);
- ~Window (void);
-
- void setVisibility (bool visible);
+ XlibDisplay (EventState& platform, const char* name);
+ virtual ~XlibDisplay (void);
- void processEvents (void);
- Display& getDisplay (void) { return m_display; }
- ::Window& getXID (void) { return m_window; }
+ ::Display* getXDisplay (void) { return m_display; }
+ Atom getDeleteAtom (void) { return m_deleteAtom; }
- void getDimensions (int* width, int* height) const;
- void setDimensions (int width, int height);
+ ::Visual* getVisual (VisualID visualID);
+ bool getVisualInfo (VisualID visualID, XVisualInfo& dst);
+ void processEvents (void);
protected:
+ ::Display* m_display;
+ Atom m_deleteAtom;
- Display& m_display;
- ::Colormap m_colormap;
- ::Window m_window;
- bool m_visible;
+private:
+ XlibDisplay (const XlibDisplay&);
+ XlibDisplay& operator= (const XlibDisplay&);
+};
+
+class XlibWindow : public WindowBase
+{
+public:
+ XlibWindow (XlibDisplay& display, int width, int height,
+ ::Visual* visual);
+ ~XlibWindow (void);
+
+ void setVisibility (bool visible);
+
+ void processEvents (void);
+ DisplayBase& getDisplay (void) { return (DisplayBase&)m_display; }
+ ::Window& getXID (void) { return m_window; }
+
+ void getDimensions (int* width, int* height) const;
+ void setDimensions (int width, int height);
+
+protected:
+ XlibDisplay& m_display;
+ ::Colormap m_colormap;
+ ::Window m_window;
private:
- Window (const Window&);
- Window& operator= (const Window&);
+ XlibWindow (const XlibWindow&);
+ XlibWindow& operator= (const XlibWindow&);
};
} // x11
static const Capability CAPABILITIES = Capability(CAPABILITY_GET_DISPLAY_LEGACY |
CAPABILITY_GET_DISPLAY_PLATFORM);
- Display (MovePtr<x11::Display> x11Display)
+ Display (MovePtr<XlibDisplay> x11Display)
: NativeDisplay (CAPABILITIES,
EGL_PLATFORM_X11_EXT,
"EGL_EXT_platform_x11")
void* getPlatformNative (void) { return m_display->getXDisplay(); }
eglw::EGLNativeDisplayType getLegacyNative (void) { return reinterpret_cast<eglw::EGLNativeDisplayType>(m_display->getXDisplay()); }
- x11::Display& getX11Display (void) { return *m_display; }
+ XlibDisplay& getX11Display (void) { return *m_display; }
const eglw::Library& getLibrary (void) const { return m_library; }
const eglw::EGLAttrib* getPlatformAttributes (void) const { return DE_NULL; }
private:
- UniquePtr<x11::Display> m_display;
+ UniquePtr<XlibDisplay> m_display;
Library m_library;
};
IVec2 getScreenSize (void) const { return getSurfaceSize(); }
private:
- x11::Window m_window;
+ XlibWindow m_window;
};
Window::Window (Display& display, const WindowParams& params, Visual* visual)
DE_UNREF(attribList);
//! \todo [2014-03-18 lauri] Somehow make the display configurable from command line
- MovePtr<x11::Display> x11Display (new x11::Display(m_eventState, DE_NULL));
+ MovePtr<XlibDisplay> x11Display (new XlibDisplay(m_eventState, DE_NULL));
return new Display(x11Display);
}
*//*--------------------------------------------------------------------*/
#include "tcuX11Platform.hpp"
+#include "vkWsiPlatform.hpp"
#include "deUniquePtr.hpp"
#include "gluPlatform.hpp"
#include "tcuX11.hpp"
#include "tcuFunctionLibrary.hpp"
#include "deMemory.h"
-
+#include "tcuX11VulkanPlatform.hpp"
#if defined (DEQP_SUPPORT_GLX)
# include "tcuX11GlxPlatform.hpp"
#endif
#include <sys/utsname.h>
+using de::MovePtr;
+using de::UniquePtr;
+
namespace tcu
{
namespace x11
}
};
-class VulkanLibrary : public vk::Library
-{
-public:
- VulkanLibrary (void)
- : m_library ("libvulkan.so.1")
- , m_driver (m_library)
- {
- }
-
- const vk::PlatformInterface& getPlatformInterface (void) const
- {
- return m_driver;
- }
-
-private:
- const tcu::DynamicFunctionLibrary m_library;
- const vk::PlatformDriver m_driver;
-};
-
-class X11VulkanPlatform : public vk::Platform
-{
-public:
- vk::Library* createLibrary (void) const
- {
- return new VulkanLibrary();
- }
-
- void describePlatform (std::ostream& dst) const
- {
- utsname sysInfo;
-
- deMemset(&sysInfo, 0, sizeof(sysInfo));
-
- if (uname(&sysInfo) != 0)
- throw std::runtime_error("uname() failed");
-
- dst << "OS: " << sysInfo.sysname << " " << sysInfo.release << " " << sysInfo.version << "\n";
- dst << "CPU: " << sysInfo.machine << "\n";
- }
-
- void getMemoryLimits (vk::PlatformMemoryLimits& limits) const
- {
- limits.totalSystemMemory = 256*1024*1024;
- limits.totalDeviceLocalMemory = 128*1024*1024;
- limits.deviceMemoryAllocationGranularity = 64*1024;
- limits.devicePageSize = 4096;
- limits.devicePageTableEntrySize = 8;
- limits.devicePageTableHierarchyLevels = 3;
- }
-};
-
class X11Platform : public tcu::Platform
{
public:
private:
EventState m_eventState;
+ x11::VulkanPlatform m_vkPlatform;
#if defined (DEQP_SUPPORT_EGL)
x11::egl::Platform m_eglPlatform;
#endif // DEQP_SPPORT_EGL
X11GLPlatform m_glPlatform;
- X11VulkanPlatform m_vkPlatform;
};
+
X11Platform::X11Platform (void)
+ : m_vkPlatform (m_eventState)
#if defined (DEQP_SUPPORT_EGL)
- : m_eglPlatform (m_eventState)
+ , m_eglPlatform (m_eventState)
#endif // DEQP_SUPPORT_EGL
{
#if defined (DEQP_SUPPORT_GLX)
--- /dev/null
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program Tester Core
+ * ----------------------------------------
+ *
+ * Copyright (c) 2016 The Khronos Group Inc.
+ *
+ * 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 X11Vulkan Platform.
+ *//*--------------------------------------------------------------------*/
+
+#include "tcuX11VulkanPlatform.hpp"
+#include "tcuX11Platform.hpp"
+#include "vkWsiPlatform.hpp"
+#include "gluPlatform.hpp"
+#include "tcuX11.hpp"
+#include "tcuFunctionLibrary.hpp"
+#include "deUniquePtr.hpp"
+#include "deMemory.h"
+
+#include <sys/utsname.h>
+
+using de::MovePtr;
+using de::UniquePtr;
+
+#if defined (DEQP_SUPPORT_XCB)
+#include "tcuX11Xcb.hpp"
+#endif // DEQP_SUPPORT_XCB
+
+namespace tcu
+{
+namespace x11
+{
+
+class VulkanWindowXlib : public vk::wsi::XlibWindowInterface
+{
+public:
+ VulkanWindowXlib (MovePtr<XlibWindow> window)
+ : vk::wsi::XlibWindowInterface (vk::pt::XlibWindow(window->getXID()))
+ , m_window (window)
+ {
+ }
+
+ void resize (const UVec2& newSize)
+ {
+ m_window->setDimensions((int)newSize.x(), (int)newSize.y());
+ }
+
+private:
+ UniquePtr<XlibWindow> m_window;
+};
+
+class VulkanDisplayXlib : public vk::wsi::XlibDisplayInterface
+{
+public:
+ VulkanDisplayXlib (MovePtr<DisplayBase> display)
+ : vk::wsi::XlibDisplayInterface (vk::pt::XlibDisplayPtr(((XlibDisplay*)display.get())->getXDisplay()))
+ , m_display (display)
+ {
+ }
+
+ vk::wsi::Window* createWindow (const Maybe<UVec2>& initialSize) const
+ {
+ XlibDisplay* instance = (XlibDisplay*)(m_display.get());
+ const deUint32 height = !initialSize ? (deUint32)DEFAULT_WINDOW_HEIGHT : initialSize->y();
+ const deUint32 width = !initialSize ? (deUint32)DEFAULT_WINDOW_WIDTH : initialSize->x();
+ return new VulkanWindowXlib(MovePtr<XlibWindow>(new XlibWindow(*instance, (int)width, (int)height, instance->getVisual(0))));
+ }
+
+private:
+ MovePtr<DisplayBase> m_display;
+};
+
+#if defined (DEQP_SUPPORT_XCB)
+
+class VulkanWindowXcb : public vk::wsi::XcbWindowInterface
+{
+public:
+ VulkanWindowXcb (MovePtr<XcbWindow> window)
+ : vk::wsi::XcbWindowInterface (vk::pt::XcbWindow(window->getXID()))
+ , m_window (window)
+ {
+ }
+
+ void resize (const UVec2& newSize)
+ {
+ m_window->setDimensions((int)newSize.x(), (int)newSize.y());
+ }
+
+private:
+ UniquePtr<XcbWindow> m_window;
+};
+
+class VulkanDisplayXcb : public vk::wsi::XcbDisplayInterface
+{
+public:
+ VulkanDisplayXcb (MovePtr<DisplayBase> display)
+ : vk::wsi::XcbDisplayInterface (vk::pt::XcbConnectionPtr(((XcbDisplay*)display.get())->getConnection()))
+ , m_display (display)
+ {
+ }
+
+ vk::wsi::Window* createWindow (const Maybe<UVec2>& initialSize) const
+ {
+ XcbDisplay* instance = (XcbDisplay*)(m_display.get());
+ const deUint32 height = !initialSize ? (deUint32)DEFAULT_WINDOW_HEIGHT : initialSize->y();
+ const deUint32 width = !initialSize ? (deUint32)DEFAULT_WINDOW_WIDTH : initialSize->x();
+ return new VulkanWindowXcb(MovePtr<XcbWindow>(new XcbWindow(*instance, (int)width, (int)height, DE_NULL)));
+ }
+
+private:
+ MovePtr<DisplayBase> m_display;
+};
+#endif // DEQP_SUPPORT_XCB
+
+class VulkanLibrary : public vk::Library
+{
+public:
+ VulkanLibrary (void)
+ : m_library ("libvulkan.so.1")
+ , m_driver (m_library)
+ {
+ }
+
+ const vk::PlatformInterface& getPlatformInterface (void) const
+ {
+ return m_driver;
+ }
+
+private:
+ const DynamicFunctionLibrary m_library;
+ const vk::PlatformDriver m_driver;
+};
+
+VulkanPlatform::VulkanPlatform (EventState& eventState)
+ : m_eventState(eventState)
+{
+}
+
+vk::wsi::Display* VulkanPlatform::createWsiDisplay (vk::wsi::Type wsiType) const
+{
+ switch(wsiType)
+ {
+ case vk::wsi::TYPE_XLIB:
+ return new VulkanDisplayXlib(MovePtr<DisplayBase>(new XlibDisplay(m_eventState,"")));
+ break;
+#if defined (DEQP_SUPPORT_XCB)
+ case vk::wsi::TYPE_XCB:
+ return new VulkanDisplayXcb(MovePtr<DisplayBase>(new XcbDisplay(m_eventState,"")));
+ break;
+#endif // DEQP_SUPPORT_XCB
+ default:
+ TCU_THROW(NotSupportedError, "WSI type not supported");
+
+ };
+}
+
+vk::Library* VulkanPlatform::createLibrary (void) const
+{
+ return new VulkanLibrary();
+}
+
+void VulkanPlatform::describePlatform (std::ostream& dst) const
+{
+ utsname sysInfo;
+ deMemset(&sysInfo, 0, sizeof(sysInfo));
+
+ if (uname(&sysInfo) != 0)
+ throw std::runtime_error("uname() failed");
+
+ dst << "OS: " << sysInfo.sysname << " " << sysInfo.release << " " << sysInfo.version << "\n";
+ dst << "CPU: " << sysInfo.machine << "\n";
+}
+
+void VulkanPlatform::getMemoryLimits (vk::PlatformMemoryLimits& limits) const
+{
+ limits.totalSystemMemory = 256*1024*1024;
+ limits.totalDeviceLocalMemory = 128*1024*1024;
+ limits.deviceMemoryAllocationGranularity = 64*1024;
+ limits.devicePageSize = 4096;
+ limits.devicePageTableEntrySize = 8;
+ limits.devicePageTableHierarchyLevels = 3;
+}
+
+} // x11
+} // tcu
+
--- /dev/null
+#ifndef _TCUX11VULKANPLATFORM_HPP
+#define _TCUX11VULKANPLATFORM_HPP
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program Tester Core
+ * ----------------------------------------
+ *
+ * Copyright (c) 2016 The Khronos Group Inc.
+ *
+ * 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 X11Vulkan Platform.
+ *//*--------------------------------------------------------------------*/
+
+#include "vkWsiPlatform.hpp"
+#include "vkPlatform.hpp"
+#include "tcuX11.hpp"
+
+namespace tcu
+{
+namespace x11
+{
+
+class VulkanPlatform : public vk::Platform
+{
+public:
+ VulkanPlatform (EventState& eventState);
+ vk::wsi::Display* createWsiDisplay (vk::wsi::Type wsiType) const;
+ vk::Library* createLibrary (void) const;
+ void describePlatform (std::ostream& dst) const;
+ void getMemoryLimits (vk::PlatformMemoryLimits& limits) const;
+
+private :
+ EventState& m_eventState;
+};
+
+
+} // x11
+} // tcu
+
+#endif // _TCUX11VULKANPLATFORM_HPP
--- /dev/null
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program Tester Core
+ * ----------------------------------------
+ *
+ * Copyright (c) 2016 The Khronos Group Inc.
+ *
+ * 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 X11 using XCB utilities.
+ *//*--------------------------------------------------------------------*/
+
+#include "tcuX11Xcb.hpp"
+#include "deMemory.h"
+
+namespace tcu
+{
+namespace x11
+{
+
+XcbDisplay::XcbDisplay (EventState& platform, const char* name)
+ : DisplayBase (platform)
+{
+ m_connection = xcb_connect(name, NULL);
+ const xcb_setup_t *setup = xcb_get_setup(m_connection);
+ xcb_screen_iterator_t iterator = xcb_setup_roots_iterator(setup);
+ m_screen = iterator.data;
+}
+
+XcbDisplay::~XcbDisplay (void)
+{
+ xcb_disconnect (m_connection);
+}
+
+void XcbDisplay::processEvents (void)
+{
+ xcb_generic_event_t *ev;
+ while ((ev = xcb_poll_for_event(m_connection)))
+ {
+ deFree(ev);
+ /* Manage your event */
+ }
+}
+
+XcbWindow::XcbWindow (XcbDisplay& display, int width, int height, xcb_visualid_t* visual)
+ : WindowBase ()
+ , m_display (display)
+{
+ xcb_connection_t* connection = m_display.getConnection();
+ uint32_t values[2];
+ m_window = xcb_generate_id(connection);
+ m_colormap = xcb_generate_id(connection);
+
+ if (visual == DE_NULL)
+ visual = &m_display.getScreen()->root_visual;
+
+ values[0] = m_display.getScreen()->white_pixel;
+ values[1] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_PROPERTY_CHANGE;
+
+ xcb_create_window (
+ connection, // Connection
+ XCB_COPY_FROM_PARENT, // depth (same as root)
+ m_window, // window Id
+ display.getScreen()->root, // parent window
+ 0, 0, // x, y
+ static_cast<uint16_t >(width), // width
+ static_cast<uint16_t >(height), // height
+ 10, // border_width
+ XCB_WINDOW_CLASS_INPUT_OUTPUT, // class
+ *visual, // visual
+ XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK, // masks
+ values //not used yet
+ );
+
+ xcb_create_colormap (
+ connection,
+ XCB_COLORMAP_ALLOC_NONE,
+ m_colormap,
+ m_window,
+ *visual
+ );
+
+ xcb_alloc_color_reply_t* rep = xcb_alloc_color_reply(connection, xcb_alloc_color(connection, m_colormap, 65535, 0, 0), NULL);
+ deFree(rep);
+ xcb_flush (connection);
+}
+
+XcbWindow::~XcbWindow (void)
+{
+ xcb_flush (m_display.getConnection());
+ xcb_free_colormap(m_display.getConnection(), m_colormap);
+ xcb_destroy_window(m_display.getConnection(), m_window);
+}
+
+void XcbWindow::setVisibility (bool visible)
+{
+ if (visible == m_visible)
+ return;
+
+ if (visible)
+ xcb_map_window(m_display.getConnection(), m_window);
+ else
+ xcb_unmap_window(m_display.getConnection(), m_window);
+
+ m_visible = visible;
+ xcb_flush (m_display.getConnection());
+
+}
+
+void XcbWindow::processEvents (void)
+{
+ // A bit of a hack, since we don't really handle all the events.
+ m_display.processEvents();
+}
+
+void XcbWindow::getDimensions (int* width, int* height) const
+{
+ xcb_get_geometry_reply_t *geom;
+ geom = xcb_get_geometry_reply(m_display.getConnection(), xcb_get_geometry(m_display.getConnection(), m_window), NULL);
+ *height = static_cast<int>(geom->height);
+ *width = static_cast<int>(geom->width);
+ deFree(geom);
+}
+
+void XcbWindow::setDimensions (int width, int height)
+{
+ const uint32_t values[] = {static_cast<uint32_t >(width), static_cast<uint32_t >(height)};
+ xcb_void_cookie_t result;
+ xcb_connection_t* display = m_display.getConnection();
+ result = xcb_configure_window(display, m_window, XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values);
+ DE_ASSERT(DE_NULL == xcb_request_check(display,result));
+ xcb_flush (display);
+
+ for(;;)
+ {
+ xcb_generic_event_t* event = xcb_poll_for_event(display);
+ int w, h;
+ if(event != DE_NULL)
+ {
+ if (XCB_PROPERTY_NOTIFY == (event->response_type & ~0x80))
+ {
+ deFree(event);
+ break;
+ }
+ deFree(event);
+ }
+ getDimensions (&w,&h);
+ if (h==height || w==width)
+ break;
+ }
+}
+
+} // xcb
+} // tcu
--- /dev/null
+#ifndef _TCUX11XCB_HPP
+#define _TCUX11XCB_HPP
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program Tester Core
+ * ----------------------------------------
+ *
+ * Copyright (c) 2016 The Khronos Group Inc.
+ *
+ * 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 X11 using XCB utilities.
+ *//*--------------------------------------------------------------------*/
+
+#include "tcuX11.hpp"
+#include <xcb/xcb.h>
+
+namespace tcu
+{
+namespace x11
+{
+
+class XcbDisplay : public DisplayBase
+{
+public:
+ XcbDisplay (EventState& platform, const char* name);
+ virtual ~XcbDisplay (void);
+
+ xcb_screen_t* getScreen (void) { return m_screen; }
+ xcb_connection_t* getConnection (void) { return m_connection; }
+
+ void processEvents (void);
+
+protected:
+ xcb_screen_t* m_screen;
+ xcb_connection_t* m_connection;
+
+private:
+ XcbDisplay (const XcbDisplay&);
+ XcbDisplay& operator= (const XcbDisplay&);
+};
+
+class XcbWindow : public WindowBase
+{
+public:
+ XcbWindow (XcbDisplay& display, int width, int height, xcb_visualid_t* visual);
+ ~XcbWindow (void);
+
+ void setVisibility (bool visible);
+
+ void processEvents (void);
+ DisplayBase& getDisplay (void) { return (DisplayBase&)m_display; }
+ xcb_window_t& getXID (void) { return m_window; }
+
+ void getDimensions (int* width, int* height) const;
+ void setDimensions (int width, int height);
+
+protected:
+
+ XcbDisplay& m_display;
+ xcb_colormap_t m_colormap;
+ xcb_window_t m_window;
+
+private:
+ XcbWindow (const XcbWindow&);
+ XcbWindow& operator= (const XcbWindow&);
+};
+
+} // x11
+} // tcu
+
+#endif // _TCUX11XCB_HPP
--- /dev/null
+# FindXCB
+FIND_PACKAGE(PkgConfig)
+PKG_CHECK_MODULES(XCB xcb)
+FIND_PATH(XCB_INCLUDE_DIR NAMES xcb/xcb.h HINTS ${PKG_XCB_INCLUDE_DIRS})
+FIND_LIBRARY(XCB_LIBRARIES NAMES xcb HINTS ${PKG_XCB_LIBRARY_DIRS})
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(XCB DEFAULT_MSG XCB_LIBRARIES XCB_INCLUDE_DIR)
set(DEQP_PLATFORM_LIBRARIES ${X11_LIBRARIES})
include_directories(${X11_INCLUDE_DIR})
+
+ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/targets/default")
+
+ # Use XCB target if available
+ set(DEQP_USE_XCB OFF)
+ find_package(XCB)
+ if (XCB_FOUND)
+ set(DEQP_USE_XCB ON)
+ set(DEQP_PLATFORM_LIBRARIES ${XCB_LIBRARIES})
+ include_directories(${XCB_INCLUDE_DIR})
+ endif ()
endif ()