[vlc-devel] [PATCH 4/6] vout/vulkan: add win32 extension module
Niklas Haas
vlc at haasn.xyz
Mon Oct 29 14:28:52 CET 2018
From: Marvin Scholz <epirat07 at gmail.com>
---
modules/video_output/Makefile.am | 10 +++
modules/video_output/vulkan/platform_win32.c | 64 ++++++++++++++++++++
2 files changed, 74 insertions(+)
create mode 100644 modules/video_output/vulkan/platform_win32.c
diff --git a/modules/video_output/Makefile.am b/modules/video_output/Makefile.am
index 96ee30c336..6a459fe102 100644
--- a/modules/video_output/Makefile.am
+++ b/modules/video_output/Makefile.am
@@ -146,11 +146,20 @@ 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_win32_plugin_la_SOURCES = $(VULKAN_COMMONSOURCES) video_output/vulkan/surface.c \
+ video_output/vulkan/platform_win32.c
+libvk_win32_plugin_la_CFLAGS = $(AM_CFLAGS) $(VULKAN_COMMONCFLAGS) \
+ -DVK_USE_PLATFORM_WIN32_KHR -DPLATFORM_NAME=Win32
+libvk_win32_plugin_la_LIBADD = $(VULKAN_COMMONLIBS)
+
if HAVE_VULKAN
vout_LTLIBRARIES += libvk_plugin.la
if HAVE_XCB
vout_LTLIBRARIES += libvk_x11_plugin.la
endif
+if HAVE_WIN32_DESKTOP
+vout_LTLIBRARIES += libvk_win32_plugin.la
+endif
endif
### XCB ###
@@ -405,6 +414,7 @@ if HAVE_WIN32
vout_LTLIBRARIES += libdrawable_plugin.la
endif
+
### OS/2 ###
if HAVE_OS2
vout_LTLIBRARIES += libdrawable_plugin.la
diff --git a/modules/video_output/vulkan/platform_win32.c b/modules/video_output/vulkan/platform_win32.c
new file mode 100644
index 0000000000..5f03c41c52
--- /dev/null
+++ b/modules/video_output/vulkan/platform_win32.c
@@ -0,0 +1,64 @@
+/**
+ * @file platform_win32.c
+ * @brief Vulkan platform-specific code for Win32
+ */
+/*****************************************************************************
+ * Copyright © 2018 Niklas Haas, Marvin Scholz
+ *
+ * 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.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "platform.h"
+
+int vlc_vk_InitPlatform(vlc_vk_t *vk)
+{
+ if (vk->window->type != VOUT_WINDOW_TYPE_HWND)
+ return VLC_EGENERIC;
+
+ return VLC_SUCCESS;
+}
+
+void vlc_vk_ClosePlatform(vlc_vk_t *vk)
+{
+ VLC_UNUSED(vk);
+}
+
+const char * const vlc_vk_PlatformExt = VK_KHR_WIN32_SURFACE_EXTENSION_NAME;
+
+int vlc_vk_CreateSurface(vlc_vk_t *vk)
+{
+ VkInstance vkinst = vk->instance->instance;
+
+ // Get current win32 HINSTANCE
+ HINSTANCE hInst = GetModuleHandle(NULL);
+
+ VkWin32SurfaceCreateInfoKHR winfo = {
+ .sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR,
+ .hinstance = hInst,
+ .hwnd = (HWND) vk->window->handle.hwnd,
+ };
+
+ VkResult res = vkCreateWin32SurfaceKHR(vkinst, &winfo, NULL, &vk->surface);
+ if (res != VK_SUCCESS) {
+ msg_Err(vk, "Failed creating Win32 surface");
+ return VLC_EGENERIC;
+ }
+
+ return VLC_SUCCESS;
+}
--
2.19.1
More information about the vlc-devel
mailing list