mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-17 23:42:04 +00:00
172 lines
6.1 KiB
Diff
172 lines
6.1 KiB
Diff
diff --git forkSrcPrefix/meson.build forkDstPrefix/meson.build
|
|
index 7572769e0e6f280391668c6797d67e37e2dea30f..e6109987a3d38025a5eede04441c03ee23413255 100644
|
|
--- forkSrcPrefix/meson.build
|
|
+++ forkDstPrefix/meson.build
|
|
@@ -1315,6 +1315,17 @@ if features['vulkan'] and features['x11']
|
|
sources += files('video/out/vulkan/context_xlib.c')
|
|
endif
|
|
|
|
+if host_machine.system() == 'darwin'
|
|
+ moltenvk = get_option('moltenvk').require(
|
|
+ features['vulkan'],
|
|
+ error_message: 'vulkan or moltenvk header could not be found!',
|
|
+ )
|
|
+ features += {'moltenvk': moltenvk.allowed()}
|
|
+ if features['vulkan'] and features['moltenvk']
|
|
+ sources += files('video/out/vulkan/context_moltenvk.m')
|
|
+ endif
|
|
+endif
|
|
+
|
|
features += {'vk-khr-display': vulkan.type_name() == 'internal' or
|
|
cc.has_function('vkCreateDisplayPlaneSurfaceKHR', prefix: '#include <vulkan/vulkan_core.h>',
|
|
dependencies: [vulkan])}
|
|
diff --git forkSrcPrefix/video/out/gpu/context.c forkDstPrefix/video/out/gpu/context.c
|
|
index 75dd804005ba3a1e36375b47dcc9d9bb756ab867..299841cb256372a04c3d1603f856695ce246ec01 100644
|
|
--- forkSrcPrefix/video/out/gpu/context.c
|
|
+++ forkDstPrefix/video/out/gpu/context.c
|
|
@@ -50,6 +50,7 @@ extern const struct ra_ctx_fns ra_ctx_vulkan_xlib;
|
|
extern const struct ra_ctx_fns ra_ctx_vulkan_android;
|
|
extern const struct ra_ctx_fns ra_ctx_vulkan_display;
|
|
extern const struct ra_ctx_fns ra_ctx_vulkan_mac;
|
|
+extern const struct ra_ctx_fns ra_ctx_vulkan_moltenvk;
|
|
|
|
/* Direct3D 11 */
|
|
extern const struct ra_ctx_fns ra_ctx_d3d11;
|
|
@@ -93,6 +94,9 @@ static const struct ra_ctx_fns *contexts[] = {
|
|
#if HAVE_X11
|
|
&ra_ctx_vulkan_xlib,
|
|
#endif
|
|
+#if HAVE_MOLTENVK
|
|
+ &ra_ctx_vulkan_moltenvk,
|
|
+#endif
|
|
#if HAVE_COCOA && HAVE_SWIFT
|
|
&ra_ctx_vulkan_mac,
|
|
#endif
|
|
diff --git forkSrcPrefix/video/out/vulkan/common.h forkDstPrefix/video/out/vulkan/common.h
|
|
index e75cb228f8d99462ccecf7780098ea97ae7cfe02..afc17284773204563f4c90b4860758e61068d460 100644
|
|
--- forkSrcPrefix/video/out/vulkan/common.h
|
|
+++ forkDstPrefix/video/out/vulkan/common.h
|
|
@@ -22,6 +22,9 @@
|
|
#if HAVE_WIN32_DESKTOP
|
|
#define VK_USE_PLATFORM_WIN32_KHR
|
|
#endif
|
|
+#if HAVE_MOLTENVK
|
|
+#include <MoltenVK/mvk_vulkan.h>
|
|
+#endif
|
|
#if HAVE_COCOA
|
|
#define VK_USE_PLATFORM_METAL_EXT
|
|
#endif
|
|
diff --git forkSrcPrefix/video/out/vulkan/context_moltenvk.m forkDstPrefix/video/out/vulkan/context_moltenvk.m
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..445b907f795b24b8df80389394d4ae7b3f94c6e5
|
|
--- /dev/null
|
|
+++ forkDstPrefix/video/out/vulkan/context_moltenvk.m
|
|
@@ -0,0 +1,96 @@
|
|
+/*
|
|
+ * This file is part of mpv.
|
|
+ *
|
|
+ * mpv 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.
|
|
+ *
|
|
+ * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
|
|
+ */
|
|
+
|
|
+#include <CoreGraphics/CoreGraphics.h>
|
|
+#include <QuartzCore/CAMetalLayer.h>
|
|
+#include <MoltenVK/mvk_vulkan.h>
|
|
+
|
|
+#include "common.h"
|
|
+#include "context.h"
|
|
+#include "utils.h"
|
|
+
|
|
+struct priv {
|
|
+ struct mpvk_ctx vk;
|
|
+ CAMetalLayer *layer;
|
|
+};
|
|
+
|
|
+static void moltenvk_uninit(struct ra_ctx *ctx)
|
|
+{
|
|
+ struct priv *p = ctx->priv;
|
|
+ ra_vk_ctx_uninit(ctx);
|
|
+ mpvk_uninit(&p->vk);
|
|
+}
|
|
+
|
|
+static bool moltenvk_init(struct ra_ctx *ctx)
|
|
+{
|
|
+ struct priv *p = ctx->priv = talloc_zero(ctx, struct priv);
|
|
+ struct mpvk_ctx *vk = &p->vk;
|
|
+ int msgl = ctx->opts.probing ? MSGL_V : MSGL_ERR;
|
|
+
|
|
+ if (ctx->vo->opts->WinID == -1) {
|
|
+ MP_MSG(ctx, msgl, "WinID missing\n");
|
|
+ goto fail;
|
|
+ }
|
|
+
|
|
+ if (!mpvk_init(vk, ctx, VK_EXT_METAL_SURFACE_EXTENSION_NAME))
|
|
+ goto fail;
|
|
+
|
|
+ p->layer = (__bridge CAMetalLayer *)(intptr_t)ctx->vo->opts->WinID;
|
|
+ VkMetalSurfaceCreateInfoEXT info = {
|
|
+ .sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT,
|
|
+ .pLayer = p->layer,
|
|
+ };
|
|
+
|
|
+ struct ra_ctx_params params = {0};
|
|
+
|
|
+ VkInstance inst = vk->vkinst->instance;
|
|
+ VkResult res = vkCreateMetalSurfaceEXT(inst, &info, NULL, &vk->surface);
|
|
+ if (res != VK_SUCCESS) {
|
|
+ MP_MSG(ctx, msgl, "Failed creating MoltenVK surface\n");
|
|
+ goto fail;
|
|
+ }
|
|
+
|
|
+ if (!ra_vk_ctx_init(ctx, vk, params, VK_PRESENT_MODE_FIFO_KHR))
|
|
+ goto fail;
|
|
+
|
|
+ return true;
|
|
+fail:
|
|
+ moltenvk_uninit(ctx);
|
|
+ return false;
|
|
+}
|
|
+
|
|
+static bool moltenvk_reconfig(struct ra_ctx *ctx)
|
|
+{
|
|
+ struct priv *p = ctx->priv;
|
|
+ CGSize s = p->layer.drawableSize;
|
|
+ ra_vk_ctx_resize(ctx, s.width, s.height);
|
|
+ return true;
|
|
+}
|
|
+
|
|
+static int moltenvk_control(struct ra_ctx *ctx, int *events, int request, void *arg)
|
|
+{
|
|
+ return VO_NOTIMPL;
|
|
+}
|
|
+
|
|
+const struct ra_ctx_fns ra_ctx_vulkan_moltenvk = {
|
|
+ .type = "vulkan",
|
|
+ .name = "moltenvk",
|
|
+ .reconfig = moltenvk_reconfig,
|
|
+ .control = moltenvk_control,
|
|
+ .init = moltenvk_init,
|
|
+ .uninit = moltenvk_uninit,
|
|
+};
|
|
diff --git forkSrcPrefix/meson.options forkDstPrefix/meson.options
|
|
index dae0a333ef71b75a6bb36a236de7feebd99bda40..6ed28af20a09501b4997ca81e86bb198e75327fd 100644
|
|
--- forkSrcPrefix/meson.options
|
|
+++ forkDstPrefix/meson.options
|
|
@@ -101,6 +101,7 @@ option('gl-dxinterop-d3d9', type: 'feature', value: 'auto', description: 'OpenGL
|
|
option('ios-gl', type: 'feature', value: 'auto', description: 'iOS OpenGL ES interop support')
|
|
option('videotoolbox-gl', type: 'feature', value: 'auto', description: 'Videotoolbox with OpenGL')
|
|
option('videotoolbox-pl', type: 'feature', value: 'auto', description: 'Videotoolbox with libplacebo')
|
|
+option('moltenvk', type: 'feature', value: 'auto', description: 'Moltenvk context')
|
|
|
|
# macOS features
|
|
option('macos-10-15-4-features', type: 'feature', value: 'auto', description: 'macOS 10.15.4 SDK Features')
|