diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2018-03-02 10:58:46 +0100 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2018-03-16 11:21:07 +0000 |
commit | 00b7e4b76ab0454178a7f6412100152cc52d0581 (patch) | |
tree | 43f3486a16a58378a2b069d68e31a27d3370a0c0 /src/render/backend/commandthread_p.h | |
parent | c1b495f70c3b4f0c23d44dfcd99aed5882312100 (diff) |
Perform Shader loading within frame
- CommandThread has been improved to not use an exec loop and properly
instantiate its own GL context + GraphicsContext that is bound to an
offscreen surface
- The dirtyShaderGathering job has been renamed and now performs the loading
of shaders and their introspection. It is also run before the
materiaparameter gathering, so that these jobs and the following can assume
a shader is ready
Change-Id: I6d99b3a104bd96530dc45f4b05d3aaac09d2d077
Reviewed-by: Mike Krus <mike.krus@kdab.com>
Reviewed-by: Svenn-Arne Dragly <svenn-arne.dragly@qt.io>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/backend/commandthread_p.h')
-rw-r--r-- | src/render/backend/commandthread_p.h | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/render/backend/commandthread_p.h b/src/render/backend/commandthread_p.h index a87d13a2e..0508675c4 100644 --- a/src/render/backend/commandthread_p.h +++ b/src/render/backend/commandthread_p.h @@ -53,6 +53,7 @@ #include <QtCore/QThread> #include <QtCore/QSemaphore> +#include <QtCore/QMutex> QT_BEGIN_NAMESPACE @@ -63,12 +64,10 @@ namespace Qt3DRender { namespace Render { class Renderer; - -class Command -{ -public: - virtual void execute(Renderer *renderer, QOpenGLContext *localContext) = 0; -}; +class GLCommand; +class OffscreenSurfaceHelper; +class GraphicsContext; +class ShaderCache; class CommandThread : public QThread { @@ -79,21 +78,32 @@ public: Render::Renderer* renderer() const { return m_renderer; } - void initialize(QOpenGLContext *mainContext); + void setShaderCache(ShaderCache *shaderCache); + ShaderCache *shaderCache() const { return m_shaderCache; } + + void initialize(QOpenGLContext *mainContext, OffscreenSurfaceHelper *offsreenSurfaceHelper); void shutdown(); - void executeCommand(Command *command); + void executeCommand(GLCommand *command); private: void run() override; - Q_INVOKABLE void executeCommandInternal(Command *command); + void executeCommandInternal(Qt3DRender::Render::GLCommand *command); private: Renderer* m_renderer; QSemaphore m_waitForStartSemaphore; QSemaphore m_initializedSemaphore; + QSemaphore m_commandRequestedSemaphore; + QSemaphore m_commandExecutionSemaphore; + QMutex m_blockingCallerMutex; QOpenGLContext *m_mainContext; + ShaderCache *m_shaderCache; + OffscreenSurfaceHelper *m_offsreenSurfaceHelper; QScopedPointer<QOpenGLContext> m_localContext; + QScopedPointer<GraphicsContext> m_graphicsContext; + GLCommand *m_currentCommand; + QAtomicInt m_running; }; } // Render |