src/opengl/gl2paintengineex/qglengineshadermanager.cpp
changeset 25 e24348a560a6
parent 18 2f34d5167611
child 30 5dc02b23752f
equal deleted inserted replaced
23:89e065397ea6 25:e24348a560a6
   263     QGLEngineShaderProg *newProg = 0;
   263     QGLEngineShaderProg *newProg = 0;
   264     bool success = false;
   264     bool success = false;
   265 
   265 
   266     do {
   266     do {
   267         QByteArray source;
   267         QByteArray source;
       
   268         // Insert the custom stage before the srcPixel shader to work around an ATI driver bug
       
   269         // where you cannot forward declare a function that takes a sampler as argument.
       
   270         if (prog.srcPixelFragShader == CustomImageSrcFragmentShader)
       
   271             source.append(prog.customStageSource);
   268         source.append(qShaderSnippets[prog.mainFragShader]);
   272         source.append(qShaderSnippets[prog.mainFragShader]);
   269         source.append(qShaderSnippets[prog.srcPixelFragShader]);
   273         source.append(qShaderSnippets[prog.srcPixelFragShader]);
   270         if (prog.srcPixelFragShader == CustomImageSrcFragmentShader)
       
   271             source.append(prog.customStageSource);
       
   272         if (prog.compositionFragShader)
   274         if (prog.compositionFragShader)
   273             source.append(qShaderSnippets[prog.compositionFragShader]);
   275             source.append(qShaderSnippets[prog.compositionFragShader]);
   274         if (prog.maskFragShader)
   276         if (prog.maskFragShader)
   275             source.append(qShaderSnippets[prog.maskFragShader]);
   277             source.append(qShaderSnippets[prog.maskFragShader]);
   276         fragShader = new QGLShader(QGLShader::Fragment, ctxGuard.context(), this);
   278         fragShader = new QGLShader(QGLShader::Fragment, ctxGuard.context(), this);
   763 
   765 
   764     // Make sure all the vertex attribute arrays the program uses are enabled (and the ones it
   766     // Make sure all the vertex attribute arrays the program uses are enabled (and the ones it
   765     // doesn't use are disabled)
   767     // doesn't use are disabled)
   766     QGLContextPrivate* ctx_d = ctx->d_func();
   768     QGLContextPrivate* ctx_d = ctx->d_func();
   767     ctx_d->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, true);
   769     ctx_d->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, true);
   768     ctx_d->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, currentShaderProg->useTextureCoords);
   770     ctx_d->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, currentShaderProg && currentShaderProg->useTextureCoords);
   769     ctx_d->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, currentShaderProg->useOpacityAttribute);
   771     ctx_d->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, currentShaderProg && currentShaderProg->useOpacityAttribute);
   770 
   772 
   771     shaderProgNeedsChanging = false;
   773     shaderProgNeedsChanging = false;
   772     return true;
   774     return true;
   773 }
   775 }
   774 
   776