zink: support using lavapipe
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Wed, 2 Dec 2020 16:26:26 +0000 (17:26 +0100)
committerMarge Bot <eric+marge@anholt.net>
Fri, 5 Feb 2021 16:45:43 +0000 (16:45 +0000)
commit3824c06aff27f9aae05c82c85a1a7779b27df980
tree24ab608a507260625af2d13872f40a93d5dfa160
parent3adf6da4c10c0bc1a5209455fee7cc6e75683a74
zink: support using lavapipe

This is really nasty, and shouldn't really be needed, but we have a
problem where both Zink and Lavapipe checks $GALLIUM_DRIVER, meaning that
Zink tries to use Lavapipe, and Lavapipe tries to use Zink.

This patch side-steps that by temporarily setting $GALLIUM_DRIVER to
"llvmpipe", giving Lavapipe a chance to succeed.

This is not great at all. The most obvious problem is that this is super
thread-unsafe, effectively modifying global state without any care. In
reality, we'd only want the pipe-loader in the *same thread* to ignore
Zink, but it's not so obvious how to do that without introducing lots of
ugly zink-specific cruft.

People shouldn't be using Zink if they don't have a GPU, it's going to
be much better to use LLVMpipe in that case. So let's not worry too much
about this case, and instead guard this dangerous logic with an
ZINK_USE_LAVAPIPE environment variable. This means this behavior only
happens if people opt in to it.

With this in place, we can start using Zink + Lavapipe on CI.

In the longer run, it might be better to use Adam Jackson's copper
loader instead, and drop exposing Zink as a software rasterizer
entirely. But that's something for the great future where we have flying
cars and all.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7881>
src/gallium/drivers/zink/meson.build
src/gallium/drivers/zink/zink_screen.c