i965: Fix the SF Vertex URB Read Length calculation for Sandybridge.
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 2 Feb 2013 20:46:49 +0000 (12:46 -0800)
committerAndreas Boll <andreas.boll.dev@gmail.com>
Wed, 13 Feb 2013 20:48:37 +0000 (21:48 +0100)
commite11ef54a92843be70850ae0244169b5b9708ecab
treeeace2608eb1ad649e160b62f350003220e764457
parent2de8874ec37bfc548de2e16bbefa51341e25d340
i965: Fix the SF Vertex URB Read Length calculation for Sandybridge.

(This commit message was primarily written by Paul Berry, who explained
 what's going on far better than I would have.)

Previous to this patch, we thought that the only restrictions on
3DSTATE_SF's URB read length were (a) it needs to be large enough to
read all the VUE data that the SF needs, and (b) it can't be so large
that it tries to read VUE data that doesn't exist.  Since the VUE map
already tells us how much VUE data exists, we didn't bother worrying
about restriction (a); we just did the easy thing and programmed the
read length to satisfy restriction (b).

However, we didn't notice this erratum in the hardware docs: "[errata]
Corruption/Hang possible if length programmed larger than recommended".
Judging by the context surrounding this erratum, it's pretty clear that
it means "URB read length must be exactly the size necessary to read all
the VUE data that the SF needs, and no larger".  Which means that we
can't program the read length based on restriction (b)--we have to
program it based on restriction (a).

The URB read size needs to precisely match the amount of data that the
SF consumes; it doesn't work to simply base it on the size of the VUE.

Thankfully, the PRM contains the precise formula the hardware expects.

Fixes random UI corruption in Steam's "Big Picture Mode", random terrain
corruption in PlaneShift, and Piglit's fbo-5-varyings test.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=56920
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=60172
Tested-by: Jordan Justen <jordan.l.justen@intel.com> (v1/Piglit)
Tested-by: Martin Steigerwald <martin@lichtvoll.de> (PlaneShift)
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 09fbc298283b41cf3f25d75842a6d8ab4952dca1)
src/mesa/drivers/dri/i965/gen6_sf_state.c