1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program Tester Core
3 * ----------------------------------------
5 * Copyright (c) 2016 The Khronos Group Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Wayland Vulkan Platform.
22 *//*--------------------------------------------------------------------*/
24 #include "tcuWaylandVulkanPlatform.hpp"
25 #include "tcuWaylandPlatform.hpp"
26 #include "vkWsiPlatform.hpp"
27 #include "gluPlatform.hpp"
28 #include "tcuWayland.hpp"
29 #include "tcuFunctionLibrary.hpp"
30 #include "deUniquePtr.hpp"
33 #include <sys/utsname.h>
43 class VulkanWindowWayland : public vk::wsi::WaylandWindowInterface
46 VulkanWindowWayland (MovePtr<wayland::Window> window)
47 : vk::wsi::WaylandWindowInterface (vk::pt::WaylandSurfacePtr(window->getSurface()))
52 void resize (const UVec2& newSize)
54 m_window->setDimensions((int)newSize.x(), (int)newSize.y());
58 UniquePtr<wayland::Window> m_window;
61 class VulkanDisplayWayland : public vk::wsi::WaylandDisplayInterface
64 VulkanDisplayWayland (MovePtr<wayland::Display> display)
65 : vk::wsi::WaylandDisplayInterface (vk::pt::WaylandDisplayPtr(display->getDisplay()))
70 vk::wsi::Window* createWindow (const Maybe<UVec2>& initialSize) const
72 const deUint32 height = !initialSize ? (deUint32)DEFAULT_WINDOW_HEIGHT : initialSize->y();
73 const deUint32 width = !initialSize ? (deUint32)DEFAULT_WINDOW_WIDTH : initialSize->x();
74 return new VulkanWindowWayland(MovePtr<wayland::Window>(new wayland::Window(*m_display, (int)width, (int)height)));
78 MovePtr<wayland::Display> m_display;
81 class VulkanLibrary : public vk::Library
85 : m_library ("libvulkan.so.1")
86 , m_driver (m_library)
90 const vk::PlatformInterface& getPlatformInterface (void) const
96 const DynamicFunctionLibrary m_library;
97 const vk::PlatformDriver m_driver;
100 WaylandVulkanPlatform::WaylandVulkanPlatform (EventState& eventState)
101 : m_eventState(eventState)
105 vk::wsi::Display* WaylandVulkanPlatform::createWsiDisplay (vk::wsi::Type wsiType) const
109 case vk::wsi::TYPE_WAYLAND:
110 return new VulkanDisplayWayland(MovePtr<Display>(new Display(m_eventState, DE_NULL)));
113 TCU_THROW(NotSupportedError, "WSI type not supported");
118 vk::Library* WaylandVulkanPlatform::createLibrary (void) const
120 return new VulkanLibrary();
123 void WaylandVulkanPlatform::describePlatform (std::ostream& dst) const
126 deMemset(&sysInfo, 0, sizeof(sysInfo));
128 if (uname(&sysInfo) != 0)
129 throw std::runtime_error("uname() failed");
131 dst << "OS: " << sysInfo.sysname << " " << sysInfo.release << " " << sysInfo.version << "\n";
132 dst << "CPU: " << sysInfo.machine << "\n";
135 void WaylandVulkanPlatform::getMemoryLimits (vk::PlatformMemoryLimits& limits) const
137 limits.totalSystemMemory = 256*1024*1024;
138 limits.totalDeviceLocalMemory = 128*1024*1024;
139 limits.deviceMemoryAllocationGranularity = 64*1024;
140 limits.devicePageSize = 4096;
141 limits.devicePageTableEntrySize = 8;
142 limits.devicePageTableHierarchyLevels = 3;