OSDN Git Service

i965: Clamp "Maximum VP Index" to 1 when gl_ViewportIndex isn't written.
authorKenneth Graunke <kenneth@whitecape.org>
Sun, 8 May 2016 00:30:02 +0000 (17:30 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 9 May 2016 22:31:27 +0000 (15:31 -0700)
commite0e7280db0b03b08479ef9db681db186f80605e5
tree03dffdfd50b3c1afe3e3d18b501a2877d02a8b4e
parente74812dbfefa2006d6de5c3edfe5c66f5ce24650
i965: Clamp "Maximum VP Index" to 1 when gl_ViewportIndex isn't written.

fs_visitor::emit_urb_writes skips writing the VUE header for shaders
that don't write gl_PointSize, gl_Layer, or gl_ViewportIndex.  This
leaves their values uninitialized.  Kristian's nearby comment says:

"But often none of the special varyings that live there are written
 and in that case we can skip writing to the vue header, provided the
 corresponding state properly clamps the values further down the
 pipeline."

However, we were clamping gl_ViewportIndex to [0, 15], so we would end
up using a random viewport.  To fix this, detect when the shader doesn't
write gl_ViewportIndex, and clamp it to [0, 0].

The vec4 backend always writes zeros to the VUE header, so it doesn't
suffer from this problem.  With vec4-style HWord writes, we can write
the header and position together in a single message.  In the FS world,
we would need 4 extra MOVs of 0 and a longer message, or a separate
OWord write.  It's likely cheaper to just clamp the value.

Fixes DiRT Showdown and Bioshock Infinite, which only rendered half of
the screen - the lower left of two triangles.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93054
Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/mesa/drivers/dri/i965/gen6_clip_state.c