From 519f235459b503c8dde442e6a25ab5eec79141b6 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 30 Aug 2021 13:56:03 +1000 Subject: [PATCH] llvmpipe/scissor: rewrite scissor planes interaction. This just changes the calcs to be cleaner and easier to interpret. Adjust the inclusive (x0/y0) by -1 like before, and then flip the sign for the correct direction. Add full pixel to the exclusive side after scaling, this is do show that this value is incorrect and the next patch fixes that taking multisample into account Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/drivers/llvmpipe/lp_setup.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index bbf52e93f86..031fc41b157 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -1779,30 +1779,38 @@ lp_setup_add_scissor_planes(const struct u_rect *scissor, * (easier to evaluate) to ordinary planes.) */ if (s_planes[0]) { + int x0 = scissor->x0 - 1; plane_s->dcdx = ~0U << 8; plane_s->dcdy = 0; - plane_s->c = (1-scissor->x0) << 8; + plane_s->c = x0 << 8; + plane_s->c = -plane_s->c; /* flip sign */ plane_s->eo = 1 << 8; plane_s++; } if (s_planes[1]) { + int x1 = scissor->x1; plane_s->dcdx = 1 << 8; plane_s->dcdy = 0; - plane_s->c = (scissor->x1+1) << 8; + plane_s->c = x1 << 8; + plane_s->c += 255; plane_s->eo = 0 << 8; plane_s++; } if (s_planes[2]) { + int y0 = scissor->y0 - 1; plane_s->dcdx = 0; plane_s->dcdy = 1 << 8; - plane_s->c = (1-scissor->y0) << 8; + plane_s->c = y0 << 8; + plane_s->c = -plane_s->c; /* flip sign */ plane_s->eo = 1 << 8; plane_s++; } if (s_planes[3]) { + int y1 = scissor->y1; plane_s->dcdx = 0; plane_s->dcdy = ~0U << 8; - plane_s->c = (scissor->y1+1) << 8; + plane_s->c = y1 << 8; + plane_s->c += 255; plane_s->eo = 0; plane_s++; }