From 23a2ad6f61ce237ea21e960726d2f92c84d200fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 26 Aug 2014 12:33:13 +0200 Subject: [PATCH] Fail early when creating QOpenGLVertexArrayObject There is a significant performance regression with using QOpenGLVertexArrayObject::Binder on platforms not supporting VAOs. This is because of the function resolving/initialization in create which is called once pr bind if d->vao == 0. Change-Id: I74e77f50921116c306247dc371c68b287a2e22d7 Reviewed-by: Sean Harmer Reviewed-by: Giuseppe D'Angelo --- src/gui/opengl/qopenglvertexarrayobject.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp index 3b106fecf54..f39b10dc608 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.cpp +++ b/src/gui/opengl/qopenglvertexarrayobject.cpp @@ -150,6 +150,11 @@ bool QOpenGLVertexArrayObjectPrivate::create() qWarning("QOpenGLVertexArrayObject::create() requires a valid current OpenGL context"); return false; } + + //Fail early, if context is the same as ctx, it means we have tried to initialize for this context and failed + if (ctx == context) + return false; + context = ctx; QObject::connect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed()));