diff --git a/GPU/Software/Rasterizer.cpp b/GPU/Software/Rasterizer.cpp index dbb53dea76..94faed8610 100644 --- a/GPU/Software/Rasterizer.cpp +++ b/GPU/Software/Rasterizer.cpp @@ -927,6 +927,10 @@ void DrawTriangleSlice( const Vec3 v1_c1 = Vec3::FromRGB(v1.color1); const Vec3 v2_c1 = Vec3::FromRGB(v2.color1); + const Vec4 v0_z4 = Vec4::AssignToAll(v0.screenpos.z).Cast(); + const Vec4 v1_z4 = Vec4::AssignToAll(v1.screenpos.z).Cast(); + const Vec4 v2_z4 = Vec4::AssignToAll(v2.screenpos.z).Cast(); + for (int64_t curY = minY; curY <= maxY; curY += SCREEN_SCALE_FACTOR * 2, w0_base = e0.StepY(w0_base), w1_base = e1.StepY(w1_base), @@ -970,7 +974,7 @@ void DrawTriangleSlice( z = Vec4::AssignToAll(v2.screenpos.z); } else { // Z is interpolated pretty much directly. - Vec4 zfloats = w0.Cast() * v0.screenpos.z + w1.Cast() * v1.screenpos.z + w2.Cast() * v2.screenpos.z; + Vec4 zfloats = w0.Cast() * v0_z4 + w1.Cast() * v1_z4 + w2.Cast() * v2_z4; z = (zfloats * wsum_recip).Cast(); }