• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program Tester Core
3  * ----------------------------------------
4  *
5  * Copyright 2017 The Android Open Source Project
6  *
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  *//*!
20  * \file
21  * \brief Linux Platform.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "tcuLnxPlatform.hpp"
25 
26 #include "tcuLnxVulkanPlatform.hpp"
27 #include "tcuLnxEglPlatform.hpp"
28 
29 #include "deUniquePtr.hpp"
30 #include "gluPlatform.hpp"
31 #include "vkPlatform.hpp"
32 
33 #if defined (DEQP_SUPPORT_X11)
34 #	include <X11/Xlib.h>
35 #endif // DEQP_SUPPORT_X11
36 
37 #if defined (DEQP_SUPPORT_GLX)
38 #	include "tcuLnxX11GlxPlatform.hpp"
39 #endif // DEQP_SUPPORT_GLX
40 
41 using de::MovePtr;
42 using de::UniquePtr;
43 
44 namespace tcu
45 {
46 namespace lnx
47 {
48 
49 class LinuxGLPlatform : public glu::Platform
50 {
51 public:
registerFactory(de::MovePtr<glu::ContextFactory> factory)52 	void		registerFactory	(de::MovePtr<glu::ContextFactory> factory)
53 	{
54 		m_contextFactoryRegistry.registerFactory(factory.release());
55 	}
56 };
57 
58 class LinuxPlatform : public tcu::Platform
59 {
60 public:
61 							LinuxPlatform		(void);
processEvents(void)62 	bool					processEvents		(void) { return !m_eventState.getQuitFlag(); }
63 
getVulkanPlatform(void) const64 	const vk::Platform&		getVulkanPlatform	(void) const { return m_vkPlatform; }
getEGLPlatform(void) const65 	const eglu::Platform&	getEGLPlatform		(void) const { return m_eglPlatform; }
getGLPlatform(void) const66 	const glu::Platform&	getGLPlatform		(void) const { return m_glPlatform; }
67 
68 private:
69 	EventState				m_eventState;
70 	VulkanPlatform			m_vkPlatform;
71 	egl::Platform			m_eglPlatform;
72 	LinuxGLPlatform			m_glPlatform;
73 };
74 
LinuxPlatform(void)75 LinuxPlatform::LinuxPlatform (void)
76 	: m_vkPlatform	(m_eventState)
77 	, m_eglPlatform	(m_eventState)
78 {
79 #if defined (DEQP_SUPPORT_GLX)
80 	m_glPlatform.registerFactory(x11::glx::createContextFactory(m_eventState));
81 #endif // DEQP_SUPPORT_GLX
82 
83 	m_glPlatform.registerFactory(m_eglPlatform.createContextFactory());
84 }
85 
86 } // lnx
87 } // tcu
88 
createPlatform(void)89 tcu::Platform* createPlatform (void)
90 {
91 #if defined (DEQP_SUPPORT_X11)
92 	// From man:XinitThreads(3):
93 	//
94 	//     The XInitThreads function initializes Xlib support for concurrent
95 	//     threads.  This function must be the first Xlib function
96 	//     a multi-threaded program calls, and it must complete before any other
97 	//     Xlib call is made.
98 	DE_CHECK_RUNTIME_ERR(XInitThreads() != 0);
99 #endif // DEQP_SUPPORT_X11
100 
101 	return new tcu::lnx::LinuxPlatform();
102 }
103