Fixed by a commit series which starts here: http://cgit.freedesktop.org/mesa/mesa/commit/?id=74edd56927801e8c646c7d5cddba397c2f54b4ef