mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.12k stars 2.88k forks source link

vo=gpu-next does not use r16ui to map planes, so no yuv420p10 support (GLES) #13706

Open sfan5 opened 6 months ago

sfan5 commented 6 months ago

Important Information

Reproduction steps

Play 10-bit video

Expected behavior

vo_gpu gpu.txt

Actual behavior

vo_gpu_next gpu2.txt here mpv does a conversion to gbrpf32 because it's the only >8-bit format the VO reports. this results in playback becoming a slideshow.

haasn commented 6 months ago

Seems like we need to allow for an extra UINT correction scaling factor, like what vo_gpu does in copy_image.

kasper93 commented 3 weeks ago

To support this it is as simple as allowing the UINT formats, this is 5 minute patch. Though it needs special pass to support hooks, because they might not expect uint.

This works, for simple direct sampling case:

commit 387613bc823a9d4f8091b216ebfb694c351006ec
Author: Kacper Michajłow <kasper93@gmail.com>
Date:   Mon Sep 16 21:58:26 2024 +0200

    utils/upload: allow integer upload for opengl

diff --git a/src/shaders/sampling.c b/src/shaders/sampling.c
index e7bddaf2..aff2c2e0 100644
--- a/src/shaders/sampling.c
+++ b/src/shaders/sampling.c
@@ -108,6 +108,9 @@ static bool setup_src(pl_shader sh, const struct pl_sample_src *src,
     if (scale)
         *scale = PL_DEF(src->scale, 1.0);

+    if (src->tex->params.format->type == PL_FMT_UINT)
+        *scale *= 1.0 / ((1ull << 16) - 1);
+
     if (comp_mask) {
         uint8_t tex_mask = 0x0Fu;
         if (src->tex) {
@@ -277,8 +280,8 @@ bool pl_shader_sample_direct(pl_shader sh, const struct pl_sample_src *src)
     if (!setup_src(sh, src, &tex, &pos, NULL, NULL, NULL, NULL, &scale, true, BEST))
         return false;

-    GLSL("// pl_shader_sample_direct                            \n"
-         "vec4 color = vec4("$") * textureLod("$", "$", 0.0);   \n",
+    GLSL("// pl_shader_sample_direct                                  \n"
+         "vec4 color = vec4("$") * vec4(textureLod("$", "$", 0.0));   \n",
          SH_FLOAT(scale), tex, pos);
     return true;
 }
diff --git a/src/utils/upload.c b/src/utils/upload.c
index 4a94fd18..2c0ca185 100644
--- a/src/utils/upload.c
+++ b/src/utils/upload.c
@@ -187,7 +187,9 @@ pl_fmt pl_plane_find_fmt(pl_gpu gpu, int out_map[4], const struct pl_plane_data
         pl_fmt fmt = gpu->formats[n];
         if (fmt->opaque || fmt->num_components < num)
             continue;
-        if (fmt->type != data->type || fmt->texel_size != data->pixel_stride)
+        if (fmt->texel_size != data->pixel_stride)
+            continue;
+        if (fmt->type != data->type && fmt->type != PL_FMT_UINT)
             continue;
         if (!(fmt->caps & PL_FMT_CAP_SAMPLEABLE))
             continue;