mirror of https://github.com/mpv-player/mpv
hwdec_cuda: drop old PL_API_VER compatibility path
LIBPLACEBO_NEXT is now implied by libplacebo being available
This commit is contained in:
parent
b1f9aa648a
commit
e3ae072414
|
@ -23,9 +23,7 @@
|
|||
|
||||
#include <libavutil/hwcontext.h>
|
||||
#include <libavutil/hwcontext_cuda.h>
|
||||
#if HAVE_LIBPLACEBO_NEXT
|
||||
#include <libplacebo/vulkan.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
||||
#if HAVE_WIN32_DESKTOP
|
||||
|
@ -42,16 +40,9 @@ struct ext_vk {
|
|||
CUmipmappedArray mma;
|
||||
|
||||
pl_tex pltex;
|
||||
#if HAVE_LIBPLACEBO_NEXT
|
||||
pl_vulkan_sem vk_sem;
|
||||
union pl_handle sem_handle;
|
||||
CUexternalSemaphore cuda_sem;
|
||||
#else
|
||||
pl_sync sync;
|
||||
|
||||
CUexternalSemaphore ss;
|
||||
CUexternalSemaphore ws;
|
||||
#endif
|
||||
};
|
||||
|
||||
static bool cuda_ext_vk_init(struct ra_hwdec_mapper *mapper,
|
||||
|
@ -61,9 +52,6 @@ static bool cuda_ext_vk_init(struct ra_hwdec_mapper *mapper,
|
|||
struct cuda_mapper_priv *p = mapper->priv;
|
||||
CudaFunctions *cu = p_owner->cu;
|
||||
int mem_fd = -1;
|
||||
#if !HAVE_LIBPLACEBO_NEXT
|
||||
int wait_fd = -1, signal_fd = -1;
|
||||
#endif
|
||||
int ret = 0;
|
||||
|
||||
struct ext_vk *evk = talloc_ptrtype(NULL, evk);
|
||||
|
@ -151,7 +139,6 @@ static bool cuda_ext_vk_init(struct ra_hwdec_mapper *mapper,
|
|||
if (ret < 0)
|
||||
goto error;
|
||||
|
||||
#if HAVE_LIBPLACEBO_NEXT
|
||||
evk->vk_sem.sem = pl_vulkan_sem_create(gpu, pl_vulkan_sem_params(
|
||||
.type = VK_SEMAPHORE_TYPE_TIMELINE,
|
||||
.export_handle = HANDLE_TYPE,
|
||||
|
@ -177,47 +164,6 @@ static bool cuda_ext_vk_init(struct ra_hwdec_mapper *mapper,
|
|||
goto error;
|
||||
// CUDA takes ownership of an imported FD *but not* an imported Handle.
|
||||
evk->sem_handle.fd = -1;
|
||||
#else
|
||||
evk->sync = pl_sync_create(gpu, HANDLE_TYPE);
|
||||
if (!evk->sync) {
|
||||
ret = -1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
#if !HAVE_WIN32_DESKTOP
|
||||
wait_fd = dup(evk->sync->wait_handle.fd);
|
||||
signal_fd = dup(evk->sync->signal_handle.fd);
|
||||
#endif
|
||||
|
||||
CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC w_desc = {
|
||||
#if HAVE_WIN32_DESKTOP
|
||||
.type = CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32,
|
||||
.handle.win32.handle = evk->sync->wait_handle.handle,
|
||||
#else
|
||||
.type = CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD,
|
||||
.handle.fd = wait_fd,
|
||||
#endif
|
||||
};
|
||||
ret = CHECK_CU(cu->cuImportExternalSemaphore(&evk->ws, &w_desc));
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
wait_fd = -1;
|
||||
|
||||
CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC s_desc = {
|
||||
#if HAVE_WIN32_DESKTOP
|
||||
.type = CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32,
|
||||
.handle.win32.handle = evk->sync->signal_handle.handle,
|
||||
#else
|
||||
.type = CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD,
|
||||
.handle.fd = signal_fd,
|
||||
#endif
|
||||
};
|
||||
|
||||
ret = CHECK_CU(cu->cuImportExternalSemaphore(&evk->ss, &s_desc));
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
signal_fd = -1;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -225,19 +171,12 @@ error:
|
|||
MP_ERR(mapper, "cuda_ext_vk_init failed\n");
|
||||
if (mem_fd > -1)
|
||||
close(mem_fd);
|
||||
#if HAVE_LIBPLACEBO_NEXT
|
||||
#if HAVE_WIN32_DESKTOP
|
||||
if (evk->sem_handle.handle != NULL)
|
||||
CloseHandle(evk->sem_handle.handle);
|
||||
#else
|
||||
if (evk->sem_handle.fd > -1)
|
||||
close(evk->sem_handle.fd);
|
||||
#endif
|
||||
#else
|
||||
if (wait_fd > -1)
|
||||
close(wait_fd);
|
||||
if (signal_fd > -1)
|
||||
close(signal_fd);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
@ -258,7 +197,6 @@ static void cuda_ext_vk_uninit(const struct ra_hwdec_mapper *mapper, int n)
|
|||
CHECK_CU(cu->cuDestroyExternalMemory(evk->mem));
|
||||
evk->mem = 0;
|
||||
}
|
||||
#if HAVE_LIBPLACEBO_NEXT
|
||||
if (evk->cuda_sem) {
|
||||
CHECK_CU(cu->cuDestroyExternalSemaphore(evk->cuda_sem));
|
||||
evk->cuda_sem = 0;
|
||||
|
@ -266,17 +204,6 @@ static void cuda_ext_vk_uninit(const struct ra_hwdec_mapper *mapper, int n)
|
|||
pl_vulkan_sem_destroy(ra_pl_get(mapper->ra), &evk->vk_sem.sem);
|
||||
#if HAVE_WIN32_DESKTOP
|
||||
CloseHandle(evk->sem_handle.handle);
|
||||
#endif
|
||||
#else
|
||||
if (evk->ss) {
|
||||
CHECK_CU(cu->cuDestroyExternalSemaphore(evk->ss));
|
||||
evk->ss = 0;
|
||||
}
|
||||
if (evk->ws) {
|
||||
CHECK_CU(cu->cuDestroyExternalSemaphore(evk->ws));
|
||||
evk->ws = 0;
|
||||
}
|
||||
pl_sync_destroy(ra_pl_get(mapper->ra), &evk->sync);
|
||||
#endif
|
||||
}
|
||||
talloc_free(evk);
|
||||
|
@ -290,7 +217,6 @@ static bool cuda_ext_vk_wait(const struct ra_hwdec_mapper *mapper, int n)
|
|||
int ret;
|
||||
struct ext_vk *evk = p->ext[n];
|
||||
|
||||
#if HAVE_LIBPLACEBO_NEXT
|
||||
evk->vk_sem.value += 1;
|
||||
ret = pl_vulkan_hold_ex(ra_pl_get(mapper->ra), pl_vulkan_hold_params(
|
||||
.tex = evk->pltex,
|
||||
|
@ -310,16 +236,6 @@ static bool cuda_ext_vk_wait(const struct ra_hwdec_mapper *mapper, int n)
|
|||
};
|
||||
ret = CHECK_CU(cu->cuWaitExternalSemaphoresAsync(&evk->cuda_sem,
|
||||
&wp, 1, 0));
|
||||
#else
|
||||
ret = pl_tex_export(ra_pl_get(mapper->ra),
|
||||
evk->pltex, evk->sync);
|
||||
if (!ret)
|
||||
return false;
|
||||
|
||||
CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS wp = { 0, };
|
||||
ret = CHECK_CU(cu->cuWaitExternalSemaphoresAsync(&evk->ws,
|
||||
&wp, 1, 0));
|
||||
#endif
|
||||
return ret == 0;
|
||||
}
|
||||
|
||||
|
@ -331,7 +247,6 @@ static bool cuda_ext_vk_signal(const struct ra_hwdec_mapper *mapper, int n)
|
|||
int ret;
|
||||
struct ext_vk *evk = p->ext[n];
|
||||
|
||||
#if HAVE_LIBPLACEBO_NEXT
|
||||
evk->vk_sem.value += 1;
|
||||
CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS sp = {
|
||||
.params = {
|
||||
|
@ -351,11 +266,6 @@ static bool cuda_ext_vk_signal(const struct ra_hwdec_mapper *mapper, int n)
|
|||
.qf = VK_QUEUE_FAMILY_EXTERNAL,
|
||||
.semaphore = evk->vk_sem,
|
||||
));
|
||||
#else
|
||||
CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS sp = { 0, };
|
||||
ret = CHECK_CU(cu->cuSignalExternalSemaphoresAsync(&evk->ss,
|
||||
&sp, 1, 0));
|
||||
#endif
|
||||
return ret == 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue