aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2016-06-27 17:13:37 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2016-06-29 11:59:54 +0000
commit5ee02242d72ac9a536584b36ba549480a97303f7 (patch)
treec898b2eedad203ee0536d7b40cab6c1c08234056 /src/quick/scenegraph/coreapi/qsgrendererinterface.cpp
parent12bff27aa6f1caac9bfacf365c542cf5da6e3148 (diff)
Unify ShaderEffect property setting
rendererInterface() should not require isSceneGraphInitialized() to be true - the API and language queries like graphicsApi() have no need for the scenegraph, they only need the plugin to be loaded, i.e. that the QQuickWindow is constructed. This is the key to be able to make GraphicsInfo report graphicsApi and shaderType with the correct values as early as possible - meaning as soon as the item is associated with a window. The initialization of the scenegraph (the exact timing of which varies backend to backend) does not matter here. The fragment and vertex shader property setting is now unified in the two ShaderEffect implementations: - If the component is complete, the shader is attempted to be processed right from the setter. - Otherwise the item will trigger processing once the component is complete. - If there is no window when processing is trigerred, it is deferred via polish. To implement item polish handling we need a new virtual in QQuickItemPrivate since we cannot intrdouce virtuals into the public classes. This way one can write a condition (and later potentially use file selectors) like this: fragmentShader: GraphicsInfo.shaderType == GraphicsInfo.GLSL ? "..." : ... without having to worry about getting an unintended value processed due to GraphicsInfo not yet reporting an up-to-date value. parseLog() forces, for GL at least, shader processing to prevent autotests from breaking. Change-Id: If55c69d746c29cd07348ddad2d6b0f2b5dd7f3a2 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/quick/scenegraph/coreapi/qsgrendererinterface.cpp')
-rw-r--r--src/quick/scenegraph/coreapi/qsgrendererinterface.cpp41
1 files changed, 19 insertions, 22 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp b/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp
index 149baab3a9..e818d35dd7 100644
--- a/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp
@@ -54,12 +54,21 @@ QT_BEGIN_NAMESPACE
necessary to query certain values, for instance the graphics device (e.g.
the Direct3D or Vulkan device) that is used by the scenegraph.
- \note QSGRendererInterface is only available after the scenegraph is
- initialized. Additionally, there may be backend-specific limitations on
- when the functions can be called. The only way that is guaranteed to
- succeed is calling them when the rendering of a node (i.e. the preparation
- of the command list for the next frame) is active. In practice this
- typically means QSGRenderNode::render().
+ QSGRendererInterface's functions have varying availability. API and
+ language queries, like graphicsApi() or shaderType() are always available,
+ meaning it is sufficient to construct a QQuickWindow or QQuickView, and the
+ graphics API or shading language in use can be queried right after via
+ QQuickWindow::rendererInterface(). This guarantees that utilities like the
+ GraphicsInfo QML type are able to report the correct values as early as
+ possible, without having conditional property values - depending on for
+ instance shaderType() - evaluate to unexpected values.
+
+ Engine-specific accessors, like getResource(), are however available only
+ after the scenegraph is initialized. Additionally, there may be
+ backend-specific limitations on when such functions can be called. The only
+ way that is guaranteed to succeed is calling them when the rendering of a
+ node (i.e. the preparation of the command list for the next frame) is
+ active. In practice this typically means QSGRenderNode::render().
*/
/*!
@@ -112,10 +121,7 @@ QSGRendererInterface::~QSGRendererInterface()
Returns the graphics API that is in use by the Qt Quick scenegraph.
- \note This function can be called on any thread. However, the renderer
- interface's lifetime may be tied to the render thread and therefore calling
- this function from other threads during the process of application shutdown
- or QQuickWindow closing is likely to become invalid.
+ \note This function can be called on any thread.
*/
/*!
@@ -155,10 +161,7 @@ void *QSGRendererInterface::getResource(const char *resource) const
\return the shading language supported by the Qt Quick backend the
application is using.
- \note This function can be called on any thread. However, the renderer
- interface's lifetime may be tied to the render thread and therefore calling
- this function from other threads during the process of application shutdown
- or QQuickWindow closing is likely to become invalid.
+ \note This function can be called on any thread.
\sa QtQuick::GraphicsInfo
*/
@@ -169,10 +172,7 @@ void *QSGRendererInterface::getResource(const char *resource) const
\return a bitmask of the shader compilation approaches supported by the Qt
Quick backend the application is using.
- \note This function can be called on any thread. However, the renderer
- interface's lifetime may be tied to the render thread and therefore calling
- this function from other threads during the process of application shutdown
- or QQuickWindow closing is likely to become invalid.
+ \note This function can be called on any thread.
\sa QtQuick::GraphicsInfo
*/
@@ -182,10 +182,7 @@ void *QSGRendererInterface::getResource(const char *resource) const
\return a bitmask of the supported ways of providing shader sources in ShaderEffect items.
- \note This function can be called on any thread. However, the renderer
- interface's lifetime may be tied to the render thread and therefore calling
- this function from other threads during the process of application shutdown
- or QQuickWindow closing is likely to become invalid.
+ \note This function can be called on any thread.
\sa QtQuick::GraphicsInfo
*/