i965/fs: Don't issue FB writes for bound but unwritten color targets.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 27 Feb 2015 01:45:49 +0000 (17:45 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 9 Mar 2015 23:07:04 +0000 (16:07 -0700)
commite95969cd9548033250ba12f2adf11740319b41e7
treed2cd232de34360b71755ce23329851d281ba2dbf
parent4ebeb71573ad44f7657810dc5dd2c9030e3e63db
i965/fs: Don't issue FB writes for bound but unwritten color targets.

We used to loop over all color attachments, and emit FB writes for each
one, even if the shader didn't write to a corresponding output variable.
Those color attachments would be filled with garbage (undefined values).

Football Manager binds a framebuffer with 4 color attachments, but draws
to it using a shader that only writes to gl_FragData[0..2].  This meant
that color attachment 3 would be filled with garbage, resulting in
rendering artifacts.  Now we skip writing to it, fixing rendering.

Writes to gl_FragColor initialize outputs[0..nr_color_regions-1] to
GRFs, while writes to gl_FragData[i] initialize outputs[i].

Thanks to Jason Ekstrand for tracking this down.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=86747
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Cc: mesa-stable@lists.freedesktop.org
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp