[Mesa-dev] [PATCH 1/2] llvmpipe: drop scissor planes early if the tri is fully inside it

sroland at vmware.com sroland at vmware.com
Sun Jan 17 19:33:32 PST 2016


From: Roland Scheidegger <sroland at vmware.com>

If the tri is fully inside the scissor (or rather, we just use the
bounding box of the tri for the comparison), then we can drop these
additional scissor "planes" early.
(We could, of course, not even emit the scissor planes in this case
in the first place, but for now it seems easier to do it in the
binning code as we have already calculated the intersection of the
scissor/fb and tri bounding box there.)
The math actually appears to be slightly iffy due to bounding boxes
being rounded, but it doesn't matter in the end.
Those scissor rects are costly - the 4 planes from the scissor are
already more expensive to calculate than the 3 planes from the tri itself,
and it also prevents us from using the specialized raster code for small
tris.
This helps openarena performance by about 8% or so. Of course, it helps
there that while openarena often enables scissoring (and even moves the
scissor rect around) I have not seen a single tri actually hit the
scissor rect, ever.
---
 src/gallium/drivers/llvmpipe/lp_setup_tri.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
index aa24176..0694f5b 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
@@ -758,6 +758,17 @@ lp_setup_bin_triangle( struct lp_setup_context *setup,
    u_rect_find_intersection(&setup->draw_regions[viewport_index],
                             &trimmed_box);
 
+   if (nr_planes >= 7 && !memcmp(&trimmed_box, bbox, sizeof(trimmed_box))) {
+      /*
+       * If the trimmed box and the tri bbox is the same, scissor is fully
+       * outside tri. Hence, simply drop the additional planes (which are
+       * actually expensive to evaluate, scissor probably shouldn't be
+       * ordinary planes in the first place), which also means we can use
+       * the special small tri rasterization code.
+       */
+      nr_planes -= 4;
+   }
+
    /* Determine which tile(s) intersect the triangle's bounding box
     */
    if (dx < TILE_SIZE)
-- 
2.1.4



More information about the mesa-dev mailing list