diff options
author | Antti Määttä <antti.maatta@qt.io> | 2016-08-12 12:56:28 +0300 |
---|---|---|
committer | Antti Määttä <antti.maatta@qt.io> | 2016-08-29 05:29:09 +0000 |
commit | 733dfe608ef70c82dbed43ba85e318e11254a30f (patch) | |
tree | cb7402836bc3c0befced0bd9b3ffdc3f998dd467 | |
parent | 446a92c01003df192d01ff562c6088eee66a8b6c (diff) |
Add sendRenderCaptureJob
Implement job for sending render capture images to frontend nodes
Change-Id: I39e9cc2f059f7a7528538b3bd0279cf001ed01c6
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r-- | src/render/backend/renderer.cpp | 11 | ||||
-rw-r--r-- | src/render/backend/renderer_p.h | 4 | ||||
-rw-r--r-- | src/render/jobs/job_common_p.h | 3 | ||||
-rw-r--r-- | src/render/jobs/jobs.pri | 6 | ||||
-rw-r--r-- | src/render/jobs/sendrendercapturejob.cpp | 81 | ||||
-rw-r--r-- | src/render/jobs/sendrendercapturejob_p.h | 90 |
6 files changed, 192 insertions, 3 deletions
diff --git a/src/render/backend/renderer.cpp b/src/render/backend/renderer.cpp index c91eff86e..530363c0b 100644 --- a/src/render/backend/renderer.cpp +++ b/src/render/backend/renderer.cpp @@ -1257,6 +1257,17 @@ const GraphicsApiFilterData *Renderer::contextInfo() const return m_graphicsContext->contextInfo(); } +void Renderer::addRenderCaptureSendRequest(Qt3DCore::QNodeId nodeId) +{ + if (!m_pendingRenderCaptureSendRequests.contains(nodeId)) + m_pendingRenderCaptureSendRequests.push_back(nodeId); +} + +const QVector<Qt3DCore::QNodeId> Renderer::takePendingRenderCaptureSendRequests() +{ + return std::move(m_pendingRenderCaptureSendRequests); +} + // Returns a vector of jobs to be performed for dirty buffers // 1 dirty buffer == 1 job, all job can be performed in parallel QVector<Qt3DCore::QAspectJobPtr> Renderer::createRenderBufferJobs() const diff --git a/src/render/backend/renderer_p.h b/src/render/backend/renderer_p.h index 3e6ef6ffc..f0b56d271 100644 --- a/src/render/backend/renderer_p.h +++ b/src/render/backend/renderer_p.h @@ -210,6 +210,8 @@ public: QList<QMouseEvent> pendingPickingEvents() const; + void addRenderCaptureSendRequest(Qt3DCore::QNodeId nodeId); + const QVector<Qt3DCore::QNodeId> takePendingRenderCaptureSendRequests(); void enqueueRenderView(RenderView *renderView, int submitOrder); bool isReadyToSubmit(); @@ -285,6 +287,8 @@ private: CalculateBoundingVolumeJobPtr m_calculateBoundingVolumeJob; UpdateWorldBoundingVolumeJobPtr m_updateWorldBoundingVolumeJob; + QVector<Qt3DCore::QNodeId> m_pendingRenderCaptureSendRequests; + void performDraw(RenderCommand *command); void performCompute(const RenderView *rv, RenderCommand *command); void createOrUpdateVAO(RenderCommand *command, diff --git a/src/render/jobs/job_common_p.h b/src/render/jobs/job_common_p.h index a24c428eb..3266e0f6d 100644 --- a/src/render/jobs/job_common_p.h +++ b/src/render/jobs/job_common_p.h @@ -83,7 +83,8 @@ namespace JobTypes { FrustumCulling, LightGathering, UpdateWorldBoundingVolume, - FrameSubmissionPart2 + FrameSubmissionPart2, + SendRenderCapture, }; } // JobTypes diff --git a/src/render/jobs/jobs.pri b/src/render/jobs/jobs.pri index a970f2efc..9ad8f9bc0 100644 --- a/src/render/jobs/jobs.pri +++ b/src/render/jobs/jobs.pri @@ -22,7 +22,8 @@ HEADERS += \ $$PWD/frustumcullingjob_p.h \ $$PWD/lightgatherer_p.h \ $$PWD/expandboundingvolumejob_p.h \ - $$PWD/updateworldboundingvolumejob_p.h + $$PWD/updateworldboundingvolumejob_p.h \ + $$PWD/sendrendercapturejob_p.h SOURCES += \ $$PWD/updateworldtransformjob.cpp \ @@ -43,4 +44,5 @@ SOURCES += \ $$PWD/frustumcullingjob.cpp \ $$PWD/lightgatherer.cpp \ $$PWD/expandboundingvolumejob.cpp \ - $$PWD/updateworldboundingvolumejob.cpp + $$PWD/updateworldboundingvolumejob.cpp \ + $$PWD/sendrendercapturejob.cpp diff --git a/src/render/jobs/sendrendercapturejob.cpp b/src/render/jobs/sendrendercapturejob.cpp new file mode 100644 index 000000000..6dd9387e0 --- /dev/null +++ b/src/render/jobs/sendrendercapturejob.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "sendrendercapturejob_p.h" + +#include "Qt3DRender/private/renderer_p.h" +#include "Qt3DRender/private/nodemanagers_p.h" +#include "Qt3DRender/private/rendercapture_p.h" +#include <Qt3DRender/private/job_common_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +namespace Render { + +SendRenderCaptureJob::SendRenderCaptureJob(Renderer *renderer) + : Qt3DCore::QAspectJob() + , m_renderer(renderer) +{ + SET_JOB_RUN_STAT_TYPE(this, JobTypes::SendRenderCapture, 0); +} + +SendRenderCaptureJob::~SendRenderCaptureJob() +{ + +} + +void SendRenderCaptureJob::setManagers(NodeManagers *managers) +{ + m_managers = managers; +} + +void SendRenderCaptureJob::run() +{ + const auto pendingCaptures = m_renderer->takePendingRenderCaptureSendRequests(); + for (Qt3DCore::QNodeId id : pendingCaptures) { + auto *node = static_cast<Qt3DRender::Render::RenderCapture *> + (m_managers->frameGraphManager()->lookupNode(id)); + node->sendRenderCaptures(); + } +} + +} // Render + +} // Qt3DRender + +QT_END_NAMESPACE diff --git a/src/render/jobs/sendrendercapturejob_p.h b/src/render/jobs/sendrendercapturejob_p.h new file mode 100644 index 000000000..f1e6b65f2 --- /dev/null +++ b/src/render/jobs/sendrendercapturejob_p.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SENDRENDERCAPTUREJOB_P_H +#define SENDRENDERCAPTUREJOB_P_H + + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <Qt3DCore/qaspectjob.h> +#include <Qt3DRender/qt3drender_global.h> +#include <Qt3DRender/private/qt3drender_global_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +namespace Render { + +class NodeManagers; +class Entity; +class Renderer; + +class QT3DRENDERSHARED_PRIVATE_EXPORT SendRenderCaptureJob : public Qt3DCore::QAspectJob +{ +public: + explicit SendRenderCaptureJob(Renderer *renderer); + ~SendRenderCaptureJob(); + + void setManagers(NodeManagers *managers); + +protected: + void run() Q_DECL_FINAL; + +private: + Renderer *m_renderer; + NodeManagers *m_managers; +}; + +typedef QSharedPointer<SendRenderCaptureJob> SendRenderCaptureJobPtr; + +} // namespace Render + +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // SENDRENDERCAPTUREJOB_P_H |