summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowsintegration.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-01-12 15:59:36 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-01-15 23:25:48 +0100
commit97a82f62c46c272fe3ef1cd9d5c2214b6a7626af (patch)
treeb8f74ccbf8bf053d44f8f5fe5533f97effca0009 /src/plugins/platforms/windows/qwindowsintegration.cpp
parent0fa092cbae1593ca73577ecf9ec71283ae3f2498 (diff)
Windows: Add infrastructure to be able to a GL renderer based on GPU.
Introduce flags for the renderer type and move code to qwindowsopengltester. Introduce QWindowsOpenGLTester::supportedGlesRenderers() where type-dependent checking can be added. Change-Id: I4bbffaf861cb0fdbea0919e081e3626fb5a872de Task-number: QTBUG-43263 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsintegration.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp76
1 files changed, 45 insertions, 31 deletions
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index 54fb138d85..82686f38ad 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -328,47 +328,61 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons
}
#ifndef QT_NO_OPENGL
-static QWindowsStaticOpenGLContext *q_staticOpenGLContext = 0;
-QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::create()
+QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::doCreate()
{
- QWindowsStaticOpenGLContext *ctx = 0;
-
#if defined(QT_OPENGL_DYNAMIC)
- const QByteArray requested = qgetenv("QT_OPENGL"); // angle, desktop, software
- const bool angleRequested = QCoreApplication::testAttribute(Qt::AA_UseOpenGLES) || requested == "angle";
- const bool desktopRequested = QCoreApplication::testAttribute(Qt::AA_UseDesktopOpenGL) || requested == "desktop";
- const bool softwareRequested = QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL) || requested == "software";
-
+ QWindowsOpenGLTester::Renderer requestedRenderer = QWindowsOpenGLTester::requestedRenderer();
+ switch (requestedRenderer) {
+ case QWindowsOpenGLTester::DesktopGl:
+ if (QWindowsStaticOpenGLContext *glCtx = QOpenGLStaticContext::create())
+ return glCtx;
+ qCWarning(lcQpaGl, "System OpenGL failed. Falling back to Software OpenGL.");
+ return QOpenGLStaticContext::create(true);
// If ANGLE is requested, use it, don't try anything else.
- if (angleRequested) {
- ctx = QWindowsEGLStaticContext::create();
- } else {
- // If opengl32.dll seems to be OpenGL 2.x capable, or desktop OpenGL is requested, use it.
- if (!softwareRequested && (desktopRequested || QWindowsOpenGLTester::testDesktopGL()))
- ctx = QOpenGLStaticContext::create();
- // If failed and desktop OpenGL is not explicitly requested, try ANGLE.
- if (!ctx && !desktopRequested && !softwareRequested)
- ctx = QWindowsEGLStaticContext::create();
- // Try software.
- if (!ctx) {
- ctx = QOpenGLStaticContext::create(true);
- // If software was explicitly requested but failed, try the regular one.
- if (!ctx && softwareRequested && QWindowsOpenGLTester::testDesktopGL()) {
- qCWarning(lcQpaGl, "Software OpenGL failed. Falling back to system OpenGL.");
- ctx = QOpenGLStaticContext::create();
- }
- }
+ case QWindowsOpenGLTester::AngleRendererD3d9:
+ case QWindowsOpenGLTester::AngleRendererD3d11:
+ case QWindowsOpenGLTester::AngleRendererD3d11Warp:
+ return QWindowsEGLStaticContext::create(requestedRenderer);
+ case QWindowsOpenGLTester::Gles:
+ return QWindowsEGLStaticContext::create(QWindowsOpenGLTester::supportedGlesRenderers());
+ case QWindowsOpenGLTester::SoftwareRasterizer:
+ if (QWindowsStaticOpenGLContext *swCtx = QOpenGLStaticContext::create(true))
+ return swCtx;
+ qCWarning(lcQpaGl, "Software OpenGL failed. Falling back to system OpenGL.");
+ if (QWindowsOpenGLTester::supportedRenderers() & QWindowsOpenGLTester::DesktopGl)
+ return QOpenGLStaticContext::create();
+ return Q_NULLPTR;
+ default:
+ break;
}
+
+ const QWindowsOpenGLTester::Renderers supportedRenderers = QWindowsOpenGLTester::supportedRenderers();
+ if (supportedRenderers & QWindowsOpenGLTester::DesktopGl) {
+ if (QWindowsStaticOpenGLContext *glCtx = QOpenGLStaticContext::create())
+ return glCtx;
+ }
+ if (QWindowsOpenGLTester::Renderers glesRenderers = supportedRenderers & QWindowsOpenGLTester::GlesMask) {
+ if (QWindowsEGLStaticContext *eglCtx = QWindowsEGLStaticContext::create(glesRenderers))
+ return eglCtx;
+ }
+ return QOpenGLStaticContext::create(true);
#elif defined(QT_OPENGL_ES_2)
- ctx = QWindowsEGLStaticContext::create();
+ QWindowsOpenGLTester::Renderers glesRenderers = QWindowsOpenGLTester::requestedGlesRenderer();
+ if (glesRenderers == QWindowsOpenGLTester::InvalidRenderer)
+ glesRenderers = QWindowsOpenGLTester::supportedGlesRenderers();
+ return QWindowsEGLStaticContext::create(glesRenderers);
#elif !defined(QT_NO_OPENGL)
- ctx = QOpenGLStaticContext::create();
+ return QOpenGLStaticContext::create();
#endif
+}
- q_staticOpenGLContext = ctx;
+static QWindowsStaticOpenGLContext *q_staticOpenGLContext = 0;
- return ctx;
+QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::create()
+{
+ q_staticOpenGLContext = QWindowsStaticOpenGLContext::doCreate();
+ return q_staticOpenGLContext;
}
bool QWindowsIntegrationPrivate::ensureStaticOpenGLContext()