From 0060a14fa78f9c5a7d860aa2b0946e3613af7d65 Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 2 Dec 2022 20:48:35 +0100 Subject: [PATCH 1/8] OpenXR - Adjust the render resolution for VR --- GPU/Common/PresentationCommon.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index 5980bbb95e..5e495c44bd 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -914,7 +914,10 @@ void PresentationCommon::CalculateRenderResolution(int *width, int *height, int } } - if (g_Config.IsPortrait()) { + if (IsVREnabled()) { + *width = 480 * zoom; + *height = 480 * zoom; + } else if (g_Config.IsPortrait()) { *width = 272 * zoom; *height = 480 * zoom; } else { From 353bdc2d3d3d46406d92e30f7c01765f04701cfb Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 2 Dec 2022 20:57:50 +0100 Subject: [PATCH 2/8] OpenXR - Default config updated --- Core/Config.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 40e3478d3f..5f8cf990d9 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -644,6 +644,9 @@ static int DefaultInternalResolution() { #if defined(USING_WIN_UI) || defined(USING_QT_UI) return 0; #else + if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_VR) { + return 4; + } int longestDisplaySide = std::max(System_GetPropertyInt(SYSPROP_DISPLAY_XRES), System_GetPropertyInt(SYSPROP_DISPLAY_YRES)); int scale = longestDisplaySide >= 1000 ? 2 : 1; INFO_LOG(G3D, "Longest display side: %d pixels. Choosing scale %d", longestDisplaySide, scale); @@ -887,7 +890,7 @@ static ConfigSetting graphicsSettings[] = { ReportedConfigSetting("HighQualityDepth", &g_Config.bHighQualityDepth, true, true, true), ReportedConfigSetting("FrameSkip", &g_Config.iFrameSkip, 0, true, true), ReportedConfigSetting("FrameSkipType", &g_Config.iFrameSkipType, 0, true, true), - ReportedConfigSetting("AutoFrameSkip", &g_Config.bAutoFrameSkip, false, true, true), + ReportedConfigSetting("AutoFrameSkip", &g_Config.bAutoFrameSkip, IsVREnabled(), true, true), ConfigSetting("StereoRendering", &g_Config.bStereoRendering, false, true, true), ConfigSetting("StereoToMonoShader", &g_Config.sStereoToMonoShader, "RedBlue", true, true), ConfigSetting("FrameRate", &g_Config.iFpsLimit1, 0, true, true), @@ -1214,7 +1217,7 @@ static ConfigSetting vrSettings[] = { ConfigSetting("VRCameraDistance", &g_Config.fCameraDistance, 0.0f), ConfigSetting("VRCameraHeight", &g_Config.fCameraHeight, 0.0f), ConfigSetting("VRCameraSide", &g_Config.fCameraSide, 0.0f), - ConfigSetting("VRCanvasDistance", &g_Config.fCanvasDistance, 6.0f), + ConfigSetting("VRCanvasDistance", &g_Config.fCanvasDistance, 12.0f), ConfigSetting("VRFieldOfView", &g_Config.fFieldOfViewPercentage, 100.0f), ConfigSetting("VRHeadUpDisplayScale", &g_Config.fHeadUpDisplayScale, 0.3f), ConfigSetting("VRMotionLength", &g_Config.fMotionLength, 0.5f), From 38c4774f4a28b9b1d66804edea04a676a2141661 Mon Sep 17 00:00:00 2001 From: Lubos Date: Sun, 4 Dec 2022 18:14:05 +0100 Subject: [PATCH 3/8] Change package of the Android VR builds --- android/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 3ee429208b..94dfd3bf80 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -151,7 +151,7 @@ android { } } vr_pico { - applicationId 'org.ppsspp.ppsspp' + applicationId 'org.ppsspp.ppssppvr' dimension "variant" externalNativeBuild { cmake { @@ -171,7 +171,7 @@ android { } } vr_quest { - applicationId 'org.ppsspp.ppsspp' + applicationId 'org.ppsspp.ppssppvr' dimension "variant" externalNativeBuild { cmake { From 0aeb2074288c1a635f025b9fd685a92f91d907bf Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 7 Dec 2022 21:40:13 +0100 Subject: [PATCH 4/8] OpenXR - Separate config for VR build --- Core/Config.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 8d7606e554..e4f893d54a 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1324,9 +1324,11 @@ void Config::Reload() { // really think of any other legit uses). void Config::UpdateIniLocation(const char *iniFileName, const char *controllerIniFilename) { const bool useIniFilename = iniFileName != nullptr && strlen(iniFileName) > 0; - iniFilename_ = FindConfigFile(useIniFilename ? iniFileName : "ppsspp.ini"); + const char *ppssppIniFilename = IsVREnabled() ? "ppssppvr.ini" : "ppsspp.ini"; + iniFilename_ = FindConfigFile(useIniFilename ? iniFileName : ppssppIniFilename); const bool useControllerIniFilename = controllerIniFilename != nullptr && strlen(controllerIniFilename) > 0; - controllerIniFilename_ = FindConfigFile(useControllerIniFilename ? controllerIniFilename : "controls.ini"); + const char *controlsIniFilename = IsVREnabled() ? "controlsvr.ini" : "controls.ini"; + controllerIniFilename_ = FindConfigFile(useControllerIniFilename ? controllerIniFilename : controlsIniFilename); } void Config::Load(const char *iniFileName, const char *controllerIniFilename) { @@ -1819,7 +1821,8 @@ bool Config::deleteGameConfig(const std::string& pGameId) { } Path Config::getGameConfigFile(const std::string &pGameId) { - std::string iniFileName = pGameId + "_ppsspp.ini"; + const char *ppssppIniFilename = IsVREnabled() ? "_ppssppvr.ini" : "_ppsspp.ini"; + std::string iniFileName = pGameId + ppssppIniFilename; Path iniFileNameFull = FindConfigFile(iniFileName); return iniFileNameFull; From 3cc979859c57d95986c8f6b84ff223eea0d72c02 Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 10 Dec 2022 21:31:39 +0100 Subject: [PATCH 5/8] OpenXR - Release keys on activation of camera adjust --- Common/VR/PPSSPPVR.cpp | 30 ++++++++++++++++++++++++++++-- Common/VR/PPSSPPVR.h | 4 ++-- android/jni/app-android.cpp | 3 ++- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 98e2ee7ec0..a6a7d0c0e3 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -46,6 +46,10 @@ static bool vrFlatGame = false; static float vrMatrix[VR_MATRIX_COUNT][16]; static bool vrMirroring[VR_MIRRORING_COUNT]; +static bool(*NativeAxis)(const AxisInput &axis); +static bool(*NativeKey)(const KeyInput &key); +static bool(*NativeTouch)(const TouchInput &touch); + /* ================================================================================ @@ -185,6 +189,12 @@ void GetVRResolutionPerEye(int* width, int* height) { } } +void SetVRCallbacks(bool(*axis)(const AxisInput &axis), bool(*key)(const KeyInput &key), bool(*touch)(const TouchInput &touch)) { + NativeAxis = axis; + NativeKey = key; + NativeTouch = touch; +} + /* ================================================================================ @@ -197,8 +207,7 @@ void SetVRAppMode(VRAppMode mode) { appMode = mode; } -void UpdateVRInput(bool(*NativeAxis)(const AxisInput &axis), bool(*NativeKey)(const KeyInput &key), - bool(*NativeTouch)(const TouchInput &touch), bool haptics, float dp_xscale, float dp_yscale) { +void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) { //axis if (pspKeys[VIRTKEY_VR_CAMERA_ADJUST]) { AxisInput axis = {}; @@ -405,6 +414,7 @@ bool UpdateVRAxis(const AxisInput &axis) { bool UpdateVRKeys(const KeyInput &key) { //store key value std::vector nativeKeys; + bool wasCameraAdjustOn = pspKeys[VIRTKEY_VR_CAMERA_ADJUST]; if (KeyMap::KeyToPspButton(key.deviceId, key.keyCode, &nativeKeys)) { for (int& nativeKey : nativeKeys) { pspKeys[nativeKey] = key.flags & KEY_DOWN; @@ -425,6 +435,22 @@ bool UpdateVRKeys(const KeyInput &key) { } } + // Release keys on enabling camera adjust + if (!wasCameraAdjustOn && pspKeys[VIRTKEY_VR_CAMERA_ADJUST]) { + KeyInput keyUp; + keyUp.deviceId = key.deviceId; + keyUp.flags = KEY_UP; + + pspKeys[VIRTKEY_VR_CAMERA_ADJUST] = false; + for (auto& pspKey : pspKeys) { + if (pspKey.second) { + keyUp.keyCode = pspKey.first; + NativeKey(keyUp); + } + } + pspKeys[VIRTKEY_VR_CAMERA_ADJUST] = true; + } + // Reset camera adjust if (pspKeys[VIRTKEY_VR_CAMERA_ADJUST] && pspKeys[VIRTKEY_VR_CAMERA_RESET]) { g_Config.fCameraHeight = 0; diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index dec2daaffa..009726a948 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -29,11 +29,11 @@ bool IsVREnabled(); void InitVROnAndroid(void* vm, void* activity, const char* system, int version, const char* name); void EnterVR(bool firstStart, void* vulkanContext); void GetVRResolutionPerEye(int* width, int* height); +void SetVRCallbacks(bool(*axis)(const AxisInput &axis), bool(*key)(const KeyInput &key), bool(*touch)(const TouchInput &touch)); // VR input integration void SetVRAppMode(VRAppMode mode); -void UpdateVRInput(bool(*NativeAxis)(const AxisInput &axis), bool(*NativeKey)(const KeyInput &key), - bool(*NativeTouch)(const TouchInput &touch), bool haptics, float dp_xscale, float dp_yscale); +void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale); bool UpdateVRAxis(const AxisInput &axis); bool UpdateVRKeys(const KeyInput &key); diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index b144bc8dcd..ee0cf4c198 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -770,6 +770,7 @@ retry: if (IsVREnabled()) { Version gitVer(PPSSPP_GIT_VERSION); InitVROnAndroid(gJvm, nativeActivity, systemName.c_str(), gitVer.ToInteger(), "PPSSPP"); + SetVRCallbacks(NativeAxis, NativeKey, NativeTouch); } } @@ -1079,7 +1080,7 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayRender(JNIEnv *env, } if (IsVREnabled()) { - UpdateVRInput(NativeAxis, NativeKey, NativeTouch, g_Config.bHapticFeedback, dp_xscale, dp_yscale); + UpdateVRInput(g_Config.bHapticFeedback, dp_xscale, dp_yscale); FinishVRRender(); } } From 28c115c4bafaa33d4686c92af6668f64768650d4 Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 10 Dec 2022 21:36:39 +0100 Subject: [PATCH 6/8] OpenXR - Allow to put HUD out of the screen --- Common/VR/PPSSPPVR.cpp | 2 +- UI/GameSettingsScreen.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index a6a7d0c0e3..46dca63f4b 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -327,7 +327,7 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) { case JOYSTICK_AXIS_Z: if (axis.second < -0.75f) g_Config.fHeadUpDisplayScale -= 0.01f; if (axis.second > 0.75f) g_Config.fHeadUpDisplayScale += 0.01f; - g_Config.fHeadUpDisplayScale = clampFloat(g_Config.fHeadUpDisplayScale, 0.2f, 1.0f); + g_Config.fHeadUpDisplayScale = clampFloat(g_Config.fHeadUpDisplayScale, 0.2f, 1.5f); break; case JOYSTICK_AXIS_RZ: if (axis.second > 0.75f) g_Config.fCameraDistance -= 0.1f; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 3e2a3229a2..9ca9ce1282 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1091,7 +1091,7 @@ void GameSettingsScreen::CreateViews() { vrSettings->Add(new ItemHeader(vr->T("VR camera"))); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCanvasDistance, 1.0f, 15.0f, vr->T("Distance to 2D menus and scenes"), 1.0f, screenManager(), "")); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fFieldOfViewPercentage, 100.0f, 200.0f, vr->T("Field of view scale"), 10.0f, screenManager(), vr->T("% of native FoV"))); - vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fHeadUpDisplayScale, 0.2f, 1.0f, vr->T("Heads-up display scale"), 0.1f, screenManager(), "")); + vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fHeadUpDisplayScale, 0.2f, 1.5f, vr->T("Heads-up display scale"), 0.1f, screenManager(), "")); vrSettings->Add(new ItemHeader(vr->T("VR controllers"))); vrSettings->Add(new CheckBox(&g_Config.bEnableMotions, vr->T("Map controller movements to keys"))); From c2d6e05dd1524270257a398a8417d3501f3aa013 Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 10 Dec 2022 21:57:02 +0100 Subject: [PATCH 7/8] OpenXR - Default UI saturation adjusted --- Core/Config.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 31ed1956d8..864568f2ef 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -516,6 +516,19 @@ static bool DefaultEnableStateUndo() { return true; } +static float DefaultUISaturation() { + std::string device = System_GetProperty(SYSPROP_NAME); + if (IsVREnabled() && startsWith(device, "Pico")) { + return 1.5f; + } else if (IsVREnabled() && startsWith(device, "Oculus")) { + return 1.25f; + } else if (IsVREnabled() && startsWith(device, "Meta")) { + return 1.25f; + } else { + return 1.0f; + } +} + struct ConfigSectionSettings { const char *section; ConfigSetting *settings; @@ -597,7 +610,7 @@ static ConfigSetting generalSettings[] = { ConfigSetting("BackgroundAnimation", &g_Config.iBackgroundAnimation, 1, true, false), ConfigSetting("UITint", &g_Config.fUITint, 0.0, true, false), - ConfigSetting("UISaturation", &g_Config.fUISaturation, 1.0, true, false), + ConfigSetting("UISaturation", &g_Config.fUISaturation, &DefaultUISaturation, true, false), #if defined(USING_WIN_UI) ConfigSetting("TopMost", &g_Config.bTopMost, false), From 58ad49b79cb8d8ed5a55a5c852609b26f63beabd Mon Sep 17 00:00:00 2001 From: Lubos Date: Sun, 11 Dec 2022 12:35:52 +0100 Subject: [PATCH 8/8] OpenXR - Default color correction adjusted --- Core/Config.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 864568f2ef..af4dd75c7f 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -517,16 +517,7 @@ static bool DefaultEnableStateUndo() { } static float DefaultUISaturation() { - std::string device = System_GetProperty(SYSPROP_NAME); - if (IsVREnabled() && startsWith(device, "Pico")) { - return 1.5f; - } else if (IsVREnabled() && startsWith(device, "Oculus")) { - return 1.25f; - } else if (IsVREnabled() && startsWith(device, "Meta")) { - return 1.25f; - } else { - return 1.0f; - } + return IsVREnabled() ? 1.5f : 1.0f; } struct ConfigSectionSettings { @@ -1420,15 +1411,27 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { } } - auto postShaderSetting = iniFile.GetOrCreateSection("PostShaderSetting")->ToMap(); + // Default values for post process shaders + bool postShadersInitialized = iniFile.HasSection("PostShaderList"); + Section *postShaderChain = iniFile.GetOrCreateSection("PostShaderList"); + Section *postShaderSetting = iniFile.GetOrCreateSection("PostShaderSetting"); + if (IsVREnabled() && !postShadersInitialized) { + postShaderChain->Set("PostShader1", "ColorCorrection"); + postShaderSetting->Set("ColorCorrectionSettingValue1",1.0f); + postShaderSetting->Set("ColorCorrectionSettingValue2",1.5f); + postShaderSetting->Set("ColorCorrectionSettingValue3",1.1f); + postShaderSetting->Set("ColorCorrectionSettingValue4",1.0f); + } + + // Load post process shader values mPostShaderSetting.clear(); - for (auto it : postShaderSetting) { + for (const auto& it : postShaderSetting->ToMap()) { mPostShaderSetting[it.first] = std::stof(it.second); } - auto postShaderChain = iniFile.GetOrCreateSection("PostShaderList")->ToMap(); + // Load post process shader names vPostShaderNames.clear(); - for (auto it : postShaderChain) { + for (const auto& it : postShaderChain->ToMap()) { if (it.second != "Off") vPostShaderNames.push_back(it.second); }