diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2018-04-05 11:45:38 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2018-04-05 09:50:50 +0000 |
commit | af4972fd15e6b11a99c631ff91b3360ceb8be5cc (patch) | |
tree | 4138c3e3b81c4c5b4a4fc0733a519099e8c91681 | |
parent | 2a260617b96281375e2ee018af8c7547d99e4a6d (diff) |
Fix CommandThread context creation
Task-number: QTBUG-67498
Change-Id: I4a98a81e2c5fc9fda221505b7504c3ec93e47d69
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r-- | src/render/renderers/opengl/renderer/commandthread.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/render/renderers/opengl/renderer/commandthread.cpp b/src/render/renderers/opengl/renderer/commandthread.cpp index fc654097c..dcaacadcc 100644 --- a/src/render/renderers/opengl/renderer/commandthread.cpp +++ b/src/render/renderers/opengl/renderer/commandthread.cpp @@ -89,6 +89,19 @@ void CommandThread::initialize(QOpenGLContext *mainContext, OffscreenSurfaceHelp m_mainContext = mainContext; m_offsreenSurfaceHelper = offsreenSurfaceHelper; Q_ASSERT(m_mainContext && offsreenSurfaceHelper); + + // Initialize shared context and resources for the thread. This must be + // done here since some platforms do not allow context sharing to be set up + // with contexts created on different threads. (Windows with WGL, in + // particular; resource sharing works fine later on, what matters is the + // thread the wglShareLists call is made on) + m_localContext.reset(new QOpenGLContext()); + m_localContext->setFormat(m_mainContext->format()); + m_localContext->setShareContext(m_mainContext); + if (!m_localContext->create()) + qWarning("CommandThread: Failed to create local context"); + m_localContext->moveToThread(this); + m_running.fetchAndStoreOrdered(1); // Allow thread to proceed @@ -151,11 +164,6 @@ void CommandThread::run() Q_ASSERT(m_mainContext && m_shaderCache); - // Initialize shared context and resources for the thread - m_localContext.reset(new QOpenGLContext()); - m_localContext->setShareContext(m_mainContext); - m_localContext->create(); - // Initialize GraphicsContext m_graphicsContext.reset(new GraphicsContext()); m_graphicsContext->setShaderCache(m_shaderCache); |