mirror of
https://github.com/overte-org/overte.git
synced 2025-06-21 17:41:24 +02:00
Stop messing about with the context, leave it bound on the render thread
This commit is contained in:
parent
841d27ad20
commit
9f4fb0e8bd
1 changed files with 10 additions and 8 deletions
|
@ -113,10 +113,14 @@ public:
|
||||||
setPriority(QThread::HighPriority);
|
setPriority(QThread::HighPriority);
|
||||||
OpenGLDisplayPlugin* currentPlugin{ nullptr };
|
OpenGLDisplayPlugin* currentPlugin{ nullptr };
|
||||||
Q_ASSERT(_context);
|
Q_ASSERT(_context);
|
||||||
|
_context->makeCurrent();
|
||||||
|
Q_ASSERT(isCurrentContext(_context->contextHandle()));
|
||||||
while (!_shutdown) {
|
while (!_shutdown) {
|
||||||
if (_pendingMainThreadOperation) {
|
if (_pendingMainThreadOperation) {
|
||||||
|
PROFILE_RANGE("MainThreadOp")
|
||||||
{
|
{
|
||||||
Lock lock(_mutex);
|
Lock lock(_mutex);
|
||||||
|
_context->doneCurrent();
|
||||||
// Move the context to the main thread
|
// Move the context to the main thread
|
||||||
_context->moveToThread(qApp->thread());
|
_context->moveToThread(qApp->thread());
|
||||||
_pendingMainThreadOperation = false;
|
_pendingMainThreadOperation = false;
|
||||||
|
@ -129,13 +133,14 @@ public:
|
||||||
// Main thread does it's thing while we wait on the lock to release
|
// Main thread does it's thing while we wait on the lock to release
|
||||||
Lock lock(_mutex);
|
Lock lock(_mutex);
|
||||||
_condition.wait(lock, [&] { return _finishedMainThreadOperation; });
|
_condition.wait(lock, [&] { return _finishedMainThreadOperation; });
|
||||||
|
_context->makeCurrent();
|
||||||
|
Q_ASSERT(isCurrentContext(_context->contextHandle()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for a new display plugin
|
// Check for a new display plugin
|
||||||
{
|
{
|
||||||
Lock lock(_mutex);
|
Lock lock(_mutex);
|
||||||
_context->makeCurrent();
|
|
||||||
// Check if we have a new plugin to activate
|
// Check if we have a new plugin to activate
|
||||||
while (!_newPluginQueue.empty()) {
|
while (!_newPluginQueue.empty()) {
|
||||||
auto newPlugin = _newPluginQueue.front();
|
auto newPlugin = _newPluginQueue.front();
|
||||||
|
@ -155,7 +160,6 @@ public:
|
||||||
_condition.notify_one();
|
_condition.notify_one();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_context->doneCurrent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there's no active plugin, just sleep
|
// If there's no active plugin, just sleep
|
||||||
|
@ -165,16 +169,14 @@ public:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// take the latest texture and present it
|
// Execute the frame and present it to the display device.
|
||||||
_context->makeCurrent();
|
{
|
||||||
if (isCurrentContext(_context->contextHandle())) {
|
PROFILE_RANGE("PluginPresent")
|
||||||
currentPlugin->present();
|
currentPlugin->present();
|
||||||
CHECK_GL_ERROR();
|
CHECK_GL_ERROR();
|
||||||
|
}
|
||||||
|
}
|
||||||
_context->doneCurrent();
|
_context->doneCurrent();
|
||||||
} else {
|
|
||||||
qWarning() << "Makecurrent failed";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Lock lock(_mutex);
|
Lock lock(_mutex);
|
||||||
_context->moveToThread(qApp->thread());
|
_context->moveToThread(qApp->thread());
|
||||||
|
|
Loading…
Reference in a new issue