From a8b243b42e95094b4b464eed884b641cc1cbdbf4 Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Mon, 1 Sep 2014 14:39:17 +0300 Subject: windows: Allow selection of ANGLE's renderer The default behavior of ANGLE is to use D3D11 before falling back to D3D9. This change improves flexibility the platform plugin to explicitly create a D3D11, D3D9, or D3D11 software (WARP) context by setting the QT_ANGLE_PLATFORM to "d3d11", "d3d9", or "warp", respectively. Task-number: QTBUG-41031 Change-Id: Ie1d399c1cb0e360e5b3a6d9f2a4b28745d86cc71 Reviewed-by: Friedemann Kleint Reviewed-by: Laszlo Agocs --- .../platforms/windows/qwindowseglcontext.cpp | 31 +++++++++++++++++++++- src/plugins/platforms/windows/qwindowseglcontext.h | 1 + 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp index 2d2d409a0f..698a153533 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp @@ -46,6 +46,10 @@ #include #include +#if defined(QT_OPENGL_ES_2_ANGLE) +# include +#endif + QT_BEGIN_NAMESPACE /*! @@ -140,6 +144,7 @@ bool QWindowsLibEGL::init() eglGetError = RESOLVE((EGLint (EGLAPIENTRY *)(void)), eglGetError); eglGetDisplay = RESOLVE((EGLDisplay (EGLAPIENTRY *)(EGLNativeDisplayType)), eglGetDisplay); + eglGetPlatformDisplayEXT = RESOLVE((EGLDisplay (EGLAPIENTRY *)(EGLenum platform, void *native_display, const EGLint *attrib_list)), eglGetPlatformDisplayEXT); eglInitialize = RESOLVE((EGLBoolean (EGLAPIENTRY *)(EGLDisplay, EGLint *, EGLint *)), eglInitialize); eglTerminate = RESOLVE((EGLBoolean (EGLAPIENTRY *)(EGLDisplay)), eglTerminate); eglChooseConfig = RESOLVE((EGLBoolean (EGLAPIENTRY *)(EGLDisplay, const EGLint *, EGLConfig *, EGLint, EGLint *)), eglChooseConfig); @@ -359,7 +364,31 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create() return 0; } - EGLDisplay display = libEGL.eglGetDisplay((EGLNativeDisplayType)dc); + EGLDisplay display = EGL_NO_DISPLAY; +#ifdef EGL_ANGLE_platform_angle_opengl + if (libEGL.eglGetPlatformDisplayEXT && qEnvironmentVariableIsSet("QT_ANGLE_PLATFORM")) { + const EGLint anglePlatformAttributes[][3] = { + { EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, EGL_NONE }, + { EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE, EGL_NONE }, + { EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_WARP_ANGLE, EGL_NONE } + }; + const EGLint *attributes = 0; + const QByteArray anglePlatform = qgetenv("QT_ANGLE_PLATFORM"); + if (anglePlatform == "d3d11") + attributes = anglePlatformAttributes[0]; + else if (anglePlatform == "d3d9") + attributes = anglePlatformAttributes[1]; + else if (anglePlatform == "warp") + attributes = anglePlatformAttributes[2]; + else + qCWarning(lcQpaGl) << "Invalid value set for QT_ANGLE_PLATFORM:" << anglePlatform; + + if (attributes) + display = libEGL.eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, dc, attributes); + } +#endif // EGL_ANGLE_platform_angle_opengl + if (display == EGL_NO_DISPLAY) + display = libEGL.eglGetDisplay((EGLNativeDisplayType)dc); if (!display) { qWarning("%s: Could not obtain EGL display", Q_FUNC_INFO); return 0; diff --git a/src/plugins/platforms/windows/qwindowseglcontext.h b/src/plugins/platforms/windows/qwindowseglcontext.h index 6c4ac08da1..a7866516f0 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.h +++ b/src/plugins/platforms/windows/qwindowseglcontext.h @@ -53,6 +53,7 @@ struct QWindowsLibEGL EGLint (EGLAPIENTRY * eglGetError)(void); EGLDisplay (EGLAPIENTRY * eglGetDisplay)(EGLNativeDisplayType display_id); + EGLDisplay (EGLAPIENTRY * eglGetPlatformDisplayEXT)(EGLenum platform, void *native_display, const EGLint *attrib_list); EGLBoolean (EGLAPIENTRY * eglInitialize)(EGLDisplay dpy, EGLint *major, EGLint *minor); EGLBoolean (EGLAPIENTRY * eglTerminate)(EGLDisplay dpy); EGLBoolean (EGLAPIENTRY * eglChooseConfig)(EGLDisplay dpy, const EGLint *attrib_list, -- cgit v1.2.3