[frameworks/kdeclarative] src/qmlcontrols/graphicaleffects: graphicaleffects: Avoid complicated matrix multiply

Kai Uwe Broulik <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit e8c0120d4c8b581eca6cdfb8bf73bec04cc803ae by Kai Uwe Broulik.
Committed on 28/07/2026 at 05:54.
Pushed by broulik into branch 'master'.

graphicaleffects: Avoid complicated matrix multiply

It doesn't seem work in all profiles/configurations.
Implement it manually instead.

M  +15   -5    src/qmlcontrols/graphicaleffects/lanczos2sharp.frag

https://invent.kde.org/frameworks/kdeclarative/-/commit/e8c0120d4c8b581eca6cdfb8bf73bec04cc803ae

diff --git a/src/qmlcontrols/graphicaleffects/lanczos2sharp.frag b/src/qmlcontrols/graphicaleffects/lanczos2sharp.frag
index b6477e24..0c5771e3 100644
--- a/src/qmlcontrols/graphicaleffects/lanczos2sharp.frag
+++ b/src/qmlcontrols/graphicaleffects/lanczos2sharp.frag
@@ -56,7 +56,16 @@ const vec3 dtt = vec3(65536.0, 255.0, 1.0);
 
 vec4 reduce4(vec3 A, vec3 B, vec3 C, vec3 D)
 {
-    return dtt * mat4x3(A, B, C, D);
+    return vec4(dot(dtt, A), dot(dtt, B), dot(dtt, C), dot(dtt, D));
+}
+
+vec3 weightedSum4(vec4 w, vec3 a, vec3 b, vec3 c, vec3 d)
+{
+    return vec3(
+        dot(w, vec4(a.x, b.x, c.x, d.x)),
+        dot(w, vec4(a.y, b.y, c.y, d.y)),
+        dot(w, vec4(a.z, b.z, c.z, d.z))
+    );
 }
 
 vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d)
@@ -149,10 +158,11 @@ void main()
     vec3 min_sample = min4(c11, c21, c12, c22);
     vec3 max_sample = max4(c11, c21, c12, c22);
 
-    color = weights[0] * transpose(mat4x3(c00, c10, c20, c30));
-    color += weights[1] * transpose(mat4x3(c01, c11, c21, c31));
-    color += weights[2] * transpose(mat4x3(c02, c12, c22, c32));
-    color += weights[3] * transpose(mat4x3(c03, c13, c23, c33));
+    color  = weightedSum4(weights[0], c00, c10, c20, c30);
+    color += weightedSum4(weights[1], c01, c11, c21, c31);
+    color += weightedSum4(weights[2], c02, c12, c22, c32);
+    color += weightedSum4(weights[3], c03, c13, c23, c33);
+
     color = color / dot(vec4(1.0) * weights, vec4(1.0));
 
     // Anti-ringing
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.