mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +02:00
Merge pull request #8800 from jherico/openvr_crash
Don't crash on OpenVR activation when SteamVR isn't running
This commit is contained in:
commit
964377429a
4 changed files with 29 additions and 9 deletions
|
@ -414,6 +414,7 @@ void OpenGLDisplayPlugin::customizeContext() {
|
|||
_cursorPipeline = gpu::Pipeline::create(program, state);
|
||||
}
|
||||
}
|
||||
updateCompositeFramebuffer();
|
||||
}
|
||||
|
||||
void OpenGLDisplayPlugin::uncustomizeContext() {
|
||||
|
@ -557,10 +558,7 @@ void OpenGLDisplayPlugin::compositeScene() {
|
|||
}
|
||||
|
||||
void OpenGLDisplayPlugin::compositeLayers() {
|
||||
auto renderSize = getRecommendedRenderSize();
|
||||
if (!_compositeFramebuffer || _compositeFramebuffer->getSize() != renderSize) {
|
||||
_compositeFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("displayPlugin::composite", gpu::Element::COLOR_RGBA_32, renderSize.x, renderSize.y));
|
||||
}
|
||||
updateCompositeFramebuffer();
|
||||
|
||||
{
|
||||
PROFILE_RANGE_EX("compositeScene", 0xff0077ff, (uint64_t)presentCount())
|
||||
|
@ -760,3 +758,10 @@ void OpenGLDisplayPlugin::render(std::function<void(gpu::Batch& batch)> f) {
|
|||
OpenGLDisplayPlugin::~OpenGLDisplayPlugin() {
|
||||
qDebug() << "Destroying OpenGLDisplayPlugin";
|
||||
}
|
||||
|
||||
void OpenGLDisplayPlugin::updateCompositeFramebuffer() {
|
||||
auto renderSize = getRecommendedRenderSize();
|
||||
if (!_compositeFramebuffer || _compositeFramebuffer->getSize() != renderSize) {
|
||||
_compositeFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("OpenGLDisplayPlugin::composite", gpu::Element::COLOR_RGBA_32, renderSize.x, renderSize.y));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,6 +78,8 @@ protected:
|
|||
glm::uvec2 getSurfaceSize() const;
|
||||
glm::uvec2 getSurfacePixels() const;
|
||||
|
||||
void updateCompositeFramebuffer();
|
||||
|
||||
virtual void compositeLayers();
|
||||
virtual void compositeScene();
|
||||
virtual void compositeOverlay();
|
||||
|
|
|
@ -377,9 +377,6 @@ void OpenVrDisplayPlugin::init() {
|
|||
}
|
||||
|
||||
bool OpenVrDisplayPlugin::internalActivate() {
|
||||
_openVrDisplayActive = true;
|
||||
_container->setIsOptionChecked(StandingHMDSensorMode, true);
|
||||
|
||||
if (!_system) {
|
||||
_system = acquireOpenVrSystem();
|
||||
}
|
||||
|
@ -388,6 +385,18 @@ bool OpenVrDisplayPlugin::internalActivate() {
|
|||
return false;
|
||||
}
|
||||
|
||||
// If OpenVR isn't running, then the compositor won't be accessible
|
||||
// FIXME find a way to launch the compositor?
|
||||
if (!vr::VRCompositor()) {
|
||||
qWarning() << "Failed to acquire OpenVR compositor";
|
||||
releaseOpenVrSystem();
|
||||
_system = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
_openVrDisplayActive = true;
|
||||
_container->setIsOptionChecked(StandingHMDSensorMode, true);
|
||||
|
||||
_system->GetRecommendedRenderTargetSize(&_renderTargetSize.x, &_renderTargetSize.y);
|
||||
// Recommended render target size is per-eye, so double the X size for
|
||||
// left + right eyes
|
||||
|
|
|
@ -109,8 +109,12 @@ void releaseOpenVrSystem() {
|
|||
vr::Texture_t vrTexture{ (void*)INVALID_GL_TEXTURE_HANDLE, vr::API_OpenGL, vr::ColorSpace_Auto };
|
||||
static vr::VRTextureBounds_t OPENVR_TEXTURE_BOUNDS_LEFT{ 0, 0, 0.5f, 1 };
|
||||
static vr::VRTextureBounds_t OPENVR_TEXTURE_BOUNDS_RIGHT{ 0.5f, 0, 1, 1 };
|
||||
vr::VRCompositor()->Submit(vr::Eye_Left, &vrTexture, &OPENVR_TEXTURE_BOUNDS_LEFT);
|
||||
vr::VRCompositor()->Submit(vr::Eye_Right, &vrTexture, &OPENVR_TEXTURE_BOUNDS_RIGHT);
|
||||
|
||||
auto compositor = vr::VRCompositor();
|
||||
if (compositor) {
|
||||
compositor->Submit(vr::Eye_Left, &vrTexture, &OPENVR_TEXTURE_BOUNDS_LEFT);
|
||||
compositor->Submit(vr::Eye_Right, &vrTexture, &OPENVR_TEXTURE_BOUNDS_RIGHT);
|
||||
}
|
||||
|
||||
vr::VR_Shutdown();
|
||||
_openVrQuitRequested = false;
|
||||
|
|
Loading…
Reference in a new issue