Mesa (main): vulkan/wsi/wayland: fix crash when force_bgra8_unorm_first is true
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Aug 16 08:56:09 UTC 2021
Module: Mesa
Branch: main
Commit: 1c9299eaded4f5dc760c0094230a908de1672912
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1c9299eaded4f5dc760c0094230a908de1672912
Author: Leandro Ribeiro <leandro.ribeiro at collabora.com>
Date: Wed Jul 28 14:08:34 2021 -0300
vulkan/wsi/wayland: fix crash when force_bgra8_unorm_first is true
When force_bgra8_unorm_first is true, we access display->formats and
change the order of certain formats. The final result is BGRA8_UNORM
being the first in the format list, as some clients require this.
But we are trying to do this before before setting up display->formats,
so it should result in a crash. Fix this by changing the order of
things. Now we first set up display->formats before trying to access it.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro at collabora.com>
Reviewed-by: Simon Ser <contact at emersion.fr>
Reviewed-by: Eric Engestrom <eric at engestrom.ch>
Acked-by: Daniel Stone <daniels at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12117>
---
src/vulkan/wsi/wsi_common_wayland.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index bc0aad9cfac..a534868554f 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -492,6 +492,11 @@ wsi_wl_display_init(struct wsi_wayland *wsi_wl,
/* Round-trip again to get formats and modifiers */
wl_display_roundtrip_queue(display->wl_display, display->queue);
+ if (display->sw)
+ display->formats = &display->swrast.formats;
+ else if (display->dmabuf.wl_dmabuf)
+ display->formats = &display->dmabuf.formats;
+
if (wsi_wl->wsi->force_bgra8_unorm_first) {
/* Find BGRA8_UNORM in the list and swap it to the first position if we
* can find it. Some apps get confused if SRGB is first in the list.
@@ -507,11 +512,6 @@ wsi_wl_display_init(struct wsi_wayland *wsi_wl,
}
}
- if (display->sw)
- display->formats = &display->swrast.formats;
- else if (display->dmabuf.wl_dmabuf)
- display->formats = &display->dmabuf.formats;
-
out:
/* We don't need this anymore */
wl_registry_destroy(registry);
More information about the mesa-commit
mailing list