summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJrelvas <55360900+jrelvas-ipc@users.noreply.github.com>2024-05-03 09:47:19 +0100
committerKacper Michajłow <kasper93@gmail.com>2024-05-07 00:34:46 +0200
commit1759d73c83a4a6c191d423cf6735affb8c474d9c (patch)
treebc7e6d098c8ad8dcbffe6ea66568c69b4253974c
parent58f50c8e491f3c95ccc2f83120a0428641ff3661 (diff)
downloadmpv-1759d73c83a4a6c191d423cf6735affb8c474d9c.tar.bz2
mpv-1759d73c83a4a6c191d423cf6735affb8c474d9c.tar.xz
hwdec_cuda: reduce nesting in check functions
This simplifies the code and makes it easier to read.
-rw-r--r--video/out/hwdec/hwdec_cuda_gl.c14
-rw-r--r--video/out/hwdec/hwdec_cuda_vk.c22
2 files changed, 16 insertions, 20 deletions
diff --git a/video/out/hwdec/hwdec_cuda_gl.c b/video/out/hwdec/hwdec_cuda_gl.c
index d483de7f19..4c2535232f 100644
--- a/video/out/hwdec/hwdec_cuda_gl.c
+++ b/video/out/hwdec/hwdec_cuda_gl.c
@@ -106,14 +106,12 @@ static void cuda_ext_gl_uninit(const struct ra_hwdec_mapper *mapper, int n)
#define CHECK_CU(x) check_cu(hw, (x), #x)
static bool cuda_gl_check(const struct ra_hwdec *hw) {
- if (ra_is_gl(hw->ra_ctx->ra)) {
- GL *gl = ra_gl_get(hw->ra_ctx->ra);
- if (gl->version < 210 && gl->es < 300) {
- MP_VERBOSE(hw, "need OpenGL >= 2.1 or OpenGL-ES >= 3.0\n");
- return false;
- }
- } else {
- // This is not an OpenGL RA.
+ if (!ra_is_gl(hw->ra_ctx->ra))
+ return false; // This is not an OpenGL RA.
+
+ GL *gl = ra_gl_get(hw->ra_ctx->ra);
+ if (gl->version < 210 && gl->es < 300) {
+ MP_VERBOSE(hw, "need OpenGL >= 2.1 or OpenGL-ES >= 3.0\n");
return false;
}
diff --git a/video/out/hwdec/hwdec_cuda_vk.c b/video/out/hwdec/hwdec_cuda_vk.c
index 10b94931a0..73d38fb53d 100644
--- a/video/out/hwdec/hwdec_cuda_vk.c
+++ b/video/out/hwdec/hwdec_cuda_vk.c
@@ -273,18 +273,16 @@ static bool cuda_ext_vk_signal(const struct ra_hwdec_mapper *mapper, int n)
static bool cuda_vk_check(const struct ra_hwdec *hw) {
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.
+ 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;
}