1/****************************************************************************
2**
3** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
4** Copyright (C) 2016 Paul Lemire
5** Contact: https://www.qt.io/licensing/
6**
7** This file is part of the Qt3D module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial License Usage
11** Licensees holding valid commercial Qt licenses may use this file in
12** accordance with the commercial license agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and The Qt Company. For licensing terms
15** and conditions see https://www.qt.io/terms-conditions. For further
16** information use the contact form at https://www.qt.io/contact-us.
17**
18** GNU Lesser General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU Lesser
20** General Public License version 3 as published by the Free Software
21** Foundation and appearing in the file LICENSE.LGPL3 included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU Lesser General Public License version 3 requirements
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25**
26** GNU General Public License Usage
27** Alternatively, this file may be used under the terms of the GNU
28** General Public License version 2.0 or (at your option) the GNU General
29** Public license version 3 or any later version approved by the KDE Free
30** Qt Foundation. The licenses are as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32** included in the packaging of this file. Please review the following
33** information to ensure the GNU General Public License requirements will
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35** https://www.gnu.org/licenses/gpl-3.0.html.
36**
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41#include "renderviewinitializerjob_p.h"
42
43#include <renderview_p.h>
44#include <renderer_p.h>
45#include <renderviewjobutils_p.h>
46#include <Qt3DRender/private/renderlogging_p.h>
47#include <Qt3DRender/private/job_common_p.h>
48
49#include <QElapsedTimer>
50
51QT_BEGIN_NAMESPACE
52
53namespace Qt3DRender {
54namespace Render {
55namespace OpenGL {
56
57namespace {
58// only accessed in ctor and dtor of RenderViewJob
59// which are always being called in a non concurrent manner
60int renderViewInstanceCounter = 0;
61} // anonymous
62
63RenderViewInitializerJob::RenderViewInitializerJob()
64 : m_renderer(nullptr)
65 , m_fgLeaf(nullptr)
66 , m_index(0)
67 , m_renderView(nullptr)
68{
69 SET_JOB_RUN_STAT_TYPE(this, JobTypes::RenderView, renderViewInstanceCounter++)
70}
71
72RenderViewInitializerJob::~RenderViewInitializerJob()
73{
74 renderViewInstanceCounter--;
75}
76
77void RenderViewInitializerJob::run()
78{
79 qCDebug(Jobs) << Q_FUNC_INFO << m_index;
80#if defined(QT3D_RENDER_VIEW_JOB_TIMINGS)
81 QElapsedTimer timer;
82 timer.start();
83 qint64 gatherLightsTime;
84 qint64 buildCommandsTime;
85#endif
86
87 // Create a RenderView object
88 // The RenderView are created from a QFrameAllocator stored in the current Thread local storage
89 m_renderView = new RenderView;
90
91 // RenderView should allocate heap resources using only the currentFrameAllocator
92 m_renderView->setRenderer(m_renderer);
93
94 // Populate the renderview's configuration from the framegraph
95 setRenderViewConfigFromFrameGraphLeafNode(rv: m_renderView, fgLeaf: m_fgLeaf);
96#if defined(QT3D_RENDER_VIEW_JOB_TIMINGS)
97 qint64 gatherStateTime = timer.nsecsElapsed();
98 timer.restart();
99#endif
100}
101
102} // namespace OpenGL
103} // namespace Render
104} // namespace Qt3DRender
105
106QT_END_NAMESPACE
107

source code of qt3d/src/plugins/renderers/opengl/jobs/renderviewinitializerjob.cpp