[vlc-commits] [Git][videolan/vlc][master] 2 commits: vulkan: platform: add vlc_vk_DestroySurface helper

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Mon Nov 7 08:05:52 UTC 2022



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
fd83edc4 by Niklas Haas at 2022-11-07T07:50:46+00:00
vulkan: platform: add vlc_vk_DestroySurface helper

- - - - -
959a0e2b by Niklas Haas at 2022-11-07T07:50:46+00:00
libplacebo: vulkan: destroy surface on uninit

We create a surface, so we need to destroy it, too.

- - - - -


2 changed files:

- modules/video_output/libplacebo/instance_vulkan.c
- modules/video_output/vulkan/platform.h


Changes:

=====================================
modules/video_output/libplacebo/instance_vulkan.c
=====================================
@@ -35,6 +35,7 @@
 
 struct vlc_placebo_system_t {
     vlc_vk_platform_t *platform;
+    VkSurfaceKHR surface;
     pl_vk_inst instance;
     pl_vulkan vulkan;
 };
@@ -75,15 +76,14 @@ static int InitInstance(vlc_placebo_t *pl, const vout_display_cfg_t *cfg)
     };
 
     // Create the platform-specific surface object
-    VkSurfaceKHR surface;
-    if (vlc_vk_CreateSurface(sys->platform, &inst, &surface) != VLC_SUCCESS)
+    if (vlc_vk_CreateSurface(sys->platform, &inst, &sys->surface) != VLC_SUCCESS)
         goto error;
 
     // Create vulkan device
     char *device_name = var_InheritString(pl, "vk-device");
     sys->vulkan = pl_vulkan_create(pl->log, &(struct pl_vulkan_params) {
         .instance = sys->instance->instance,
-        .surface = surface,
+        .surface = sys->surface,
         .device_name = device_name,
         .allow_software = var_InheritBool(pl, "vk-allow-sw"),
         .async_transfer = var_InheritBool(pl, "vk-async-xfer"),
@@ -96,7 +96,7 @@ static int InitInstance(vlc_placebo_t *pl, const vout_display_cfg_t *cfg)
 
     // Create swapchain for this surface
     struct pl_vulkan_swapchain_params swap_params = {
-        .surface = surface,
+        .surface = sys->surface,
         .present_mode = var_InheritInteger(pl, "vk-present-mode"),
         .swapchain_depth = var_InheritInteger(pl, "vk-queue-depth"),
     };
@@ -119,6 +119,15 @@ static void CloseInstance(vlc_placebo_t *pl)
     vlc_placebo_system_t *sys = pl->sys;
 
     pl_swapchain_destroy(&pl->swapchain);
+
+    if (sys->surface) {
+        vlc_vk_instance_t inst = {
+            .instance = sys->instance->instance,
+            .get_proc_address = sys->instance->get_proc_addr,
+        };
+        vlc_vk_DestroySurface(&inst, sys->surface);
+    }
+
     pl_vulkan_destroy(&sys->vulkan);
     pl_vk_inst_destroy(&sys->instance);
 


=====================================
modules/video_output/vulkan/platform.h
=====================================
@@ -59,4 +59,13 @@ static inline int vlc_vk_CreateSurface(vlc_vk_platform_t * vk,
     return vk->ops->create_surface(vk, instance, surface_out);
 }
 
+static inline void vlc_vk_DestroySurface(const vlc_vk_instance_t *inst,
+                                         VkSurfaceKHR surface)
+{
+    PFN_vkDestroySurfaceKHR DestroySurfaceKHR = (PFN_vkDestroySurfaceKHR)
+        inst->get_proc_address(inst->instance, "vkDestroySurfaceKHR");
+
+    DestroySurfaceKHR(inst->instance, surface, NULL);
+}
+
 #endif // VLC_VULKAN_PLATFORM_H



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f3ad16b176d83de6e311b8250350346073969bb5...959a0e2be7dff078419076a427d71a4641c890e6

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f3ad16b176d83de6e311b8250350346073969bb5...959a0e2be7dff078419076a427d71a4641c890e6
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list