From 72d197fc47fdcbb8adbb9edc6ff2d498d832295d Mon Sep 17 00:00:00 2001 From: Lubos Date: Thu, 10 Nov 2022 18:44:11 +0100 Subject: [PATCH 1/3] Revert "OpenXR - Disable range culling properly" This reverts commit d1dabd40eea94240fa7d9ba05ca50b8ef6b78757. --- GPU/Common/VertexShaderGenerator.cpp | 2 +- GPU/GPUCommon.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index 4b42670c8185..70fc803dd1c2 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -1304,7 +1304,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag WRITE(p, " }\n"); } - if (vertexRangeCulling) { + if (vertexRangeCulling && !gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { WRITE(p, " vec3 projPos = outPos.xyz / outPos.w;\n"); WRITE(p, " float projZ = (projPos.z - u_depthRange.z) * u_depthRange.w;\n"); diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 183b71c4dcc0..17de04fc52f9 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -3338,7 +3338,7 @@ u32 GPUCommon::CheckGPUFeatures() const { bool canClipOrCull = draw_->GetDeviceCaps().clipDistanceSupported || draw_->GetDeviceCaps().cullDistanceSupported; bool canDiscardVertex = draw_->GetBugs().Has(Draw::Bugs::BROKEN_NAN_IN_CONDITIONAL); - if (!gstate_c.Use(GPU_USE_VIRTUAL_REALITY) && (canClipOrCull || canDiscardVertex)) { + if (canClipOrCull || canDiscardVertex) { // We'll dynamically use the parts that are supported, to reduce artifacts as much as possible. features |= GPU_USE_VS_RANGE_CULLING; } From d32b6ceff0c4243bdfe8025925feef3fd25ff712 Mon Sep 17 00:00:00 2001 From: Lubos Date: Thu, 10 Nov 2022 20:45:34 +0100 Subject: [PATCH 2/3] OpenXR - Get all mirroring variants --- Common/VR/PPSSPPVR.cpp | 71 ++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 23 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 5cd35fc59012..92a187d390a5 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -485,13 +485,11 @@ bool StartVRRender() { } // create updated quaternion - if (mx + my + mz < 3 - EPSILON) { - XrVector3f rotation = XrQuaternionf_ToEulerAngles(invView.orientation); - XrQuaternionf pitch = XrQuaternionf_CreateFromVectorAngle({1, 0, 0}, mx * ToRadians(rotation.x)); - XrQuaternionf yaw = XrQuaternionf_CreateFromVectorAngle({0, 1, 0}, my * ToRadians(rotation.y)); - XrQuaternionf roll = XrQuaternionf_CreateFromVectorAngle({0, 0, 1}, mz * ToRadians(rotation.z)); - invView.orientation = XrQuaternionf_Multiply(roll, XrQuaternionf_Multiply(pitch, yaw)); - } + XrVector3f rotation = XrQuaternionf_ToEulerAngles(invView.orientation); + XrQuaternionf pitch = XrQuaternionf_CreateFromVectorAngle({1, 0, 0}, mx * ToRadians(rotation.x)); + XrQuaternionf yaw = XrQuaternionf_CreateFromVectorAngle({0, 1, 0}, my * ToRadians(rotation.y)); + XrQuaternionf roll = XrQuaternionf_CreateFromVectorAngle({0, 0, 1}, mz * ToRadians(rotation.z)); + invView.orientation = XrQuaternionf_Multiply(roll, XrQuaternionf_Multiply(pitch, yaw)); float M[16]; XrQuaternionf_ToMatrix4f(&invView.orientation, M); @@ -661,22 +659,49 @@ void UpdateVRParams(float* projMatrix, float* viewMatrix) { vrMirroring[VR_MIRRORING_AXIS_X] = projMatrix[0] < 0; vrMirroring[VR_MIRRORING_AXIS_Y] = projMatrix[5] < 0; vrMirroring[VR_MIRRORING_AXIS_Z] = projMatrix[10] > 0; - if ((projMatrix[0] < 0) && (projMatrix[10] < 0)) { //e.g. Dante's inferno - vrMirroring[VR_MIRRORING_PITCH] = true; - vrMirroring[VR_MIRRORING_YAW] = true; - vrMirroring[VR_MIRRORING_ROLL] = false; - } else if (projMatrix[10] < 0) { //e.g. GTA - Liberty city - vrMirroring[VR_MIRRORING_PITCH] = false; - vrMirroring[VR_MIRRORING_YAW] = false; - vrMirroring[VR_MIRRORING_ROLL] = false; - } else if (projMatrix[5] < 0) { //e.g. PES 2014 - vrMirroring[VR_MIRRORING_PITCH] = true; - vrMirroring[VR_MIRRORING_YAW] = true; - vrMirroring[VR_MIRRORING_ROLL] = false; - } else { //e.g. Lego Pirates - vrMirroring[VR_MIRRORING_PITCH] = false; - vrMirroring[VR_MIRRORING_YAW] = true; - vrMirroring[VR_MIRRORING_ROLL] = true; + + float up = 0; + for (int i = 4; i < 8; i++) { + up += viewMatrix[i]; + } + + int variant = projMatrix[0] < 0; + variant += (projMatrix[5] < 0) << 1; + variant += (projMatrix[10] < 0) << 2; + variant += (up < 0) << 3; + + switch (variant) { + case 0: + case 1: + vrMirroring[VR_MIRRORING_PITCH] = false; + vrMirroring[VR_MIRRORING_YAW] = true; + vrMirroring[VR_MIRRORING_ROLL] = true; + break; + case 2: + case 3: + case 5: + case 7: + case 8: + case 9: + case 10: + case 11: + case 13: + case 15: + vrMirroring[VR_MIRRORING_PITCH] = true; + vrMirroring[VR_MIRRORING_YAW] = true; + vrMirroring[VR_MIRRORING_ROLL] = false; + break; + case 4: + case 6: + case 12: + case 14: + vrMirroring[VR_MIRRORING_PITCH] = true; + vrMirroring[VR_MIRRORING_YAW] = false; + vrMirroring[VR_MIRRORING_ROLL] = true; + break; + default: + assert(false); + std::exit(1); } } } From 97d63a321cd3730c8ab16db81e6a3fb310f282cf Mon Sep 17 00:00:00 2001 From: Lubos Date: Thu, 10 Nov 2022 21:30:15 +0100 Subject: [PATCH 3/3] OpenXR - Test mirroring over 30 various games --- Common/VR/PPSSPPVR.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 92a187d390a5..92e00f898a3f 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -661,7 +661,7 @@ void UpdateVRParams(float* projMatrix, float* viewMatrix) { vrMirroring[VR_MIRRORING_AXIS_Z] = projMatrix[10] > 0; float up = 0; - for (int i = 4; i < 8; i++) { + for (int i = 4; i < 7; i++) { up += viewMatrix[i]; } @@ -671,30 +671,30 @@ void UpdateVRParams(float* projMatrix, float* viewMatrix) { variant += (up < 0) << 3; switch (variant) { - case 0: - case 1: + case 0: //e.g. ATV + case 1: //untested vrMirroring[VR_MIRRORING_PITCH] = false; vrMirroring[VR_MIRRORING_YAW] = true; vrMirroring[VR_MIRRORING_ROLL] = true; break; - case 2: - case 3: - case 5: - case 7: - case 8: - case 9: - case 10: - case 11: - case 13: - case 15: + case 2: //e.g.PES 2014 + case 3: //untested + case 5: //e.g Dante's Inferno + case 7: //untested + case 8: //untested + case 9: //untested + case 10: //untested + case 11: //untested + case 13: //untested + case 15: //untested vrMirroring[VR_MIRRORING_PITCH] = true; vrMirroring[VR_MIRRORING_YAW] = true; vrMirroring[VR_MIRRORING_ROLL] = false; break; - case 4: - case 6: - case 12: - case 14: + case 4: //e.g. Assassins Creed + case 6: //e.g. Ghost in the shell + case 12: //e.g. GTA Vice City + case 14: //untested vrMirroring[VR_MIRRORING_PITCH] = true; vrMirroring[VR_MIRRORING_YAW] = false; vrMirroring[VR_MIRRORING_ROLL] = true;