Bug 51962 - Raz's eyes flicker in Psychonauts on nv50
Summary: Raz's eyes flicker in Psychonauts on nv50
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/DRI/nouveau (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Nouveau Project
QA Contact:
Depends on:
Reported: 2012-07-10 20:24 UTC by Bryan Cain
Modified: 2012-11-01 15:41 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Description Bryan Cain 2012-07-10 20:24:39 UTC
This bug affects the Gallium nv50 driver, but for some reason there's no "Drivers/Gallium/nv50" component listed in Bugzilla.

In Psychonauts on the nv50 driver, Raz's eyes (supposed to be red) flicker between red and white.  This behavior first appears in git with the commit that switches the nv50 driver to use the new nv50/nvc0 shader compiler.  The eye flickering is caused by one vertex shader being miscompiled.  In the attached apitrace, the GL program number used to draw Raz's eyes (which has the vertex shader in question) is 541.  If vertex shader optimizations are disabled in nv50_program.c, Raz's eyes stay white all the time instead of flickering.  If shader program 541 is disabled entirely, Raz's eyes render correctly.

It is evident that there is a problem with the vertex shader by looking at its nv50 IR source after it is converted to SSA - there are several "nop" instructions at the beginning of the program to compensate for undefined source registers emitted by the TGSI to nv50 IR conversion.
Comment 1 Bryan Cain 2012-07-10 20:33:39 UTC
The apitrace is too large for fd.o to accept it as an attachment; it can be downloaded from the following link: http://assortedtools.pbworks.com/f/Psychonauts.3.trace.xz
Comment 2 Bryan Cain 2012-07-18 04:59:50 UTC
I did some more investigation into this bug and produced a fix: http://lists.freedesktop.org/archives/mesa-dev/2012-July/024196.html

The problem was that in lowering the POW instruction, the lg2/mul/preex2 instructions that go before the ex2 instruction were not being emitted properly, which as a side effect made each of the four ex2 instructions in the shader read from an undefined source register.  This in turn made the SSA generator produce 4 of the 5 nop instructions mentioned in the original description.

The first of the five nop instructions is not the nv50 shader compiler's fault, but is the result of the GLSL compiler's pass to lower output registers emitting reads to undefined components of gl_TexCoord.  It's an unrelated issue that happened to show up in the same shader, and doesn't affect the shader at the driver level post-optimization.  I will file a separate bug report about it against glsl-compiler.
Comment 3 Fabio Pedretti 2012-09-10 12:06:09 UTC
It should be fixed with 248e6f03313afdfd3c23be269b0da7a1aa31cff2 .
Comment 4 Emil Velikov 2012-11-01 15:41:58 UTC
Marking as Resolved/Fixed

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.