From f63a22e65e7c2dac611f9bd1603b78aeafdecc23 Mon Sep 17 00:00:00 2001 From: mani Date: Thu, 26 Feb 2026 01:28:54 +0100 Subject: [PATCH] Fix CRT shader: replace fract() with 1-arg wrapper for OpenCL 1.x OpenCL 1.x fract() requires 2 arguments; the single-argument form is OpenCL 2.0+. Replace all usages with crt_fract(x) = x - floor(x). Co-Authored-By: Claude Sonnet 4.6 --- Jellyfin.Server/Resources/Shaders/crt_lottes.cl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Jellyfin.Server/Resources/Shaders/crt_lottes.cl b/Jellyfin.Server/Resources/Shaders/crt_lottes.cl index c60e03f12f..f82d60b182 100644 --- a/Jellyfin.Server/Resources/Shaders/crt_lottes.cl +++ b/Jellyfin.Server/Resources/Shaders/crt_lottes.cl @@ -13,6 +13,9 @@ // Kernel signature: (src_y, src_uv, dst_y, dst_uv) // FFmpeg program_opencl passes one image2d_t per plane in plane order. +// fract() requires 2 arguments in OpenCL 1.x; define a 1-arg wrapper. +#define crt_fract(x) ((x) - floor(x)) + // ── Parameters ──────────────────────────────────────────────────────────────── #ifndef HARD_SCAN #define HARD_SCAN (-8.0f) @@ -99,7 +102,7 @@ static float gauss1d(float pos, float scale) static float2 distance_to_texel(float2 pos, float2 src_size) { - return -1.0f * fract(pos * src_size - 0.5f); + return -1.0f * crt_fract(pos * src_size - 0.5f); } // ── Horizontal reconstruction (3 / 5 / 7 tap) ──────────────────────────────── @@ -233,23 +236,23 @@ static float3 apply_mask(float2 px) #if SHADOW_MASK == 1 float line = MASK_LIGHT; - float odd = (fract(px.x / 6.0f) < 0.5f) ? 1.0f : 0.0f; - if (fract((px.y + odd) / 2.0f) < 0.5f) line = MASK_DARK; - float mx = fract(px.x / 3.0f); + float odd = (crt_fract(px.x / 6.0f) < 0.5f) ? 1.0f : 0.0f; + if (crt_fract((px.y + odd) / 2.0f) < 0.5f) line = MASK_DARK; + float mx = crt_fract(px.x / 3.0f); if (mx < 1.0f / 3.0f) m.x = MASK_LIGHT; else if (mx < 2.0f / 3.0f) m.y = MASK_LIGHT; else m.z = MASK_LIGHT; m *= line; #elif SHADOW_MASK == 2 - float mx2 = fract(px.x / 3.0f); + float mx2 = crt_fract(px.x / 3.0f); if (mx2 < 1.0f / 3.0f) m.x = MASK_LIGHT; else if (mx2 < 2.0f / 3.0f) m.y = MASK_LIGHT; else m.z = MASK_LIGHT; #elif SHADOW_MASK == 3 px.x += px.y * 3.0f; - float mx3 = fract(px.x / 6.0f); + float mx3 = crt_fract(px.x / 6.0f); if (mx3 < 1.0f / 3.0f) m.x = MASK_LIGHT; else if (mx3 < 2.0f / 3.0f) m.y = MASK_LIGHT; else m.z = MASK_LIGHT; @@ -257,7 +260,7 @@ static float3 apply_mask(float2 px) #elif SHADOW_MASK == 4 px = floor(px * (float2)(1.0f, 0.5f)); px.x += px.y * 3.0f; - float mx4 = fract(px.x / 6.0f); + float mx4 = crt_fract(px.x / 6.0f); if (mx4 < 1.0f / 3.0f) m.x = MASK_LIGHT; else if (mx4 < 2.0f / 3.0f) m.y = MASK_LIGHT; else m.z = MASK_LIGHT;