summaryrefslogtreecommitdiffstats
path: root/video/out/hwdec/hwdec_cuda_vk.c
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/hwdec/hwdec_cuda_vk.c')
-rw-r--r--video/out/hwdec/hwdec_cuda_vk.c50
1 files changed, 29 insertions, 21 deletions
diff --git a/video/out/hwdec/hwdec_cuda_vk.c b/video/out/hwdec/hwdec_cuda_vk.c
index b9f8caa815..e744ff628a 100644
--- a/video/out/hwdec/hwdec_cuda_vk.c
+++ b/video/out/hwdec/hwdec_cuda_vk.c
@@ -24,7 +24,8 @@
#include <libavutil/hwcontext.h>
#include <libavutil/hwcontext_cuda.h>
#include <libplacebo/vulkan.h>
-#include <unistd.h>
+
+#include "osdep/io.h"
#if HAVE_WIN32_DESKTOP
#include <versionhelpers.h>
@@ -147,8 +148,8 @@ static bool cuda_ext_vk_init(struct ra_hwdec_mapper *mapper,
if (evk->vk_sem.sem == VK_NULL_HANDLE) {
ret = -1;
goto error;
- }
- // The returned FD or Handle is owned by the caller (us).
+ }
+ // The returned FD or Handle is owned by the caller (us).
CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC w_desc = {
#if HAVE_WIN32_DESKTOP
@@ -233,8 +234,8 @@ static bool cuda_ext_vk_wait(const struct ra_hwdec_mapper *mapper, int n)
.value = evk->vk_sem.value
}
}
- };
- ret = CHECK_CU(cu->cuWaitExternalSemaphoresAsync(&evk->cuda_sem,
+ };
+ ret = CHECK_CU(cu->cuWaitExternalSemaphoresAsync(&evk->cuda_sem,
&wp, 1, 0));
return ret == 0;
}
@@ -272,27 +273,30 @@ static bool cuda_ext_vk_signal(const struct ra_hwdec_mapper *mapper, int n)
#undef CHECK_CU
#define CHECK_CU(x) check_cu(hw, (x), #x)
-bool cuda_vk_init(const struct ra_hwdec *hw) {
+static bool cuda_vk_check(const struct ra_hwdec *hw) {
+ pl_gpu gpu = ra_pl_get(hw->ra_ctx->ra);
+ if (gpu == NULL)
+ return false; // This is not a Vulkan RA.
+
+ if (!(gpu->export_caps.tex & HANDLE_TYPE)) {
+ MP_VERBOSE(hw, "CUDA hwdec with Vulkan requires exportable texture memory of type 0x%X.\n",
+ HANDLE_TYPE);
+ return false;
+ } else if (!(gpu->export_caps.sync & HANDLE_TYPE)) {
+ MP_VERBOSE(hw, "CUDA hwdec with Vulkan requires exportable semaphores of type 0x%X.\n",
+ HANDLE_TYPE);
+ return false;
+ }
+
+ return true;
+}
+
+static bool cuda_vk_init(const struct ra_hwdec *hw) {
int ret = 0;
int level = hw->probing ? MSGL_V : MSGL_ERR;
struct cuda_hw_priv *p = hw->priv;
CudaFunctions *cu = p->cu;
-
pl_gpu gpu = ra_pl_get(hw->ra_ctx->ra);
- if (gpu != NULL) {
- if (!(gpu->export_caps.tex & HANDLE_TYPE)) {
- MP_VERBOSE(hw, "CUDA hwdec with Vulkan requires exportable texture memory of type 0x%X.\n",
- HANDLE_TYPE);
- return false;
- } else if (!(gpu->export_caps.sync & HANDLE_TYPE)) {
- MP_VERBOSE(hw, "CUDA hwdec with Vulkan requires exportable semaphores of type 0x%X.\n",
- HANDLE_TYPE);
- return false;
- }
- } else {
- // This is not a Vulkan RA.
- return false;
- }
if (!cu->cuImportExternalMemory) {
MP_MSG(hw, level, "CUDA hwdec with Vulkan requires driver version 410.48 or newer.\n");
@@ -342,3 +346,7 @@ bool cuda_vk_init(const struct ra_hwdec *hw) {
return true;
}
+struct cuda_interop_fn cuda_vk_fn = {
+ .check = cuda_vk_check,
+ .init = cuda_vk_init
+};