diff options
author | Gunnar Sletta <gunnar@trolltech.com> | 2009-09-16 06:18:10 (GMT) |
---|---|---|
committer | Gunnar Sletta <gunnar@trolltech.com> | 2009-09-16 06:52:05 (GMT) |
commit | ec6c31b95c8c83d785ae884a5522a82351610461 (patch) | |
tree | df8486cd56996a7504085117bbff7421e0a0cddc /src | |
parent | 60d2026c8fc9295df2777a84e7831dbea07560d8 (diff) | |
download | Qt-ec6c31b95c8c83d785ae884a5522a82351610461.zip Qt-ec6c31b95c8c83d785ae884a5522a82351610461.tar.gz Qt-ec6c31b95c8c83d785ae884a5522a82351610461.tar.bz2 |
Fixed glsl warnings on mac and stop using texturecoords when not needed
The setTextureCoordsEnabled was enabled in two places, but never disabled
causing it to always be used. When using a varying in a vertex shader
and not using it again in the fragment shader this produces a warning,
and rightly so. Since the property is 100% detectable based on the
fragment shader used, move the logic into the shader selection code
and kill the property all together. This should also speed up
solid filling a bit...
Diffstat (limited to 'src')
-rw-r--r-- | src/opengl/gl2paintengineex/qglengineshadermanager.cpp | 42 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qglengineshadermanager_p.h | 2 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 2 |
3 files changed, 20 insertions, 26 deletions
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index fec1973..b3458af 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -332,7 +332,6 @@ QGLEngineShaderManager::QGLEngineShaderManager(QGLContext* context) srcPixelType(Qt::NoBrush), useGlobalOpacity(false), maskType(NoMask), - useTextureCoords(false), compositionMode(QPainter::CompositionMode_SourceOver), customSrcStage(0), currentShaderProg(0), @@ -407,15 +406,6 @@ void QGLEngineShaderManager::setSrcPixelType(PixelSrcType type) shaderProgNeedsChanging = true; //### } -void QGLEngineShaderManager::setTextureCoordsEnabled(bool enabled) -{ - if (useTextureCoords == enabled) - return; - - useTextureCoords = enabled; - shaderProgNeedsChanging = true; //### -} - void QGLEngineShaderManager::setUseGlobalOpacity(bool useOpacity) { if (useGlobalOpacity == useOpacity) @@ -492,15 +482,8 @@ bool QGLEngineShaderManager::useCorrectShaderProg() QGLEngineShaderProg requiredProgram; requiredProgram.program = 0; - requiredProgram.useTextureCoords = useTextureCoords; - // Choose vertex shader main function - QGLEngineSharedShaders::ShaderName mainVertexShaderName = QGLEngineSharedShaders::InvalidShaderName; - if (useTextureCoords) - mainVertexShaderName = QGLEngineSharedShaders::MainWithTexCoordsVertexShader; - else - mainVertexShaderName = QGLEngineSharedShaders::MainVertexShader; - requiredProgram.mainVertexShader = sharedShaders->compileNamedShader(mainVertexShaderName, QGLShader::PartialVertexShader); + bool texCoords = false; // Choose vertex shader shader position function (which typically also sets // varyings) and the source pixel (srcPixel) fragment shader function: @@ -523,14 +506,17 @@ bool QGLEngineShaderManager::useCorrectShaderProg() case QGLEngineShaderManager::ImageSrc: srcPixelFragShaderName = QGLEngineSharedShaders::ImageSrcFragmentShader; positionVertexShaderName = QGLEngineSharedShaders::PositionOnlyVertexShader; + texCoords = true; break; case QGLEngineShaderManager::NonPremultipliedImageSrc: srcPixelFragShaderName = QGLEngineSharedShaders::NonPremultipliedImageSrcFragmentShader; positionVertexShaderName = QGLEngineSharedShaders::PositionOnlyVertexShader; + texCoords = true; break; case QGLEngineShaderManager::PatternSrc: srcPixelFragShaderName = QGLEngineSharedShaders::ImageSrcWithPatternFragmentShader; positionVertexShaderName = QGLEngineSharedShaders::PositionOnlyVertexShader; + texCoords = true; break; case QGLEngineShaderManager::TextureSrcWithPattern: srcPixelFragShaderName = QGLEngineSharedShaders::TextureBrushSrcWithPatternFragmentShader; @@ -598,14 +584,16 @@ bool QGLEngineShaderManager::useCorrectShaderProg() if (hasMask) { QGLEngineSharedShaders::ShaderName maskShaderName = QGLEngineSharedShaders::InvalidShaderName; - if (maskType == PixelMask) + if (maskType == PixelMask) { maskShaderName = QGLEngineSharedShaders::MaskFragmentShader; - else if (maskType == SubPixelMask) + texCoords = true; + } else if (maskType == SubPixelMask) { maskShaderName = QGLEngineSharedShaders::RgbMaskFragmentShader; - else if (maskType == SubPixelWithGammaMask) + } else if (maskType == SubPixelWithGammaMask) { maskShaderName = QGLEngineSharedShaders::RgbMaskWithGammaFragmentShader; - else + } else { qCritical("QGLEngineShaderManager::useCorrectShaderProg() - Unknown mask type"); + } requiredProgram.maskFragShader = sharedShaders->compileNamedShader(maskShaderName, QGLShader::PartialFragmentShader); } else { @@ -656,6 +644,16 @@ bool QGLEngineShaderManager::useCorrectShaderProg() requiredProgram.compositionFragShader = 0; } + // Choose vertex shader main function + QGLEngineSharedShaders::ShaderName mainVertexShaderName = QGLEngineSharedShaders::InvalidShaderName; + if (texCoords) + mainVertexShaderName = QGLEngineSharedShaders::MainWithTexCoordsVertexShader; + else + mainVertexShaderName = QGLEngineSharedShaders::MainVertexShader; + requiredProgram.mainVertexShader = sharedShaders->compileNamedShader(mainVertexShaderName, QGLShader::PartialVertexShader); + requiredProgram.useTextureCoords = texCoords; + + // At this point, requiredProgram is fully populated so try to find the program in the cache currentShaderProg = sharedShaders->findProgramInCache(requiredProgram); diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index 0bb580d..3c5a5f5 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -410,7 +410,6 @@ public: void optimiseForBrushTransform(const QTransform &transform); void setSrcPixelType(Qt::BrushStyle); void setSrcPixelType(PixelSrcType); // For non-brush sources, like pixmaps & images - void setTextureCoordsEnabled(bool); // For images & text glyphs void setUseGlobalOpacity(bool); void setMaskType(MaskType); void setCompositionMode(QPainter::CompositionMode); @@ -452,7 +451,6 @@ private: int srcPixelType; bool useGlobalOpacity; MaskType maskType; - bool useTextureCoords; QPainter::CompositionMode compositionMode; QGLCustomShaderStage* customSrcStage; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index e41d0b4..70e7ef3 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -668,7 +668,6 @@ void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& s { // Setup for texture drawing shaderManager->setSrcPixelType(pattern ? QGLEngineShaderManager::PatternSrc : QGLEngineShaderManager::ImageSrc); - shaderManager->setTextureCoordsEnabled(true); if (prepareForDraw(opaque)) shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::ImageTexture), QT_IMAGE_TEXTURE_UNIT); @@ -1241,7 +1240,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextIte else if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) shaderManager->setMaskType(QGLEngineShaderManager::SubPixelMask); //### TODO: Gamma correction - shaderManager->setTextureCoordsEnabled(true); int margin = cache->glyphMargin(); |