Use GLSL 1.40 shaders as GLSL 300 es shaders

In case OpenGL ES 3 is provided by the driver we can use the GLSL 1.40
shaders as GLSL 300 ES shaders. The #version declarative is rewritten in
such a case.

REVIEW: 110590
master
Martin Gräßlin 11 years ago
parent ad1203e3b2
commit 769c746a06

@ -359,12 +359,19 @@ const QByteArray GLShader::prepareSource(GLenum shaderType, const QByteArray &so
// Prepare the source code
QByteArray ba;
#ifdef KWIN_HAVE_OPENGLES
ba.append("#ifdef GL_ES\nprecision highp float;\n#endif\n");
if (GLPlatform::instance()->glslVersion() < kVersionNumber(3, 0)) {
ba.append("precision highp float;\n");
}
#endif
if (ShaderManager::instance()->isShaderDebug()) {
ba.append("#define KWIN_SHADER_DEBUG 1\n");
}
ba.append(source);
#ifdef KWIN_HAVE_OPENGLES
if (GLPlatform::instance()->glslVersion() >= kVersionNumber(3, 0)) {
ba.replace("#version 140", "#version 300 es\n\nprecision highp float;\n");
}
#endif
// Inject color correction code for fragment shaders, if possible
if (shaderType == GL_FRAGMENT_SHADER && sColorCorrect)
@ -873,11 +880,14 @@ void ShaderManager::initShaders()
"scene-color-fragment.glsl",
};
#ifndef KWIN_HAVE_OPENGLES
if (GLPlatform::instance()->glslVersion() >= kVersionNumber(1, 40))
#ifdef KWIN_HAVE_OPENGLES
const qint64 coreVersionNumber = kVersionNumber(3, 0);
#else
const qint64 coreVersionNumber = kVersionNumber(1, 40);
#endif
if (GLPlatform::instance()->glslVersion() >= coreVersionNumber)
m_shaderDir = ":/resources/shaders/1.40/";
else
#endif
m_shaderDir = ":/resources/shaders/1.10/";
// Be optimistic

Loading…
Cancel
Save