summaryrefslogtreecommitdiff
path: root/pkg/mpv/patch/0003-video-out-gpu-Prevent-empty-array-when-no-compilers-.patch
blob: 2630466d45c9741ddd983376372298419b29eb18 (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 153cf9738ea8b6e108ead1707a7a9193f57f3685 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 2203b5cad9..2836d72513 100644
--- a/video/out/gpu/context.c
+++ b/video/out/gpu/context.c
@@ -117,6 +117,7 @@ static const struct ra_ctx_fns *contexts[] = {
 #if HAVE_DMABUF_WAYLAND
     &ra_ctx_wldmabuf,
 #endif
+    NULL
 };
 
 static int ra_ctx_api_help(struct mp_log *log, const struct m_option *opt,
@@ -124,7 +125,7 @@ static 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++) {
         if (!contexts[n]->hidden)
             mp_info(log, "    %s (%s)\n", contexts[n]->type, contexts[n]->name);
     }
@@ -137,7 +138,7 @@ static 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) && !contexts[i]->hidden)
             return 1;
     }
@@ -149,7 +150,7 @@ static 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++) {
         if (!contexts[n]->hidden)
             mp_info(log, "    %s (%s)\n", contexts[n]->name, contexts[n]->type);
     }
@@ -162,7 +163,7 @@ static int ra_ctx_validate_context(struct mp_log *log, const struct m_option *op
     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) && !contexts[i]->hidden)
             return 1;
     }
@@ -186,7 +187,7 @@ struct ra_ctx *ra_ctx_create(struct vo *vo, struct ra_ctx_opts opts)
     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 (contexts[i]->hidden)
             continue;
         if (!opts.probing && strcmp(contexts[i]->name, opts.context_name) != 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.37.3