diff options
author | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2010-05-12 15:39:12 (GMT) |
---|---|---|
committer | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2010-05-12 15:47:43 (GMT) |
commit | 7f1b5ae80535f7be95002ef947744828ad70be89 (patch) | |
tree | a3778dbd7471318ef40e53b8633dc457e2544dbc /src/opengl/gl2paintengineex | |
parent | 89be252042955a01a17baa91f2d318cbb2d2a5a4 (diff) | |
download | Qt-7f1b5ae80535f7be95002ef947744828ad70be89.zip Qt-7f1b5ae80535f7be95002ef947744828ad70be89.tar.gz Qt-7f1b5ae80535f7be95002ef947744828ad70be89.tar.bz2 |
Workaround for ATI driver bug when using QGraphicsEffect with GL.
If you forward declare a shader function which takes a sampler as
argument, the shader program will fail to link on ATI cards under
Windows.
Task-number: QTBUG-10510
Reviewed-by: Trond
Diffstat (limited to 'src/opengl/gl2paintengineex')
-rw-r--r-- | src/opengl/gl2paintengineex/qglengineshadermanager.cpp | 10 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qglengineshadersource_p.h | 1 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 8183f08..0c98e3b 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -265,10 +265,12 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS do { QByteArray source; - source.append(qShaderSnippets[prog.mainFragShader]); - source.append(qShaderSnippets[prog.srcPixelFragShader]); + // Insert the custom stage before the srcPixel shader to work around an ATI driver bug + // where you cannot forward declare a function that takes a sampler as argument. if (prog.srcPixelFragShader == CustomImageSrcFragmentShader) source.append(prog.customStageSource); + source.append(qShaderSnippets[prog.mainFragShader]); + source.append(qShaderSnippets[prog.srcPixelFragShader]); if (prog.compositionFragShader) source.append(qShaderSnippets[prog.compositionFragShader]); if (prog.maskFragShader) @@ -765,8 +767,8 @@ bool QGLEngineShaderManager::useCorrectShaderProg() // doesn't use are disabled) QGLContextPrivate* ctx_d = ctx->d_func(); ctx_d->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, true); - ctx_d->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, currentShaderProg->useTextureCoords); - ctx_d->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, currentShaderProg->useOpacityAttribute); + ctx_d->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, currentShaderProg && currentShaderProg->useTextureCoords); + ctx_d->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, currentShaderProg && currentShaderProg->useOpacityAttribute); shaderProgNeedsChanging = false; return true; diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index c88c041..c963265 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -343,7 +343,6 @@ static const char* const qglslImageSrcFragmentShader = "\n\ static const char* const qglslCustomSrcFragmentShader = "\n\ varying highp vec2 textureCoords; \n\ uniform lowp sampler2D imageTexture; \n\ - lowp vec4 customShader(lowp sampler2D texture, highp vec2 coords); \n\ lowp vec4 srcPixel() \n\ { \n\ return customShader(imageTexture, textureCoords); \n\ |