diff --git a/libkwineffects/kwinglutils.cpp b/libkwineffects/kwinglutils.cpp index f8a6058eb8..2f016305b2 100644 --- a/libkwineffects/kwinglutils.cpp +++ b/libkwineffects/kwinglutils.cpp @@ -295,6 +295,9 @@ bool GLShader::compile(GLuint program, GLenum shaderType, const QByteArray &sour #ifdef KWIN_HAVE_OPENGLES ba.append("#ifdef GL_ES\nprecision highp float;\n#endif\n"); #endif + if (ShaderManager::instance()->isShaderDebug()) { + ba.append("#define KWIN_SHADER_DEBUG 1\n"); + } ba.append(source); const char* src = ba.constData(); @@ -615,6 +618,7 @@ ShaderManager::ShaderManager() , m_inited(false) , m_valid(false) { + m_debug = qstrcmp(qgetenv("KWIN_GL_DEBUG"), "1") == 0; initShaders(); m_inited = true; } @@ -648,6 +652,11 @@ bool ShaderManager::isValid() const return m_valid; } +bool ShaderManager::isShaderDebug() const +{ + return m_debug; +} + GLShader *ShaderManager::pushShader(ShaderType type, bool reset) { if (m_inited && !m_valid) { @@ -840,7 +849,6 @@ void ShaderManager::resetShader(ShaderType type) break; } - //shader->setUniform("debug", 0); shader->setUniform("sampler", 0); shader->setUniform(GLShader::ProjectionMatrix, projection); diff --git a/libkwineffects/kwinglutils.h b/libkwineffects/kwinglutils.h index 0c86212637..76b8104454 100644 --- a/libkwineffects/kwinglutils.h +++ b/libkwineffects/kwinglutils.h @@ -289,6 +289,13 @@ public: * @return @c true if the built-in shaders are valid, @c false otherwise **/ bool isValid() const; + /** + * Is @c true if the environment variable KWIN_GL_DEBUG is set to 1. + * In that case shaders are compiled with KWIN_SHADER_DEBUG defined. + * @returns @c true if shaders are compiled with debug information + * @since 4.8 + **/ + bool isShaderDebug() const; /** * Binds the shader of specified @p type. @@ -363,6 +370,7 @@ private: GLShader *m_colorShader; bool m_inited; bool m_valid; + bool m_debug; static ShaderManager *s_shaderManager; }; diff --git a/scene-fragment.glsl b/scene-fragment.glsl index 812299159a..da4b31a25a 100644 --- a/scene-fragment.glsl +++ b/scene-fragment.glsl @@ -1,7 +1,6 @@ uniform sampler2D sampler; uniform vec4 modulation; uniform float saturation; -uniform int debug; uniform int u_forceAlpha; varying vec2 varyingTexCoords; @@ -23,9 +22,9 @@ void main() { tex *= modulation; - /*if (debug != 0) { - tex.g += 0.5; - }*/ +#ifdef KWIN_SHADER_DEBUG + tex.g = min(tex.g + 0.5, 1.0); +#endif gl_FragColor = tex; }