mirror of
https://github.com/overte-org/overte.git
synced 2025-06-20 05:00:00 +02:00
Fix the OpenVR issues on AMD
This commit is contained in:
parent
95b5a23c7a
commit
02c79d9714
2 changed files with 28 additions and 16 deletions
|
@ -56,7 +56,7 @@ public:
|
||||||
using Condition = std::condition_variable;
|
using Condition = std::condition_variable;
|
||||||
using Lock = std::unique_lock<Mutex>;
|
using Lock = std::unique_lock<Mutex>;
|
||||||
friend class OpenVrDisplayPlugin;
|
friend class OpenVrDisplayPlugin;
|
||||||
OffscreenGLCanvas _canvas;
|
std::shared_ptr<OffscreenGLCanvas> _canvas;
|
||||||
BasicFramebufferWrapperPtr _framebuffer;
|
BasicFramebufferWrapperPtr _framebuffer;
|
||||||
ProgramPtr _program;
|
ProgramPtr _program;
|
||||||
ShapeWrapperPtr _plane;
|
ShapeWrapperPtr _plane;
|
||||||
|
@ -68,9 +68,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
OpenVrSubmitThread(OpenVrDisplayPlugin& plugin) : _plugin(plugin) {
|
OpenVrSubmitThread(OpenVrDisplayPlugin& plugin) : _plugin(plugin) {
|
||||||
_canvas.create(plugin._container->getPrimaryContext());
|
setObjectName("OpenVR Submit Thread");
|
||||||
_canvas.doneCurrent();
|
|
||||||
_canvas.moveToThreadWithContext(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateReprojectionProgram() {
|
void updateReprojectionProgram() {
|
||||||
|
@ -131,19 +129,20 @@ public:
|
||||||
|
|
||||||
void run() override {
|
void run() override {
|
||||||
QThread::currentThread()->setPriority(QThread::Priority::TimeCriticalPriority);
|
QThread::currentThread()->setPriority(QThread::Priority::TimeCriticalPriority);
|
||||||
_canvas.makeCurrent();
|
assert(_canvas->thread() == QThread::currentThread());
|
||||||
|
_canvas->makeCurrent();
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glViewport(0, 0, _plugin._renderTargetSize.x, _plugin._renderTargetSize.y);
|
glViewport(0, 0, _plugin._renderTargetSize.x, _plugin._renderTargetSize.y);
|
||||||
_framebuffer = std::make_shared<BasicFramebufferWrapper>();
|
_framebuffer = std::make_shared<BasicFramebufferWrapper>();
|
||||||
_framebuffer->Init(_plugin._renderTargetSize);
|
_framebuffer->Init(_plugin._renderTargetSize);
|
||||||
updateReprojectionProgram();
|
updateReprojectionProgram();
|
||||||
_plane = loadPlane(_program);
|
_plane = loadPlane(_program);
|
||||||
_canvas.doneCurrent();
|
_canvas->doneCurrent();
|
||||||
while (!_quit) {
|
while (!_quit) {
|
||||||
_canvas.makeCurrent();
|
_canvas->makeCurrent();
|
||||||
updateSource();
|
updateSource();
|
||||||
if (!_current.texture) {
|
if (!_current.texture) {
|
||||||
_canvas.doneCurrent();
|
_canvas->doneCurrent();
|
||||||
QThread::usleep(1);
|
QThread::usleep(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -199,15 +198,15 @@ public:
|
||||||
_presented.notify_one();
|
_presented.notify_one();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
_canvas.doneCurrent();
|
_canvas->doneCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
_canvas.makeCurrent();
|
_canvas->makeCurrent();
|
||||||
_plane.reset();
|
_plane.reset();
|
||||||
_program.reset();
|
_program.reset();
|
||||||
_framebuffer.reset();
|
_framebuffer.reset();
|
||||||
_canvas.doneCurrent();
|
_canvas->doneCurrent();
|
||||||
|
_canvas->moveToThreadWithContext(qApp->thread());
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(const CompositeInfo& newCompositeInfo) {
|
void update(const CompositeInfo& newCompositeInfo) {
|
||||||
|
@ -307,10 +306,17 @@ bool OpenVrDisplayPlugin::internalActivate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if OPENVR_THREADED_SUBMIT
|
#if OPENVR_THREADED_SUBMIT
|
||||||
withMainThreadContext([&] {
|
|
||||||
_submitThread = std::make_shared<OpenVrSubmitThread>(*this);
|
_submitThread = std::make_shared<OpenVrSubmitThread>(*this);
|
||||||
|
if (!_submitCanvas) {
|
||||||
|
withMainThreadContext([&] {
|
||||||
|
_submitCanvas = std::make_shared<OffscreenGLCanvas>();
|
||||||
|
_submitCanvas->setObjectName("OpenVRSubmitContext");
|
||||||
|
_submitCanvas->create(_container->getPrimaryContext());
|
||||||
|
_submitCanvas->doneCurrent();
|
||||||
});
|
});
|
||||||
_submitThread->setObjectName("OpenVR Submit Thread");
|
}
|
||||||
|
_submitCanvas->moveToThreadWithContext(_submitThread.get());
|
||||||
|
assert(_submitCanvas->thread() == _submitThread.get());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return Parent::internalActivate();
|
return Parent::internalActivate();
|
||||||
|
@ -348,6 +354,8 @@ void OpenVrDisplayPlugin::customizeContext() {
|
||||||
}
|
}
|
||||||
_compositeInfos[i].textureID = getGLBackend()->getTextureID(_compositeInfos[i].texture, false);
|
_compositeInfos[i].textureID = getGLBackend()->getTextureID(_compositeInfos[i].texture, false);
|
||||||
}
|
}
|
||||||
|
assert(_submitCanvas->thread() == _submitThread.get());
|
||||||
|
_submitThread->_canvas = _submitCanvas;
|
||||||
_submitThread->start(QThread::HighPriority);
|
_submitThread->start(QThread::HighPriority);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -358,6 +366,8 @@ void OpenVrDisplayPlugin::uncustomizeContext() {
|
||||||
#if OPENVR_THREADED_SUBMIT
|
#if OPENVR_THREADED_SUBMIT
|
||||||
_submitThread->_quit = true;
|
_submitThread->_quit = true;
|
||||||
_submitThread->wait();
|
_submitThread->wait();
|
||||||
|
_submitThread.reset();
|
||||||
|
assert(_submitCanvas->thread() == qApp->thread());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ const float TARGET_RATE_OpenVr = 90.0f; // FIXME: get from sdk tracked device p
|
||||||
|
|
||||||
#if OPENVR_THREADED_SUBMIT
|
#if OPENVR_THREADED_SUBMIT
|
||||||
class OpenVrSubmitThread;
|
class OpenVrSubmitThread;
|
||||||
|
class OffscreenGLCanvas;
|
||||||
static const size_t COMPOSITING_BUFFER_SIZE = 3;
|
static const size_t COMPOSITING_BUFFER_SIZE = 3;
|
||||||
|
|
||||||
struct CompositeInfo {
|
struct CompositeInfo {
|
||||||
|
@ -78,6 +79,7 @@ private:
|
||||||
CompositeInfo::Array _compositeInfos;
|
CompositeInfo::Array _compositeInfos;
|
||||||
size_t _renderingIndex { 0 };
|
size_t _renderingIndex { 0 };
|
||||||
std::shared_ptr<OpenVrSubmitThread> _submitThread;
|
std::shared_ptr<OpenVrSubmitThread> _submitThread;
|
||||||
|
std::shared_ptr<OffscreenGLCanvas> _submitCanvas;
|
||||||
friend class OpenVrSubmitThread;
|
friend class OpenVrSubmitThread;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue