From fc3335a4720398645895b5259e3bfc6b736fa235 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Mon, 5 Apr 2021 21:20:09 +0000 Subject: [PATCH] venus: properly enable WSI for different platforms Signed-off-by: Yiwei Zhang Reviewed-by: Chia-I Wu Part-of: --- src/virtio/vulkan/meson.build | 11 +++++++++-- src/virtio/vulkan/vn_device.c | 4 ++++ src/virtio/vulkan/vn_wsi.h | 13 +++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/virtio/vulkan/meson.build b/src/virtio/vulkan/meson.build index 7843b85cf01..ccc704180dc 100644 --- a/src/virtio/vulkan/meson.build +++ b/src/virtio/vulkan/meson.build @@ -38,7 +38,6 @@ libvn_files = files( 'vn_ring.c', 'vn_renderer_virtgpu.c', 'vn_renderer_vtest.c', - 'vn_wsi.c', ) vn_deps = [ @@ -53,6 +52,14 @@ vn_flags = [ no_override_init_args, ] +vn_libs = [] + +if with_platform_wayland or with_platform_x11 + libvn_files += files('vn_wsi.c') + vn_flags += '-DVN_USE_WSI_PLATFORM' + vn_libs += libvulkan_wsi +endif + if with_platform_wayland libvn_files += files('vn_wsi_wayland.c') vn_deps += dep_wayland_client @@ -74,7 +81,7 @@ libvulkan_virtio = shared_library( include_directories : [ inc_include, inc_src, inc_vulkan_wsi, inc_virtio, ], - link_with : [libvulkan_wsi], + link_with : vn_libs, dependencies : [vn_deps], c_args : [vn_flags], link_args : [ld_args_bsymbolic, ld_args_gc_sections], diff --git a/src/virtio/vulkan/vn_device.c b/src/virtio/vulkan/vn_device.c index a92cc90b65e..6ad9806796f 100644 --- a/src/virtio/vulkan/vn_device.c +++ b/src/virtio/vulkan/vn_device.c @@ -39,9 +39,11 @@ static const struct vk_instance_extension_table .KHR_get_physical_device_properties2 = true, /* WSI */ +#ifdef VN_USE_WSI_PLATFORM .KHR_get_surface_capabilities2 = true, .KHR_surface = true, .KHR_surface_protected_capabilities = true, +#endif #ifdef VK_USE_PLATFORM_WAYLAND_KHR .KHR_wayland_surface = true, #endif @@ -1404,9 +1406,11 @@ vn_physical_device_get_supported_extensions( { *supported = (struct vk_device_extension_table){ /* WSI */ +#ifdef VN_USE_WSI_PLATFORM .KHR_incremental_present = true, .KHR_swapchain = true, .KHR_swapchain_mutable_format = true, +#endif }; *recognized = (struct vk_device_extension_table){ diff --git a/src/virtio/vulkan/vn_wsi.h b/src/virtio/vulkan/vn_wsi.h index c49065f8455..efed0401b26 100644 --- a/src/virtio/vulkan/vn_wsi.h +++ b/src/virtio/vulkan/vn_wsi.h @@ -15,10 +15,23 @@ #include "wsi_common.h" +#ifdef VN_USE_WSI_PLATFORM VkResult vn_wsi_init(struct vn_physical_device *physical_dev); void vn_wsi_fini(struct vn_physical_device *physical_dev); +#else +static inline VkResult +vn_wsi_init(UNUSED struct vn_physical_device *physical_dev) +{ + return VK_SUCCESS; +} + +static inline void +vn_wsi_fini(UNUSED struct vn_physical_device *physical_dev) +{ +} +#endif #endif /* VN_WSI_H */