summaryrefslogtreecommitdiff
path: root/pkg/mpv/patch/0003-video-out-gpu-Prevent-empty-array-when-no-compilers-.patch
blob: 862f2caa6c38fc7753266835ca99442481987d77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
From 25a7c939446a456b258e889013a1f3136199f09b Mon Sep 17 00:00:00 2001
From: Michael Forney <mforney@mforney.org>
Date: Wed, 3 Jul 2019 02:21:16 -0700
Subject: [PATCH] video/out/gpu: Prevent empty array when no compilers or
 contexts are enabled

---
 video/out/gpu/context.c | 11 ++++++-----
 video/out/gpu/spirv.c   |  1 +
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/video/out/gpu/context.c b/video/out/gpu/context.c
index 6e58cce485..0e68c45b91 100644
--- a/video/out/gpu/context.c
+++ b/video/out/gpu/context.c
@@ -110,6 +110,7 @@ static const struct ra_ctx_fns *contexts[] = {
     &ra_ctx_vulkan_display,
 
 #endif
+    NULL
 };
 
 int ra_ctx_api_help(struct mp_log *log, const struct m_option *opt,
@@ -117,7 +118,7 @@ int ra_ctx_api_help(struct mp_log *log, const struct m_option *opt,
 {
     mp_info(log, "GPU APIs (contexts):\n");
     mp_info(log, "    auto (autodetect)\n");
-    for (int n = 0; n < MP_ARRAY_SIZE(contexts); n++)
+    for (int n = 0; n < MP_ARRAY_SIZE(contexts) - 1; n++)
         mp_info(log, "    %s (%s)\n", contexts[n]->type, contexts[n]->name);
     return M_OPT_EXIT;
 }
@@ -128,7 +129,7 @@ int ra_ctx_validate_api(struct mp_log *log, const struct m_option *opt,
     struct bstr param = bstr0(*value);
     if (bstr_equals0(param, "auto"))
         return 1;
-    for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
+    for (int i = 0; i < MP_ARRAY_SIZE(contexts) - 1; i++) {
         if (bstr_equals0(param, contexts[i]->type))
             return 1;
     }
@@ -140,7 +141,7 @@ int ra_ctx_context_help(struct mp_log *log, const struct m_option *opt,
 {
     mp_info(log, "GPU contexts (APIs):\n");
     mp_info(log, "    auto (autodetect)\n");
-    for (int n = 0; n < MP_ARRAY_SIZE(contexts); n++)
+    for (int n = 0; n < MP_ARRAY_SIZE(contexts) - 1; n++)
         mp_info(log, "    %s (%s)\n", contexts[n]->name, contexts[n]->type);
     return M_OPT_EXIT;
 }
@@ -151,7 +152,7 @@ int ra_ctx_validate_context(struct mp_log *log, const struct m_option *opt,
     struct bstr param = bstr0(*value);
     if (bstr_equals0(param, "auto"))
         return 1;
-    for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
+    for (int i = 0; i < MP_ARRAY_SIZE(contexts) - 1; i++) {
         if (bstr_equals0(param, contexts[i]->name))
             return 1;
     }
@@ -176,7 +177,7 @@ struct ra_ctx *ra_ctx_create(struct vo *vo, const char *context_type,
     bool old_probing = vo->probing;
     vo->probing = opts.probing;
 
-    for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
+    for (int i = 0; i < MP_ARRAY_SIZE(contexts) - 1; i++) {
         if (!opts.probing && strcmp(contexts[i]->name, context_name) != 0)
             continue;
         if (!api_auto && strcmp(contexts[i]->type, context_type) != 0)
diff --git a/video/out/gpu/spirv.c b/video/out/gpu/spirv.c
index 67088bc7df..69100497eb 100644
--- a/video/out/gpu/spirv.c
+++ b/video/out/gpu/spirv.c
@@ -16,6 +16,7 @@ static const struct spirv_compiler_fns *compilers[] = {
 #if HAVE_SHADERC
     [SPIRV_SHADERC] = &spirv_shaderc,
 #endif
+    NULL
 };
 
 static const struct m_opt_choice_alternatives compiler_choices[] = {
-- 
2.35.1