Commit 6d55ba73 by Sean Risser

Move calculation after clip check

This is to prevent undefined behavior if the calculation overflows. Moving the calculation won't cause issues with the clipping since the projected coordinates are not used in the clipping calculations. Bug chromium:979644 Change-Id: I5a6fba0f067d8d3ad310de573bacd2f68dfe4b78 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/34109 Presubmit-Ready: Sean Risser <srisser@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Tested-by: 's avatarSean Risser <srisser@google.com>
parent bc73bcb3
...@@ -1196,12 +1196,6 @@ namespace sw ...@@ -1196,12 +1196,6 @@ namespace sw
P[3].y -= Y; P[3].y -= Y;
C[3] = Clipper::ComputeClipFlags(P[3]); C[3] = Clipper::ComputeClipFlags(P[3]);
triangle.v1 = triangle.v0;
triangle.v2 = triangle.v0;
triangle.v1.projected.x += iround(16 * 0.5f * pSize);
triangle.v2.projected.y -= iround(16 * 0.5f * pSize) * (data.Hx16[0] > 0.0f ? 1 : -1); // Both Direct3D and OpenGL expect (0, 0) in the top-left corner
Polygon polygon(P, 4); Polygon polygon(P, 4);
if((C[0] & C[1] & C[2] & C[3]) == Clipper::CLIP_FINITE) if((C[0] & C[1] & C[2] & C[3]) == Clipper::CLIP_FINITE)
...@@ -1216,6 +1210,11 @@ namespace sw ...@@ -1216,6 +1210,11 @@ namespace sw
} }
} }
triangle.v1 = triangle.v0;
triangle.v2 = triangle.v0;
triangle.v1.projected.x += iround(16 * 0.5f * pSize);
triangle.v2.projected.y -= iround(16 * 0.5f * pSize) * (data.Hx16[0] > 0.0f ? 1 : -1); // Both Direct3D and OpenGL expect (0, 0) in the top-left corner
return setupRoutine(&primitive, &triangle, &polygon, &data); return setupRoutine(&primitive, &triangle, &polygon, &data);
} }
......
...@@ -2010,12 +2010,6 @@ namespace sw ...@@ -2010,12 +2010,6 @@ namespace sw
P[3].y -= Y; P[3].y -= Y;
C[3] = clipper->computeClipFlags(P[3]); C[3] = clipper->computeClipFlags(P[3]);
triangle.v1 = triangle.v0;
triangle.v2 = triangle.v0;
triangle.v1.X += iround(16 * 0.5f * pSize);
triangle.v2.Y -= iround(16 * 0.5f * pSize) * (data.Hx16[0] > 0.0f ? 1 : -1); // Both Direct3D and OpenGL expect (0, 0) in the top-left corner
Polygon polygon(P, 4); Polygon polygon(P, 4);
if((C[0] & C[1] & C[2] & C[3]) == Clipper::CLIP_FINITE) if((C[0] & C[1] & C[2] & C[3]) == Clipper::CLIP_FINITE)
...@@ -2030,6 +2024,11 @@ namespace sw ...@@ -2030,6 +2024,11 @@ namespace sw
} }
} }
triangle.v1 = triangle.v0;
triangle.v2 = triangle.v0;
triangle.v1.X += iround(16 * 0.5f * pSize);
triangle.v2.Y -= iround(16 * 0.5f * pSize) * (data.Hx16[0] > 0.0f ? 1 : -1); // Both Direct3D and OpenGL expect (0, 0) in the top-left corner
return setupRoutine(&primitive, &triangle, &polygon, &data); return setupRoutine(&primitive, &triangle, &polygon, &data);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment