diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index e175fdaedf34..c86bb67a881c 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -53,7 +53,7 @@ static bool vrFlatForced = false; static bool vrFlatGame = false; static float vrMatrix[VR_MATRIX_COUNT][16]; static bool vrMirroring[VR_MIRRORING_COUNT]; -static int vrMirroringVariant = -1; +static int vrMirroringVariant = 0; static XrView vrView[2]; static void (*NativeAxis)(const AxisInput &axis); @@ -626,7 +626,6 @@ bool StartVRRender() { bool vrStereo = !PSP_CoreParameter().compat.vrCompat().ForceMono && g_Config.bEnableStereo; // Get VR status - vrMirroringVariant = -1; for (int eye = 0; eye < ovrMaxNumEyes; eye++) { vrView[eye] = VR_GetView(eye); } @@ -746,52 +745,42 @@ bool Is2DVRObject(float* projMatrix, bool ortho) { return identity || ortho; } -void UpdateVRParams(float* projMatrix, float* viewMatrix) { +void UpdateVRParams(float* projMatrix) { // Set mirroring of axes vrMirroring[VR_MIRRORING_AXIS_X] = projMatrix[0] < 0; vrMirroring[VR_MIRRORING_AXIS_Y] = projMatrix[5] < 0; vrMirroring[VR_MIRRORING_AXIS_Z] = projMatrix[10] > 0; - float up = 0; - for (int i = 4; i < 7; i++) { - up += viewMatrix[i]; - } - - int variant = projMatrix[0] < 0; + int variant = 1; + variant += projMatrix[0] < 0; variant += (projMatrix[5] < 0) << 1; variant += (projMatrix[10] < 0) << 2; - variant += (up < 0) << 3; + if (PSP_CoreParameter().compat.vrCompat().MirroringVariant > 0) { + variant = PSP_CoreParameter().compat.vrCompat().MirroringVariant; + } switch (variant) { - case 0: //e.g. ATV - case 8: //e,g, Flatout (dynamic objects only) + case 1: //e.g. ATV vrMirroring[VR_MIRRORING_PITCH] = false; vrMirroring[VR_MIRRORING_YAW] = true; vrMirroring[VR_MIRRORING_ROLL] = true; break; - case 1: //e.g. Tales of the World + case 2: //e.g. Tales of the World vrMirroring[VR_MIRRORING_PITCH] = false; vrMirroring[VR_MIRRORING_YAW] = false; vrMirroring[VR_MIRRORING_ROLL] = false; break; - case 2: //e.g.PES 2014 - case 3: //untested - case 5: //e.g Dante's Inferno - case 7: //untested - case 9: //untested - case 10: //untested - case 11: //untested - case 13: //untested - case 15: //untested + case 3: //e.g.PES 2014 + case 4: //untested + case 6: //e.g Dante's Inferno + case 8: //untested vrMirroring[VR_MIRRORING_PITCH] = true; vrMirroring[VR_MIRRORING_YAW] = true; vrMirroring[VR_MIRRORING_ROLL] = false; break; - case 4: //e.g. Assassins Creed - case 6: //e.g. Ghost in the shell - case 12: //e.g. GTA Vice City - case 14: //untested + case 5: //e.g. Assassins Creed + case 7: //e.g. Ghost in the shell vrMirroring[VR_MIRRORING_PITCH] = true; vrMirroring[VR_MIRRORING_YAW] = false; vrMirroring[VR_MIRRORING_ROLL] = true; diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index 9d11523a967b..9ece2f2ab875 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -56,7 +56,7 @@ bool IsFlatVRGame(); bool IsFlatVRScene(); bool IsGameVRScene(); bool Is2DVRObject(float* projMatrix, bool ortho); -void UpdateVRParams(float* projMatrix, float* viewMatrix); +void UpdateVRParams(float* projMatrix); void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye); void UpdateVRView(float* leftEye, float* rightEye); void UpdateVRViewMatrices(); diff --git a/Core/Compatibility.cpp b/Core/Compatibility.cpp index 578bcdec3ae4..af2c5300c7c6 100644 --- a/Core/Compatibility.cpp +++ b/Core/Compatibility.cpp @@ -137,6 +137,7 @@ 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, "MirroringVariant", &vrCompat_.MirroringVariant); CheckSetting(iniFile, gameID, "Skyplane", &vrCompat_.Skyplane); CheckSetting(iniFile, gameID, "UnitsPerMeter", &vrCompat_.UnitsPerMeter); @@ -159,3 +160,9 @@ void Compatibility::CheckSetting(IniFile &iniFile, const std::string &gameID, co iniFile.Get(option, gameID.c_str(), &value, "0"); *flag = stof(value); } + +void Compatibility::CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, int *flag) { + std::string value; + iniFile.Get(option, gameID.c_str(), &value, "0"); + *flag = stof(value); +} diff --git a/Core/Compatibility.h b/Core/Compatibility.h index 6bbdc3353ce1..5042735768b2 100644 --- a/Core/Compatibility.h +++ b/Core/Compatibility.h @@ -107,6 +107,7 @@ struct VRCompat { bool ForceMono; bool ForceFlatScreen; bool IdentityViewHack; + int MirroringVariant; bool Skyplane; float UnitsPerMeter; }; @@ -132,6 +133,7 @@ class Compatibility { void CheckVRSettings(IniFile &iniFile, const std::string &gameID); void CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, bool *flag); void CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, float *value); + void CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, int *value); CompatFlags flags_{}; VRCompat vrCompat_{}; diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 9b7bcc82ad0b..fd49d4409252 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -356,6 +356,8 @@ static inline bool GuessVRDrawingHUD(bool is2D, bool flatScreen) { else if (gstate.isClearModeDepthMask()) hud = false; //HUD texture has to contain alpha channel else if (!gstate.isTextureAlphaUsed()) hud = false; + //HUD texture cannot be in 5551 format + else if (gstate.getTextureFormat() == GETextureFormat::GE_TFMT_5551) hud = false; //HUD texture cannot be in CLUT16 format else if (gstate.getTextureFormat() == GETextureFormat::GE_TFMT_CLUT16) hud = false; //HUD texture cannot be in CLUT32 format @@ -427,6 +429,7 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, bool useBufferedRenderin } else { UpdateVRProjection(gstate.projMatrix, leftEyeMatrix.m, rightEyeMatrix.m); } + UpdateVRParams(gstate.projMatrix); FlipProjMatrix(leftEyeMatrix, useBufferedRendering); FlipProjMatrix(rightEyeMatrix, useBufferedRendering); @@ -564,14 +567,13 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, bool useBufferedRenderin if (dirty & DIRTY_WORLDMATRIX) { SetMatrix4x3(render_, &u_world, gstate.worldMatrix); } - if ((dirty & DIRTY_VIEWMATRIX) || IsVREnabled()) { + if (dirty & DIRTY_VIEWMATRIX) { if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { float leftEyeView[16]; float rightEyeView[16]; ConvertMatrix4x3To4x4Transposed(leftEyeView, gstate.viewMatrix); ConvertMatrix4x3To4x4Transposed(rightEyeView, gstate.viewMatrix); if (!is2D) { - UpdateVRParams(gstate.projMatrix, leftEyeView); UpdateVRView(leftEyeView, rightEyeView); } render_->SetUniformM4x4Stereo("u_view", &u_view, leftEyeView, rightEyeView); diff --git a/assets/compatvr.ini b/assets/compatvr.ini index bad7368d924e..015a9e1cf62c 100644 --- a/assets/compatvr.ini +++ b/assets/compatvr.ini @@ -84,7 +84,7 @@ ULUS10105 = true [IdentityViewHack] -# Disables head tracking for render passes where view matrix is Identity +# Disables head tracking for render passes where view matrix is identity # Sonic Rivals 1 ULES00622 = true @@ -95,6 +95,16 @@ ULES00940 = true ULUS10323 = true +[MirroringVariant] +# Forces mirroring of the view matrix + +# Tony Hawk's Underground 2 Remix +ULES00033 = 3 +ULES00034 = 3 +ULES00035 = 3 +ULUS10014 = 3 + + [Skyplane] # Workaround to remove the background skyplane and add clearing framebuffer with a fog color.