src/opengl/gl2paintengineex/qglengineshadermanager.cpp
changeset 25 e24348a560a6
parent 18 2f34d5167611
child 30 5dc02b23752f
--- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp	Thu May 27 13:40:48 2010 +0300
+++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp	Fri Jun 11 14:24:45 2010 +0300
@@ -265,10 +265,12 @@
 
     do {
         QByteArray source;
+        // 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.srcPixelFragShader == CustomImageSrcFragmentShader)
-            source.append(prog.customStageSource);
         if (prog.compositionFragShader)
             source.append(qShaderSnippets[prog.compositionFragShader]);
         if (prog.maskFragShader)
@@ -765,8 +767,8 @@
     // 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;