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 <brianp@vmware.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13794>
This commit is contained in:
parent
f6dd931640
commit
b7e2214b3c
|
@ -922,10 +922,10 @@ lp_setup_set_viewports(struct lp_setup_context *setup,
|
||||||
half_height = fabsf(viewports[0].scale[1]);
|
half_height = fabsf(viewports[0].scale[1]);
|
||||||
x0 = viewports[0].translate[0] - viewports[0].scale[0];
|
x0 = viewports[0].translate[0] - viewports[0].scale[0];
|
||||||
y0 = viewports[0].translate[1] - half_height;
|
y0 = viewports[0].translate[1] - half_height;
|
||||||
setup->vpwh.x0 = (int)(x0 + 0.5f);
|
setup->vpwh.x0 = (int)(x0 + 0.499f);
|
||||||
setup->vpwh.x1 = (int)(viewports[0].scale[0] * 2.0f + x0 - 0.5f);
|
setup->vpwh.x1 = (int)(viewports[0].scale[0] * 2.0f + x0 - 0.501f);
|
||||||
setup->vpwh.y0 = (int)(y0 + 0.5f);
|
setup->vpwh.y0 = (int)(y0 + 0.499f);
|
||||||
setup->vpwh.y1 = (int)(half_height * 2.0f + y0 - 0.5f);
|
setup->vpwh.y1 = (int)(half_height * 2.0f + y0 - 0.501f);
|
||||||
setup->dirty |= LP_SETUP_NEW_SCISSOR;
|
setup->dirty |= LP_SETUP_NEW_SCISSOR;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue