Mesa (main): vulkan/wsi: unify format logic in dmabuf_handle_modifier

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 30 05:05:19 UTC 2021


Module: Mesa
Branch: main
Commit: 14f0c0d9dbf4133a49c8f7790e440fe9c398f2bc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=14f0c0d9dbf4133a49c8f7790e440fe9c398f2bc

Author: Simon Ser <contact at emersion.fr>
Date:   Thu May 28 19:54:49 2020 +0200

vulkan/wsi: unify format logic in dmabuf_handle_modifier

This function has a switch which currently duplicates the format
handling logic.

Move this logic out of the switch.

This avoids repeating the same code for each supported format and
prepares the work for proper DRM_FORMAT_MOD_INVALID handling.

Signed-off-by: Simon Ser <contact at emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4942>

---

 src/vulkan/wsi/wsi_common_wayland.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index 1408c8c86b8..d0cabf9514e 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -303,6 +303,7 @@ dmabuf_handle_modifier(void *data, struct zwp_linux_dmabuf_v1 *dmabuf,
                        uint32_t modifier_lo)
 {
    struct wsi_wl_display *display = data;
+   struct u_vector *modifiers;
    uint64_t *mod = NULL;
 
    /* If we're not fetching formats, don't fetch modifiers either. */
@@ -315,17 +316,18 @@ dmabuf_handle_modifier(void *data, struct zwp_linux_dmabuf_v1 *dmabuf,
 
    switch (format) {
    case WL_DRM_FORMAT_ARGB8888:
-      wsi_wl_display_add_wl_format(display, &display->dmabuf.formats, format);
-      mod = u_vector_add(&display->dmabuf.modifiers.argb8888);
+      modifiers = &display->dmabuf.modifiers.argb8888;
       break;
    case WL_DRM_FORMAT_XRGB8888:
-      wsi_wl_display_add_wl_format(display, &display->dmabuf.formats, format);
-      mod = u_vector_add(&display->dmabuf.modifiers.xrgb8888);
+      modifiers = &display->dmabuf.modifiers.xrgb8888;
       break;
    default:
-      break;
+      return; /* Unsupported format */
    }
 
+   wsi_wl_display_add_wl_format(display, &display->dmabuf.formats, format);
+
+   mod = u_vector_add(modifiers);
    if (!mod)
       return;
 



More information about the mesa-commit mailing list