diff options
author | Philip Langdale <philipl@overt.org> | 2018-10-28 09:25:30 -0700 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2018-10-31 09:20:06 +0100 |
commit | 84d6638907b488a1724ec33978773ef8a586dfc0 (patch) | |
tree | 77300732de8f5142f4b5baf54ad16f8119fd12e5 | |
parent | 4056a9a420a3d404d44994606a942b3a7ec1766c (diff) | |
download | mpv-84d6638907b488a1724ec33978773ef8a586dfc0.tar.bz2 mpv-84d6638907b488a1724ec33978773ef8a586dfc0.tar.xz |
vo_gpu: hwdec_cuda: Clean up init() error handling
Currently, the error paths in init() are a bit confusing, and we can
end up trying to pop the current context when there is no context,
which leads to distracting error messages.
I also added an explicit path to return early if the GPU backend is
not OpenGL or Vulkan. It's pointless to do any other cuda init
after that point. (Of course, someone could write more interops.)
Fixes #6256
-rw-r--r-- | video/out/opengl/hwdec_cuda.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/video/out/opengl/hwdec_cuda.c b/video/out/opengl/hwdec_cuda.c index b90344794c..af7ea6ca48 100644 --- a/video/out/opengl/hwdec_cuda.c +++ b/video/out/opengl/hwdec_cuda.c @@ -123,13 +123,18 @@ static int cuda_init(struct ra_hwdec *hw) p->is_vk = ra_vk_get(hw->ra) != NULL; if (p->is_vk) { if (!ra_vk_get(hw->ra)->has_ext_external_memory_export) { - MP_ERR(hw, "CUDA hwdec with Vulkan requires the %s extension\n", - MP_VK_EXTERNAL_MEMORY_EXPORT_EXTENSION_NAME); + MP_VERBOSE(hw, "CUDA hwdec with Vulkan requires the %s extension\n", + MP_VK_EXTERNAL_MEMORY_EXPORT_EXTENSION_NAME); return -1; } } #endif + if (!p->is_gl && !p->is_vk) { + MP_VERBOSE(hw, "CUDA hwdec only works with OpenGL or Vulkan backends.\n"); + return -1; + } + ret = cuda_load_functions(&p->cu, NULL); if (ret != 0) { MP_VERBOSE(hw, "Failed to load CUDA symbols\n"); @@ -144,7 +149,7 @@ static int cuda_init(struct ra_hwdec *hw) ret = CHECK_CU(cu->cuInit(0)); if (ret < 0) - goto error; + return -1; // Allocate display context if (p->is_gl) { @@ -152,12 +157,12 @@ static int cuda_init(struct ra_hwdec *hw) ret = CHECK_CU(cu->cuGLGetDevices(&device_count, &display_dev, 1, CU_GL_DEVICE_LIST_ALL)); if (ret < 0) - goto error; + return -1; ret = CHECK_CU(cu->cuCtxCreate(&p->display_ctx, CU_CTX_SCHED_BLOCKING_SYNC, display_dev)); if (ret < 0) - goto error; + return -1; p->decode_ctx = p->display_ctx; @@ -177,12 +182,12 @@ static int cuda_init(struct ra_hwdec *hw) // Pop the display context. We won't use it again during init() ret = CHECK_CU(cu->cuCtxPopCurrent(&dummy)); if (ret < 0) - goto error; + return -1; ret = CHECK_CU(cu->cuCtxCreate(&p->decode_ctx, CU_CTX_SCHED_BLOCKING_SYNC, decode_dev)); if (ret < 0) - goto error; + return -1; } } } else if (p->is_vk) { @@ -195,7 +200,7 @@ static int cuda_init(struct ra_hwdec *hw) int count; ret = CHECK_CU(cu->cuDeviceGetCount(&count)); if (ret < 0) - goto error; + return -1; display_dev = -1; for (int i = 0; i < count; i++) { @@ -217,13 +222,13 @@ static int cuda_init(struct ra_hwdec *hw) if (display_dev == -1) { MP_ERR(hw, "Could not match Vulkan display device in CUDA.\n"); - goto error; + return -1; } ret = CHECK_CU(cu->cuCtxCreate(&p->display_ctx, CU_CTX_SCHED_BLOCKING_SYNC, display_dev)); if (ret < 0) - goto error; + return -1; p->decode_ctx = p->display_ctx; #endif |