diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 49d05c834f..423b74bd27 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -42,6 +42,7 @@ static std::map pspKeys; static int vr3DGeometryCount = 0; static long vrCompat[VR_COMPAT_MAX]; +static bool vrFlatGame = false; static float vrMatrix[VR_MATRIX_COUNT][16]; static bool vrMirroring[VR_MIRRORING_COUNT]; @@ -647,8 +648,12 @@ bool StartVRRender() { VR_SetConfigFloat(VR_CONFIG_CANVAS_ASPECT, 480.0f / 272.0f); if (g_Config.bEnableVR && !pspKeys[CTRL_SCREEN] && (appMode == VR_GAME_MODE) && (vr3DGeometryCount > 15)) { VR_SetConfig(VR_CONFIG_MODE, stereo ? VR_MODE_STEREO_6DOF : VR_MODE_MONO_6DOF); + vrFlatGame = false; } else { VR_SetConfig(VR_CONFIG_MODE, stereo ? VR_MODE_STEREO_SCREEN : VR_MODE_MONO_SCREEN); + if (IsGameVRScene()) { + vrFlatGame = true; + } } vr3DGeometryCount /= 2; @@ -693,11 +698,19 @@ bool IsMultiviewSupported() { return false; } +bool IsFlatVRGame() { + return vrFlatGame; +} + bool IsFlatVRScene() { int vrMode = VR_GetConfig(VR_CONFIG_MODE); return (vrMode == VR_MODE_MONO_SCREEN) || (vrMode == VR_MODE_STEREO_SCREEN); } +bool IsGameVRScene() { + return (appMode == VR_GAME_MODE) || (appMode == VR_DIALOG_MODE); +} + bool Is2DVRObject(float* projMatrix, bool ortho) { // Quick analyze if the object is in 2D diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index 5b31cc7a7f..dec2daaffa 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -50,7 +50,9 @@ void PostVRFrameRender(); int GetVRFBOIndex(); int GetVRPassesCount(); bool IsMultiviewSupported(); +bool IsFlatVRGame(); bool IsFlatVRScene(); +bool IsGameVRScene(); bool Is2DVRObject(float* projMatrix, bool ortho); void UpdateVRParams(float* projMatrix, float* viewMatrix); void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye); diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 7a104bc515..e931b65461 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -27,6 +27,7 @@ #include "Common/Math/lin/matrix4x4.h" #include "Common/Math/math_util.h" #include "Common/System/Display.h" +#include "Common/VR/PPSSPPVR.h" #include "Common/CommonTypes.h" #include "Common/StringUtils.h" #include "Core/Config.h" @@ -1452,6 +1453,21 @@ void FramebufferManagerCommon::CopyDisplayToOutput(bool reallyDirty) { float u1 = (480.0f + offsetX) / (float)vfb->bufferWidth; float v1 = (272.0f + offsetY) / (float)vfb->bufferHeight; + //clip the VR framebuffer to keep the aspect ratio + if (IsVREnabled() && !IsFlatVRGame() && !IsGameVRScene()) { + float aspect = 272.0f / 480.0f; + float clipY = 272.0f * (1.0f - aspect) / 2.0f; + v0 = (clipY + offsetY) / (float)vfb->bufferHeight; + v1 = (272.0f - clipY + offsetY) / (float)vfb->bufferHeight; + + //zoom inside + float zoom = 0.1f; + u0 += zoom / aspect; + u1 -= zoom / aspect; + v0 += zoom; + v1 -= zoom; + } + textureCache_->ForgetLastTexture(); int uvRotation = useBufferedRendering_ ? g_Config.iInternalScreenRotation : ROTATION_LOCKED_HORIZONTAL;