Warning, /plasma/kwin/src/backends/drm/icc.frag is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2023 Xaver Hugl <xaver.hugl@gmail.com>
0002 // SPDX-License-Identifier: GPL-2.0-or-later
0003 precision highp float;
0004 precision highp sampler2D;
0005 precision highp sampler3D;
0006 
0007 in vec2 texcoord0;
0008 
0009 uniform sampler2D src;
0010 uniform float sdrBrightness;
0011 
0012 uniform mat4 toXYZD50;
0013 
0014 uniform int Bsize;
0015 uniform sampler2D Bsampler;
0016 
0017 uniform mat4 matrix2;
0018 
0019 uniform int Msize;
0020 uniform sampler2D Msamplrt;
0021 
0022 uniform ivec3 Csize;
0023 uniform sampler3D Csampler;
0024 
0025 uniform int Asize;
0026 uniform sampler2D Asampler;
0027 
0028 vec3 sample1DLut(vec3 input, sampler2D lut, int lutSize) {
0029     float lutOffset = 0.5 / float(lutSize);
0030     float lutScale = 1.0 - lutOffset * 2.0;
0031     float lutR = texture2D(lut, vec2(lutOffset + input.r * lutScale, 0.5)).r;
0032     float lutG = texture2D(lut, vec2(lutOffset + input.g * lutScale, 0.5)).g;
0033     float lutB = texture2D(lut, vec2(lutOffset + input.b * lutScale, 0.5)).b;
0034     return vec3(lutR, lutG, lutB);
0035 }
0036 
0037 void main()
0038 {
0039     vec4 tex = texture2D(src, texcoord0);
0040     tex.rgb /= max(tex.a, 0.001);
0041     tex.rgb /= sdrBrightness;
0042     tex.rgb = (toXYZD50 * vec4(tex.rgb, 1.0)).rgb;
0043     if (Bsize > 0) {
0044         tex.rgb = sample1DLut(tex.rgb, Bsampler, Bsize);
0045     }
0046     tex.rgb = (matrix2 * vec4(tex.rgb, 1.0)).rgb;
0047     if (Msize > 0) {
0048         tex.rgb = sample1DLut(tex.rgb, Msampler, Msize);
0049     }
0050     if (Csize > 0) {
0051         vec3 lutOffset = vec3(0.5) / vec3(Csize);
0052         vec3 lutScale = vec3(1.0) - lutOffset * 2.0;
0053         tex.rgb = texture3D(Csampler, lutOffset + tex.rgb * lutScale).rgb;
0054     }
0055     if (Asize > 0) {
0056         tex.rgb = sample1DLut(tex.rgb, Asampler, Asize);
0057     }
0058     tex.rgb *= tex.a;
0059     gl_FragColor = tex;
0060 }