From 5addc772581da5d94b86b78de3dd7833100907b4 Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 1 Apr 2023 18:05:18 +0200 Subject: [PATCH 1/5] OpenXR - Invalid operation removed --- Common/VR/PPSSPPVR.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 30df54352c..a6fa162606 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -708,7 +708,6 @@ bool StartVRRender() { float M[16]; XrQuaternionf_ToMatrix4f(&invView.orientation, M); - memcpy(&M, M, sizeof(float) * 16); // Apply 6Dof head movement if (!flatScreen && g_Config.bEnable6DoF && !g_Config.bHeadRotationEnabled && (g_Config.iCameraPitch == 0)) { From ee3e53581d241c0eb9597961ed1b4e108a1c67fb Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 1 Apr 2023 18:36:14 +0200 Subject: [PATCH 2/5] OpenXR - Camera lags fixed --- GPU/GLES/ShaderManagerGLES.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 13a0f33761..884fea84d4 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -565,7 +565,7 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, bool useBufferedRenderin if (dirty & DIRTY_WORLDMATRIX) { SetMatrix4x3(render_, &u_world, gstate.worldMatrix); } - if (dirty & DIRTY_VIEWMATRIX) { + if ((dirty & DIRTY_VIEWMATRIX) || IsVREnabled()) { if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { float leftEyeView[16]; float rightEyeView[16]; From e7bbe322cdee4221e96d6a51cc127c6593ae4fb4 Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 1 Apr 2023 18:58:46 +0200 Subject: [PATCH 3/5] OpenXR - Stereoscopy math better --- Common/VR/PPSSPPVR.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index a6fa162606..a7515d8fb4 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -743,18 +743,18 @@ bool StartVRRender() { M[11] += side.z; } // Stereoscopy - if (matrix == VR_VIEW_MATRIX_RIGHT_EYE) { - float dx = fabs(invViewTransform[1].position.x - invViewTransform[0].position.x); - float dy = fabs(invViewTransform[1].position.y - invViewTransform[0].position.y); - float dz = fabs(invViewTransform[1].position.z - invViewTransform[0].position.z); - float ipd = sqrt(dx * dx + dy * dy + dz * dz); - XrVector3f separation = {ipd * scale, 0.0f, 0.0f}; - separation = XrQuaternionf_Rotate(invView.orientation, separation); - separation = XrVector3f_ScalarMultiply(separation, vrMirroring[VR_MIRRORING_AXIS_Z] ? -1.0f : 1.0f); - M[3] -= separation.x; - M[7] -= separation.y; - M[11] -= separation.z; - } + bool mirrored = vrMirroring[VR_MIRRORING_AXIS_Z] ^ (matrix == VR_VIEW_MATRIX_LEFT_EYE); + float dx = fabs(invViewTransform[1].position.x - invViewTransform[0].position.x); + float dy = fabs(invViewTransform[1].position.y - invViewTransform[0].position.y); + float dz = fabs(invViewTransform[1].position.z - invViewTransform[0].position.z); + float ipd = sqrt(dx * dx + dy * dy + dz * dz); + XrVector3f separation = {ipd * scale * 0.5f, 0.0f, 0.0f}; + separation = XrQuaternionf_Rotate(invView.orientation, separation); + separation = XrVector3f_ScalarMultiply(separation, mirrored ? -1.0f : 1.0f); + M[3] -= separation.x; + M[7] -= separation.y; + M[11] -= separation.z; + memcpy(vrMatrix[matrix], M, sizeof(float) * 16); } else { assert(false); From b59a0728f6fcace817d8d4a05f1400e91dad3610 Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 1 Apr 2023 19:10:18 +0200 Subject: [PATCH 4/5] OpenXR - Stereo separation only when enabled --- Common/VR/PPSSPPVR.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index a7515d8fb4..683f3e43bb 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -743,17 +743,19 @@ bool StartVRRender() { M[11] += side.z; } // Stereoscopy - bool mirrored = vrMirroring[VR_MIRRORING_AXIS_Z] ^ (matrix == VR_VIEW_MATRIX_LEFT_EYE); - float dx = fabs(invViewTransform[1].position.x - invViewTransform[0].position.x); - float dy = fabs(invViewTransform[1].position.y - invViewTransform[0].position.y); - float dz = fabs(invViewTransform[1].position.z - invViewTransform[0].position.z); - float ipd = sqrt(dx * dx + dy * dy + dz * dz); - XrVector3f separation = {ipd * scale * 0.5f, 0.0f, 0.0f}; - separation = XrQuaternionf_Rotate(invView.orientation, separation); - separation = XrVector3f_ScalarMultiply(separation, mirrored ? -1.0f : 1.0f); - M[3] -= separation.x; - M[7] -= separation.y; - M[11] -= separation.z; + if (g_Config.bEnableStereo) { + bool mirrored = vrMirroring[VR_MIRRORING_AXIS_Z] ^ (matrix == VR_VIEW_MATRIX_RIGHT_EYE); + float dx = fabs(invViewTransform[1].position.x - invViewTransform[0].position.x); + float dy = fabs(invViewTransform[1].position.y - invViewTransform[0].position.y); + float dz = fabs(invViewTransform[1].position.z - invViewTransform[0].position.z); + float ipd = sqrt(dx * dx + dy * dy + dz * dz); + XrVector3f separation = {ipd * scale * 0.5f, 0.0f, 0.0f}; + separation = XrQuaternionf_Rotate(invView.orientation, separation); + separation = XrVector3f_ScalarMultiply(separation, mirrored ? -1.0f : 1.0f); + M[3] += separation.x; + M[7] += separation.y; + M[11] += separation.z; + } memcpy(vrMatrix[matrix], M, sizeof(float) * 16); } else { From de462f481f436df34f7fbf89aaca8de964ce5325 Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 1 Apr 2023 19:48:53 +0200 Subject: [PATCH 5/5] OpenXR - Disable stereo in Motorstorm --- Common/VR/PPSSPPVR.cpp | 16 ++++++++++------ Core/Compatibility.cpp | 1 + Core/Compatibility.h | 1 + assets/compatvr.ini | 12 ++++++++++++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 683f3e43bb..21fd41ea1e 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -613,6 +613,11 @@ bool StartVRRender() { if (VR_InitFrame(VR_GetEngine())) { + // VR flags + bool vrIncompatibleGame = PSP_CoreParameter().compat.vrCompat().ForceFlatScreen; + bool vrScene = !vrFlatForced && (g_Config.bManualForceVR || (vr3DGeometryCount > 15)); + bool vrStereo = !PSP_CoreParameter().compat.vrCompat().ForceMono && g_Config.bEnableStereo; + // Get OpenXR view and fov XrFovf fov = {}; XrPosef invViewTransform[2]; @@ -743,7 +748,7 @@ bool StartVRRender() { M[11] += side.z; } // Stereoscopy - if (g_Config.bEnableStereo) { + if (vrStereo) { bool mirrored = vrMirroring[VR_MIRRORING_AXIS_Z] ^ (matrix == VR_VIEW_MATRIX_RIGHT_EYE); float dx = fabs(invViewTransform[1].position.x - invViewTransform[0].position.x); float dy = fabs(invViewTransform[1].position.y - invViewTransform[0].position.y); @@ -764,14 +769,12 @@ bool StartVRRender() { } // Decide if the scene is 3D or not - bool vrIncompatibleGame = PSP_CoreParameter().compat.vrCompat().ForceFlatScreen; - bool vrScene = !vrFlatForced && (g_Config.bManualForceVR || (vr3DGeometryCount > 15)); VR_SetConfigFloat(VR_CONFIG_CANVAS_ASPECT, 480.0f / 272.0f); if (g_Config.bEnableVR && !vrIncompatibleGame && (appMode == VR_GAME_MODE) && vrScene) { - VR_SetConfig(VR_CONFIG_MODE, g_Config.bEnableStereo ? VR_MODE_STEREO_6DOF : VR_MODE_MONO_6DOF); + VR_SetConfig(VR_CONFIG_MODE, vrStereo ? VR_MODE_STEREO_6DOF : VR_MODE_MONO_6DOF); vrFlatGame = false; } else { - VR_SetConfig(VR_CONFIG_MODE, g_Config.bEnableStereo ? VR_MODE_STEREO_SCREEN : VR_MODE_MONO_SCREEN); + VR_SetConfig(VR_CONFIG_MODE, vrStereo ? VR_MODE_STEREO_SCREEN : VR_MODE_MONO_SCREEN); if (IsGameVRScene()) { vrFlatGame = true; } @@ -808,7 +811,8 @@ int GetVRFBOIndex() { } int GetVRPassesCount() { - if (!IsMultiviewSupported() && g_Config.bEnableStereo) { + bool vrStereo = !PSP_CoreParameter().compat.vrCompat().ForceMono && g_Config.bEnableStereo; + if (!IsMultiviewSupported() && vrStereo) { return 2; } else { return 1; diff --git a/Core/Compatibility.cpp b/Core/Compatibility.cpp index c8dd83ef47..da7746cfca 100644 --- a/Core/Compatibility.cpp +++ b/Core/Compatibility.cpp @@ -134,6 +134,7 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) { void Compatibility::CheckVRSettings(IniFile &iniFile, const std::string &gameID) { CheckSetting(iniFile, gameID, "ForceFlatScreen", &vrCompat_.ForceFlatScreen); + CheckSetting(iniFile, gameID, "ForceMono", &vrCompat_.ForceMono); CheckSetting(iniFile, gameID, "IdentityViewHack", &vrCompat_.IdentityViewHack); CheckSetting(iniFile, gameID, "Skyplane", &vrCompat_.Skyplane); CheckSetting(iniFile, gameID, "UnitsPerMeter", &vrCompat_.UnitsPerMeter); diff --git a/Core/Compatibility.h b/Core/Compatibility.h index 9e9f0d00cb..3fdf284631 100644 --- a/Core/Compatibility.h +++ b/Core/Compatibility.h @@ -103,6 +103,7 @@ struct CompatFlags { }; struct VRCompat { + bool ForceMono; bool ForceFlatScreen; bool IdentityViewHack; bool Skyplane; diff --git a/assets/compatvr.ini b/assets/compatvr.ini index 55c2f84291..c4154298af 100644 --- a/assets/compatvr.ini +++ b/assets/compatvr.ini @@ -60,6 +60,18 @@ ULUS10541 = true ULUS10581 = true +[ForceMono] +# Forces disabled stereo as the game rendering cannot be called twice + +# MotorStorm: Arctic Edge +NPJG00047 = true +UCAS40266 = true +UCES01250 = true +UCJS10104 = true +UCKS45124 = true +UCUS98743 = true + + [IdentityViewHack] # Disables head tracking for render passes where view matrix is Identity