mirror of
https://github.com/JulianGro/overte.git
synced 2025-07-22 20:55:37 +02:00
Merge pull request #14271 from SamGondelman/oculus
Case 19475: Fix various Oculus Store test failures
This commit is contained in:
commit
4bafcd2cfa
10 changed files with 79 additions and 41 deletions
|
@ -2867,8 +2867,10 @@ void Application::initializeDisplayPlugins() {
|
||||||
[this](const QSize& size) { resizeGL(); });
|
[this](const QSize& size) { resizeGL(); });
|
||||||
QObject::connect(displayPlugin.get(), &DisplayPlugin::resetSensorsRequested, this, &Application::requestReset);
|
QObject::connect(displayPlugin.get(), &DisplayPlugin::resetSensorsRequested, this, &Application::requestReset);
|
||||||
if (displayPlugin->isHmd()) {
|
if (displayPlugin->isHmd()) {
|
||||||
QObject::connect(dynamic_cast<HmdDisplayPlugin*>(displayPlugin.get()), &HmdDisplayPlugin::hmdMountedChanged,
|
auto hmdDisplayPlugin = dynamic_cast<HmdDisplayPlugin*>(displayPlugin.get());
|
||||||
|
QObject::connect(hmdDisplayPlugin, &HmdDisplayPlugin::hmdMountedChanged,
|
||||||
DependencyManager::get<HMDScriptingInterface>().data(), &HMDScriptingInterface::mountedChanged);
|
DependencyManager::get<HMDScriptingInterface>().data(), &HMDScriptingInterface::mountedChanged);
|
||||||
|
QObject::connect(hmdDisplayPlugin, &HmdDisplayPlugin::hmdVisibleChanged, this, &Application::hmdVisibleChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6521,6 +6523,14 @@ void Application::resetSensors(bool andReload) {
|
||||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "reset", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "reset", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::hmdVisibleChanged(bool visible) {
|
||||||
|
if (visible) {
|
||||||
|
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "start", Qt::QueuedConnection);
|
||||||
|
} else {
|
||||||
|
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "stop", Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Application::updateWindowTitle() const {
|
void Application::updateWindowTitle() const {
|
||||||
|
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
|
|
@ -382,6 +382,8 @@ public slots:
|
||||||
void resetSensors(bool andReload = false);
|
void resetSensors(bool andReload = false);
|
||||||
void setActiveFaceTracker() const;
|
void setActiveFaceTracker() const;
|
||||||
|
|
||||||
|
void hmdVisibleChanged(bool visible);
|
||||||
|
|
||||||
#if (PR_BUILD || DEV_BUILD)
|
#if (PR_BUILD || DEV_BUILD)
|
||||||
void sendWrongProtocolVersionsSignature(bool checked) { ::sendWrongProtocolVersionsSignature(checked); }
|
void sendWrongProtocolVersionsSignature(bool checked) { ::sendWrongProtocolVersionsSignature(checked); }
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <SettingHandle.h>
|
#include <SettingHandle.h>
|
||||||
#include <OctreeUtils.h>
|
#include <OctreeUtils.h>
|
||||||
#include <Util.h>
|
#include <Util.h>
|
||||||
|
#include <shared/GlobalAppProperties.h>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "ui/DialogsManager.h"
|
#include "ui/DialogsManager.h"
|
||||||
|
@ -309,8 +310,14 @@ QString LODManager::getLODFeedbackText() {
|
||||||
|
|
||||||
void LODManager::loadSettings() {
|
void LODManager::loadSettings() {
|
||||||
setDesktopLODTargetFPS(desktopLODDecreaseFPS.get());
|
setDesktopLODTargetFPS(desktopLODDecreaseFPS.get());
|
||||||
|
Setting::Handle<bool> firstRun { Settings::firstRun, true };
|
||||||
|
if (qApp->property(hifi::properties::OCULUS_STORE).toBool() && firstRun.get()) {
|
||||||
|
const float LOD_HIGH_QUALITY_LEVEL = 0.75f;
|
||||||
|
setHMDLODTargetFPS(LOD_HIGH_QUALITY_LEVEL * LOD_MAX_LIKELY_HMD_FPS);
|
||||||
|
} else {
|
||||||
setHMDLODTargetFPS(hmdLODDecreaseFPS.get());
|
setHMDLODTargetFPS(hmdLODDecreaseFPS.get());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LODManager::saveSettings() {
|
void LODManager::saveSettings() {
|
||||||
desktopLODDecreaseFPS.set(getDesktopLODTargetFPS());
|
desktopLODDecreaseFPS.set(getDesktopLODTargetFPS());
|
||||||
|
|
|
@ -48,6 +48,7 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void hmdMountedChanged();
|
void hmdMountedChanged();
|
||||||
|
void hmdVisibleChanged(bool visible);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void hmdPresent() = 0;
|
virtual void hmdPresent() = 0;
|
||||||
|
|
|
@ -23,13 +23,14 @@ void OculusBaseDisplayPlugin::resetSensors() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OculusBaseDisplayPlugin::beginFrameRender(uint32_t frameIndex) {
|
bool OculusBaseDisplayPlugin::beginFrameRender(uint32_t frameIndex) {
|
||||||
ovrSessionStatus status{};
|
ovrResult getStatusResult;
|
||||||
if (!OVR_SUCCESS(ovr_GetSessionStatus(_session, &status))) {
|
ovrSessionStatus status = ovr::getStatus(getStatusResult);
|
||||||
|
if (!OVR_SUCCESS(getStatusResult)) {
|
||||||
qCWarning(oculusLog) << "Unable to fetch Oculus session status" << ovr::getError();
|
qCWarning(oculusLog) << "Unable to fetch Oculus session status" << ovr::getError();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ovr::quitRequested(status)) {
|
if (ovr::quitRequested(status) || ovr::displayLost(status) || !ovr::handleOVREvents()) {
|
||||||
QMetaObject::invokeMethod(qApp, "quit");
|
QMetaObject::invokeMethod(qApp, "quit");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -40,11 +41,15 @@ bool OculusBaseDisplayPlugin::beginFrameRender(uint32_t frameIndex) {
|
||||||
_hmdMounted = !_hmdMounted;
|
_hmdMounted = !_hmdMounted;
|
||||||
emit hmdMountedChanged();
|
emit hmdMountedChanged();
|
||||||
}
|
}
|
||||||
|
if (ovr::isVisible(status) != _visible) {
|
||||||
|
_visible = !_visible;
|
||||||
|
emit hmdVisibleChanged(_visible);
|
||||||
|
}
|
||||||
|
|
||||||
_currentRenderFrameInfo = FrameInfo();
|
_currentRenderFrameInfo = FrameInfo();
|
||||||
_currentRenderFrameInfo.sensorSampleTime = ovr_GetTimeInSeconds();
|
_currentRenderFrameInfo.sensorSampleTime = ovr_GetTimeInSeconds();
|
||||||
_currentRenderFrameInfo.predictedDisplayTime = ovr_GetPredictedDisplayTime(_session, frameIndex);
|
_currentRenderFrameInfo.predictedDisplayTime = ovr_GetPredictedDisplayTime(_session, frameIndex);
|
||||||
auto trackingState = ovr_GetTrackingState(_session, _currentRenderFrameInfo.predictedDisplayTime, ovrTrue);
|
auto trackingState = ovr::getTrackingState(_currentRenderFrameInfo.predictedDisplayTime, ovrTrue);
|
||||||
_currentRenderFrameInfo.renderPose = ovr::toGlm(trackingState.HeadPose.ThePose);
|
_currentRenderFrameInfo.renderPose = ovr::toGlm(trackingState.HeadPose.ThePose);
|
||||||
_currentRenderFrameInfo.presentPose = _currentRenderFrameInfo.renderPose;
|
_currentRenderFrameInfo.presentPose = _currentRenderFrameInfo.renderPose;
|
||||||
|
|
||||||
|
@ -167,7 +172,7 @@ void OculusBaseDisplayPlugin::updatePresentPose() {
|
||||||
ovrTrackingState trackingState;
|
ovrTrackingState trackingState;
|
||||||
_currentPresentFrameInfo.sensorSampleTime = ovr_GetTimeInSeconds();
|
_currentPresentFrameInfo.sensorSampleTime = ovr_GetTimeInSeconds();
|
||||||
_currentPresentFrameInfo.predictedDisplayTime = ovr_GetPredictedDisplayTime(_session, 0);
|
_currentPresentFrameInfo.predictedDisplayTime = ovr_GetPredictedDisplayTime(_session, 0);
|
||||||
trackingState = ovr_GetTrackingState(_session, _currentRenderFrameInfo.predictedDisplayTime, ovrFalse);
|
trackingState = ovr::getTrackingState(_currentRenderFrameInfo.predictedDisplayTime);
|
||||||
_currentPresentFrameInfo.presentPose = ovr::toGlm(trackingState.HeadPose.ThePose);
|
_currentPresentFrameInfo.presentPose = ovr::toGlm(trackingState.HeadPose.ThePose);
|
||||||
_currentPresentFrameInfo.renderPose = _currentPresentFrameInfo.presentPose;
|
_currentPresentFrameInfo.renderPose = _currentPresentFrameInfo.presentPose;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,4 +48,5 @@ protected:
|
||||||
ovrViewScaleDesc _viewScaleDesc;
|
ovrViewScaleDesc _viewScaleDesc;
|
||||||
// ovrLayerEyeFovDepth _depthLayer;
|
// ovrLayerEyeFovDepth _depthLayer;
|
||||||
bool _hmdMounted { false };
|
bool _hmdMounted { false };
|
||||||
|
bool _visible { true };
|
||||||
};
|
};
|
||||||
|
|
|
@ -134,6 +134,10 @@ void OculusDisplayPlugin::hmdPresent() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_visible) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PROFILE_RANGE_EX(render, __FUNCTION__, 0xff00ff00, (uint64_t)_currentFrame->frameIndex)
|
PROFILE_RANGE_EX(render, __FUNCTION__, 0xff00ff00, (uint64_t)_currentFrame->frameIndex)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -195,6 +199,10 @@ void OculusDisplayPlugin::hmdPresent() {
|
||||||
|
|
||||||
if (!OVR_SUCCESS(result)) {
|
if (!OVR_SUCCESS(result)) {
|
||||||
qWarning(oculusLog) << "Failed to present" << ovr::getError();
|
qWarning(oculusLog) << "Failed to present" << ovr::getError();
|
||||||
|
if (result == ovrError_DisplayLost) {
|
||||||
|
qWarning(oculusLog) << "Display lost, shutting down";
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int compositorDroppedFrames = 0;
|
static int compositorDroppedFrames = 0;
|
||||||
|
|
|
@ -81,6 +81,18 @@ private:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef OCULUS_APP_ID
|
||||||
|
if (qApp->property(hifi::properties::OCULUS_STORE).toBool()) {
|
||||||
|
if (ovr_PlatformInitializeWindows(OCULUS_APP_ID) != ovrPlatformInitialize_Success) {
|
||||||
|
qCWarning(oculusLog) << "Unable to initialize the platform for entitlement check - fail the check" << ovr::getError();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
qCDebug(oculusLog) << "Performing Oculus Platform entitlement check";
|
||||||
|
ovr_Entitlement_GetIsViewerEntitled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ovrGraphicsLuid luid;
|
ovrGraphicsLuid luid;
|
||||||
if (!OVR_SUCCESS(ovr_Create(&session, &luid))) {
|
if (!OVR_SUCCESS(ovr_Create(&session, &luid))) {
|
||||||
qCWarning(oculusLog) << "Failed to acquire Oculus session" << ovr::getError();
|
qCWarning(oculusLog) << "Failed to acquire Oculus session" << ovr::getError();
|
||||||
|
@ -141,18 +153,24 @@ void ovr::withSession(const std::function<void(ovrSession)>& f) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ovrSessionStatus ovr::getStatus() {
|
ovrSessionStatus ovr::getStatus() {
|
||||||
|
ovrResult result;
|
||||||
|
return ovr::getStatus(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
ovrSessionStatus ovr::getStatus(ovrResult& result) {
|
||||||
ovrSessionStatus status{};
|
ovrSessionStatus status{};
|
||||||
withSession([&](ovrSession session) {
|
withSession([&](ovrSession session) {
|
||||||
if (!OVR_SUCCESS(ovr_GetSessionStatus(session, &status))) {
|
result = ovr_GetSessionStatus(session, &status);
|
||||||
|
if (!OVR_SUCCESS(result)) {
|
||||||
qCWarning(oculusLog) << "Failed to get session status" << ovr::getError();
|
qCWarning(oculusLog) << "Failed to get session status" << ovr::getError();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
ovrTrackingState ovr::getTrackingState() {
|
ovrTrackingState ovr::getTrackingState(double absTime, ovrBool latencyMarker) {
|
||||||
ovrTrackingState result{};
|
ovrTrackingState result{};
|
||||||
withSession([&](ovrSession session) { result = ovr_GetTrackingState(session, 0, ovrFalse); });
|
withSession([&](ovrSession session) { result = ovr_GetTrackingState(session, absTime, latencyMarker); });
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,28 +294,22 @@ controller::Pose hifi::ovr::toControllerPose(ovrHandType hand,
|
||||||
return pose;
|
return pose;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME These should be moved to an oculusPlatform plugin, they don't interact with the controller or session state
|
bool hifi::ovr::handleOVREvents() {
|
||||||
#if 0
|
|
||||||
void handleOVREvents() {
|
|
||||||
updateSessionStatus(true);
|
|
||||||
|
|
||||||
#ifdef OCULUS_APP_ID
|
#ifdef OCULUS_APP_ID
|
||||||
|
|
||||||
if (qApp->property(hifi::properties::OCULUS_STORE).toBool()) {
|
if (qApp->property(hifi::properties::OCULUS_STORE).toBool()) {
|
||||||
// pop messages to see if we got a return for an entitlement check
|
// pop messages to see if we got a return for an entitlement check
|
||||||
ovrMessageHandle message = ovr_PopMessage();
|
ovrMessageHandle message = ovr_PopMessage();
|
||||||
|
|
||||||
while (message) {
|
while (message) {
|
||||||
switch (ovr_Message_GetType(message)) {
|
switch (ovr_Message_GetType(message)) {
|
||||||
case ovrMessage_Entitlement_GetIsViewerEntitled:
|
case ovrMessage_Entitlement_GetIsViewerEntitled: {
|
||||||
{
|
|
||||||
if (!ovr_Message_IsError(message)) {
|
if (!ovr_Message_IsError(message)) {
|
||||||
// this viewer is entitled, no need to flag anything
|
// this viewer is entitled, no need to flag anything
|
||||||
qCDebug(oculus) << "Oculus Platform entitlement check succeeded, proceeding normally";
|
qCDebug(oculusLog) << "Oculus Platform entitlement check succeeded, proceeding normally";
|
||||||
} else {
|
} else {
|
||||||
// we failed the entitlement check, set our flag so the app can stop
|
// we failed the entitlement check, quit
|
||||||
qCDebug(oculus) << "Oculus Platform entitlement check failed, app will now quit" << OCULUS_APP_ID;
|
qCDebug(oculusLog) << "Oculus Platform entitlement check failed, app will now quit" << OCULUS_APP_ID;
|
||||||
_quitRequested = true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -310,17 +322,5 @@ void handleOVREvents() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OCULUS_APP_ID
|
|
||||||
if (qApp->property(hifi::properties::OCULUS_STORE).toBool()) {
|
|
||||||
if (ovr_PlatformInitializeWindows(OCULUS_APP_ID) != ovrPlatformInitialize_Success) {
|
|
||||||
// we were unable to initialize the platform for entitlement check - fail the check
|
|
||||||
_quitRequested = true;
|
|
||||||
} else {
|
|
||||||
qCDebug(oculusLog) << "Performing Oculus Platform entitlement check";
|
|
||||||
ovr_Entitlement_GetIsViewerEntitled();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -27,8 +27,10 @@ struct ovr {
|
||||||
static void releaseRenderSession(ovrSession session);
|
static void releaseRenderSession(ovrSession session);
|
||||||
static void withSession(const std::function<void(ovrSession)>& f);
|
static void withSession(const std::function<void(ovrSession)>& f);
|
||||||
static ovrSessionStatus getStatus();
|
static ovrSessionStatus getStatus();
|
||||||
static ovrTrackingState getTrackingState();
|
static ovrSessionStatus getStatus(ovrResult& result);
|
||||||
|
static ovrTrackingState getTrackingState(double absTime = 0.0, ovrBool latencyMarker = ovrFalse);
|
||||||
static QString getError();
|
static QString getError();
|
||||||
|
static bool handleOVREvents();
|
||||||
|
|
||||||
static inline bool quitRequested() { return quitRequested(getStatus()); }
|
static inline bool quitRequested() { return quitRequested(getStatus()); }
|
||||||
static inline bool reorientRequested() { return reorientRequested(getStatus()); }
|
static inline bool reorientRequested() { return reorientRequested(getStatus()); }
|
||||||
|
@ -36,6 +38,8 @@ struct ovr {
|
||||||
static inline bool hasInputFocus() { return hasInputFocus(getStatus()); }
|
static inline bool hasInputFocus() { return hasInputFocus(getStatus()); }
|
||||||
|
|
||||||
static inline bool quitRequested(const ovrSessionStatus& status) { return status.ShouldQuit != ovrFalse; }
|
static inline bool quitRequested(const ovrSessionStatus& status) { return status.ShouldQuit != ovrFalse; }
|
||||||
|
static inline bool displayLost(const ovrSessionStatus& status) { return status.DisplayLost != ovrFalse; }
|
||||||
|
static inline bool isVisible(const ovrSessionStatus& status) { return status.IsVisible != ovrFalse; }
|
||||||
static inline bool reorientRequested(const ovrSessionStatus& status) { return status.ShouldRecenter != ovrFalse; }
|
static inline bool reorientRequested(const ovrSessionStatus& status) { return status.ShouldRecenter != ovrFalse; }
|
||||||
static inline bool hmdMounted(const ovrSessionStatus& status) { return status.HmdMounted != ovrFalse; }
|
static inline bool hmdMounted(const ovrSessionStatus& status) { return status.HmdMounted != ovrFalse; }
|
||||||
static inline bool hasInputFocus(const ovrSessionStatus& status) { return status.HasInputFocus != ovrFalse; }
|
static inline bool hasInputFocus(const ovrSessionStatus& status) { return status.HasInputFocus != ovrFalse; }
|
||||||
|
|
Loading…
Reference in a new issue