summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-03-22 15:32:36 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-05-23 12:37:23 +0000
commitbdb1c18e411a1660f038e4f0e219d363d38e987a (patch)
tree98e1bb45d8794f8f907f6510e0d066fd5325f8d6 /src/plugins
parent5c6d27b8dfa695ab04766a1711b00421dba9c7d0 (diff)
windows: Fall back to D3D9 when 11 fails
It is assumed that this happens automatically but that is not always the case. Do not become stuck with a non-functional D3D11-backed EGL environment. Instead, try again as if QT_ANGLE_PLATFORM=d3d9 was requested. Task-number: QTBUG-52056 Change-Id: I12ac6ca5f1d06f9504d05120d8e1053e97edfab3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/windows/qwindowseglcontext.cpp67
-rw-r--r--src/plugins/platforms/windows/qwindowseglcontext.h2
2 files changed, 45 insertions, 24 deletions
diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp
index 787a072a7a..9ae1ca8acb 100644
--- a/src/plugins/platforms/windows/qwindowseglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp
@@ -347,26 +347,9 @@ QWindowsEGLStaticContext::QWindowsEGLStaticContext(EGLDisplay display)
{
}
-QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester::Renderers preferredType)
+bool QWindowsEGLStaticContext::initializeAngle(QWindowsOpenGLTester::Renderers preferredType, HDC dc,
+ EGLDisplay *display, EGLint *major, EGLint *minor)
{
- const HDC dc = QWindowsContext::instance()->displayContext();
- if (!dc){
- qWarning("%s: No Display", __FUNCTION__);
- return 0;
- }
-
- if (!libEGL.init()) {
- qWarning("%s: Failed to load and resolve libEGL functions", __FUNCTION__);
- return 0;
- }
- if (!libGLESv2.init()) {
- qWarning("%s: Failed to load and resolve libGLESv2 functions", __FUNCTION__);
- return 0;
- }
-
- EGLDisplay display = EGL_NO_DISPLAY;
- EGLint major = 0;
- EGLint minor = 0;
#ifdef EGL_ANGLE_platform_angle
if (libEGL.eglGetPlatformDisplayEXT
&& (preferredType & QWindowsOpenGLTester::AngleBackendMask)) {
@@ -384,16 +367,52 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester:
else if (preferredType & QWindowsOpenGLTester::AngleRendererD3d11Warp)
attributes = anglePlatformAttributes[2];
if (attributes) {
- display = libEGL.eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, dc, attributes);
- if (!libEGL.eglInitialize(display, &major, &minor)) {
- display = EGL_NO_DISPLAY;
- major = minor = 0;
+ *display = libEGL.eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, dc, attributes);
+ if (!libEGL.eglInitialize(*display, major, minor)) {
+ libEGL.eglTerminate(*display);
+ *display = EGL_NO_DISPLAY;
+ *major = *minor = 0;
+ return false;
}
}
}
#else // EGL_ANGLE_platform_angle
- Q_UNUSED(preferredType)
+ Q_UNUSED(preferredType);
+ Q_UNUSED(dc);
+ Q_UNUSED(display);
+ Q_UNUSED(major);
+ Q_UNUSED(minor);
#endif
+ return true;
+}
+
+QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester::Renderers preferredType)
+{
+ const HDC dc = QWindowsContext::instance()->displayContext();
+ if (!dc){
+ qWarning("%s: No Display", __FUNCTION__);
+ return 0;
+ }
+
+ if (!libEGL.init()) {
+ qWarning("%s: Failed to load and resolve libEGL functions", __FUNCTION__);
+ return 0;
+ }
+ if (!libGLESv2.init()) {
+ qWarning("%s: Failed to load and resolve libGLESv2 functions", __FUNCTION__);
+ return 0;
+ }
+
+ EGLDisplay display = EGL_NO_DISPLAY;
+ EGLint major = 0;
+ EGLint minor = 0;
+
+ if (!initializeAngle(preferredType, dc, &display, &major, &minor)
+ && (preferredType & QWindowsOpenGLTester::AngleRendererD3d11)) {
+ preferredType &= ~QWindowsOpenGLTester::AngleRendererD3d11;
+ initializeAngle(preferredType, dc, &display, &major, &minor);
+ }
+
if (display == EGL_NO_DISPLAY)
display = libEGL.eglGetDisplay(dc);
if (!display) {
diff --git a/src/plugins/platforms/windows/qwindowseglcontext.h b/src/plugins/platforms/windows/qwindowseglcontext.h
index 6945939941..1a6058c921 100644
--- a/src/plugins/platforms/windows/qwindowseglcontext.h
+++ b/src/plugins/platforms/windows/qwindowseglcontext.h
@@ -271,6 +271,8 @@ public:
private:
explicit QWindowsEGLStaticContext(EGLDisplay display);
+ static bool initializeAngle(QWindowsOpenGLTester::Renderers preferredType, HDC dc,
+ EGLDisplay *display, EGLint *major, EGLint *minor);
const EGLDisplay m_display;
};