[plasma/kwin] src/opengl: opengl: fix shaders with the external_oes extension

Xaver Hugl <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit bf74abc685eb4a2c8654b33f7b24690e9d214f05 by Xaver Hugl.
Committed on 31/07/2026 at 11:46.
Pushed by zamundaaa into branch 'master'.

opengl: fix shaders with the external_oes extension

The extension has to be enabled before any non-preprocessor code in the shader.
To keep both shaders and the preprocessor as simple as possible, just require
the extension in all shaders.

M  +0    -1    src/opengl/base.frag
M  +2    -0    src/opengl/glshader.cpp

https://invent.kde.org/plasma/kwin/-/commit/bf74abc685eb4a2c8654b33f7b24690e9d214f05

diff --git a/src/opengl/base.frag b/src/opengl/base.frag
index 78d21f6cb06..afd4bdc105c 100644
--- a/src/opengl/base.frag
+++ b/src/opengl/base.frag
@@ -10,7 +10,6 @@ uniform sampler2D sampler1;
 #endif
 
 #if TRAIT_MAP_EXTERNAL_TEXTURE
-#extension GL_OES_EGL_image_external : require
 uniform samplerExternalOES sampler;
 in vec2 texcoord0;
 #endif
diff --git a/src/opengl/glshader.cpp b/src/opengl/glshader.cpp
index 399902cb0b8..96355d538d1 100644
--- a/src/opengl/glshader.cpp
+++ b/src/opengl/glshader.cpp
@@ -85,10 +85,12 @@ std::optional<QByteArray> GLShader::preprocess(const QByteArray &src, GLenum sha
     if (recursionDepth == 1) {
         if (coreShader) {
             ret.append("#version 300 es\n");
+            ret.append("#extension GL_OES_EGL_image_external : require\n");
             ret.append("precision highp float;\n");
             ret.append("precision highp sampler2D;\n");
             ret.append("precision highp sampler3D;\n");
         } else {
+            ret.append("#extension GL_OES_EGL_image_external : require\n");
             // derivative functions are optional in 2.0
             ret.append("#extension GL_OES_standard_derivatives : enable\n");
             ret.append("precision highp float;\n");
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.