From a6a12d8c0fc918972c15268f749ecc7c90b95d6c Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Tue, 5 Aug 2014 12:59:44 +0300 Subject: ANGLE: upgrade to 2.1~07d49ef5350a This version of ANGLE provides partial ES3 support, numerous bug fixes, and several potentially useful vendor extensions. All patches have been rebased. The following changes are noted: 0000-General-fixes-for-ANGLE-2.1.patch contains compile fixes for the new ANGLE 0004-Make-it-possible-to-link-ANGLE-statically-for-single.patch has incorporated patch 0015. 0007-Make-DX9-DX11-mutually-exclusive.patch has been removed as it was fixed upstream. 0007-Fix-ANGLE-build-with-Microsoft-Visual-Studio-14-CTP.patch has been moved up to fill the patch number gap. 0010-ANGLE-Enable-D3D11-for-feature-level-9-cards.patch now contains patch 0014 and 0017. 0013-ANGLE-Allow-for-universal-program-binaries.patch has been removed as it is no longer relevant. 0014-ANGLE-D3D11-Fix-internal-index-buffer-for-level-9-ha.patch has been merged with patch 0010. 0015-ANGLE-Don-t-export-DLLMain-functions-for-static-buil.patch has been merged with patch 0004. 0016-ANGLE-WinRT-Call-Trim-when-application-suspends.patch has been removed and will be replaced by a follow-up patch using a different technique. 0017-ANGLE-D3D11-Don-t-use-mipmaps-in-level-9-textures.patch has been merged with patch 0010. 0018-ANGLE-WinRT-Create-swap-chain-using-physical-resolut.patch has been removed and will be replaced by a follow-up patch extending the EGL_ANGLE_window_fixed_size extension. 0019-Fix-ANGLE-build-with-Microsoft-Visual-Studio-14-CTP.patch is now patch 0007. [ChangeLog][Third-party libraries] ANGLE has been upgraded to version 2.1, bringing partial support for OpenGL ES3 over Direct3D 11, numerous bug fixes, and several new vendor extensions. Change-Id: I6d95ce1480462d67228d83c1e5c74a1706b5b21c Reviewed-by: Friedemann Kleint --- src/3rdparty/angle/src/libEGL/Display.cpp | 192 +++++++++++++++++++++--------- 1 file changed, 135 insertions(+), 57 deletions(-) (limited to 'src/3rdparty/angle/src/libEGL/Display.cpp') diff --git a/src/3rdparty/angle/src/libEGL/Display.cpp b/src/3rdparty/angle/src/libEGL/Display.cpp index e75a4b6440..7cd83c3db4 100644 --- a/src/3rdparty/angle/src/libEGL/Display.cpp +++ b/src/3rdparty/angle/src/libEGL/Display.cpp @@ -1,6 +1,5 @@ -#include "../libGLESv2/precompiled.h" // -// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. +// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -14,9 +13,11 @@ #include #include #include +#include +#include #include "common/debug.h" -#include "libGLESv2/mathutil.h" +#include "common/mathutil.h" #include "libGLESv2/main.h" #include "libGLESv2/Context.h" #include "libGLESv2/renderer/SwapChain.h" @@ -26,43 +27,57 @@ namespace egl { -namespace + +typedef std::map DisplayMap; +static DisplayMap *GetDisplayMap() { - typedef std::map DisplayMap; - DisplayMap displays; + static DisplayMap displays; + return &displays; } -egl::Display *Display::getDisplay(EGLNativeDisplayType displayId) +egl::Display *Display::getDisplay(EGLNativeDisplayType displayId, EGLint displayType) { - if (displays.find(displayId) != displays.end()) + DisplayMap *displays = GetDisplayMap(); + DisplayMap::const_iterator iter = displays->find(displayId); + if (iter != displays->end()) { - return displays[displayId]; + return iter->second; } - + // FIXME: Check if displayId is a valid display device context - egl::Display *display = new egl::Display(displayId); + egl::Display *display = new egl::Display(displayId, displayType); + displays->insert(std::make_pair(displayId, display)); - displays[displayId] = display; return display; } -Display::Display(EGLNativeDisplayType displayId) +Display::Display(EGLNativeDisplayType displayId, EGLint displayType) + : mDisplayId(displayId), + mRequestedDisplayType(displayType), + mRenderer(NULL) { - mDisplayId = displayId; - mRenderer = NULL; +#if defined(ANGLE_PLATFORM_WINRT) + if (mDisplayId) + mDisplayId->AddRef(); +#endif } Display::~Display() { terminate(); - DisplayMap::iterator thisDisplay = displays.find(mDisplayId); - - if (thisDisplay != displays.end()) + DisplayMap *displays = GetDisplayMap(); + DisplayMap::iterator iter = displays->find(mDisplayId); + if (iter != displays->end()) { - displays.erase(thisDisplay); + displays->erase(iter); } + +#if defined(ANGLE_PLATFORM_WINRT) + if (mDisplayId) + mDisplayId->Release(); +#endif } bool Display::initialize() @@ -72,8 +87,8 @@ bool Display::initialize() return true; } - mRenderer = glCreateRenderer(this, mDisplayId); - + mRenderer = glCreateRenderer(this, mDisplayId, mRequestedDisplayType); + if (!mRenderer) { terminate(); @@ -82,16 +97,16 @@ bool Display::initialize() EGLint minSwapInterval = mRenderer->getMinSwapInterval(); EGLint maxSwapInterval = mRenderer->getMaxSwapInterval(); - EGLint maxTextureWidth = mRenderer->getMaxTextureWidth(); - EGLint maxTextureHeight = mRenderer->getMaxTextureHeight(); + EGLint maxTextureSize = mRenderer->getRendererCaps().max2DTextureSize; rx::ConfigDesc *descList; int numConfigs = mRenderer->generateConfigs(&descList); ConfigSet configSet; for (int i = 0; i < numConfigs; ++i) - configSet.add(descList[i], minSwapInterval, maxSwapInterval, - maxTextureWidth, maxTextureHeight); + { + configSet.add(descList[i], minSwapInterval, maxSwapInterval, maxTextureSize, maxTextureSize); + } // Give the sorted configs a unique ID and store them internally EGLint index = 1; @@ -113,7 +128,7 @@ bool Display::initialize() return false; } - initExtensionString(); + initDisplayExtensionString(); initVendorString(); return true; @@ -192,6 +207,10 @@ EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig co const Config *configuration = mConfigSet.get(config); EGLint postSubBufferSupported = EGL_FALSE; + EGLint width = 0; + EGLint height = 0; + EGLint fixedSize = EGL_FALSE; + if (attribList) { while (*attribList != EGL_NONE) @@ -212,6 +231,15 @@ EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig co case EGL_POST_SUB_BUFFER_SUPPORTED_NV: postSubBufferSupported = attribList[1]; break; + case EGL_WIDTH: + width = attribList[1]; + break; + case EGL_HEIGHT: + height = attribList[1]; + break; + case EGL_FIXED_SIZE_ANGLE: + fixedSize = attribList[1]; + break; case EGL_VG_COLORSPACE: return error(EGL_BAD_MATCH, EGL_NO_SURFACE); case EGL_VG_ALPHA_FORMAT: @@ -224,6 +252,17 @@ EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig co } } + if (width < 0 || height < 0) + { + return error(EGL_BAD_PARAMETER, EGL_NO_SURFACE); + } + + if (!fixedSize) + { + width = -1; + height = -1; + } + if (hasExistingWindowSurface(window)) { return error(EGL_BAD_ALLOC, EGL_NO_SURFACE); @@ -235,7 +274,7 @@ EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig co return EGL_NO_SURFACE; } - Surface *surface = new Surface(this, configuration, window, postSubBufferSupported); + Surface *surface = new Surface(this, configuration, window, fixedSize, width, height, postSubBufferSupported); if (!surface->initialize()) { @@ -320,7 +359,7 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle, return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); } - if (textureFormat != EGL_NO_TEXTURE && !mRenderer->getNonPower2TextureSupport() && (!gl::isPow2(width) || !gl::isPow2(height))) + if (textureFormat != EGL_NO_TEXTURE && !mRenderer->getRendererExtensions().textureNPOT && (!gl::isPow2(width) || !gl::isPow2(height))) { return error(EGL_BAD_MATCH, EGL_NO_SURFACE); } @@ -361,22 +400,29 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle, return success(surface); } -EGLContext Display::createContext(EGLConfig configHandle, const gl::Context *shareContext, bool notifyResets, bool robustAccess) +EGLContext Display::createContext(EGLConfig configHandle, EGLint clientVersion, const gl::Context *shareContext, bool notifyResets, bool robustAccess) { if (!mRenderer) { - return NULL; + return EGL_NO_CONTEXT; } else if (mRenderer->testDeviceLost(false)) // Lost device { if (!restoreLostDevice()) - return NULL; + { + return error(EGL_CONTEXT_LOST, EGL_NO_CONTEXT); + } } - gl::Context *context = glCreateContext(shareContext, mRenderer, notifyResets, robustAccess); + if (clientVersion > 2 && mRenderer->getMajorShaderModel() < 4) + { + return error(EGL_BAD_CONFIG, EGL_NO_CONTEXT); + } + + gl::Context *context = glCreateContext(clientVersion, shareContext, mRenderer, notifyResets, robustAccess); mContextSet.insert(context); - return context; + return success(context); } bool Display::restoreLostDevice() @@ -470,51 +516,84 @@ bool Display::hasExistingWindowSurface(EGLNativeWindowType window) return false; } -void Display::initExtensionString() +std::string Display::generateClientExtensionString() { - bool shareHandleSupported = mRenderer->getShareHandleSupport(); + std::vector extensions; - mExtensionString = ""; + extensions.push_back("EGL_EXT_client_extensions"); - // Multi-vendor (EXT) extensions - mExtensionString += "EGL_EXT_create_context_robustness "; + extensions.push_back("ANGLE_platform_angle"); - // ANGLE-specific extensions - if (shareHandleSupported) + if (supportsPlatformD3D()) { - mExtensionString += "EGL_ANGLE_d3d_share_handle_client_buffer "; + extensions.push_back("ANGLE_platform_angle_d3d"); } - mExtensionString += "EGL_ANGLE_query_surface_pointer "; - -#if defined(ANGLE_ENABLE_D3D9) - HMODULE swiftShader = GetModuleHandle(TEXT("swiftshader_d3d9.dll")); - if (swiftShader) + if (supportsPlatformOpenGL()) { - mExtensionString += "EGL_ANGLE_software_display "; + extensions.push_back("ANGLE_platform_angle_opengl"); } -#endif - if (shareHandleSupported) + std::ostringstream stream; + std::copy(extensions.begin(), extensions.end(), std::ostream_iterator(stream, " ")); + return stream.str(); +} + +void Display::initDisplayExtensionString() +{ + std::vector extensions; + + // Multi-vendor (EXT) extensions + extensions.push_back("EGL_EXT_create_context_robustness"); + + // ANGLE-specific extensions + if (mRenderer->getShareHandleSupport()) { - mExtensionString += "EGL_ANGLE_surface_d3d_texture_2d_share_handle "; + extensions.push_back("EGL_ANGLE_d3d_share_handle_client_buffer"); + extensions.push_back("EGL_ANGLE_surface_d3d_texture_2d_share_handle"); } + extensions.push_back("EGL_ANGLE_query_surface_pointer"); + extensions.push_back("EGL_ANGLE_window_fixed_size"); + if (mRenderer->getPostSubBufferSupport()) { - mExtensionString += "EGL_NV_post_sub_buffer"; + extensions.push_back("EGL_NV_post_sub_buffer"); } - std::string::size_type end = mExtensionString.find_last_not_of(' '); - if (end != std::string::npos) + // TODO: complete support for the EGL_KHR_create_context extension + //extensions.push_back("EGL_KHR_create_context"); + + std::ostringstream stream; + std::copy(extensions.begin(), extensions.end(), std::ostream_iterator(stream, " ")); + mDisplayExtensionString = stream.str(); +} + +const char *Display::getExtensionString(egl::Display *display) +{ + if (display != EGL_NO_DISPLAY) { - mExtensionString.resize(end+1); + return display->mDisplayExtensionString.c_str(); } + else + { + static std::string clientExtensions = generateClientExtensionString(); + return clientExtensions.c_str(); + } +} + +bool Display::supportsPlatformD3D() +{ +#if defined(ANGLE_ENABLE_D3D9) || defined(ANGLE_ENABLE_D3D11) + return true; +#else + return false; +#endif } -const char *Display::getExtensionString() const +bool Display::supportsPlatformOpenGL() { - return mExtensionString.c_str(); + return false; } void Display::initVendorString() @@ -527,7 +606,6 @@ void Display::initVendorString() { char adapterLuidString[64]; snprintf(adapterLuidString, sizeof(adapterLuidString), " (adapter LUID: %08x%08x)", adapterLuid.HighPart, adapterLuid.LowPart); - mVendorString += adapterLuidString; } } -- cgit v1.2.3