diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-02-18 09:58:57 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-02-18 09:58:57 +0100 |
commit | ba9ca0e3d64c46fc63cdbc62f3e4a96e36a842f8 (patch) | |
tree | f9631624c841281302a2a546fbcc06a2375f410e /src/quick/scenegraph | |
parent | a65b8785621ebf58f34eb0c1759376fc0a1117c7 (diff) | |
parent | 464bd2bf975797241213191a374e70431c5c3763 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
src/qml/jsruntime/qv4functionobject.cpp
src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
Change-Id: Id164f6c3b45501aa466908659ec4e3b957323753
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 22 | ||||
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h | 3 | ||||
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgmaterial.cpp | 6 | ||||
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgnode.cpp | 5 | ||||
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgnode.h | 1 | ||||
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgrenderer_p.h | 1 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgcontext.cpp | 34 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgcontext_p.h | 3 |
8 files changed, 49 insertions, 26 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index f121e16523..30081093f2 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -143,11 +143,6 @@ ShaderManager::Shader *ShaderManager::prepareMaterial(QSGMaterial *material) QSurfaceFormat::OpenGLContextProfile profile = ctx->format().profile(); QOpenGLShaderProgram *p = s->program(); - p->addShaderFromSourceCode(QOpenGLShader::Vertex, - qsgShaderRewriter_insertZAttributes(s->vertexShader(), profile)); - p->addShaderFromSourceCode(QOpenGLShader::Fragment, - s->fragmentShader()); - char const *const *attr = s->attributeNames(); int i; for (i = 0; attr[i]; ++i) { @@ -155,14 +150,10 @@ ShaderManager::Shader *ShaderManager::prepareMaterial(QSGMaterial *material) p->bindAttributeLocation(attr[i], i); } p->bindAttributeLocation("_qt_order", i); - - p->link(); - if (!p->isLinked()) { - qDebug() << "Renderer failed shader compilation:" << endl << p->log(); + context->compile(s, material, qsgShaderRewriter_insertZAttributes(s->vertexShader(), profile), 0); + context->initialize(s); + if (!p->isLinked()) return 0; - } - - s->initialize(); shader = new Shader; shader->program = s; @@ -198,8 +189,8 @@ ShaderManager::Shader *ShaderManager::prepareMaterialNoRewrite(QSGMaterial *mate #endif QSGMaterialShader *s = static_cast<QSGMaterialShader *>(material->createShader()); - s->compile(); - s->initialize(); + context->compile(s, material); + context->initialize(s); shader = new Shader(); shader->program = s; @@ -292,6 +283,7 @@ void Updater::updateStates(QSGNode *n) m_added = 0; m_transformChange = 0; + m_opacityChange = 0; Node *sn = renderer->m_nodes.value(n, 0); Q_ASSERT(sn); @@ -779,7 +771,7 @@ Renderer::Renderer(QSGRenderContext *ctx) m_shaderManager = ctx->findChild<ShaderManager *>(QStringLiteral("__qt_ShaderManager"), Qt::FindDirectChildrenOnly); if (!m_shaderManager) { - m_shaderManager = new ShaderManager(); + m_shaderManager = new ShaderManager(ctx); m_shaderManager->setObjectName(QStringLiteral("__qt_ShaderManager")); m_shaderManager->setParent(ctx); QObject::connect(ctx, SIGNAL(invalidated()), m_shaderManager, SLOT(invalidated()), Qt::DirectConnection); diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h index c38c483df4..7c06de774a 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h @@ -371,7 +371,7 @@ public: float lastOpacity; }; - ShaderManager() : blitProgram(0), visualizeProgram(0) { } + ShaderManager(QSGRenderContext *ctx) : blitProgram(0), visualizeProgram(0), context(ctx) { } ~ShaderManager() { qDeleteAll(rewrittenShaders.values()); qDeleteAll(stockShaders.values()); @@ -389,6 +389,7 @@ public: QOpenGLShaderProgram *blitProgram; QOpenGLShaderProgram *visualizeProgram; + QSGRenderContext *context; }; class Q_QUICK_PRIVATE_EXPORT Renderer : public QSGRenderer diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.cpp b/src/quick/scenegraph/coreapi/qsgmaterial.cpp index 686d1438b4..4954fe20bb 100644 --- a/src/quick/scenegraph/coreapi/qsgmaterial.cpp +++ b/src/quick/scenegraph/coreapi/qsgmaterial.cpp @@ -257,9 +257,6 @@ const char *QSGMaterialShader::fragmentShader() const State that is global for all uses of the shader, independent of the geometry that is being drawn, can be setup in this function. - - If reimplemented, make sure to either call the base class implementation to - enable the vertex attribute registers. */ void QSGMaterialShader::activate() @@ -271,9 +268,6 @@ void QSGMaterialShader::activate() /*! This function is called by the scene graph to indicate that geometry will no longer to be rendered using this shader. - - If reimplemented, make sure to either call the base class implementation to - disable the vertex attribute registers. */ void QSGMaterialShader::deactivate() diff --git a/src/quick/scenegraph/coreapi/qsgnode.cpp b/src/quick/scenegraph/coreapi/qsgnode.cpp index b0c869c096..5c196b252c 100644 --- a/src/quick/scenegraph/coreapi/qsgnode.cpp +++ b/src/quick/scenegraph/coreapi/qsgnode.cpp @@ -648,10 +648,7 @@ void QSGNode::setFlags(Flags f, bool enabled) /*! - Marks this node with the states in \a bits as dirty. - - When a node is marked dirty, it recursively marks the parent chain - as dirty and notify all connected renderers that the has dirty states. + Notifies all connected renderers that the node has dirty \a bits. */ void QSGNode::markDirty(DirtyState bits) diff --git a/src/quick/scenegraph/coreapi/qsgnode.h b/src/quick/scenegraph/coreapi/qsgnode.h index 60e7652e7a..f85184db90 100644 --- a/src/quick/scenegraph/coreapi/qsgnode.h +++ b/src/quick/scenegraph/coreapi/qsgnode.h @@ -161,6 +161,7 @@ protected: private: friend class QSGRootNode; friend class QSGBatchRenderer::Renderer; + friend class QSGRenderer; void init(); void destroy(); diff --git a/src/quick/scenegraph/coreapi/qsgrenderer_p.h b/src/quick/scenegraph/coreapi/qsgrenderer_p.h index 296d6e2cfd..55c9444365 100644 --- a/src/quick/scenegraph/coreapi/qsgrenderer_p.h +++ b/src/quick/scenegraph/coreapi/qsgrenderer_p.h @@ -150,6 +150,7 @@ protected: void addNodesToPreprocess(QSGNode *node); void removeNodesToPreprocess(QSGNode *node); + void markNodeDirtyState(QSGNode *node, QSGNode::DirtyState state) { node->m_dirtyState |= state; } QColor m_clear_color; ClearMode m_clear_mode; diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index dd00f75fae..9f58876def 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -631,4 +631,38 @@ void QSGRenderContext::textureFactoryDestroyed(QObject *o) m_mutex.unlock(); } +/*! + Compile \a shader, optionally using \a vertexCode and \a fragmentCode as + replacement for the source code supplied by \a shader. + + If \a vertexCode or \a fragmentCode is supplied, the caller is responsible + for setting up attribute bindings. + + \a material is supplied in case the implementation needs to take the + material flags into account. + */ + +void QSGRenderContext::compile(QSGMaterialShader *shader, QSGMaterial *material, const char *vertexCode, const char *fragmentCode) +{ + Q_UNUSED(material); + if (vertexCode || fragmentCode) { + Q_ASSERT_X((material->flags() & QSGMaterial::CustomCompileStep) == 0, + "QSGRenderContext::compile()", + "materials with custom compile step cannot have custom vertex/fragment code"); + QOpenGLShaderProgram *p = shader->program(); + p->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexCode ? vertexCode : shader->vertexShader()); + p->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentCode ? fragmentCode : shader->fragmentShader()); + p->link(); + if (!p->isLinked()) + qWarning() << "shader compilation failed:" << endl << p->log(); + } else { + shader->compile(); + } +} + +void QSGRenderContext::initialize(QSGMaterialShader *shader) +{ + shader->initialize(); +} + QT_END_NAMESPACE diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h index 3b58cecd6a..f8d5588649 100644 --- a/src/quick/scenegraph/qsgcontext_p.h +++ b/src/quick/scenegraph/qsgcontext_p.h @@ -106,6 +106,9 @@ public: virtual QSGTexture *createTextureNoAtlas(const QImage &image) const; virtual QSGRenderer *createRenderer(); + virtual void compile(QSGMaterialShader *shader, QSGMaterial *material, const char *vertexCode = 0, const char *fragmentCode = 0); + virtual void initialize(QSGMaterialShader *shader); + void registerFontengineForCleanup(QFontEngine *engine); static QSGRenderContext *from(QOpenGLContext *context); |