[vlc-commits] vout/vulkan: add win32 extension module

Marvin Scholz git at videolan.org
Wed Nov 7 17:09:49 CET 2018


vlc | branch: master | Marvin Scholz <epirat07 at gmail.com> | Sun Feb 25 01:48:03 2018 +0100| [b3f9280f78781e27087a79e686e4ed1e14d9dea5] | committer: Thomas Guillem

vout/vulkan: add win32 extension module

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b3f9280f78781e27087a79e686e4ed1e14d9dea5
---

 modules/video_output/Makefile.am             | 10 +++++
 modules/video_output/vulkan/platform_win32.c | 64 ++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+)

diff --git a/modules/video_output/Makefile.am b/modules/video_output/Makefile.am
index 52858ca293..32889e3da7 100644
--- a/modules/video_output/Makefile.am
+++ b/modules/video_output/Makefile.am
@@ -148,11 +148,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 ###
@@ -407,6 +416,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;
+}



More information about the vlc-commits mailing list