OSDN Git Service

Optimize flat triangle edge rasterization.
authorNicolas Capens <capn@google.com>
Thu, 5 Jan 2017 15:11:01 +0000 (10:11 -0500)
committerNicolas Capens <capn@google.com>
Thu, 5 Jan 2017 20:14:07 +0000 (20:14 +0000)
Change-Id: Ibfd483ce3cba6ec036327b32cba1460d68f8c9e8
Reviewed-on: https://swiftshader-review.googlesource.com/3542
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
src/Shader/SetupRoutine.cpp

index c31bbec..ac65afa 100644 (file)
@@ -559,15 +559,8 @@ namespace sw
        {
                If(Ya != Yb)
                {
-                       Int xMin = *Pointer<Int>(data + OFFSET(DrawData,scissorX0));
-                       Int xMax = *Pointer<Int>(data + OFFSET(DrawData,scissorX1));
-
                        Bool swap = Yb < Ya;
 
-                       Pointer<Byte> leftEdge = primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->left);
-                       Pointer<Byte> rightEdge = primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->right);
-                       Pointer<Byte> edge = IfThenElse(swap, rightEdge, leftEdge);
-
                        Int X1 = IfThenElse(swap, Xb, Xa);
                        Int X2 = IfThenElse(swap, Xa, Xb);
                        Int Y1 = IfThenElse(swap, Yb, Ya);
@@ -578,6 +571,13 @@ namespace sw
 
                        If(y1 < y2)
                        {
+                               Int xMin = *Pointer<Int>(data + OFFSET(DrawData,scissorX0));
+                               Int xMax = *Pointer<Int>(data + OFFSET(DrawData,scissorX1));
+
+                               Pointer<Byte> leftEdge = primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->left);
+                               Pointer<Byte> rightEdge = primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->right);
+                               Pointer<Byte> edge = IfThenElse(swap, rightEdge, leftEdge);
+
                                // Deltas
                                Int DX12 = X2 - X1;
                                Int DY12 = Y2 - Y1;