From 0e2fd7c2a2ee05d94f55b019e58c84762bc4670d Mon Sep 17 00:00:00 2001 From: Lubos Date: Thu, 24 Nov 2022 19:17:00 +0100 Subject: [PATCH 01/11] OpenXR - Fix HUD in many games which breaks postprocess effects --- Common/VR/PPSSPPVR.cpp | 2 +- GPU/GLES/ShaderManagerGLES.cpp | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 423b74bd27..0fba20ac61 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -727,7 +727,7 @@ bool Is2DVRObject(float* projMatrix, bool ortho) { if (!identity && !ortho) { vr3DGeometryCount++; } - return identity; + return identity || ortho; } void UpdateVRParams(float* projMatrix, float* viewMatrix) { diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 7195bcd8af..aed35841f8 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -385,12 +385,11 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu // Set HUD mode if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { - bool is3D = gstate.isDepthWriteEnabled(); - bool hud = is2D && !is3D && !flatScreen && - gstate.isModeThrough() && //2D content requires orthographic projection + bool hud = is2D && !flatScreen && gstate.isAlphaBlendEnabled() && //2D content has to be blended !gstate.isLightingEnabled() && //2D content cannot be rendered with lights on - !gstate.isFogEnabled(); //2D content cannot be rendered with fog on + !gstate.isFogEnabled() && //2D content cannot be rendered with fog on + !gstate.isDepthWriteEnabled(); //This breaks minimap in GTA but works elsewhere if (hud) { float scale = 0.5f; render_->SetUniformF1(&u_scaleX, scale); From 5417e828de7f77c62c7ec314996e7f07fc24ade4 Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 25 Nov 2022 09:05:48 +0100 Subject: [PATCH 02/11] OpenXR - Do not rescale the postprocess effects --- GPU/GLES/ShaderManagerGLES.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index aed35841f8..446413014e 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -385,7 +385,8 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu // Set HUD mode if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { - bool hud = is2D && !flatScreen && + bool postprocess = ((gstate_c.curTextureWidth % 480 == 0) && (gstate_c.curTextureHeight % 272 == 0)) || gstate_c.textureFullAlpha; + bool hud = is2D && !flatScreen && !postprocess && gstate.isAlphaBlendEnabled() && //2D content has to be blended !gstate.isLightingEnabled() && //2D content cannot be rendered with lights on !gstate.isFogEnabled() && //2D content cannot be rendered with fog on From a58ea86318bd236d3b02c65cd715f86cfed1a225 Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 25 Nov 2022 09:18:16 +0100 Subject: [PATCH 03/11] OpenXR - HUD scale option added --- Core/Config.cpp | 1 + Core/Config.h | 1 + GPU/GLES/ShaderManagerGLES.cpp | 5 ++--- UI/GameSettingsScreen.cpp | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 35a05ba910..5ba047389d 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1214,6 +1214,7 @@ static ConfigSetting vrSettings[] = { ConfigSetting("VRCameraSide", &g_Config.fCameraSide, 0.0f), ConfigSetting("VRCanvasDistance", &g_Config.fCanvasDistance, 6.0f), ConfigSetting("VRFieldOfView", &g_Config.fFieldOfViewPercentage, 100.0f), + ConfigSetting("VRHeadUpDidplayScale", &g_Config.fHeadUpDidplayScale, 0.5f), ConfigSetting("VRMotionLength", &g_Config.fMotionLength, 0.5f), ConfigSetting(false), diff --git a/Core/Config.h b/Core/Config.h index af20f6289e..e99db82d10 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -471,6 +471,7 @@ public: float fCameraSide; float fCanvasDistance; float fFieldOfViewPercentage; + float fHeadUpDidplayScale; float fMotionLength; // Debugger diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 446413014e..5458342ad9 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -392,9 +392,8 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu !gstate.isFogEnabled() && //2D content cannot be rendered with fog on !gstate.isDepthWriteEnabled(); //This breaks minimap in GTA but works elsewhere if (hud) { - float scale = 0.5f; - render_->SetUniformF1(&u_scaleX, scale); - render_->SetUniformF1(&u_scaleY, scale / 480.0f * 272.0f); + render_->SetUniformF1(&u_scaleX, g_Config.fHeadUpDidplayScale); + render_->SetUniformF1(&u_scaleY, g_Config.fHeadUpDidplayScale / 480.0f * 272.0f); } else { render_->SetUniformF1(&u_scaleX, 1.0f); render_->SetUniformF1(&u_scaleY, 1.0f); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index ef7d5b6c3a..f444c0e23c 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1103,6 +1103,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.fHeadUpDidplayScale, 0.2f, 1.0f, vr->T("Head 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 08432dd4e1bee5fd7b3c862f989e5606416afa16 Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 25 Nov 2022 09:25:23 +0100 Subject: [PATCH 04/11] OpenXR - Camera controls adjust HUD instead of FOV --- Common/VR/PPSSPPVR.cpp | 6 +++--- Core/Config.cpp | 2 +- GPU/GLES/ShaderManagerGLES.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 0fba20ac61..7e9241042f 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -316,9 +316,9 @@ void UpdateVRInput(bool(*NativeAxis)(const AxisInput &axis), bool(*NativeKey)(co g_Config.fCameraHeight = clampFloat(g_Config.fCameraHeight, -50.0f, 50.0f); break; case JOYSTICK_AXIS_Z: - if (axis.second < -0.75f) g_Config.fFieldOfViewPercentage -= 1.0f; - if (axis.second > 0.75f) g_Config.fFieldOfViewPercentage += 1.0f; - g_Config.fFieldOfViewPercentage = clampFloat(g_Config.fFieldOfViewPercentage, 100.0f, 200.0f); + if (axis.second < -0.75f) g_Config.fHeadUpDidplayScale -= 0.01f; + if (axis.second > 0.75f) g_Config.fHeadUpDidplayScale += 0.01f; + g_Config.fHeadUpDidplayScale = clampFloat(g_Config.fHeadUpDidplayScale, 0.2f, 1.0f); break; case JOYSTICK_AXIS_RZ: if (axis.second > 0.75f) g_Config.fCameraDistance -= 0.1f; diff --git a/Core/Config.cpp b/Core/Config.cpp index 5ba047389d..49b2e953ba 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1214,7 +1214,7 @@ static ConfigSetting vrSettings[] = { ConfigSetting("VRCameraSide", &g_Config.fCameraSide, 0.0f), ConfigSetting("VRCanvasDistance", &g_Config.fCanvasDistance, 6.0f), ConfigSetting("VRFieldOfView", &g_Config.fFieldOfViewPercentage, 100.0f), - ConfigSetting("VRHeadUpDidplayScale", &g_Config.fHeadUpDidplayScale, 0.5f), + ConfigSetting("VRHeadUpDidplayScale", &g_Config.fHeadUpDidplayScale, 0.3f), ConfigSetting("VRMotionLength", &g_Config.fMotionLength, 0.5f), ConfigSetting(false), diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 5458342ad9..698e7afd49 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -392,8 +392,8 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu !gstate.isFogEnabled() && //2D content cannot be rendered with fog on !gstate.isDepthWriteEnabled(); //This breaks minimap in GTA but works elsewhere if (hud) { - render_->SetUniformF1(&u_scaleX, g_Config.fHeadUpDidplayScale); - render_->SetUniformF1(&u_scaleY, g_Config.fHeadUpDidplayScale / 480.0f * 272.0f); + render_->SetUniformF1(&u_scaleX, g_Config.fHeadUpDidplayScale * 480.0f / 272.0f); + render_->SetUniformF1(&u_scaleY, g_Config.fHeadUpDidplayScale); } else { render_->SetUniformF1(&u_scaleX, 1.0f); render_->SetUniformF1(&u_scaleY, 1.0f); From 3aae47c331961ad6d9ad81a5803e7c1ae9f11d45 Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 25 Nov 2022 09:31:44 +0100 Subject: [PATCH 05/11] OpenXR - Add a TODO for follow-up PR --- 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 698e7afd49..064abbeeb7 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -390,7 +390,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu gstate.isAlphaBlendEnabled() && //2D content has to be blended !gstate.isLightingEnabled() && //2D content cannot be rendered with lights on !gstate.isFogEnabled() && //2D content cannot be rendered with fog on - !gstate.isDepthWriteEnabled(); //This breaks minimap in GTA but works elsewhere + !gstate.isDepthWriteEnabled(); //TODO:this needs to be improved! (GTA-LC, Tekken 6, Sonic Rivals) if (hud) { render_->SetUniformF1(&u_scaleX, g_Config.fHeadUpDidplayScale * 480.0f / 272.0f); render_->SetUniformF1(&u_scaleY, g_Config.fHeadUpDidplayScale); From 38fa30b42ddc094bcd4aac57a2aa032c8e4bd1d5 Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 25 Nov 2022 09:43:12 +0100 Subject: [PATCH 06/11] OpenXR - Camera adjust reset fixed --- Common/VR/PPSSPPVR.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 7e9241042f..4152eb3896 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -430,7 +430,7 @@ bool UpdateVRKeys(const KeyInput &key) { g_Config.fCameraHeight = 0; g_Config.fCameraSide = 0; g_Config.fCameraDistance = 0; - g_Config.fFieldOfViewPercentage = 100; + g_Config.fHeadUpDidplayScale = 0.3f; } //block keys by camera adjust From 0b089dd1e54eaac06c53c2328dba3dbad1c1b75f Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 25 Nov 2022 11:08:49 +0100 Subject: [PATCH 07/11] OpenXR - HUD support improved --- GPU/GLES/ShaderManagerGLES.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 064abbeeb7..d9c6ebea42 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -385,12 +385,16 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu // Set HUD mode if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { - bool postprocess = ((gstate_c.curTextureWidth % 480 == 0) && (gstate_c.curTextureHeight % 272 == 0)) || gstate_c.textureFullAlpha; + bool postprocess = gstate.isClearModeColorMask() || gstate_c.textureFullAlpha || + //rendering framebuffer on screen + (gstate_c.curTextureWidth % 480 == 0) && (gstate_c.curTextureHeight % 272 == 0) || + //rendering far plane + (fabs(gstate.viewMatrix[9]) > 1000) || (fabs(gstate.viewMatrix[11]) > 1000); + bool hud = is2D && !flatScreen && !postprocess && gstate.isAlphaBlendEnabled() && //2D content has to be blended !gstate.isLightingEnabled() && //2D content cannot be rendered with lights on - !gstate.isFogEnabled() && //2D content cannot be rendered with fog on - !gstate.isDepthWriteEnabled(); //TODO:this needs to be improved! (GTA-LC, Tekken 6, Sonic Rivals) + !gstate.isFogEnabled(); //2D content cannot be rendered with fog on if (hud) { render_->SetUniformF1(&u_scaleX, g_Config.fHeadUpDidplayScale * 480.0f / 272.0f); render_->SetUniformF1(&u_scaleY, g_Config.fHeadUpDidplayScale); From 390ee28cd90543f9f1d99ca5df0b3172a02db0b5 Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 25 Nov 2022 12:01:51 +0100 Subject: [PATCH 08/11] OpenXR - HUD fixes --- GPU/GLES/ShaderManagerGLES.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index d9c6ebea42..29ba2ad227 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -385,16 +385,29 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu // Set HUD mode if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { - bool postprocess = gstate.isClearModeColorMask() || gstate_c.textureFullAlpha || - //rendering framebuffer on screen - (gstate_c.curTextureWidth % 480 == 0) && (gstate_c.curTextureHeight % 272 == 0) || - //rendering far plane - (fabs(gstate.viewMatrix[9]) > 1000) || (fabs(gstate.viewMatrix[11]) > 1000); - bool hud = is2D && !flatScreen && !postprocess && - gstate.isAlphaBlendEnabled() && //2D content has to be blended - !gstate.isLightingEnabled() && //2D content cannot be rendered with lights on - !gstate.isFogEnabled(); //2D content cannot be rendered with fog on + bool hud = true; + //HUD cannot be rendered in flatscreen + if (flatScreen) hud = false; + //HUD has to be 2D + else if (!is2D) hud = false; + //HUD has to be blended + else if (!gstate.isAlphaBlendEnabled()) hud = false; + //HUD cannot be rendered with clear color mask + else if (gstate.isClearModeColorMask()) hud = false; + //HUD cannot be rendered with fog on + else if (gstate.isFogEnabled()) hud = false; + //HUD cannot be rendered with lights on + else if (gstate.isLightingEnabled()) hud = false; + //HUD texture has to contain alpha channel + else if (!gstate.isTextureAlphaUsed()) hud = false; + //HUD cannot have full alpha + else if (gstate_c.textureFullAlpha) hud = false; + //HUD cannot render FB screenshot + else if (gstate_c.curTextureHeight == 272) hud = false; + //HUD cannot render far plane + if ((fabs(gstate.viewMatrix[9]) > 1000) || (fabs(gstate.viewMatrix[11]) > 1000)) hud = false; + if (hud) { render_->SetUniformF1(&u_scaleX, g_Config.fHeadUpDidplayScale * 480.0f / 272.0f); render_->SetUniformF1(&u_scaleY, g_Config.fHeadUpDidplayScale); From 1ef036d07cf62d309eafb016c320179054dd3d89 Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 25 Nov 2022 13:28:45 +0100 Subject: [PATCH 09/11] OpenXR - Farplane distance limit adjusted --- 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 29ba2ad227..99d3393955 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -406,7 +406,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu //HUD cannot render FB screenshot else if (gstate_c.curTextureHeight == 272) hud = false; //HUD cannot render far plane - if ((fabs(gstate.viewMatrix[9]) > 1000) || (fabs(gstate.viewMatrix[11]) > 1000)) hud = false; + if ((fabs(gstate.viewMatrix[9]) > 100) || (fabs(gstate.viewMatrix[11]) > 100)) hud = false; if (hud) { render_->SetUniformF1(&u_scaleX, g_Config.fHeadUpDidplayScale * 480.0f / 272.0f); From b2d809f4cdafd12a576326edd141128c3d316364 Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 25 Nov 2022 15:58:51 +0100 Subject: [PATCH 10/11] typos fixed --- Common/VR/PPSSPPVR.cpp | 8 ++++---- Core/Config.cpp | 2 +- Core/Config.h | 2 +- GPU/GLES/ShaderManagerGLES.cpp | 4 ++-- UI/GameSettingsScreen.cpp | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 4152eb3896..0a0ac9dd2f 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -316,9 +316,9 @@ void UpdateVRInput(bool(*NativeAxis)(const AxisInput &axis), bool(*NativeKey)(co g_Config.fCameraHeight = clampFloat(g_Config.fCameraHeight, -50.0f, 50.0f); break; case JOYSTICK_AXIS_Z: - if (axis.second < -0.75f) g_Config.fHeadUpDidplayScale -= 0.01f; - if (axis.second > 0.75f) g_Config.fHeadUpDidplayScale += 0.01f; - g_Config.fHeadUpDidplayScale = clampFloat(g_Config.fHeadUpDidplayScale, 0.2f, 1.0f); + 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); break; case JOYSTICK_AXIS_RZ: if (axis.second > 0.75f) g_Config.fCameraDistance -= 0.1f; @@ -430,7 +430,7 @@ bool UpdateVRKeys(const KeyInput &key) { g_Config.fCameraHeight = 0; g_Config.fCameraSide = 0; g_Config.fCameraDistance = 0; - g_Config.fHeadUpDidplayScale = 0.3f; + g_Config.fHeadUpDisplayScale = 0.3f; } //block keys by camera adjust diff --git a/Core/Config.cpp b/Core/Config.cpp index 49b2e953ba..cb17b4881e 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1214,7 +1214,7 @@ static ConfigSetting vrSettings[] = { ConfigSetting("VRCameraSide", &g_Config.fCameraSide, 0.0f), ConfigSetting("VRCanvasDistance", &g_Config.fCanvasDistance, 6.0f), ConfigSetting("VRFieldOfView", &g_Config.fFieldOfViewPercentage, 100.0f), - ConfigSetting("VRHeadUpDidplayScale", &g_Config.fHeadUpDidplayScale, 0.3f), + ConfigSetting("VRHeadUpDisplayScale", &g_Config.fHeadUpDisplayScale, 0.3f), ConfigSetting("VRMotionLength", &g_Config.fMotionLength, 0.5f), ConfigSetting(false), diff --git a/Core/Config.h b/Core/Config.h index e99db82d10..8b517889b0 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -471,7 +471,7 @@ public: float fCameraSide; float fCanvasDistance; float fFieldOfViewPercentage; - float fHeadUpDidplayScale; + float fHeadUpDisplayScale; float fMotionLength; // Debugger diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 99d3393955..f94e849d74 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -409,8 +409,8 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu if ((fabs(gstate.viewMatrix[9]) > 100) || (fabs(gstate.viewMatrix[11]) > 100)) hud = false; if (hud) { - render_->SetUniformF1(&u_scaleX, g_Config.fHeadUpDidplayScale * 480.0f / 272.0f); - render_->SetUniformF1(&u_scaleY, g_Config.fHeadUpDidplayScale); + render_->SetUniformF1(&u_scaleX, g_Config.fHeadUpDisplayScale * 480.0f / 272.0f); + render_->SetUniformF1(&u_scaleY, g_Config.fHeadUpDisplayScale); } else { render_->SetUniformF1(&u_scaleX, 1.0f); render_->SetUniformF1(&u_scaleY, 1.0f); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index f444c0e23c..111c4cbd37 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1103,7 +1103,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.fHeadUpDidplayScale, 0.2f, 1.0f, vr->T("Head up display scale"), 0.1f, screenManager(), "")); + vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fHeadUpDisplayScale, 0.2f, 1.0f, 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 aa66b93124d9c1c45a08ad9d5b798de2354ed5ea Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 25 Nov 2022 16:05:30 +0100 Subject: [PATCH 11/11] MOve VR heuristics into a standalone method --- GPU/GLES/ShaderManagerGLES.cpp | 52 ++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index f94e849d74..d36a68fe7a 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -353,6 +353,33 @@ static inline void FlipProjMatrix(Matrix4x4 &in, bool useBufferedRendering) { } } +static inline bool GuessVRDrawingHUD(bool is2D, bool flatScreen) { + + bool hud = true; + //HUD cannot be rendered in flatscreen + if (flatScreen) hud = false; + //HUD has to be 2D + else if (!is2D) hud = false; + //HUD has to be blended + else if (!gstate.isAlphaBlendEnabled()) hud = false; + //HUD cannot be rendered with clear color mask + else if (gstate.isClearModeColorMask()) hud = false; + //HUD cannot be rendered with fog on + else if (gstate.isFogEnabled()) hud = false; + //HUD cannot be rendered with lights on + else if (gstate.isLightingEnabled()) hud = false; + //HUD texture has to contain alpha channel + else if (!gstate.isTextureAlphaUsed()) hud = false; + //HUD cannot have full alpha + else if (gstate_c.textureFullAlpha) hud = false; + //HUD cannot render FB screenshot + else if (gstate_c.curTextureHeight == 272) hud = false; + //HUD cannot render far plane + else if ((fabs(gstate.viewMatrix[9]) > 100) || (fabs(gstate.viewMatrix[11]) > 100)) hud = false; + + return hud; +} + void LinkedShader::use(const ShaderID &VSID) { render_->BindProgram(program); // Note that we no longer track attr masks here - we do it for the input layouts instead. @@ -385,30 +412,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu // Set HUD mode if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { - - bool hud = true; - //HUD cannot be rendered in flatscreen - if (flatScreen) hud = false; - //HUD has to be 2D - else if (!is2D) hud = false; - //HUD has to be blended - else if (!gstate.isAlphaBlendEnabled()) hud = false; - //HUD cannot be rendered with clear color mask - else if (gstate.isClearModeColorMask()) hud = false; - //HUD cannot be rendered with fog on - else if (gstate.isFogEnabled()) hud = false; - //HUD cannot be rendered with lights on - else if (gstate.isLightingEnabled()) hud = false; - //HUD texture has to contain alpha channel - else if (!gstate.isTextureAlphaUsed()) hud = false; - //HUD cannot have full alpha - else if (gstate_c.textureFullAlpha) hud = false; - //HUD cannot render FB screenshot - else if (gstate_c.curTextureHeight == 272) hud = false; - //HUD cannot render far plane - if ((fabs(gstate.viewMatrix[9]) > 100) || (fabs(gstate.viewMatrix[11]) > 100)) hud = false; - - if (hud) { + if (GuessVRDrawingHUD(is2D, flatScreen)) { render_->SetUniformF1(&u_scaleX, g_Config.fHeadUpDisplayScale * 480.0f / 272.0f); render_->SetUniformF1(&u_scaleY, g_Config.fHeadUpDisplayScale); } else {