summaryrefslogtreecommitdiffstats
path: root/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2010-01-08 14:51:59 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2010-01-11 10:14:41 (GMT)
commit45fedfeb405807453e94958808c2f1d48bb846ca (patch)
tree64efd4f7dc94fed64d155a82611542c5d1b2fa99 /src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
parent8b42e57fe2946f2cd17f538d0dec2ba6edc06a11 (diff)
downloadQt-45fedfeb405807453e94958808c2f1d48bb846ca.zip
Qt-45fedfeb405807453e94958808c2f1d48bb846ca.tar.gz
Qt-45fedfeb405807453e94958808c2f1d48bb846ca.tar.bz2
Track the glVertexAttribPointer and only update it if it's changed
This removes a lot of unnecessary GL state changes resulting in an 18% performance boost on desktop and 5% on SGX for the 25920 3x3 solid rectangle test case. Reviewed-By: Samuel
Diffstat (limited to 'src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index eaae187..f745196 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -196,6 +196,9 @@ public:
void drawPixmaps(const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QDrawPixmaps::DrawingHints hints);
void drawCachedGlyphs(const QPointF &p, QFontEngineGlyphCache::Type glyphType, const QTextItemInt &ti);
+ // Calls glVertexAttributePointer if the pointer has changed
+ inline void setVertexAttributePointer(unsigned int arrayIndex, const GLfloat *pointer);
+
// draws whatever is in the vertex array:
void drawVertexArrays(const float *data, int *stops, int stopCount, GLenum primitive);
void drawVertexArrays(QGL2PEXVertexArray &vertexArray, GLenum primitive) {
@@ -230,6 +233,7 @@ public:
void regenerateClip();
void systemStateChanged();
+
static QGLEngineShaderManager* shaderManagerForEngine(QGL2PaintEngineEx *engine) { return engine->d_func()->shaderManager; }
static QGL2PaintEngineExPrivate *getData(QGL2PaintEngineEx *engine) { return engine->d_func(); }
static void cleanupVectorPath(QPaintEngineEx *engine, void *data);
@@ -291,8 +295,24 @@ public:
QSet<QVectorPath::CacheEntry *> pathCaches;
QVector<GLuint> unusedVBOSToClean;
+
+ const GLfloat *vertexAttribPointers[3];
};
+
+void QGL2PaintEngineExPrivate::setVertexAttributePointer(unsigned int arrayIndex, const GLfloat *pointer)
+{
+ Q_ASSERT(arrayIndex < 3);
+ if (pointer == vertexAttribPointers[arrayIndex])
+ return;
+
+ vertexAttribPointers[arrayIndex] = pointer;
+ if (arrayIndex == QT_OPACITY_ATTR)
+ glVertexAttribPointer(arrayIndex, 1, GL_FLOAT, GL_FALSE, 0, pointer);
+ else
+ glVertexAttribPointer(arrayIndex, 2, GL_FLOAT, GL_FALSE, 0, pointer);
+}
+
QT_END_NAMESPACE
#endif