meta: Don't botch color masks when changing drawbuffers.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 12 Apr 2016 17:19:09 +0000 (10:19 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 18 Apr 2016 17:39:31 +0000 (10:39 -0700)
commitc092f9b96a0bdc415fec1760b8b345166b115483
treebb7ad2d2d6a1550b6b74bac14c5e7b02e6ef678f
parenta33f94ba8c3a4a344fbc5a8386cec7f2a620b97e
meta: Don't botch color masks when changing drawbuffers.

Color clears should respect each drawbuffer's color mask state.

Previously, we tried to leave the color mask untouched.  However,
_mesa_meta_drawbuffers_from_bitfield() ended up rebinding all the
color drawbuffers in a different order, so we ended up pairing
drawbuffers with the wrong color mask state.

The new _mesa_meta_drawbuffers_and_colormask() function does the
same job as the old _mesa_meta_drawbuffers_from_bitfield(), but
also rearranges the color mask state to match the new drawbuffer
configuration.

This code was largely ripped off from Gallium's st_Clear code.

This fixes ES31-CTS.draw_buffers_indexed.color_masks, which binds
up to 8 drawbuffers, sets color masks for each, and then calls
glClearBufferfv to clear each buffer individually.  ClearBuffer
causes us to rebind only one drawbuffer, at which point we used
ctx->Color.ColorMask[0] (draw buffer 0's state) for everything.

We could probably delete _mesa_meta_drawbuffers_from_bitfield(),
but I'd rather not think about the i965 fast clear code.  Topi is
rewriting a bunch of that soon anyway, so let's delete it then.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94847
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/mesa/drivers/common/meta.c