diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-06-27 17:13:37 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-06-29 11:59:54 +0000 |
commit | 5ee02242d72ac9a536584b36ba549480a97303f7 (patch) | |
tree | c898b2eedad203ee0536d7b40cab6c1c08234056 /src/plugins | |
parent | 12bff27aa6f1caac9bfacf365c542cf5da6e3148 (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/plugins')
5 files changed, 43 insertions, 35 deletions
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12context.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12context.cpp index 07c9287f80..1b29ddd59c 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12context.cpp +++ b/src/plugins/scenegraph/d3d12/qsgd3d12context.cpp @@ -109,12 +109,7 @@ QSurfaceFormat QSGD3D12Context::defaultSurfaceFormat() const QSGRendererInterface *QSGD3D12Context::rendererInterface(QSGRenderContext *renderContext) { - QSGD3D12RenderContext *rc = static_cast<QSGD3D12RenderContext *>(renderContext); - if (!rc->engine()) { - qWarning("No D3D12 engine available yet (no render thread due to window not exposed?)"); - return nullptr; - } - return rc->engine(); + return static_cast<QSGD3D12RenderContext *>(renderContext); } QSGRectangleNode *QSGD3D12Context::createRectangleNode() diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp index b54d10aa85..e1b076c39a 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp +++ b/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp @@ -535,31 +535,11 @@ void QSGD3D12Engine::simulateDeviceLoss() d->simulateDeviceLoss(); } -QSGRendererInterface::GraphicsApi QSGD3D12Engine::graphicsApi() const -{ - return Direct3D12; -} - -void *QSGD3D12Engine::getResource(Resource resource) const +void *QSGD3D12Engine::getResource(QSGRendererInterface::Resource resource) const { return d->getResource(resource); } -QSGRendererInterface::ShaderType QSGD3D12Engine::shaderType() const -{ - return HLSL; -} - -QSGRendererInterface::ShaderCompilationTypes QSGD3D12Engine::shaderCompilationType() const -{ - return RuntimeCompilation | OfflineCompilation; -} - -QSGRendererInterface::ShaderSourceTypes QSGD3D12Engine::shaderSourceType() const -{ - return ShaderSourceString | ShaderByteCode; -} - static inline quint32 alignedSize(quint32 size, quint32 byteAlign) { return (size + byteAlign - 1) & ~(byteAlign - 1); diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12engine_p.h b/src/plugins/scenegraph/d3d12/qsgd3d12engine_p.h index 2ebe1e733a..ad89696bbe 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12engine_p.h +++ b/src/plugins/scenegraph/d3d12/qsgd3d12engine_p.h @@ -281,7 +281,7 @@ inline uint qHash(const QSGD3D12PipelineState &key, uint seed = 0) + key.topologyType; } -class QSGD3D12Engine : public QSGRendererInterface +class QSGD3D12Engine { public: QSGD3D12Engine(); @@ -372,12 +372,7 @@ public: void simulateDeviceLoss(); - // QSGRendererInterface - GraphicsApi graphicsApi() const override; - void *getResource(Resource resource) const override; - ShaderType shaderType() const override; - ShaderCompilationTypes shaderCompilationType() const override; - ShaderSourceTypes shaderSourceType() const override; + void *getResource(QSGRendererInterface::Resource resource) const; private: QSGD3D12EnginePrivate *d; diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12rendercontext.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12rendercontext.cpp index b32bfe063a..7e62421380 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12rendercontext.cpp +++ b/src/plugins/scenegraph/d3d12/qsgd3d12rendercontext.cpp @@ -126,4 +126,34 @@ void QSGD3D12RenderContext::ensureInitializedEmitted() emit initialized(); } +QSGRendererInterface::GraphicsApi QSGD3D12RenderContext::graphicsApi() const +{ + return Direct3D12; +} + +void *QSGD3D12RenderContext::getResource(Resource resource) const +{ + if (!m_engine) { + qWarning("getResource: No D3D12 engine available yet (window not exposed?)"); + return nullptr; + } + + return m_engine->getResource(resource); +} + +QSGRendererInterface::ShaderType QSGD3D12RenderContext::shaderType() const +{ + return HLSL; +} + +QSGRendererInterface::ShaderCompilationTypes QSGD3D12RenderContext::shaderCompilationType() const +{ + return RuntimeCompilation | OfflineCompilation; +} + +QSGRendererInterface::ShaderSourceTypes QSGD3D12RenderContext::shaderSourceType() const +{ + return ShaderSourceString | ShaderByteCode; +} + QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12rendercontext_p.h b/src/plugins/scenegraph/d3d12/qsgd3d12rendercontext_p.h index 86a300831d..a1029b019e 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12rendercontext_p.h +++ b/src/plugins/scenegraph/d3d12/qsgd3d12rendercontext_p.h @@ -52,12 +52,13 @@ // #include <private/qsgcontext_p.h> +#include <qsgrendererinterface.h> QT_BEGIN_NAMESPACE class QSGD3D12Engine; -class QSGD3D12RenderContext : public QSGRenderContext +class QSGD3D12RenderContext : public QSGRenderContext, public QSGRendererInterface { public: QSGD3D12RenderContext(QSGContext *ctx); @@ -73,6 +74,13 @@ public: void ensureInitializedEmitted(); void setInitializedPending() { m_pendingInitialized = true; } + // QSGRendererInterface + GraphicsApi graphicsApi() const override; + void *getResource(Resource resource) const override; + ShaderType shaderType() const override; + ShaderCompilationTypes shaderCompilationType() const override; + ShaderSourceTypes shaderSourceType() const override; + private: QSGD3D12Engine *m_engine = nullptr; bool m_pendingInitialized = false; |