From b7e2214b3c89490181685dded4480f2bd04d1990 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 15 Nov 2021 18:27:44 +0100 Subject: [PATCH] llvmpipe: adjust rounding for viewport scissoring Some apps may try to use a viewport adjusted by 0.5 pixels (among other things) to emulate d3d9 pixel center, and in this case we would end up with incorrect "fake scissor" box (shifted by 1 pixel), hence pixels being incorrectly scissored away when permit_linear_rasterizer is set (this happens even if the linear rasterizer is not used in the end). So adjust the offset so that the half-way points get rounded down instead of up. (This is all a bit iffy I think since we don't use fractional boxes (with 8 subpixel bits) anywhere yet, but at least without msaa it should work out.) Reviewed-by: Brian Paul Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/llvmpipe/lp_setup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 50f3cea7b00..c2a4617c313 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -922,10 +922,10 @@ lp_setup_set_viewports(struct lp_setup_context *setup, half_height = fabsf(viewports[0].scale[1]); x0 = viewports[0].translate[0] - viewports[0].scale[0]; y0 = viewports[0].translate[1] - half_height; - setup->vpwh.x0 = (int)(x0 + 0.5f); - setup->vpwh.x1 = (int)(viewports[0].scale[0] * 2.0f + x0 - 0.5f); - setup->vpwh.y0 = (int)(y0 + 0.5f); - setup->vpwh.y1 = (int)(half_height * 2.0f + y0 - 0.5f); + setup->vpwh.x0 = (int)(x0 + 0.499f); + setup->vpwh.x1 = (int)(viewports[0].scale[0] * 2.0f + x0 - 0.501f); + setup->vpwh.y0 = (int)(y0 + 0.499f); + setup->vpwh.y1 = (int)(half_height * 2.0f + y0 - 0.501f); setup->dirty |= LP_SETUP_NEW_SCISSOR; /*