diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/opengl/qgl.cpp | 34 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 41 | ||||
-rw-r--r-- | src/opengl/qglextensions_p.h | 162 | ||||
-rw-r--r-- | src/opengl/qglshaderprogram.cpp | 40 |
4 files changed, 151 insertions, 126 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index f8a9196..8b7674e 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1273,6 +1273,14 @@ bool operator!=(const QGLFormat& a, const QGLFormat& b) /***************************************************************************** QGLContext implementation *****************************************************************************/ +QGLContextPrivate::~QGLContextPrivate() +{ + if (!group->m_refs.deref()) { + Q_ASSERT(group->context() == q_ptr); + delete group; + } +} + void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) { Q_Q(QGLContext); @@ -4861,40 +4869,40 @@ bool QGLDrawable::autoFillBackground() const bool QGLShareRegister::checkSharing(const QGLContext *context1, const QGLContext *context2) { - bool sharing = (context1 && context2 && context1->d_ptr->groupResources == context2->d_ptr->groupResources); + bool sharing = (context1 && context2 && context1->d_ptr->group == context2->d_ptr->group); return sharing; } void QGLShareRegister::addShare(const QGLContext *context, const QGLContext *share) { Q_ASSERT(context && share); - if (context->d_ptr->groupResources == share->d_ptr->groupResources) + if (context->d_ptr->group == share->d_ptr->group) return; // Make sure 'context' is not already shared with another group of contexts. - Q_ASSERT(reg.find(context->d_ptr->groupResources) == reg.end()); - Q_ASSERT(context->d_ptr->groupResources->refs == 1); + Q_ASSERT(reg.find(context->d_ptr->group) == reg.end()); + Q_ASSERT(context->d_ptr->group->m_refs == 1); // Free 'context' group resources and make it use the same resources as 'share'. - delete context->d_ptr->groupResources; - context->d_ptr->groupResources = share->d_ptr->groupResources; - context->d_ptr->groupResources->refs.ref(); + delete context->d_ptr->group; + context->d_ptr->group = share->d_ptr->group; + context->d_ptr->group->m_refs.ref(); // Maintain a list of all the contexts in each group of sharing contexts. - SharingHash::iterator it = reg.find(share->d_ptr->groupResources); + SharingHash::iterator it = reg.find(share->d_ptr->group); if (it == reg.end()) - it = reg.insert(share->d_ptr->groupResources, ContextList() << share); + it = reg.insert(share->d_ptr->group, ContextList() << share); it.value() << context; } QList<const QGLContext *> QGLShareRegister::shares(const QGLContext *context) { - SharingHash::const_iterator it = reg.find(context->d_ptr->groupResources); + SharingHash::const_iterator it = reg.find(context->d_ptr->group); if (it == reg.end()) return ContextList(); return it.value(); } void QGLShareRegister::removeShare(const QGLContext *context) { - SharingHash::iterator it = reg.find(context->d_ptr->groupResources); + SharingHash::iterator it = reg.find(context->d_ptr->group); if (it == reg.end()) return; @@ -4902,6 +4910,10 @@ void QGLShareRegister::removeShare(const QGLContext *context) { Q_ASSERT(count == 1); Q_UNUSED(count); + // Update context group representative. + if (context->d_ptr->group->m_context == context) + context->d_ptr->group->m_context = it.value().first(); + Q_ASSERT(it.value().size() != 0); if (it.value().size() == 1) reg.erase(it); diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 2fd3070..dceb3f5 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -193,11 +193,24 @@ public: #endif }; -struct QGLContextGroupResources +// QGLContextPrivate has the responsibility of creating context groups. +// QGLContextPrivate and QGLShareRegister will both maintain the reference counter and destroy +// context groups when needed. +// QGLShareRegister has the responsibility of keeping the context pointer up to date. +class QGLContextGroup { - QGLContextGroupResources() : refs(1) { } - QGLExtensionFuncs extensionFuncs; - QAtomicInt refs; +public: + QGLExtensionFuncs &extensionFuncs() {return m_extensionFuncs;} + const QGLContext *context() const {return m_context;} +private: + QGLContextGroup(const QGLContext *context) : m_refs(1), m_context(context) { } + + QGLExtensionFuncs m_extensionFuncs; + const QGLContext *m_context; // context group's representative + QAtomicInt m_refs; + + friend class QGLShareRegister; + friend class QGLContextPrivate; }; class QGLTexture; @@ -206,8 +219,8 @@ class QGLContextPrivate { Q_DECLARE_PUBLIC(QGLContext) public: - explicit QGLContextPrivate(QGLContext *context) : internal_context(false), q_ptr(context) {groupResources = new QGLContextGroupResources;} - ~QGLContextPrivate() {if (!groupResources->refs.deref()) delete groupResources;} + explicit QGLContextPrivate(QGLContext *context) : internal_context(false), q_ptr(context) {group = new QGLContextGroup(context);} + ~QGLContextPrivate(); QGLTexture *bindTexture(const QImage &image, GLenum target, GLint format, QGLContext::BindOptions options); QGLTexture *bindTexture(const QImage &image, GLenum target, GLint format, const qint64 key, @@ -269,23 +282,23 @@ public: QGLContext *q_ptr; QGLFormat::OpenGLVersionFlags version_flags; - QGLContextGroupResources *groupResources; + QGLContextGroup *group; GLint max_texture_size; GLuint current_fbo; QPaintEngine *active_engine; - static inline QGLContextGroupResources *qt_get_context_group(const QGLContext *ctx) { return ctx->d_ptr->groupResources; } + static inline QGLContextGroup *contextGroup(const QGLContext *ctx) { return ctx->d_ptr->group; } #ifdef Q_WS_WIN - static inline QGLExtensionFuncs& qt_get_extension_funcs(const QGLContext *ctx) { return ctx->d_ptr->groupResources->extensionFuncs; } - static inline QGLExtensionFuncs& qt_get_extension_funcs(QGLContextGroupResources *ctx) { return ctx->extensionFuncs; } + static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *ctx) { return ctx->d_ptr->group->extensionFuncs(); } + static inline QGLExtensionFuncs& extensionFuncs(QGLContextGroup *ctx) { return ctx->extensionFuncs(); } #endif #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) static QGLExtensionFuncs qt_extensionFuncs; - static inline QGLExtensionFuncs& qt_get_extension_funcs(const QGLContext *) { return qt_extensionFuncs; } - static inline QGLExtensionFuncs& qt_get_extension_funcs(QGLContextGroupResources *ctx) { return qt_extensionFuncs; } + static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *) { return qt_extensionFuncs; } + static inline QGLExtensionFuncs& extensionFuncs(QGLContextGroup *ctx) { return qt_extensionFuncs; } #endif QPixmapFilter *createPixmapFilter(int type) const; @@ -402,9 +415,9 @@ public: QList<const QGLContext *> shares(const QGLContext *context); void removeShare(const QGLContext *context); private: - // Use a context's 'groupResources' pointer to uniquely identify a group. + // Use a context's 'group' pointer to uniquely identify a group. typedef QList<const QGLContext *> ContextList; - typedef QHash<const QGLContextGroupResources *, ContextList> SharingHash; + typedef QHash<const QGLContextGroup *, ContextList> SharingHash; SharingHash reg; }; diff --git a/src/opengl/qglextensions_p.h b/src/opengl/qglextensions_p.h index 60a4173..8839f60 100644 --- a/src/opengl/qglextensions_p.h +++ b/src/opengl/qglextensions_p.h @@ -605,114 +605,114 @@ struct QGLExtensionFuncs #if !defined(QT_OPENGL_ES_2) -#define glProgramStringARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glProgramStringARB -#define glBindProgramARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBindProgramARB -#define glDeleteProgramsARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDeleteProgramsARB -#define glGenProgramsARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGenProgramsARB -#define glProgramLocalParameter4fvARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glProgramLocalParameter4fvARB +#define glProgramStringARB QGLContextPrivate::extensionFuncs(ctx).qt_glProgramStringARB +#define glBindProgramARB QGLContextPrivate::extensionFuncs(ctx).qt_glBindProgramARB +#define glDeleteProgramsARB QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteProgramsARB +#define glGenProgramsARB QGLContextPrivate::extensionFuncs(ctx).qt_glGenProgramsARB +#define glProgramLocalParameter4fvARB QGLContextPrivate::extensionFuncs(ctx).qt_glProgramLocalParameter4fvARB -#define glActiveStencilFaceEXT QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glActiveStencilFaceEXT +#define glActiveStencilFaceEXT QGLContextPrivate::extensionFuncs(ctx).qt_glActiveStencilFaceEXT -#define glMultiTexCoord4f QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glMultiTexCoord4f +#define glMultiTexCoord4f QGLContextPrivate::extensionFuncs(ctx).qt_glMultiTexCoord4f -#define glActiveTexture QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glActiveTexture +#define glActiveTexture QGLContextPrivate::extensionFuncs(ctx).qt_glActiveTexture #endif // !defined(QT_OPENGL_ES_2) // FBOs #if !defined(QT_OPENGL_ES_2) -#define glIsRenderbuffer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glIsRenderbuffer -#define glBindRenderbuffer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBindRenderbuffer -#define glDeleteRenderbuffers QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDeleteRenderbuffers -#define glGenRenderbuffers QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGenRenderbuffers -#define glRenderbufferStorage QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glRenderbufferStorage -#define glGetRenderbufferParameteriv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetRenderbufferParameteriv -#define glIsFramebuffer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glIsFramebuffer -#define glBindFramebuffer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBindFramebuffer -#define glDeleteFramebuffers QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDeleteFramebuffers -#define glGenFramebuffers QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGenFramebuffers -#define glCheckFramebufferStatus QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glCheckFramebufferStatus -#define glFramebufferTexture2D QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glFramebufferTexture2D -#define glFramebufferRenderbuffer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glFramebufferRenderbuffer -#define glGetFramebufferAttachmentParameteriv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetFramebufferAttachmentParameteriv -#define glGenerateMipmap QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGenerateMipmap +#define glIsRenderbuffer QGLContextPrivate::extensionFuncs(ctx).qt_glIsRenderbuffer +#define glBindRenderbuffer QGLContextPrivate::extensionFuncs(ctx).qt_glBindRenderbuffer +#define glDeleteRenderbuffers QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteRenderbuffers +#define glGenRenderbuffers QGLContextPrivate::extensionFuncs(ctx).qt_glGenRenderbuffers +#define glRenderbufferStorage QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorage +#define glGetRenderbufferParameteriv QGLContextPrivate::extensionFuncs(ctx).qt_glGetRenderbufferParameteriv +#define glIsFramebuffer QGLContextPrivate::extensionFuncs(ctx).qt_glIsFramebuffer +#define glBindFramebuffer QGLContextPrivate::extensionFuncs(ctx).qt_glBindFramebuffer +#define glDeleteFramebuffers QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteFramebuffers +#define glGenFramebuffers QGLContextPrivate::extensionFuncs(ctx).qt_glGenFramebuffers +#define glCheckFramebufferStatus QGLContextPrivate::extensionFuncs(ctx).qt_glCheckFramebufferStatus +#define glFramebufferTexture2D QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferTexture2D +#define glFramebufferRenderbuffer QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferRenderbuffer +#define glGetFramebufferAttachmentParameteriv QGLContextPrivate::extensionFuncs(ctx).qt_glGetFramebufferAttachmentParameteriv +#define glGenerateMipmap QGLContextPrivate::extensionFuncs(ctx).qt_glGenerateMipmap #endif // QT_OPENGL_ES_2 -#define glBlitFramebufferEXT QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBlitFramebufferEXT -#define glRenderbufferStorageMultisampleEXT QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glRenderbufferStorageMultisampleEXT +#define glBlitFramebufferEXT QGLContextPrivate::extensionFuncs(ctx).qt_glBlitFramebufferEXT +#define glRenderbufferStorageMultisampleEXT QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT // Buffer objects #if !defined(QT_OPENGL_ES_2) -#define glBindBuffer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBindBuffer -#define glDeleteBuffers QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDeleteBuffers -#define glGenBuffers QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGenBuffers -#define glBufferData QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBufferData +#define glBindBuffer QGLContextPrivate::extensionFuncs(ctx).qt_glBindBuffer +#define glDeleteBuffers QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteBuffers +#define glGenBuffers QGLContextPrivate::extensionFuncs(ctx).qt_glGenBuffers +#define glBufferData QGLContextPrivate::extensionFuncs(ctx).qt_glBufferData #endif -#define glMapBufferARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glMapBufferARB -#define glUnmapBufferARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUnmapBufferARB +#define glMapBufferARB QGLContextPrivate::extensionFuncs(ctx).qt_glMapBufferARB +#define glUnmapBufferARB QGLContextPrivate::extensionFuncs(ctx).qt_glUnmapBufferARB // GLSL #if !defined(QT_OPENGL_ES_2) -#define glCreateShader QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glCreateShader -#define glShaderSource QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glShaderSource -#define glShaderBinary QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glShaderBinary -#define glCompileShader QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glCompileShader -#define glDeleteShader QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDeleteShader -#define glIsShader QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glIsShader - -#define glCreateProgram QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glCreateProgram -#define glAttachShader QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glAttachShader -#define glDetachShader QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDetachShader -#define glLinkProgram QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glLinkProgram -#define glUseProgram QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUseProgram -#define glDeleteProgram QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDeleteProgram -#define glIsProgram QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glIsProgram - -#define glGetShaderInfoLog QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetShaderInfoLog -#define glGetShaderiv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetShaderiv -#define glGetShaderSource QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetShaderSource -#define glGetProgramiv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetProgramiv -#define glGetProgramInfoLog QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetProgramInfoLog - -#define glGetUniformLocation QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetUniformLocation -#define glUniform4fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniform4fv -#define glUniform3fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniform3fv -#define glUniform2fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniform2fv -#define glUniform1fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniform1fv -#define glUniform1i QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniform1i -#define glUniform1iv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniform1iv -#define glUniformMatrix2fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix2fv -#define glUniformMatrix3fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix3fv -#define glUniformMatrix4fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix4fv -#define glUniformMatrix2x3fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix2x3fv -#define glUniformMatrix2x4fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix2x4fv -#define glUniformMatrix3x2fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix3x2fv -#define glUniformMatrix3x4fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix3x4fv -#define glUniformMatrix4x2fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix4x2fv -#define glUniformMatrix4x3fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix4x3fv - -#define glBindAttribLocation QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBindAttribLocation -#define glGetAttribLocation QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetAttribLocation -#define glVertexAttrib1fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glVertexAttrib1fv -#define glVertexAttrib2fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glVertexAttrib2fv -#define glVertexAttrib3fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glVertexAttrib3fv -#define glVertexAttrib4fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glVertexAttrib4fv -#define glVertexAttribPointer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glVertexAttribPointer -#define glDisableVertexAttribArray QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDisableVertexAttribArray -#define glEnableVertexAttribArray QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glEnableVertexAttribArray +#define glCreateShader QGLContextPrivate::extensionFuncs(ctx).qt_glCreateShader +#define glShaderSource QGLContextPrivate::extensionFuncs(ctx).qt_glShaderSource +#define glShaderBinary QGLContextPrivate::extensionFuncs(ctx).qt_glShaderBinary +#define glCompileShader QGLContextPrivate::extensionFuncs(ctx).qt_glCompileShader +#define glDeleteShader QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteShader +#define glIsShader QGLContextPrivate::extensionFuncs(ctx).qt_glIsShader + +#define glCreateProgram QGLContextPrivate::extensionFuncs(ctx).qt_glCreateProgram +#define glAttachShader QGLContextPrivate::extensionFuncs(ctx).qt_glAttachShader +#define glDetachShader QGLContextPrivate::extensionFuncs(ctx).qt_glDetachShader +#define glLinkProgram QGLContextPrivate::extensionFuncs(ctx).qt_glLinkProgram +#define glUseProgram QGLContextPrivate::extensionFuncs(ctx).qt_glUseProgram +#define glDeleteProgram QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteProgram +#define glIsProgram QGLContextPrivate::extensionFuncs(ctx).qt_glIsProgram + +#define glGetShaderInfoLog QGLContextPrivate::extensionFuncs(ctx).qt_glGetShaderInfoLog +#define glGetShaderiv QGLContextPrivate::extensionFuncs(ctx).qt_glGetShaderiv +#define glGetShaderSource QGLContextPrivate::extensionFuncs(ctx).qt_glGetShaderSource +#define glGetProgramiv QGLContextPrivate::extensionFuncs(ctx).qt_glGetProgramiv +#define glGetProgramInfoLog QGLContextPrivate::extensionFuncs(ctx).qt_glGetProgramInfoLog + +#define glGetUniformLocation QGLContextPrivate::extensionFuncs(ctx).qt_glGetUniformLocation +#define glUniform4fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform4fv +#define glUniform3fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform3fv +#define glUniform2fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform2fv +#define glUniform1fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform1fv +#define glUniform1i QGLContextPrivate::extensionFuncs(ctx).qt_glUniform1i +#define glUniform1iv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform1iv +#define glUniformMatrix2fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix2fv +#define glUniformMatrix3fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix3fv +#define glUniformMatrix4fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix4fv +#define glUniformMatrix2x3fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix2x3fv +#define glUniformMatrix2x4fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix2x4fv +#define glUniformMatrix3x2fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix3x2fv +#define glUniformMatrix3x4fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix3x4fv +#define glUniformMatrix4x2fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix4x2fv +#define glUniformMatrix4x3fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix4x3fv + +#define glBindAttribLocation QGLContextPrivate::extensionFuncs(ctx).qt_glBindAttribLocation +#define glGetAttribLocation QGLContextPrivate::extensionFuncs(ctx).qt_glGetAttribLocation +#define glVertexAttrib1fv QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib1fv +#define glVertexAttrib2fv QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib2fv +#define glVertexAttrib3fv QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib3fv +#define glVertexAttrib4fv QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib4fv +#define glVertexAttribPointer QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttribPointer +#define glDisableVertexAttribArray QGLContextPrivate::extensionFuncs(ctx).qt_glDisableVertexAttribArray +#define glEnableVertexAttribArray QGLContextPrivate::extensionFuncs(ctx).qt_glEnableVertexAttribArray #else // QT_OPENGL_ES_2 -#define glGetProgramBinaryOES QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetProgramBinaryOES -#define glProgramBinaryOES QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glProgramBinaryOES +#define glGetProgramBinaryOES QGLContextPrivate::extensionFuncs(ctx).qt_glGetProgramBinaryOES +#define glProgramBinaryOES QGLContextPrivate::extensionFuncs(ctx).qt_glProgramBinaryOES #endif // QT_OPENGL_ES_2 #if !defined(QT_OPENGL_ES_2) -#define glStencilOpSeparate QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glStencilOpSeparate +#define glStencilOpSeparate QGLContextPrivate::extensionFuncs(ctx).qt_glStencilOpSeparate #endif #if defined(QT_OPENGL_ES_2) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index 6e8474c..61d8b10 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -246,10 +246,10 @@ QT_BEGIN_NAMESPACE #define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 #endif -inline bool qt_check_sharing_with_current_context(QGLContextGroupResources *group) +inline bool qt_check_sharing_with_current_context(QGLContextGroup *group) { const QGLContext *context = QGLContext::currentContext(); - return context && QGLContextPrivate::qt_get_context_group(context) == group; + return context && QGLContextPrivate::contextGroup(context) == group; } class QGLShaderPrivate @@ -265,7 +265,7 @@ public: { } - QGLContextGroupResources *ctx; + QGLContextGroup *ctx; GLuint shader; QGLShader::ShaderType shaderType; bool compiled; @@ -284,7 +284,7 @@ bool QGLShaderPrivate::create(const QGLContext *context) context = QGLContext::currentContext(); if (!context) return false; - ctx = QGLContextPrivate::qt_get_context_group(context); + ctx = QGLContextPrivate::contextGroup(context); if (isPartial) return true; if (qt_resolve_glsl_extensions(const_cast<QGLContext *>(context))) { @@ -367,7 +367,7 @@ QGLShader::QGLShader d = new QGLShaderPrivate(type); if (d->create(QGLContext::currentContext()) && !compileFile(fileName)) { if (d->shader) { - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; glDeleteShader(d->shader); } d->shader = 0; @@ -421,7 +421,7 @@ QGLShader::QGLShader #endif if (d->create(context) && !compileFile(fileName)) { if (d->shader) { - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; glDeleteShader(d->shader); } d->shader = 0; @@ -436,7 +436,7 @@ QGLShader::QGLShader QGLShader::~QGLShader() { if (d->shader) { - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; #ifndef QT_NO_DEBUG if (!qt_check_sharing_with_current_context(ctx)) qWarning("QGLShader::~QGLShader: Shader is not associated with current context."); @@ -510,7 +510,7 @@ bool QGLShader::compile(const char *source) src.append(redefineHighp); #endif src.append(source); - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; glShaderSource(d->shader, src.size(), src.data(), 0); return d->compile(this); } else { @@ -593,7 +593,7 @@ bool QGLShader::compileFile(const QString& fileName) */ bool QGLShader::setShaderBinary(GLenum format, const void *binary, int length) { - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; #ifndef QT_NO_DEBUG if (!qt_check_sharing_with_current_context(ctx)) { qWarning("QGLShader::setShaderBinary: Shader is not associated with current context."); @@ -633,7 +633,7 @@ bool QGLShader::setShaderBinary(GLenum format, const void *binary, int length) bool QGLShader::setShaderBinary (QGLShader& otherShader, GLenum format, const void *binary, int length) { - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; #ifndef QT_NO_DEBUG if (!qt_check_sharing_with_current_context(ctx)) { qWarning("QGLShader::setShaderBinary: Shader is not associated with current context."); @@ -699,7 +699,7 @@ QByteArray QGLShader::sourceCode() const if (!d->shader) return QByteArray(); GLint size = 0; - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; glGetShaderiv(d->shader, GL_SHADER_SOURCE_LENGTH, &size); if (size <= 0) return QByteArray(); @@ -749,7 +749,7 @@ class QGLShaderProgramPrivate { public: QGLShaderProgramPrivate(const QGLContext *context) - : ctx(context ? QGLContextPrivate::qt_get_context_group(context) : 0) + : ctx(context ? QGLContextPrivate::contextGroup(context) : 0) , program(0) , linked(false) , inited(false) @@ -761,7 +761,7 @@ public: } ~QGLShaderProgramPrivate(); - QGLContextGroupResources *ctx; + QGLContextGroup *ctx; GLuint program; bool linked; bool inited; @@ -832,7 +832,7 @@ bool QGLShaderProgram::init() if (!context) return false; if (!d->ctx) - d->ctx = QGLContextPrivate::qt_get_context_group(context); + d->ctx = QGLContextPrivate::contextGroup(context); #ifndef QT_NO_DEBUG else if (!qt_check_sharing_with_current_context(d->ctx)) { qWarning("QGLShaderProgram: Shader program is not associated with current context."); @@ -840,7 +840,7 @@ bool QGLShaderProgram::init() } #endif if (qt_resolve_glsl_extensions(const_cast<QGLContext *>(context))) { - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; d->program = glCreateProgram(); if (!(d->program)) { qWarning() << "QGLShaderProgram: could not create shader program"; @@ -886,7 +886,7 @@ bool QGLShaderProgram::addShader(QGLShader *shader) if (!shader->d->isPartial) { if (!shader->d->shader) return false; - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; glAttachShader(d->program, shader->d->shader); } else { d->hasPartialShaders = true; @@ -999,7 +999,7 @@ bool QGLShaderProgram::addShaderFromFile void QGLShaderProgram::removeShader(QGLShader *shader) { if (d->program && shader && shader->d->shader) { - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; #ifndef QT_NO_DEBUG if (!qt_check_sharing_with_current_context(ctx)) qWarning("QGLShaderProgram::removeShader: Program is not associated with current context."); @@ -1037,7 +1037,7 @@ QList<QGLShader *> QGLShaderProgram::shaders() const void QGLShaderProgram::removeAllShaders() { d->removingShaders = true; - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; #ifndef QT_NO_DEBUG if (!qt_check_sharing_with_current_context(ctx)) qWarning("QGLShaderProgram::removeAllShaders: Program is not associated with current context."); @@ -1193,7 +1193,7 @@ bool QGLShaderProgram::link() { if (!d->program) return false; - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; #ifndef QT_NO_DEBUG if (!qt_check_sharing_with_current_context(ctx)) { qWarning("QGLShaderProgram::link: Program is not associated with current context."); @@ -1303,7 +1303,7 @@ bool QGLShaderProgram::enable() return false; if (!d->linked && !link()) return false; - QGLContextGroupResources *ctx = d->ctx; + QGLContextGroup *ctx = d->ctx; #ifndef QT_NO_DEBUG if (!qt_check_sharing_with_current_context(ctx)) { qWarning("QGLShaderProgram::enable: Program is not associated with current context."); |