i965: Use a better guardband calculation.
authorJason Ekstrand <jason@jlekstrand.net>
Sat, 21 Jan 2017 11:50:42 +0000 (03:50 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 7 Feb 2017 01:40:14 +0000 (17:40 -0800)
commitf3c068c5c89c8c3dce257ecc2b640f375d3f4836
tree44013268b9880123216038c15076a013f255ff7a
parent89ad7f1be6a607b33ffb388516b5d0547b491c33
i965: Use a better guardband calculation.

(Patch co-authored by Jason and Ken.)

We scaled the guardband based on the viewport size, but failed to
take into account the translation portion of the viewport transform.

This meant the guardband was always centered around the origin.
We want it to be centered around the screen-space drawing area,
which is the intersection of the viewport and the render target.

At best, getting this wrong would reduce the guardband's effectiveness
in some cases.  At worst, it might break things - objects outside of the
guardband are trivially rejected, so getting the guardband in the wrong
place and leaving guardband clipping enabled could cause problems.

v2: drop clamping of positive maximums.

Cc: "17.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/gen6_viewport_state.c
src/mesa/drivers/dri/i965/gen7_viewport_state.c
src/mesa/drivers/dri/i965/gen8_viewport_state.c