diff options
author | Philip Langdale <philipl@overt.org> | 2019-09-15 17:49:13 -0700 |
---|---|---|
committer | Philip Langdale <philipl@overt.org> | 2019-09-15 17:51:47 -0700 |
commit | 237f5fa1b7302d61466991d109179f86ce00b8bb (patch) | |
tree | 91cca425a57e18083ef69b386d1f1783a0b36186 /video/out/hwdec/hwdec_cuda.c | |
parent | 0abe34ed21023b83c7311d85ea317f3af7b5b89c (diff) | |
download | mpv-237f5fa1b7302d61466991d109179f86ce00b8bb.tar.bz2 mpv-237f5fa1b7302d61466991d109179f86ce00b8bb.tar.xz |
vo_gpu: hwdec_cuda: Improve interop selection mechanism
This change updates the interop selection to match what I did for
VAAPI, by iterating through an array of init functions until one
of them works.
Diffstat (limited to 'video/out/hwdec/hwdec_cuda.c')
-rw-r--r-- | video/out/hwdec/hwdec_cuda.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/video/out/hwdec/hwdec_cuda.c b/video/out/hwdec/hwdec_cuda.c index 78eb936f17..3edc58c6eb 100644 --- a/video/out/hwdec/hwdec_cuda.c +++ b/video/out/hwdec/hwdec_cuda.c @@ -56,6 +56,16 @@ int check_cu(const struct ra_hwdec *hw, CUresult err, const char *func) #define CHECK_CU(x) check_cu(hw, (x), #x) +const static cuda_interop_init interop_inits[] = { +#if HAVE_GL + cuda_gl_init, +#endif +#if HAVE_VULKAN + cuda_vk_init, +#endif + NULL +}; + static int cuda_init(struct ra_hwdec *hw) { AVBufferRef *hw_device_ctx = NULL; @@ -76,18 +86,11 @@ static int cuda_init(struct ra_hwdec *hw) return -1; // Initialise CUDA context from backend. - // We call all possible inits because these will do nothing if the ra context - // doesn't match. -#if HAVE_GL - if (!cuda_gl_init(hw)) { - return -1; - } -#endif -#if HAVE_VULKAN - if (!cuda_vk_init(hw)) { - return -1; + for (int i = 0; interop_inits[i]; i++) { + if (interop_inits[i](hw)) { + break; + } } -#endif if (!p->ext_init || !p->ext_uninit) { MP_VERBOSE(hw, "CUDA hwdec only works with OpenGL or Vulkan backends.\n"); |