• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * OpenGL Conformance Test Suite
3  * -----------------------------
4  *
5  * Copyright (c) 2016 Google Inc.
6  * Copyright (c) 2016 The Khronos Group Inc.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */ /*!
21  * \file
22  * \brief CTS rendering configuration list utility.
23  */ /*-------------------------------------------------------------------*/
24 
25 #include "deUniquePtr.hpp"
26 #include "glcConfigList.hpp"
27 
28 #include <typeinfo>
29 
30 #if defined(GLCTS_SUPPORT_WGL)
31 #include "tcuWGL.hpp"
32 #include "tcuWin32Platform.hpp"
33 #include "tcuWin32Window.hpp"
34 #endif
35 
36 namespace glcts
37 {
38 
39 #if defined(GLCTS_SUPPORT_WGL)
40 
getDefaultWglConfigList(tcu::win32::Platform & wglPlatform,glu::ApiType type,ConfigList & configList)41 static void getDefaultWglConfigList(tcu::win32::Platform& wglPlatform, glu::ApiType type, ConfigList& configList)
42 {
43 	const HINSTANCE			 instance = GetModuleHandle(DE_NULL);
44 	const tcu::wgl::Core&	wgl(instance);
45 	const tcu::win32::Window tmpWindow(instance, 1, 1);
46 	const std::vector<int>   pixelFormats = wgl.getPixelFormats(tmpWindow.getDeviceContext());
47 
48 	DE_UNREF(type); // \todo [2013-09-16 pyry] Check for support.
49 
50 	for (std::vector<int>::const_iterator fmtIter = pixelFormats.begin(); fmtIter != pixelFormats.end(); ++fmtIter)
51 	{
52 		const int						pixelFormat = *fmtIter;
53 		const tcu::wgl::PixelFormatInfo fmtInfo		= wgl.getPixelFormatInfo(tmpWindow.getDeviceContext(), pixelFormat);
54 
55 		if (!tcu::wgl::isSupportedByTests(fmtInfo))
56 			continue;
57 
58 		bool isAOSPOk = (fmtInfo.surfaceTypes & tcu::wgl::PixelFormatInfo::SURFACE_WINDOW) && fmtInfo.supportOpenGL &&
59 						fmtInfo.pixelType == tcu::wgl::PixelFormatInfo::PIXELTYPE_RGBA;
60 		bool isOk = isAOSPOk && (fmtInfo.sampleBuffers == 0);
61 
62 		if (isAOSPOk)
63 		{
64 			configList.aospConfigs.push_back(AOSPConfig(
65 				CONFIGTYPE_WGL, pixelFormat, SURFACETYPE_WINDOW, fmtInfo.redBits, fmtInfo.greenBits, fmtInfo.blueBits,
66 				fmtInfo.alphaBits, fmtInfo.depthBits, fmtInfo.stencilBits, fmtInfo.samples));
67 		}
68 
69 		if (isOk)
70 		{
71 			configList.configs.push_back(Config(CONFIGTYPE_WGL, pixelFormat, SURFACETYPE_WINDOW));
72 		}
73 		else
74 		{
75 			configList.excludedConfigs.push_back(
76 				ExcludedConfig(CONFIGTYPE_WGL, pixelFormat, EXCLUDEREASON_NOT_COMPATIBLE));
77 		}
78 	}
79 }
80 
getConfigListWGL(tcu::Platform & platform,glu::ApiType type,ConfigList & configList)81 void getConfigListWGL(tcu::Platform& platform, glu::ApiType type, ConfigList& configList)
82 {
83 	try
84 	{
85 		tcu::win32::Platform& wglPlatform = dynamic_cast<tcu::win32::Platform&>(platform);
86 		getDefaultWglConfigList(wglPlatform, type, configList);
87 	}
88 	catch (const std::bad_cast&)
89 	{
90 		throw tcu::Exception("Platform is not tcu::WGLPlatform");
91 	}
92 }
93 
94 #else
95 
96 void getConfigListWGL(tcu::Platform&, glu::ApiType, ConfigList&)
97 {
98 	throw tcu::Exception("WGL is not supported on this OS");
99 }
100 
101 #endif
102 
103 } // glcts
104