Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package libplacebo for openSUSE:Factory 
checked in at 2023-01-05 15:00:21
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libplacebo (Old)
 and      /work/SRC/openSUSE:Factory/.libplacebo.new.1563 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libplacebo"

Thu Jan  5 15:00:21 2023 rev:22 rq:1055955 version:5.229.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/libplacebo/libplacebo.changes    2022-11-27 
12:52:59.239192379 +0100
+++ /work/SRC/openSUSE:Factory/.libplacebo.new.1563/libplacebo.changes  
2023-01-05 15:00:34.452932146 +0100
@@ -1,0 +2,6 @@
+Wed Jan  4 16:22:00 UTC 2023 - Niklas Haas <o...@haasn.xyz>
+
+- Update libplacebo to version 5.229.2. See details in:
+    https://code.videolan.org/videolan/libplacebo/-/tags/v5.229.2
+
+-------------------------------------------------------------------

Old:
----
  libplacebo-v5.229.1.tar.bz2

New:
----
  libplacebo-v5.229.2.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libplacebo.spec ++++++
--- /var/tmp/diff_new_pack.kWVBXv/_old  2023-01-05 15:00:34.976934908 +0100
+++ /var/tmp/diff_new_pack.kWVBXv/_new  2023-01-05 15:00:34.980934929 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package libplacebo
 #
-# Copyright (c) 2022 SUSE LLC
+# Copyright (c) 2023 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 %define sover   229
 Name:           libplacebo
-Version:        5.229.1
+Version:        5.229.2
 Release:        0
 Summary:        Library for GPU-accelerated video/image rendering primitives
 License:        LGPL-2.1-or-later

++++++ libplacebo-v5.229.1.tar.bz2 -> libplacebo-v5.229.2.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libplacebo-v5.229.1/demos/meson.build 
new/libplacebo-v5.229.2/demos/meson.build
--- old/libplacebo-v5.229.1/demos/meson.build   2022-11-01 19:29:44.000000000 
+0100
+++ new/libplacebo-v5.229.2/demos/meson.build   2023-01-04 17:18:14.000000000 
+0100
@@ -35,6 +35,7 @@
 
 conf_demos = configuration_data()
 conf_demos.set('HAVE_NUKLEAR', nuklear.found())
+conf_demos.set('HAVE_EGL', cc.check_header('EGL/egl.h', required: false))
 
 apis = []
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libplacebo-v5.229.1/demos/window_glfw.c 
new/libplacebo-v5.229.2/demos/window_glfw.c
--- old/libplacebo-v5.229.1/demos/window_glfw.c 2022-11-01 19:29:44.000000000 
+0100
+++ new/libplacebo-v5.229.2/demos/window_glfw.c 2023-01-04 17:18:14.000000000 
+0100
@@ -32,6 +32,11 @@
 
 #include <GLFW/glfw3.h>
 
+#if defined(USE_GL) && defined(HAVE_EGL)
+#define GLFW_EXPOSE_NATIVE_EGL
+#include <GLFW/glfw3native.h>
+#endif
+
 #ifdef USE_D3D11
 #define GLFW_EXPOSE_NATIVE_WIN32
 #include <GLFW/glfw3native.h>
@@ -194,6 +199,9 @@
 
     for (int i = 0; i < PL_ARRAY_SIZE(gl_vers); i++) {
         glfwWindowHint(GLFW_CLIENT_API, gl_vers[i].api);
+#ifdef HAVE_EGL
+        glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
+#endif
         glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, gl_vers[i].major);
         glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, gl_vers[i].minor);
         glfwWindowHint(GLFW_OPENGL_PROFILE, gl_vers[i].profile);
@@ -280,6 +288,10 @@
     p->gl = pl_opengl_create(log, pl_opengl_params(
         .allow_software = true,
         .debug = DEBUG,
+#ifdef HAVE_EGL
+        .egl_display = glfwGetEGLDisplay(),
+        .egl_context = glfwGetEGLContext(p->win),
+#endif
         .make_current = make_current,
         .release_current = release_current,
         .get_proc_addr = glfwGetProcAddress,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libplacebo-v5.229.1/meson.build 
new/libplacebo-v5.229.2/meson.build
--- old/libplacebo-v5.229.1/meson.build 2022-11-01 19:29:44.000000000 +0100
+++ new/libplacebo-v5.229.2/meson.build 2023-01-04 17:18:14.000000000 +0100
@@ -243,7 +243,7 @@
       '1': '',
     }.keys().length(),
     # Fix version
-    0)
+    2)
 )
 
 ### Version number and configuration
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libplacebo-v5.229.1/src/include/libplacebo/shaders/custom.h 
new/libplacebo-v5.229.2/src/include/libplacebo/shaders/custom.h
--- old/libplacebo-v5.229.1/src/include/libplacebo/shaders/custom.h     
2022-11-01 19:29:44.000000000 +0100
+++ new/libplacebo-v5.229.2/src/include/libplacebo/shaders/custom.h     
2023-01-04 17:18:14.000000000 +0100
@@ -117,7 +117,7 @@
     PL_HOOK_RGB             = 1 << 8,  // After conversion to RGB (resizable)
     PL_HOOK_LINEAR          = 1 << 9,  // After linearization but before 
scaling
     PL_HOOK_SIGMOID         = 1 << 10, // After sigmoidization
-    PL_HOOK_PRE_KERNEL      = 1 << 11, // Immediately before the main scaler 
kernel (after overlays)
+    PL_HOOK_PRE_KERNEL      = 1 << 11, // Immediately before the main scaler 
kernel
     PL_HOOK_POST_KERNEL     = 1 << 12, // Immediately after the main scaler 
kernel
     PL_HOOK_SCALED          = 1 << 13, // After scaling, before color 
management
     PL_HOOK_OUTPUT          = 1 << 14, // After color management, before 
dithering
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libplacebo-v5.229.1/src/include/libplacebo/utils/libav_internal.h 
new/libplacebo-v5.229.2/src/include/libplacebo/utils/libav_internal.h
--- old/libplacebo-v5.229.1/src/include/libplacebo/utils/libav_internal.h       
2022-11-01 19:29:44.000000000 +0100
+++ new/libplacebo-v5.229.2/src/include/libplacebo/utils/libav_internal.h       
2023-01-04 17:18:14.000000000 +0100
@@ -436,6 +436,10 @@
             if (comp->plane != p)
                 continue;
 
+            // Reject >64-bit pixel formats
+            if (comp->depth + comp->shift + comp->offset * 8 > 64)
+                return 0;
+
             masks[c] = (1LLU << comp->depth) - 1; // e.g. 0xFF for depth=8
             masks[c] <<= comp->shift;
             masks[c] <<= comp->offset * 8;
@@ -489,8 +493,7 @@
     return planes;
 }
 
-static inline bool pl_test_pixfmt(pl_gpu gpu,
-                                  enum AVPixelFormat pixfmt)
+static inline bool pl_test_pixfmt(pl_gpu gpu, enum AVPixelFormat pixfmt)
 {
     struct pl_bit_encoding bits;
     struct pl_plane_data data[4];
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libplacebo-v5.229.1/src/opengl/meson.build 
new/libplacebo-v5.229.2/src/opengl/meson.build
--- old/libplacebo-v5.229.1/src/opengl/meson.build      2022-11-01 
19:29:44.000000000 +0100
+++ new/libplacebo-v5.229.2/src/opengl/meson.build      2023-01-04 
17:18:14.000000000 +0100
@@ -1,7 +1,8 @@
 opengl_build = get_option('opengl')
 opengl_link = get_option('gl-proc-addr')
 
-if host_machine.system() == 'windows'
+if host_machine.system() == 'windows' or host_machine.system().endswith('bsd') 
or \
+   host_machine.system() == 'dragonfly'
     libdl = declare_dependency()
 else
     libdl = cc.find_library('dl', required : opengl_link)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libplacebo-v5.229.1/src/opengl/utils.c 
new/libplacebo-v5.229.2/src/opengl/utils.c
--- old/libplacebo-v5.229.1/src/opengl/utils.c  2022-11-01 19:29:44.000000000 
+0100
+++ new/libplacebo-v5.229.2/src/opengl/utils.c  2023-01-04 17:18:14.000000000 
+0100
@@ -91,12 +91,10 @@
     struct gl_ctx *glctx = PL_PRIV(pl_gl);
     const gl_funcs *gl = &glctx->func;
     const char *renderer = (char *) gl->GetString(GL_RENDERER);
-    const char *vendor = (char *) gl->GetString(GL_VENDOR);
-    return !(renderer && vendor) ||
+    return !renderer ||
            strcmp(renderer, "Software Rasterizer") == 0 ||
            strstr(renderer, "llvmpipe") ||
            strstr(renderer, "softpipe") ||
-           strcmp(vendor, "Microsoft Corporation") == 0 ||
            strcmp(renderer, "Mesa X11") == 0 ||
            strcmp(renderer, "Apple Software Renderer") == 0;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libplacebo-v5.229.1/src/pl_alloc.c 
new/libplacebo-v5.229.2/src/pl_alloc.c
--- old/libplacebo-v5.229.1/src/pl_alloc.c      2022-11-01 19:29:44.000000000 
+0100
+++ new/libplacebo-v5.229.2/src/pl_alloc.c      2023-01-04 17:18:14.000000000 
+0100
@@ -227,9 +227,9 @@
 #endif
 }
 
-size_t pl_get_size(void *ptr)
+size_t pl_get_size(const void *ptr)
 {
-    struct header *h = get_header(ptr);
+    const struct header *h = get_header((void *) ptr);
     return h ? h->size : 0;
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libplacebo-v5.229.1/src/pl_alloc.h 
new/libplacebo-v5.229.2/src/pl_alloc.h
--- old/libplacebo-v5.229.1/src/pl_alloc.h      2022-11-01 19:29:44.000000000 
+0100
+++ new/libplacebo-v5.229.2/src/pl_alloc.h      2023-01-04 17:18:14.000000000 
+0100
@@ -59,7 +59,7 @@
     } while (0)
 
 // Get the current size of an allocation.
-size_t pl_get_size(void *ptr);
+size_t pl_get_size(const void *ptr);
 
 #define pl_grow(parent, ptr, size)                      \
     do {                                                \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libplacebo-v5.229.1/src/renderer.c 
new/libplacebo-v5.229.2/src/renderer.c
--- old/libplacebo-v5.229.1/src/renderer.c      2022-11-01 19:29:44.000000000 
+0100
+++ new/libplacebo-v5.229.2/src/renderer.c      2023-01-04 17:18:14.000000000 
+0100
@@ -1265,7 +1265,18 @@
 
     struct img *img = &st->img;
     struct pl_plane *plane = &st->plane;
-    struct pl_color_repr repr = st->img.repr;
+    struct pl_color_repr repr = image->repr;
+    bool is_orig_repr = pl_color_repr_equal(&st->img.repr, &image->repr);
+    if (!is_orig_repr) {
+        // Propagate the original color depth to the film grain algorithm, but
+        // update the sample depth and effective bit shift based on the state
+        // of the current texture, which is guaranteed to already be
+        // normalized.
+        pl_assert(st->img.repr.bits.bit_shift == 0);
+        repr.bits.sample_depth = st->img.repr.bits.sample_depth;
+        repr.bits.bit_shift = repr.bits.sample_depth - repr.bits.color_depth;
+    }
+
     struct pl_film_grain_params grain_params = {
         .data = image->film_grain,
         .luma_tex = ref->plane.texture,
@@ -1314,7 +1325,8 @@
     img->err_msg = "Failed applying film grain.. disabling!";
     img->err_bool = &rr->disable_grain;
     img->err_tex = grain_params.tex;
-    img->repr = repr;
+    if (is_orig_repr)
+        img->repr = repr;
     return true;
 }
 
@@ -1521,7 +1533,7 @@
                  "vec4 tmp = %s();  \n", sub);
             for (int jc = 0; jc < stj->img.comps; jc++) {
                 int map = stj->plane.component_mapping[jc];
-                if (!map)
+                if (map == PL_CHANNEL_NONE)
                     continue;
                 int ic = sti->img.comps++;
                 pl_assert(ic < 4);
@@ -1863,12 +1875,10 @@
     if (params->disable_linear_scaling || fbofmt->component_depth[0] < 16)
         use_sigmoid = use_linear = false;
 
-    // Avoid sigmoidization for HDR content because it clips to [0,1]
-    if (pl_color_space_is_hdr(&img->color)) {
-        use_sigmoid = false;
-        if (fbofmt->type != PL_FMT_FLOAT)
-            use_linear = false; // linear HDR needs out-of-range signals
-    }
+    // Avoid sigmoidization for HDR content because it clips to [0,1], and
+    // linearization because it causes very nasty ringing artefacts.
+    if (pl_color_space_is_hdr(&img->color))
+        use_sigmoid = use_linear = false;
 
     if (!use_linear && img->color.transfer == PL_COLOR_TRC_LINEAR) {
         img->color.transfer = image->color.transfer;
@@ -2939,7 +2949,6 @@
     struct cached_frame frames[MAX_MIX_FRAMES];
     float weights[MAX_MIX_FRAMES];
     float wsum = 0.0;
-    pass.tmp = pl_tmp(NULL);
 
     // Garbage collect the cache by evicting all frames from the cache that are
     // not determined to still be required
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libplacebo-v5.229.1/src/shaders/colorspace.c 
new/libplacebo-v5.229.2/src/shaders/colorspace.c
--- old/libplacebo-v5.229.1/src/shaders/colorspace.c    2022-11-01 
19:29:44.000000000 +0100
+++ new/libplacebo-v5.229.2/src/shaders/colorspace.c    2023-01-04 
17:18:14.000000000 +0100
@@ -1461,13 +1461,15 @@
             .data = PL_TRANSPOSE_3X3(rgb2xyz.m),
         }));
 
-        // Tuned to meet the desired desaturation at 1000 -> SDR
-        float desat = dst_max > src_max ? 1.075f : 1.1f;
-        float exponent = logf(desat) / logf(1000 / PL_COLOR_SDR_WHITE);
-        GLSL("float orig = max(xyz.y, %s);                      \n"
-             "xyz.y = tone_map(xyz.y);                          \n"
-             "xyz.xz *= pow(xyz.y / orig, %s) * xyz.y / orig;   \n",
-             SH_FLOAT(dst_min), SH_FLOAT(exponent));
+        // Tuned to meet the desired desaturation at 1000 <-> SDR
+        float ratio = logf(src_max / dst_max) / logf(1000 / 
PL_COLOR_SDR_WHITE);
+        float coeff = src_max > dst_max ? 1 / 1.1f : 1.075f;
+        float desat = (coeff - 1) * fabsf(ratio) + 1;
+
+        GLSL("float orig = max(xyz.y, %s);  \n"
+             "xyz.y = tone_map(xyz.y);      \n"
+             "xyz.xz *= %s * xyz.y / orig;  \n",
+             SH_FLOAT(dst_min), SH_FLOAT(desat));
 
         // Extra luminance correction when reducing dynamic range
         if (src_max > dst_max)
@@ -1574,9 +1576,13 @@
         break;
 
     case PL_GAMUT_WARN:
-        GLSL("if (any(lessThan(color.rgb, vec3(-0.005))) ||     \n"
-             "    any(greaterThan(color.rgb, vec3(1.005))))     \n"
-             "    color.rgb = vec3(1.0, 0.0, 1.0); // magenta   \n");
+        GLSL("if (any(lessThan(color.rgb, vec3(-1e-6))) ||          \n"
+             "    any(greaterThan(color.rgb, vec3(1.0 + 1e-6))))    \n"
+             "{                                                     \n"
+             "    float k = dot(color.rgb, vec3(2.0 / 3.0));        \n"
+             "    color.rgb = clamp(vec3(k) - color.rgb, 0.0, 1.0); \n"
+             "    color.rgb = sqrt(color.rgb);                      \n"
+             "}                                                     \n");
         break;
 
     case PL_GAMUT_DARKEN: {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libplacebo-v5.229.1/src/shaders/custom.c 
new/libplacebo-v5.229.2/src/shaders/custom.c
--- old/libplacebo-v5.229.1/src/shaders/custom.c        2022-11-01 
19:29:44.000000000 +0100
+++ new/libplacebo-v5.229.2/src/shaders/custom.c        2023-01-04 
17:18:14.000000000 +0100
@@ -369,6 +369,9 @@
                 // texture, which we just signal by not having any `save_tex`
                 // name set.
                 out->save_tex = (pl_str) {0};
+            } else if (pl_str_equals0(save_tex, "MAIN")) {
+                // Compatibility alias
+                out->save_tex = pl_str0("MAINPRESUB");
             } else {
                 out->save_tex = save_tex;
             };
@@ -554,7 +557,7 @@
             continue;
         }
 
-        if (pl_str_eatstart0(&line, "FORMAT ")) {
+        if (pl_str_eatstart0(&line, "FORMAT")) {
             line = pl_str_strip(line);
             params.format = NULL;
             for (int n = 0; n < gpu->num_formats; n++) {
@@ -1092,41 +1095,8 @@
             continue;
         }
 
-        float out_size[2] = {0};
-        if (!pl_eval_szexpr(p->log, &scope, lookup_tex, hook->width,  
&out_size[0]) ||
-            !pl_eval_szexpr(p->log, &scope, lookup_tex, hook->height, 
&out_size[1]))
-        {
-            goto error;
-        }
-
-        int out_w = roundf(out_size[0]),
-            out_h = roundf(out_size[1]);
-
-        // Generate a new texture to store the render result
-        pl_tex fbo;
-        fbo = params->get_tex(params->priv, out_w, out_h);
-        if (!fbo) {
-            PL_ERR(p, "Failed dispatching hook: `get_tex` callback failed?");
-            goto error;
-        }
-
         // Generate a new shader object
         sh = pl_dispatch_begin(params->dispatch);
-        if (!sh_require(sh, PL_SHADER_SIG_NONE, out_w, out_h))
-            goto error;
-
-        if (hook->is_compute) {
-            if (!sh_try_compute(sh, hook->threads_w, hook->threads_h, false, 
0) ||
-                !fbo->params.storable)
-            {
-                PL_ERR(p, "Failed dispatching COMPUTE shader");
-                goto error;
-            }
-        } else {
-            // Default non-COMPUTE shaders to explicitly use fragment shaders
-            // only, to avoid breaking things like fwidth()
-            sh->type = PL_DEF(sh->type, SH_FRAGMENT);
-        }
 
         // Bind all necessary input textures
         for (int i = 0; i < PL_ARRAY_SIZE(hook->bind_tex); i++) {
@@ -1199,9 +1169,12 @@
                 }
             }
 
-            // If none of the above matched, this is a bogus/unknown texture 
name
-            PL_ERR(p, "Tried binding unknown texture '%.*s'!", 
PL_STR_FMT(texname));
-            goto error;
+            // If none of the above matched, this is an unknown texture name,
+            // so silently ignore this pass to match the mpv behavior
+            PL_TRACE(p, "Skipping hook due to no texture named '%.*s'.",
+                     PL_STR_FMT(texname));
+            pl_dispatch_abort(params->dispatch, &sh);
+            goto next_pass;
 
     next_bind: ; // outer 'continue'
         }
@@ -1259,8 +1232,38 @@
         sh_append_str(sh, SH_BUF_HEADER, hook->pass_body);
         sh_describe(sh, pl_strdup0(SH_TMP(sh), hook->pass_desc));
 
+        // Resolve output size and create framebuffer
+        float out_size[2] = {0};
+        if (!pl_eval_szexpr(p->log, &scope, lookup_tex, hook->width,  
&out_size[0]) ||
+            !pl_eval_szexpr(p->log, &scope, lookup_tex, hook->height, 
&out_size[1]))
+        {
+            goto error;
+        }
+
+        int out_w = roundf(out_size[0]),
+            out_h = roundf(out_size[1]);
+
+        if (!sh_require(sh, PL_SHADER_SIG_NONE, out_w, out_h))
+            goto error;
+
+        // Generate a new texture to store the render result
+        pl_tex fbo;
+        fbo = params->get_tex(params->priv, out_w, out_h);
+        if (!fbo) {
+            PL_ERR(p, "Failed dispatching hook: `get_tex` callback failed?");
+            goto error;
+        }
+
         bool ok;
         if (hook->is_compute) {
+
+            if (!sh_try_compute(sh, hook->threads_w, hook->threads_h, false, 
0) ||
+                !fbo->params.storable)
+            {
+                PL_ERR(p, "Failed dispatching COMPUTE shader");
+                goto error;
+            }
+
             GLSLP("#define out_image %s \n", sh_desc(sh, (struct 
pl_shader_desc) {
                 .binding.object = fbo,
                 .desc = {
@@ -1284,12 +1287,19 @@
                 .width  = out_w,
                 .height = out_h,
             ));
+
         } else {
+
+            // Default non-COMPUTE shaders to explicitly use fragment shaders
+            // only, to avoid breaking things like fwidth()
+            sh->type = PL_DEF(sh->type, SH_FRAGMENT);
+
             GLSL("vec4 color = hook(); \n");
             ok = pl_dispatch_finish(params->dispatch, pl_dispatch_params(
                 .shader = &sh,
                 .target = fbo,
             ));
+
         }
 
         if (!ok)
@@ -1346,11 +1356,14 @@
                 .rect = new_rect,
             };
         }
+
+next_pass: ;
     }
 
     return res;
 
 error:
+    pl_dispatch_abort(params->dispatch, &sh);
     return (struct pl_hook_res) { .failed = true };
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libplacebo-v5.229.1/src/shaders/dithering.c 
new/libplacebo-v5.229.2/src/shaders/dithering.c
--- old/libplacebo-v5.229.1/src/shaders/dithering.c     2022-11-01 
19:29:44.000000000 +0100
+++ new/libplacebo-v5.229.2/src/shaders/dithering.c     2023-01-04 
17:18:14.000000000 +0100
@@ -273,10 +273,8 @@
     } else {
         // Approximate each gamma segment as a straight line, this simplifies
         // the process of dithering down to a single scale and (biased) round.
-        uint64_t scale = (1LLU << new_depth) - 1;
-        GLSL("color = vec4(%llu.0) * color + vec4(bias); \n"
-             "color = floor(color) * vec4(1.0 / %llu.0); \n",
-             (long long unsigned) scale, (long long unsigned) scale);
+        GLSL("color = scale * color + vec4(bias);   \n"
+             "color = floor(color) * (1.0 / scale); \n");
     }
 
     GLSL("} \n");
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libplacebo-v5.229.1/src/shaders/film_grain_av1.c 
new/libplacebo-v5.229.2/src/shaders/film_grain_av1.c
--- old/libplacebo-v5.229.1/src/shaders/film_grain_av1.c        2022-11-01 
19:29:44.000000000 +0100
+++ new/libplacebo-v5.229.2/src/shaders/film_grain_av1.c        2023-01-04 
17:18:14.000000000 +0100
@@ -235,6 +235,14 @@
     return (x + (1 << (shift - 1))) >> shift;
 }
 
+static ident_t sh_lut_quiet(pl_shader sh, const struct sh_lut_params *params)
+{
+    pl_log_level_cap(sh->log, PL_LOG_TRACE);
+    ident_t ret = sh_lut(sh, params);
+    pl_log_level_cap(sh->log, PL_LOG_NONE);
+    return ret;
+}
+
 enum {
     BLOCK_SIZE = 32,
     SCALING_LUT_SIZE = 256,
@@ -276,7 +284,7 @@
     int depth = PL_DEF(repr->bits.color_depth,
                 PL_DEF(repr->bits.sample_depth, 8));
     pl_assert(depth >= 8);
-    return depth;
+    return PL_MIN(depth, 12);
 }
 
 static struct grain_scale get_grain_scale(const struct pl_film_grain_params 
*params)
@@ -672,7 +680,7 @@
     int idx[3] = {-1};
 
     if (fg_has_y) {
-        lut[0] = sh_lut(sh, sh_lut_params(
+        lut[0] = sh_lut_quiet(sh, sh_lut_params(
             .object     = &obj->lut_grain[0],
             .var_type   = PL_VAR_FLOAT,
             .lut_type   = SH_LUT_TEXTURE,
@@ -707,7 +715,7 @@
     }
 
     if (chroma_comps > 0) {
-        lut[1] = lut[2] = sh_lut(sh, sh_lut_params(
+        lut[1] = lut[2] = sh_lut_quiet(sh, sh_lut_params(
             .object     = &obj->lut_grain[1],
             .var_type   = PL_VAR_FLOAT,
             .lut_type   = SH_LUT_TEXTURE,
@@ -729,7 +737,7 @@
             idx[1] = idx[2] = -1;
     }
 
-    ident_t offsets = sh_lut(sh, sh_lut_params(
+    ident_t offsets = sh_lut_quiet(sh, sh_lut_params(
         .object     = &obj->lut_offsets,
         .var_type   = PL_VAR_UINT,
         .lut_type   = SH_LUT_AUTO,
@@ -787,7 +795,7 @@
         // Skip scaling for unneeded channels
         bool has_c[3] = { fg_has_y, fg_has_u, fg_has_v };
         if (has_c[i] && priv.num > 0) {
-            scaling[i] = sh_lut(sh, sh_lut_params(
+            scaling[i] = sh_lut_quiet(sh, sh_lut_params(
                 .object     = &obj->lut_scaling[i],
                 .var_type   = PL_VAR_FLOAT,
                 .method     = SH_LUT_LINEAR,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libplacebo-v5.229.1/src/shaders.c 
new/libplacebo-v5.229.2/src/shaders.c
--- old/libplacebo-v5.229.1/src/shaders.c       2022-11-01 19:29:44.000000000 
+0100
+++ new/libplacebo-v5.229.2/src/shaders.c       2023-01-04 17:18:14.000000000 
+0100
@@ -39,22 +39,29 @@
     return sh;
 }
 
+static void sh_obj_deref(pl_shader_obj obj);
+
+static void sh_deref(pl_shader sh)
+{
+    for (int i = 0; i < sh->tmp.num; i++)
+        pl_ref_deref(&sh->tmp.elem[i]);
+    for (int i = 0; i < sh->obj.num; i++)
+        sh_obj_deref(sh->obj.elem[i]);
+}
+
 void pl_shader_free(pl_shader *psh)
 {
     pl_shader sh = *psh;
     if (!sh)
         return;
 
-    for (int i = 0; i < sh->tmp.num; i++)
-        pl_ref_deref(&sh->tmp.elem[i]);
-
+    sh_deref(sh);
     pl_free_ptr(psh);
 }
 
 void pl_shader_reset(pl_shader sh, const struct pl_shader_params *params)
 {
-    for (int i = 0; i < sh->tmp.num; i++)
-        pl_ref_deref(&sh->tmp.elem[i]);
+    sh_deref(sh);
 
     struct pl_shader_t new = {
         .log = sh->log,
@@ -715,19 +722,27 @@
     return true;
 }
 
-void pl_shader_obj_destroy(pl_shader_obj *ptr)
+static void sh_obj_deref(pl_shader_obj obj)
 {
-    pl_shader_obj obj = *ptr;
-    if (!obj)
+    if (!pl_rc_deref(&obj->rc))
         return;
 
     if (obj->uninit)
         obj->uninit(obj->gpu, obj->priv);
 
-    *ptr = NULL;
     pl_free(obj);
 }
 
+void pl_shader_obj_destroy(pl_shader_obj *ptr)
+{
+    pl_shader_obj obj = *ptr;
+    if (!obj)
+        return;
+
+    sh_obj_deref(obj);
+    *ptr = NULL;
+}
+
 void *sh_require_obj(pl_shader sh, pl_shader_obj *ptr,
                      enum pl_shader_obj_type type, size_t priv_size,
                      void (*uninit)(pl_gpu gpu, void *priv))
@@ -749,12 +764,16 @@
 
     if (!obj) {
         obj = pl_zalloc_ptr(NULL, obj);
+        pl_rc_init(&obj->rc);
         obj->gpu = SH_GPU(sh);
         obj->type = type;
         obj->priv = pl_zalloc(obj, priv_size);
         obj->uninit = uninit;
     }
 
+    PL_ARRAY_APPEND(sh, sh->obj, obj);
+    pl_rc_ref(&obj->rc);
+
     *ptr = obj;
     return obj->priv;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libplacebo-v5.229.1/src/shaders.h 
new/libplacebo-v5.229.2/src/shaders.h
--- old/libplacebo-v5.229.1/src/shaders.h       2022-11-01 19:29:44.000000000 
+0100
+++ new/libplacebo-v5.229.2/src/shaders.h       2023-01-04 17:18:14.000000000 
+0100
@@ -46,6 +46,7 @@
     pl_log log;
     struct pl_shader_res res; // for accumulating some of the fields
     PL_ARRAY(struct pl_ref *) tmp; // only used for var/va/desc names and data
+    PL_ARRAY(pl_shader_obj) obj;
     bool failed;
     bool mutable;
     int output_w;
@@ -179,6 +180,7 @@
 
 struct pl_shader_obj_t {
     enum pl_shader_obj_type type;
+    pl_rc_t rc;
     pl_gpu gpu;
     void (*uninit)(pl_gpu gpu, void *priv);
     void *priv;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libplacebo-v5.229.1/src/tests/vulkan.c 
new/libplacebo-v5.229.2/src/tests/vulkan.c
--- old/libplacebo-v5.229.1/src/tests/vulkan.c  2022-11-01 19:29:44.000000000 
+0100
+++ new/libplacebo-v5.229.2/src/tests/vulkan.c  2023-01-04 17:18:14.000000000 
+0100
@@ -109,7 +109,7 @@
     pl_log log = pl_test_logger();
     pl_vk_inst inst = pl_vk_inst_create(log, pl_vk_inst_params(
         .debug = true,
-        .debug_extra = true,
+        .debug_extra = false, // FIXME: re-enable when upstream fixed
         .get_proc_addr = vkGetInstanceProcAddr,
         .opt_extensions = (const char *[]){
             VK_KHR_SURFACE_EXTENSION_NAME,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libplacebo-v5.229.1/src/utils/upload.c 
new/libplacebo-v5.229.2/src/utils/upload.c
--- old/libplacebo-v5.229.1/src/utils/upload.c  2022-11-01 19:29:44.000000000 
+0100
+++ new/libplacebo-v5.229.2/src/utils/upload.c  2023-01-04 17:18:14.000000000 
+0100
@@ -171,8 +171,6 @@
             continue;
         if (!(fmt->caps & PL_FMT_CAP_SAMPLEABLE))
             continue;
-        if (data->row_stride % fmt->texel_align)
-            continue; // reject misaligned formats
 
         int idx = 0;
 
@@ -191,6 +189,17 @@
             out_map[idx++] = data->component_map[i];
         }
 
+        // Reject misaligned formats, check this last to only log such errors
+        // if this is the only thing preventing a format from being used, as
+        // this is likely an issue in the API usage.
+        if (data->row_stride % fmt->texel_align) {
+            PL_WARN(gpu, "Rejecting texture format '%s' due to misalignment: "
+                    "Row stride %zu is not a clean multiple of texel size %zu! 
"
+                    "This is likely an API usage bug.",
+                    fmt->name, data->row_stride, fmt->texel_align);
+            continue;
+        }
+
         return fmt;
 
 next_fmt: ; // acts as `continue`
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libplacebo-v5.229.1/src/vulkan/malloc.c 
new/libplacebo-v5.229.2/src/vulkan/malloc.c
--- old/libplacebo-v5.229.1/src/vulkan/malloc.c 2022-11-01 19:29:44.000000000 
+0100
+++ new/libplacebo-v5.229.2/src/vulkan/malloc.c 2023-01-04 17:18:14.000000000 
+0100
@@ -857,8 +857,6 @@
         goto error;
     }
 
-    pl_assert(ainfo.pNext);
-
     if (!find_best_memtype(ma, reqs.memoryTypeBits, params, 
&ainfo.memoryTypeIndex)) {
         PL_ERR(vk, "No compatible memory types offered for imported memory!");
         goto error;

Reply via email to