[vlc-devel] [PATCH 13/17] vulkan: remove surface from vlc_vk_t

Romain Vimont rom1v at videolabs.io
Wed Apr 14 09:47:28 UTC 2021


On Mon, Apr 12, 2021 at 03:32:29PM +0200, Alexandre Janniaux wrote:
> ---
>  modules/video_output/vulkan/display.c      | 9 +++++----
>  modules/video_output/vulkan/instance.c     | 2 --
>  modules/video_output/vulkan/instance.h     | 3 +--
>  modules/video_output/vulkan/platform.h     | 8 +++++++-
>  modules/video_output/vulkan/platform_xcb.c | 6 +++---
>  5 files changed, 16 insertions(+), 12 deletions(-)
> 
> diff --git a/modules/video_output/vulkan/display.c b/modules/video_output/vulkan/display.c
> index 4aaaad5f29..81f562e0fb 100644
> --- a/modules/video_output/vulkan/display.c
> +++ b/modules/video_output/vulkan/display.c
> @@ -50,6 +50,8 @@ struct vout_display_sys_t
>      const struct pl_swapchain *swapchain;
>      struct pl_renderer *renderer;
>  
> +    VkSurfaceKHR surface;
> +
>      // Pool of textures for the subpictures
>      struct pl_overlay *overlays;
>      const struct pl_tex **overlay_tex;
> @@ -122,15 +124,14 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
>          goto error;
>  
>      // Create the platform-specific surface object
> -    if (sys->vk->ops->create_surface(sys->vk, sys->instance->instance)
> -            != VLC_SUCCESS)
> +    if (vlc_vk_CreateSurface(sys->vk, sys->instance->instance, &sys->surface) != VLC_SUCCESS)
>          goto error;
>  
>      // Create vulkan device
>      char *device_name = var_InheritString(sys->vk, "vk-device");
>      sys->vulkan = pl_vulkan_create(sys->ctx, &(struct pl_vulkan_params) {
>          .instance = sys->instance->instance,
> -        .surface = sys->vk->surface,
> +        .surface = sys->surface,
>          .device_name = device_name,
>          .allow_software = var_InheritBool(vd, "allow-sw"),
>          .async_transfer = var_InheritBool(vd, "async-xfer"),
> @@ -143,7 +144,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
>  
>      // Create swapchain for this surface
>      struct pl_vulkan_swapchain_params swap_params = {
> -        .surface = sys->vk->surface,
> +        .surface = sys->surface,
>          .present_mode = var_InheritInteger(vd, "present-mode"),
>          .swapchain_depth = var_InheritInteger(vd, "queue-depth"),
>      };
> diff --git a/modules/video_output/vulkan/instance.c b/modules/video_output/vulkan/instance.c
> index 9ad331893e..eb9afb730c 100644
> --- a/modules/video_output/vulkan/instance.c
> +++ b/modules/video_output/vulkan/instance.c
> @@ -58,10 +58,8 @@ vlc_vk_t *vlc_vk_Create(struct vout_window_t *wnd, const char *name)
>      if (unlikely(vk == NULL))
>          return NULL;
>  
> -    vk->surface = (VkSurfaceKHR) NULL;
>      vk->platform_ext = NULL;
>      vk->ops = NULL;
> -
>      vk->window = wnd;
>  
>      vk->module = vlc_module_load(wnd, "vulkan platform", name, false,
> diff --git a/modules/video_output/vulkan/instance.h b/modules/video_output/vulkan/instance.h
> index 976205b6b0..29650398c7 100644
> --- a/modules/video_output/vulkan/instance.h
> +++ b/modules/video_output/vulkan/instance.h
> @@ -35,7 +35,7 @@ struct vlc_vk_t;
>  struct vlc_vk_operations
>  {
>      void (*close)(struct vlc_vk_t *);
> -    int (*create_surface)(struct vlc_vk_t *, VkInstance);
> +    int (*create_surface)(struct vlc_vk_t *, VkInstance, VkSurfaceKHR *);
>  };
>  
>  
> @@ -49,7 +49,6 @@ typedef struct vlc_vk_t
>      void *platform_sys;
>      const char *platform_ext;
>  
> -    VkSurfaceKHR surface;
>      struct vout_window_t *window;
>  
>      const struct vlc_vk_operations *ops;
> diff --git a/modules/video_output/vulkan/platform.h b/modules/video_output/vulkan/platform.h
> index ddd314a789..8c0045959f 100644
> --- a/modules/video_output/vulkan/platform.h
> +++ b/modules/video_output/vulkan/platform.h
> @@ -31,6 +31,12 @@ void vlc_vk_ClosePlatform(vlc_vk_t *);
>  extern const char * const vlc_vk_PlatformExt;
>  
>  // Create a vulkan surface to vk->surface
> -int vlc_vk_CreateSurface(vlc_vk_t *, VkInstance);
> +void vlc_vk_ClosePlatform(vlc_vk_t *vk);

This adds a duplicate declaration of vlc_vk_ClosePlatform(vlc_vk_t *).

> +
> +// Create a vulkan surface to vk->surface
> +inline int vlc_vk_CreateSurface(vlc_vk_t * vk, VkInstance instance, VkSurfaceKHR *surface_out)
> +{
> +    return vk->ops->create_surface(vk, instance, surface_out);
> +}
>  
>  #endif // VLC_VULKAN_PLATFORM_H
> diff --git a/modules/video_output/vulkan/platform_xcb.c b/modules/video_output/vulkan/platform_xcb.c
> index 72efbe9ef7..003267bf7e 100644
> --- a/modules/video_output/vulkan/platform_xcb.c
> +++ b/modules/video_output/vulkan/platform_xcb.c
> @@ -30,7 +30,7 @@
>  #include "platform.h"
>  
>  static void ClosePlatform(vlc_vk_t *vk);
> -static int CreateSurface(vlc_vk_t *vk, VkInstance instance);
> +static int CreateSurface(vlc_vk_t *vk, VkInstance instance, VkSurfaceKHR *surface_out);
>  
>  static const struct vlc_vk_operations platform_ops =
>  {
> @@ -66,7 +66,7 @@ static void ClosePlatform(vlc_vk_t *vk)
>      xcb_disconnect(conn);
>  }
>  
> -static int CreateSurface(vlc_vk_t *vk, VkInstance vkinst)
> +static int CreateSurface(vlc_vk_t *vk, VkInstance vkinst, VkSurfaceKHR *surface_out)
>  {
>      xcb_connection_t *conn = vk->platform_sys;
>  
> @@ -76,7 +76,7 @@ static int CreateSurface(vlc_vk_t *vk, VkInstance vkinst)
>           .connection = conn,
>      };
>  
> -    VkResult res = vkCreateXcbSurfaceKHR(vkinst, &xinfo, NULL, &vk->surface);
> +    VkResult res = vkCreateXcbSurfaceKHR(vkinst, &xinfo, NULL, surface_out);
>      if (res != VK_SUCCESS) {
>          msg_Err(vk, "Failed creating XCB surface");
>          return VLC_EGENERIC;
> -- 
> 2.31.1
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list