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 36namespace glcts 37{ 38 39#if defined(GLCTS_SUPPORT_WGL) 40 41static 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 (isOk && (type.getProfile() == glu::PROFILE_ES) && 63 (fmtInfo.redBits > 8 || fmtInfo.greenBits > 8 || fmtInfo.blueBits > 8 || fmtInfo.alphaBits > 8)) 64 { 65 // The OpenGL ES tests use of glReadPixels is not compatible with default framebufer pixel 66 // formats with more than 8-bits per pixel component. 67 isOk = false; 68 } 69 70 if (isOk && (type.getProfile() == glu::PROFILE_ES) && fmtInfo.sRGB) 71 { 72 // The OpenGL ES tests don't interact correctly with a default framebuffer 73 // in the sRGB color space. 74 isOk = false; 75 } 76 77 if (isAOSPOk) 78 { 79 configList.aospConfigs.push_back(AOSPConfig( 80 CONFIGTYPE_WGL, pixelFormat, SURFACETYPE_WINDOW, fmtInfo.redBits, fmtInfo.greenBits, fmtInfo.blueBits, 81 fmtInfo.alphaBits, fmtInfo.depthBits, fmtInfo.stencilBits, fmtInfo.samples)); 82 } 83 84 if (isOk) 85 { 86 configList.configs.push_back(Config(CONFIGTYPE_WGL, pixelFormat, SURFACETYPE_WINDOW)); 87 } 88 else 89 { 90 configList.excludedConfigs.push_back( 91 ExcludedConfig(CONFIGTYPE_WGL, pixelFormat, EXCLUDEREASON_NOT_COMPATIBLE)); 92 } 93 } 94} 95 96void getConfigListWGL(tcu::Platform& platform, glu::ApiType type, ConfigList& configList) 97{ 98 try 99 { 100 tcu::win32::Platform& wglPlatform = dynamic_cast<tcu::win32::Platform&>(platform); 101 getDefaultWglConfigList(wglPlatform, type, configList); 102 } 103 catch (const std::bad_cast&) 104 { 105 throw tcu::Exception("Platform is not tcu::WGLPlatform"); 106 } 107} 108 109#else 110 111void getConfigListWGL(tcu::Platform&, glu::ApiType, ConfigList&) 112{ 113 throw tcu::Exception("WGL is not supported on this OS"); 114} 115 116#endif 117 118} // glcts 119