summaryrefslogtreecommitdiff
path: root/src/vulkan
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2017-09-22 13:08:15 -0700
committerJason Ekstrand <jason.ekstrand@intel.com>2017-09-27 08:32:36 -0700
commit77181d95804b23210275c5b898e4d3b65f5a52a8 (patch)
tree5538b7e7173f2536354b059ce4b8334a53393eba /src/vulkan
parentf67ceeffd418d5757b01cc5493a8456b931db087 (diff)
vulkan/wsi/wayland: Refactor wsi_wl_display code
We convert it over to an inti/finish model and make create/destroy wrappers for the former. Reviewed-by: Daniel Stone <daniels@collabora.com> Cc: mesa-stable@lists.freedesktop.org
Diffstat (limited to 'src/vulkan')
-rw-r--r--src/vulkan/wsi/wsi_common_wayland.c47
1 files changed, 33 insertions, 14 deletions
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index b726d98e08..62fc97cabb 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -249,7 +249,7 @@ static const struct wl_registry_listener registry_listener = {
};
static void
-wsi_wl_display_destroy(struct wsi_wayland *wsi, struct wsi_wl_display *display)
+wsi_wl_display_finish(struct wsi_wl_display *display)
{
u_vector_finish(&display->formats);
if (display->drm)
@@ -258,21 +258,16 @@ wsi_wl_display_destroy(struct wsi_wayland *wsi, struct wsi_wl_display *display)
wl_proxy_wrapper_destroy(display->wl_display_wrapper);
if (display->queue)
wl_event_queue_destroy(display->queue);
- vk_free(wsi->alloc, display);
}
-static struct wsi_wl_display *
-wsi_wl_display_create(struct wsi_wayland *wsi, struct wl_display *wl_display)
+static int
+wsi_wl_display_init(struct wsi_wayland *wsi_wl,
+ struct wsi_wl_display *display,
+ struct wl_display *wl_display)
{
- struct wsi_wl_display *display =
- vk_alloc(wsi->alloc, sizeof(*display), 8,
- VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
- if (!display)
- return NULL;
-
memset(display, 0, sizeof(*display));
- display->wsi_wl = wsi;
+ display->wsi_wl = wsi_wl;
display->wl_display = wl_display;
if (!u_vector_init(&display->formats, sizeof(VkFormat), 8))
@@ -312,15 +307,39 @@ wsi_wl_display_create(struct wsi_wayland *wsi, struct wl_display *wl_display)
/* We don't need this anymore */
wl_registry_destroy(registry);
- return display;
+ return 0;
fail_registry:
if (registry)
wl_registry_destroy(registry);
fail:
- wsi_wl_display_destroy(wsi, display);
- return NULL;
+ wsi_wl_display_finish(display);
+ return -1;
+}
+
+static struct wsi_wl_display *
+wsi_wl_display_create(struct wsi_wayland *wsi, struct wl_display *wl_display)
+{
+ struct wsi_wl_display *display =
+ vk_alloc(wsi->alloc, sizeof(*display), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ if (!display)
+ return NULL;
+
+ if (wsi_wl_display_init(wsi, display, wl_display)) {
+ vk_free(wsi->alloc, display);
+ return NULL;
+ }
+
+ return display;
+}
+
+static void
+wsi_wl_display_destroy(struct wsi_wayland *wsi, struct wsi_wl_display *display)
+{
+ wsi_wl_display_finish(display);
+ vk_free(wsi->alloc, display);
}
static struct wsi_wl_display *