[vlc-devel] [PATCH 4/5] vout/vulkan: add win32 extension module

Niklas Haas vlc at haasn.xyz
Wed Oct 10 03:46:36 CEST 2018


From: Marvin Scholz <epirat07 at gmail.com>

---
 modules/video_output/Makefile.am             | 11 ++++
 modules/video_output/vulkan/platform_win32.c | 60 ++++++++++++++++++++
 2 files changed, 71 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 952684d57d..067e370b8f 100644
--- a/modules/video_output/Makefile.am
+++ b/modules/video_output/Makefile.am
@@ -399,6 +399,17 @@ if HAVE_WIN32
 vout_LTLIBRARIES += libdrawable_plugin.la
 endif
 
+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_WIN32_DESKTOP
+if HAVE_VULKAN
+vout_LTLIBRARIES += libvk_win32_plugin.la
+endif
+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..5dc20ae17b
--- /dev/null
+++ b/modules/video_output/vulkan/platform_win32.c
@@ -0,0 +1,60 @@
+/**
+ * @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.
+ *****************************************************************************/
+
+#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.0



More information about the vlc-devel mailing list