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

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