mpv-0.33.1 for slackware64-current (2021-04-22)

required : libplacebo-3.120 --- せっかくなので最新版にアップデート

PRGNAM="libplacebo"
VERSION="3.120"
HOMEPAGE="https://code.videolan.org/videolan/libplacebo"
DOWNLOAD="https://code.videolan.org/videolan/libplacebo/-/archive/v3.120/libplacebo-v3.120.tar.gz"
MD5SUM="c1924f7339971a7863d89e4448faaa9d"

mpv-0.33.1 オリジナルソースはコンパイルエラーになるため、Arch情報を参考にさせてもらい、
以下のパッチを作成し適用することでパッケージ作成可能。

mpv-0.33.1_vo_gpu-placebo_fix.patch
--- mpv-0.33.1/video/out/placebo/ra_pl.c 2021-04-06 01:45:41.000000000 +0900
+++ mpv-0.33.1.new/video/out/placebo/ra_pl.c 2021-04-21 23:37:11.084000636 +0900
@@ -22,9 +22,7 @@
     return ra->fns == &ra_fns_pl ? get_gpu(ra) : NULL;
}

-#if PL_API_VER >= 60
static struct pl_timer *get_active_timer(const struct ra *ra);
-#endif

struct ra *ra_create_pl(const struct pl_gpu *gpu, struct mp_log *log)
{
@@ -144,8 +142,14 @@
             .blit_dst = pltex->params.blit_dst,
             .host_mutable = pltex->params.host_writable,
             .downloadable = pltex->params.host_readable,
+#if PL_API_VER >= 103
+            // These don't exist upstream, so just pick something reasonable
+            .src_linear = pltex->params.format->caps & PL_FMT_CAP_LINEAR,
+            .src_repeat = false,
+#else
             .src_linear = pltex->params.sample_mode == PL_TEX_SAMPLE_LINEAR,
             .src_repeat = pltex->params.address_mode == PL_TEX_ADDRESS_REPEAT,
+#endif
         },
         .priv = (void *) pltex,
     };
@@ -157,32 +161,6 @@
                                     const struct ra_tex_params *params)
{
     const struct pl_gpu *gpu = get_gpu(ra);
-
-    // Check size limits
-    bool ok = false;
-    switch (params->dimensions) {
-    case 1:
-        ok = params->w <= gpu->limits.max_tex_1d_dim;
-        break;
-
-    case 2:
-        ok = params->w <= gpu->limits.max_tex_2d_dim &&
-             params->h <= gpu->limits.max_tex_2d_dim;
-        break;
-
-    case 3:
-        ok = params->w <= gpu->limits.max_tex_2d_dim &&
-             params->h <= gpu->limits.max_tex_2d_dim &&
-             params->d <= gpu->limits.max_tex_2d_dim;
-        break;
-    };
-
-    if (!ok) {
-        MP_ERR(ra, "Texture size %dx%dx%d exceeds dimension limits!\n",
-               params->w, params->h, params->d);
-        return NULL;
-    }
-
     const struct pl_tex *pltex = pl_tex_create(gpu, &(struct pl_tex_params) {
         .w = params->w,
         .h = params->dimensions >= 2 ? params->h : 0,
@@ -195,10 +173,12 @@
         .blit_dst = params->blit_dst || params->render_dst,
         .host_writable = params->host_mutable,
         .host_readable = params->downloadable,
+#if PL_API_VER < 103
         .sample_mode = params->src_linear ? PL_TEX_SAMPLE_LINEAR
                                           : PL_TEX_SAMPLE_NEAREST,
         .address_mode = params->src_repeat ? PL_TEX_ADDRESS_REPEAT
                                            : PL_TEX_ADDRESS_CLAMP,
+#endif
         .initial_data = params->initial_data,
     });

@@ -209,6 +189,10 @@
         return NULL;
     }

+    // Keep track of these, so we can correctly bind them later
+    ratex->params.src_repeat = params->src_repeat;
+    ratex->params.src_linear = params->src_linear;
+
     return ratex;
}

@@ -230,9 +214,7 @@
         .buf = params->buf ? params->buf->priv : NULL,
         .buf_offset = params->buf_offset,
         .ptr = (void *) params->src,
-#if PL_API_VER >= 60
         .timer = get_active_timer(ra),
-#endif
     };

     const struct pl_buf *staging = NULL;
@@ -285,9 +267,7 @@
         .tex = tex,
         .ptr = params->dst,
         .stride_w = params->stride / texel_size,
-#if PL_API_VER >= 60
         .timer = get_active_timer(ra),
-#endif
     };

     uint8_t *staging = NULL;
@@ -320,19 +300,7 @@
         [RA_BUF_TYPE_SHARED_MEMORY]  = 0,
     };

-    const struct pl_gpu *gpu = get_gpu(ra);
-    size_t max_size[] = {
-        [PL_BUF_TEX_TRANSFER] = gpu->limits.max_xfer_size,
-        [PL_BUF_UNIFORM]      = gpu->limits.max_ubo_size,
-        [PL_BUF_STORAGE]      = gpu->limits.max_ssbo_size,
-    };
-
-    if (params->size > max_size[buf_type[params->type]]) {
-        MP_ERR(ra, "Buffer size %zu exceeds size limits!\n", params->size);
-        return NULL;
-    }
-
-    const struct pl_buf *plbuf = pl_buf_create(gpu, &(struct pl_buf_params) {
+    const struct pl_buf *plbuf = pl_buf_create(get_gpu(ra), &(struct pl_buf_params) {
         .type = buf_type[params->type],
         .size = params->size,
         .host_mapped = params->host_mapped,
@@ -399,7 +367,18 @@
         pldst.y1 = MPMIN(MPMAX(dst_rc->y1, 0), dst->params.h);
     }

+#if PL_API_VER >= 103
+    pl_tex_blit(get_gpu(ra), &(struct pl_tex_blit_params) {
+        .src = src->priv,
+        .dst = dst->priv,
+        .src_rc = plsrc,
+        .dst_rc = pldst,
+        .sample_mode = src->params.src_linear ? PL_TEX_SAMPLE_LINEAR
+                                              : PL_TEX_SAMPLE_NEAREST,
+    });
+#else
     pl_tex_blit(get_gpu(ra), dst->priv, src->priv, pldst, plsrc);
+#endif
}

static const enum pl_var_type var_type[RA_VARTYPE_COUNT] = {
@@ -627,9 +606,17 @@
             struct pl_desc_binding bind;
             switch (inp->type) {
             case RA_VARTYPE_TEX:
-            case RA_VARTYPE_IMG_W:
-                bind.object = (* (struct ra_tex **) val->data)->priv;
+            case RA_VARTYPE_IMG_W: {
+                struct ra_tex *tex = *((struct ra_tex **) val->data);
+                bind.object = tex->priv;
+#if PL_API_VER >= 103
+                bind.sample_mode = tex->params.src_linear ? PL_TEX_SAMPLE_LINEAR
+                                                          : PL_TEX_SAMPLE_NEAREST;
+                bind.address_mode = tex->params.src_repeat ? PL_TEX_ADDRESS_REPEAT
+                                                           : PL_TEX_ADDRESS_CLAMP;
+#endif
                 break;
+            }
             case RA_VARTYPE_BUF_RO:
             case RA_VARTYPE_BUF_RW:
                 bind.object = (* (struct ra_buf **) val->data)->priv;
@@ -666,8 +653,6 @@
     pl_pass_run(get_gpu(ra), &pl_params);
}

-#if PL_API_VER >= 60
-
struct ra_timer_pl {
     // Because libpplacebo only supports one operation per timer, we need
     // to use multiple pl_timers to sum up multiple passes/transfers
@@ -739,8 +724,6 @@
     return t->timers[t->idx_timers++];
}

-#endif // PL_API_VER >= 60
-
static struct ra_fns ra_fns_pl = {
     .destroy                = destroy_ra_pl,
     .tex_create             = tex_create_pl,
@@ -759,11 +742,9 @@
     .renderpass_create      = renderpass_create_pl,
     .renderpass_destroy     = renderpass_destroy_pl,
     .renderpass_run         = renderpass_run_pl,
-#if PL_API_VER >= 60
     .timer_create           = timer_create_pl,
     .timer_destroy          = timer_destroy_pl,
     .timer_start            = timer_start_pl,
     .timer_stop             = timer_stop_pl,
-#endif
};