From a6b47be34f8e00f5efb9b7530c9e2bd5d16e6f56 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Mon, 14 Aug 2023 05:58:03 +0200 Subject: [PATCH] :beetle: Prevent GLSL from optimizing our uniforms on KWin --- resources/shaders/common.glsl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/resources/shaders/common.glsl b/resources/shaders/common.glsl index 988dbf3..cacdf4c 100644 --- a/resources/shaders/common.glsl +++ b/resources/shaders/common.glsl @@ -64,6 +64,15 @@ vec4 getInputColor(vec2 coords) { } void setOutputColor(vec4 outColor) { + + // If a uniform is not used, it will be optimized away. This condition is always + // false, but it will prevent the compiler from optimizing away the uniforms uForOpening + // and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a + // uniform is used in the shader. + if (outColor.a > 10e42 && uForOpening && uIsFullscreen) { + outColor = vec4(0.0); + } + fragColor = vec4(outColor.rgb * outColor.a, outColor.a); } @@ -90,6 +99,14 @@ vec4 getInputColor(vec2 coords) { } void setOutputColor(vec4 outColor) { + // If a uniform is not used, it will be optimized away. This condition is always + // false, but it will prevent the compiler from optimizing away the uniforms uForOpening + // and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a + // uniform is used in the shader. + if (outColor.a > 10e42 && uForOpening && uIsFullscreen) { + outColor = vec4(0.0); + } + gl_FragColor = vec4(outColor.rgb * outColor.a, outColor.a); }