mesa: WIP, much inspiration and some patches from Ubuntu