diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 5cd35fc59012..92e00f898a3f 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 < 7; 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: //e.g. ATV + case 1: //untested + vrMirroring[VR_MIRRORING_PITCH] = false; + vrMirroring[VR_MIRRORING_YAW] = true; + vrMirroring[VR_MIRRORING_ROLL] = true; + break; + 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: //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; + break; + default: + assert(false); + std::exit(1); } } } 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; }