wsi/x11: Fix the is-visual-supported check
authorAdam Jackson <ajax@redhat.com>
Thu, 1 Sep 2022 21:48:34 +0000 (17:48 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 13 Sep 2022 21:52:55 +0000 (21:52 +0000)
commited2e3f58713a48fbad03ae0087217eb214155991
treef86e079a101d38eda469ba028257428e6a62edc6
parentc23411a970144a51b3ddffb1e97d46bb3b3ca362
wsi/x11: Fix the is-visual-supported check

This was sort of well intentioned, but wrong. bits_per_rgb_value is the
number of significant bits in the color (channel) specification, not the
number of bits used to name that color within the pixel. If you have a
depth 24 visual but the colormap is 11 bits deep then each of those
channels selects one of 256 11-bit color values in the output ramp.

The open source drivers mostly don't expose anything like that, but
nvidia does, and we refuse to work. That's silly. Practically speaking
we can probably render to any TrueColor or DirectColor visual that your
X server exposes, since it is probably not going to have visuals for
non-color-renderable formats. Just check the visual class instead.

Likewise when matching formats to visuals, count the bits in the rgb
masks in the visual.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6995
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18381>
src/vulkan/wsi/wsi_common_x11.c