Skip to content

Commit

Permalink
Merge pull request #17619 from unknownbrackets/softgpu-opt-z
Browse files Browse the repository at this point in the history
softgpu: Improve Z interpolation SIMD
  • Loading branch information
hrydgard authored Jun 25, 2023
2 parents 72af8f6 + d42642e commit ec92675
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion GPU/Software/Rasterizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,10 @@ void DrawTriangleSlice(
const Vec3<int> v1_c1 = Vec3<int>::FromRGB(v1.color1);
const Vec3<int> v2_c1 = Vec3<int>::FromRGB(v2.color1);

const Vec4<float> v0_z4 = Vec4<int>::AssignToAll(v0.screenpos.z).Cast<float>();
const Vec4<float> v1_z4 = Vec4<int>::AssignToAll(v1.screenpos.z).Cast<float>();
const Vec4<float> v2_z4 = Vec4<int>::AssignToAll(v2.screenpos.z).Cast<float>();

for (int64_t curY = minY; curY <= maxY; curY += SCREEN_SCALE_FACTOR * 2,
w0_base = e0.StepY(w0_base),
w1_base = e1.StepY(w1_base),
Expand Down Expand Up @@ -967,7 +971,7 @@ void DrawTriangleSlice(
z = Vec4<int>::AssignToAll(v2.screenpos.z);
} else {
// Z is interpolated pretty much directly.
Vec4<float> zfloats = w0.Cast<float>() * v0.screenpos.z + w1.Cast<float>() * v1.screenpos.z + w2.Cast<float>() * v2.screenpos.z;
Vec4<float> zfloats = w0.Cast<float>() * v0_z4 + w1.Cast<float>() * v1_z4 + w2.Cast<float>() * v2_z4;
z = (zfloats * wsum_recip).Cast<int>();
}

Expand Down

0 comments on commit ec92675

Please sign in to comment.