From d42642edd21c27792bc55ad44a6f6cf6b5f9ad93 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 24 Jun 2023 22:17:11 -0700 Subject: [PATCH] softgpu: Improve Z interpolation SIMD. --- GPU/Software/Rasterizer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/GPU/Software/Rasterizer.cpp b/GPU/Software/Rasterizer.cpp index dbb53dea7648..94faed861065 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(); }