[vlc-commits] [Git][videolan/vlc][master] 8 commits: vulkan: platform_android: fix after API change
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Sat Sep 24 07:12:14 UTC 2022
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
7c48130e by Niklas Haas at 2022-09-24T06:52:11+00:00
vulkan: platform_android: fix after API change
This file was never updated after the signature of `CreateSurface`
changed in 79fb158ad. This bug was masked by vulkan support not
currently being built in the android CI environment.
Fixes: 79fb158adf85b30fdac8f02e1c7bb61e7e35f038
- - - - -
b6028ea8 by Niklas Haas at 2022-09-24T06:52:11+00:00
vulkan: add vlc_vk_instance_t abstraction
This is merely a convenience struct to group together instance-related
handles to calls that require it. The motivating use case is the
addition of the `vkGetInstanceProcAddr` callback.
- - - - -
ce676c48 by Niklas Haas at 2022-09-24T06:52:11+00:00
vulkan: platform: switch to vlc_vk_instance_t
Use this struct instead of VkInstance. This is motivated by a desire to
access the vkGetInstanceProcAddr callbacks inside the platform
implementations, so we can decouple the platform modules from the vulkan
loader.
- - - - -
fb112f8e by Niklas Haas at 2022-09-24T06:52:11+00:00
vulkan: platform_xcb: load function pointer
- - - - -
4d62aa3d by Niklas Haas at 2022-09-24T06:52:11+00:00
vulkan: platform_win32: load function pointer
- - - - -
decaaa04 by Niklas Haas at 2022-09-24T06:52:11+00:00
vulkan: platform_android: load function pointer
- - - - -
c81fef00 by Niklas Haas at 2022-09-24T06:52:11+00:00
wayland: vulkan: load function pointer
- - - - -
baadf3ab by Niklas Haas at 2022-09-24T06:52:11+00:00
vulkan: platform: remove unneeded dependencies
We no longer need to link against vulkan or libplacebo.
- - - - -
10 changed files:
- modules/video_output/libplacebo/instance_vulkan.c
- modules/video_output/vulkan/Makefile.am
- + modules/video_output/vulkan/instance.h
- modules/video_output/vulkan/platform.h
- modules/video_output/vulkan/platform_android.c
- modules/video_output/vulkan/platform_win32.c
- modules/video_output/vulkan/platform_xcb.c
- modules/video_output/wayland/Makefile.am
- modules/video_output/wayland/vulkan.c
- modules/video_output/xcb/Makefile.am
Changes:
=====================================
modules/video_output/libplacebo/instance_vulkan.c
=====================================
@@ -69,9 +69,14 @@ static int InitInstance(vlc_placebo_t *pl, const vout_display_cfg_t *cfg)
if (!sys->instance)
goto error;
+ vlc_vk_instance_t inst = {
+ .instance = sys->instance->instance,
+ .get_proc_address = sys->instance->get_proc_addr,
+ };
+
// Create the platform-specific surface object
VkSurfaceKHR surface;
- if (vlc_vk_CreateSurface(sys->platform, sys->instance->instance, &surface) != VLC_SUCCESS)
+ if (vlc_vk_CreateSurface(sys->platform, &inst, &surface) != VLC_SUCCESS)
goto error;
// Create vulkan device
=====================================
modules/video_output/vulkan/Makefile.am
=====================================
@@ -2,22 +2,18 @@
### Vulkan ###
VULKAN_COMMONSOURCES = video_output/vulkan/platform.c \
+ video_output/vulkan/instance.h \
video_output/vulkan/platform.h
-VULKAN_COMMONCFLAGS = $(VULKAN_CFLAGS) $(LIBPLACEBO_CFLAGS)
-VULKAN_COMMONLIBS = $(VULKAN_LIBS) $(LIBPLACEBO_LIBS)
-
libvk_win32_plugin_la_SOURCES = $(VULKAN_COMMONSOURCES) \
video_output/vulkan/platform_win32.c
-libvk_win32_plugin_la_CFLAGS = $(AM_CFLAGS) $(VULKAN_COMMONCFLAGS) \
+libvk_win32_plugin_la_CFLAGS = $(AM_CFLAGS) $(VULKAN_CFLAGS) \
-DVK_USE_PLATFORM_WIN32_KHR -DPLATFORM_NAME=Win32
-libvk_win32_plugin_la_LIBADD = $(VULKAN_COMMONLIBS)
libvk_android_plugin_la_SOURCES = $(VULKAN_COMMONSOURCES) \
video_output/vulkan/platform_android.c
-libvk_android_plugin_la_CFLAGS = $(AM_CFLAGS) $(VULKAN_COMMONCFLAGS) \
+libvk_android_plugin_la_CFLAGS = $(AM_CFLAGS) $(VULKAN_CFLAGS) \
-DVK_USE_PLATFORM_ANDROID_KHR -DPLATFORM_NAME=Android
-libvk_android_plugin_la_LIBADD = $(VULKAN_COMMONLIBS)
if HAVE_VULKAN
if HAVE_WIN32_DESKTOP
=====================================
modules/video_output/vulkan/instance.h
=====================================
@@ -0,0 +1,33 @@
+/*****************************************************************************
+ * instance.h: Vulkan instance abstraction
+ *****************************************************************************
+ * Copyright (C) 2018 Niklas Haas
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef VLC_VULKAN_INSTANCE_H
+#define VLC_VULKAN_INSTANCE_H
+
+#include <vlc_common.h>
+#include <vulkan/vulkan.h>
+
+typedef struct vlc_vk_instance_t
+{
+ VkInstance instance;
+ PFN_vkGetInstanceProcAddr get_proc_address;
+} vlc_vk_instance_t;
+
+#endif // VLC_VULKAN_INSTANCE_H
=====================================
modules/video_output/vulkan/platform.h
=====================================
@@ -24,13 +24,13 @@
#include <vlc_common.h>
#include <vlc_window.h>
-#include <vulkan/vulkan.h>
+#include "instance.h"
struct vlc_vk_platform_t;
struct vlc_vk_platform_operations
{
void (*close)(struct vlc_vk_platform_t *);
- int (*create_surface)(struct vlc_vk_platform_t *, VkInstance, VkSurfaceKHR *);
+ int (*create_surface)(struct vlc_vk_platform_t *, const vlc_vk_instance_t *, VkSurfaceKHR *);
};
@@ -52,7 +52,8 @@ vlc_vk_platform_t *vlc_vk_platform_Create(struct vlc_window *, const char *) VLC
void vlc_vk_platform_Release(vlc_vk_platform_t *);
// Create a vulkan surface and store it to `surface_out`
-static inline int vlc_vk_CreateSurface(vlc_vk_platform_t * vk, VkInstance instance,
+static inline int vlc_vk_CreateSurface(vlc_vk_platform_t * vk,
+ const vlc_vk_instance_t *instance,
VkSurfaceKHR *surface_out)
{
return vk->ops->create_surface(vk, instance, surface_out);
=====================================
modules/video_output/vulkan/platform_android.c
=====================================
@@ -31,7 +31,7 @@
#include "../android/utils.h"
static void ClosePlatform(vlc_vk_platform_t *vk);
-static int CreateSurface(vlc_vk_platform_t *vk);
+static int CreateSurface(vlc_vk_platform_t *vk, const vlc_vk_instance_t *, VkSurfaceKHR *);
static const struct vlc_vk_platform_operations platform_ops =
{
.close = ClosePlatform,
@@ -54,11 +54,14 @@ static void ClosePlatform(vlc_vk_platform_t *vk)
AWindow_Video);
}
-static int CreateSurface(vlc_vk_platform_t *vk, VkInstance vkinst)
+static int CreateSurface(vlc_vk_platform_t *vk, const vlc_vk_instance_t *inst,
+ VkSurfaceKHR *surface_out)
{
ANativeWindow *anw =
AWindowHandler_getANativeWindow(vk->window->handle.anativewindow,
AWindow_Video);
+ PFN_vkCreateAndroidSurfaceKHR CreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR)
+ inst->get_proc_address(inst->instance, "vkCreateAndroidSurfaceKHR");
VkAndroidSurfaceCreateInfoKHR ainfo = {
.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR,
@@ -67,7 +70,7 @@ static int CreateSurface(vlc_vk_platform_t *vk, VkInstance vkinst)
.window = anw,
};
- VkResult res = vkCreateAndroidSurfaceKHR(vkinst, &ainfo, NULL, &vk->surface);
+ VkResult res = CreateAndroidSurfaceKHR(inst->instance, &ainfo, NULL, surface_out);
if (res != VK_SUCCESS) {
msg_Err(vk, "Failed creating Android surface");
return VLC_EGENERIC;
=====================================
modules/video_output/vulkan/platform_win32.c
=====================================
@@ -33,10 +33,13 @@ static void ClosePlatform(vlc_vk_platform_t *vk)
VLC_UNUSED(vk);
}
-static int CreateSurface(vlc_vk_platform_t *vk, VkInstance vkinst, VkSurfaceKHR *surface_out)
+static int CreateSurface(vlc_vk_platform_t *vk, const vlc_vk_instance_t *inst,
+ VkSurfaceKHR *surface_out)
{
// Get current win32 HINSTANCE
HINSTANCE hInst = GetModuleHandle(NULL);
+ PFN_vkCreateWin32SurfaceKHR CreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)
+ inst->get_proc_address(inst->instance, "vkCreateWin32SurfaceKHR");
VkWin32SurfaceCreateInfoKHR winfo = {
.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR,
@@ -44,7 +47,7 @@ static int CreateSurface(vlc_vk_platform_t *vk, VkInstance vkinst, VkSurfaceKHR
.hwnd = (HWND) vk->window->handle.hwnd,
};
- VkResult res = vkCreateWin32SurfaceKHR(vkinst, &winfo, NULL, surface_out);
+ VkResult res = CreateWin32SurfaceKHR(inst->instance, &winfo, NULL, surface_out);
if (res != VK_SUCCESS) {
msg_Err(vk, "Failed creating Win32 surface");
return VLC_EGENERIC;
=====================================
modules/video_output/vulkan/platform_xcb.c
=====================================
@@ -30,7 +30,7 @@
#include "platform.h"
static void ClosePlatform(vlc_vk_platform_t *vk);
-static int CreateSurface(vlc_vk_platform_t *vk, VkInstance instance, VkSurfaceKHR *surface_out);
+static int CreateSurface(vlc_vk_platform_t *vk, const vlc_vk_instance_t *, VkSurfaceKHR *);
static const struct vlc_vk_platform_operations platform_ops =
{
@@ -66,9 +66,12 @@ static void ClosePlatform(vlc_vk_platform_t *vk)
xcb_disconnect(conn);
}
-static int CreateSurface(vlc_vk_platform_t *vk, VkInstance vkinst, VkSurfaceKHR *surface_out)
+static int CreateSurface(vlc_vk_platform_t *vk, const vlc_vk_instance_t *inst,
+ VkSurfaceKHR *surface_out)
{
xcb_connection_t *conn = vk->platform_sys;
+ PFN_vkCreateXcbSurfaceKHR CreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR)
+ inst->get_proc_address(inst->instance, "vkCreateXcbSurfaceKHR");
VkXcbSurfaceCreateInfoKHR xinfo = {
.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR,
@@ -76,7 +79,7 @@ static int CreateSurface(vlc_vk_platform_t *vk, VkInstance vkinst, VkSurfaceKHR
.connection = conn,
};
- VkResult res = vkCreateXcbSurfaceKHR(vkinst, &xinfo, NULL, surface_out);
+ VkResult res = CreateXcbSurfaceKHR(inst->instance, &xinfo, NULL, surface_out);
if (res != VK_SUCCESS) {
msg_Err(vk, "Failed creating XCB surface");
return VLC_EGENERIC;
=====================================
modules/video_output/wayland/Makefile.am
=====================================
@@ -79,7 +79,7 @@ libvk_wl_plugin_la_SOURCES = \
libvk_wl_plugin_la_CFLAGS = $(AM_CFLAGS) \
$(WAYLAND_CLIENT_CFLAGS) $(VULKAN_COMMONCFLAGS) \
-DVK_USE_PLATFORM_WAYLAND_KHR
-libvk_wl_plugin_la_LIBADD = $(VULKAN_COMMONLIBS) $(WAYLAND_CLIENT_LIBS)
+libvk_wl_plugin_la_LIBADD = $(WAYLAND_CLIENT_LIBS)
if HAVE_WAYLAND
BUILT_SOURCES += $(nodist_libwl_shm_plugin_la_SOURCES)
=====================================
modules/video_output/wayland/vulkan.c
=====================================
@@ -32,15 +32,19 @@
static void ClosePlatform(vlc_vk_platform_t *vk)
{ (void)vk; }
-static int CreateSurface(vlc_vk_platform_t *vk, VkInstance vkinst, VkSurfaceKHR *surface_out)
+static int CreateSurface(vlc_vk_platform_t *vk, const vlc_vk_instance_t *inst,
+ VkSurfaceKHR *surface_out)
{
+ PFN_vkCreateWaylandSurfaceKHR CreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR)
+ inst->get_proc_address(inst->instance, "vkCreateWaylandSurfaceKHR");
+
VkWaylandSurfaceCreateInfoKHR surface_info = {
.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR,
.display = vk->window->display.wl,
.surface = vk->window->handle.wl,
};
- VkResult res = vkCreateWaylandSurfaceKHR(vkinst, &surface_info, NULL, surface_out);
+ VkResult res = CreateWaylandSurfaceKHR(inst->instance, &surface_info, NULL, surface_out);
if (res != VK_SUCCESS) {
msg_Err(vk, "Failed creating Wayland surface");
return VLC_EGENERIC;
=====================================
modules/video_output/xcb/Makefile.am
=====================================
@@ -43,7 +43,7 @@ libvk_x11_plugin_la_SOURCES = $(VULKAN_COMMONSOURCES) \
libvk_x11_plugin_la_CFLAGS = $(AM_CFLAGS) \
$(XCB_CFLAGS) $(VULKAN_COMMONCFLAGS) \
-DVK_USE_PLATFORM_XCB_KHR -DPLATFORM_NAME=X11
-libvk_x11_plugin_la_LIBADD = $(VULKAN_COMMONLIBS) $(XCB_LIBS)
+libvk_x11_plugin_la_LIBADD = $(XCB_LIBS)
libegl_x11_plugin_la_SOURCES = video_output/opengl/egl.c
libegl_x11_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) -DUSE_PLATFORM_X11=1
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5e3f184e919f5dfced35e1d2b514d59a57d00088...baadf3ab3ee923aa55ee043cd689985ce46c8fdb
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5e3f184e919f5dfced35e1d2b514d59a57d00088...baadf3ab3ee923aa55ee043cd689985ce46c8fdb
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