diff --git a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp index 2e6e748a38..751240bb2e 100644 --- a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp +++ b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp @@ -3,6 +3,7 @@ #include "VideoBackends/Software/SWVertexLoader.h" +#include #include #include @@ -78,6 +79,10 @@ void SWVertexLoader::DrawCurrentBatch(u32 base_index, u32 num_indices, u32 base_ SetFormat(); ParseVertex(VertexLoaderManager::GetCurrentVertexFormat()->GetVertexDeclaration(), index); + // At least the position transform uses round-to-zero. + const auto round_mode = std::fegetround(); + std::fesetround(FE_TOWARDZERO); + // transform this vertex so that it can be used for rasterization (outVertex) OutputVertexData* outVertex = m_setup_unit.GetVertex(); TransformUnit::TransformPosition(&m_vertex, outVertex); @@ -85,6 +90,8 @@ void SWVertexLoader::DrawCurrentBatch(u32 base_index, u32 num_indices, u32 base_ TransformUnit::TransformColor(&m_vertex, outVertex); TransformUnit::TransformTexCoord(&m_vertex, outVertex); + std::fesetround(round_mode); + // assemble and rasterize the primitive m_setup_unit.SetupVertex(); diff --git a/Source/Core/VideoBackends/Software/TransformUnit.cpp b/Source/Core/VideoBackends/Software/TransformUnit.cpp index 6fcf42df9e..83a81ee324 100644 --- a/Source/Core/VideoBackends/Software/TransformUnit.cpp +++ b/Source/Core/VideoBackends/Software/TransformUnit.cpp @@ -61,8 +61,7 @@ static void MultipleVec3Perspective(const Vec3& vec, const Projection::Raw& proj { result.x = proj[0] * vec.x + proj[1] * vec.z; result.y = proj[2] * vec.y + proj[3] * vec.z; - // result.z = (proj[4] * vec.z + proj[5]); - result.z = (proj[4] * vec.z + proj[5]) * (1.0f - (float)1e-7); + result.z = proj[4] * vec.z + proj[5]; result.w = -vec.z; }