summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/qt3d/examples-common/qt3dquickwindow.cpp15
-rw-r--r--examples/qt3d/examples-common/qt3dwindow.cpp6
-rw-r--r--src/core/aspects/qabstractaspect.h2
-rw-r--r--src/core/aspects/qaspectengine.cpp20
-rw-r--r--src/core/aspects/qaspectengine.h1
-rw-r--r--src/core/aspects/qaspectmanager.cpp17
-rw-r--r--src/core/aspects/qaspectmanager_p.h2
-rw-r--r--src/input/frontend/qinputaspect.cpp6
-rw-r--r--src/input/frontend/qinputaspect.h2
-rw-r--r--src/logic/qlogicaspect.cpp3
-rw-r--r--src/logic/qlogicaspect.h2
-rw-r--r--src/quick3d/imports/scene3d/scene3ditem.cpp5
-rw-r--r--src/quick3d/imports/scene3d/scene3drenderer.cpp5
-rw-r--r--src/render/backend/abstractrenderer_p.h6
-rw-r--r--src/render/backend/platformsurfacefilter.cpp4
-rw-r--r--src/render/backend/renderer.cpp192
-rw-r--r--src/render/backend/renderer_p.h15
-rw-r--r--src/render/backend/renderview.cpp1
-rw-r--r--src/render/frontend/qrenderaspect.cpp73
-rw-r--r--src/render/frontend/qrenderaspect.h7
-rw-r--r--src/render/graphicshelpers/graphicscontext.cpp91
-rw-r--r--src/render/graphicshelpers/graphicscontext_p.h8
-rw-r--r--src/render/jobs/pickboundingvolumejob.cpp37
-rw-r--r--tests/auto/core/qaspectengine/tst_qaspectengine.cpp2
-rw-r--r--tests/auto/core/qaspectfactory/tst_qaspectfactory.cpp2
-rw-r--r--tests/benchmarks/render/jobs/tst_bench_jobs.cpp5
26 files changed, 198 insertions, 331 deletions
diff --git a/examples/qt3d/examples-common/qt3dquickwindow.cpp b/examples/qt3d/examples-common/qt3dquickwindow.cpp
index 759405541..7b0f4a70f 100644
--- a/examples/qt3d/examples-common/qt3dquickwindow.cpp
+++ b/examples/qt3d/examples-common/qt3dquickwindow.cpp
@@ -41,6 +41,7 @@
#include <Qt3DRender/qframegraph.h>
#include <Qt3DRender/qrendersurfaceselector.h>
#include <Qt3DInput/qinputaspect.h>
+#include <Qt3DInput/qinputsettings.h>
#include <Qt3DLogic/qlogicaspect.h>
#include <QQmlContext>
@@ -123,12 +124,6 @@ void Qt3DQuickWindow::showEvent(QShowEvent *e)
{
if (!m_initialized) {
- // TODO: Get rid of this
- QVariantMap data;
- data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(this)));
- data.insert(QStringLiteral("eventSource"), QVariant::fromValue(this));
- m_engine->aspectEngine()->setData(data);
-
// Connect to the QQmlAspectEngine's statusChanged signal so that when the QML is loaded
// and th eobjects hav ebeen instantiated, but before we set them on the QAspectEngine we
// can swoop in and set the window surface and camera on the framegraph and ensure the camera
@@ -165,7 +160,13 @@ void Qt3DQuickWindow::onSceneCreated(QObject *rootObject)
}
}
- // TODO: Set ourselves up as a source of input events for the input aspect
+ // Set ourselves up as a source of input events for the input aspect
+ Qt3DInput::QInputSettings *inputSettings = rootObject->findChild<Qt3DInput::QInputSettings *>();
+ if (inputSettings) {
+ inputSettings->setEventSource(this);
+ } else {
+ qWarning() << "No Input Settings found, keyboard and mouse events won't be handled";
+ }
}
void Qt3DQuickWindow::setWindowSurface(QObject *rootObject)
diff --git a/examples/qt3d/examples-common/qt3dwindow.cpp b/examples/qt3d/examples-common/qt3dwindow.cpp
index a7728771e..805d92efb 100644
--- a/examples/qt3d/examples-common/qt3dwindow.cpp
+++ b/examples/qt3d/examples-common/qt3dwindow.cpp
@@ -171,12 +171,6 @@ void Qt3DWindow::showEvent(QShowEvent *e)
if (m_userRoot != nullptr)
m_userRoot->setParent(m_root);
- // TODO: Get rid of this
- QVariantMap data;
- data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(this)));
- data.insert(QStringLiteral("eventSource"), QVariant::fromValue(this));
- m_aspectEngine->setData(data);
-
m_root->addComponent(m_frameGraph);
m_aspectEngine->setRootEntity(m_root);
diff --git a/src/core/aspects/qabstractaspect.h b/src/core/aspects/qabstractaspect.h
index e5842aa08..aa3404f1c 100644
--- a/src/core/aspects/qabstractaspect.h
+++ b/src/core/aspects/qabstractaspect.h
@@ -75,7 +75,7 @@ private:
virtual QVector<QAspectJobPtr> jobsToExecute(qint64 time) = 0;
- virtual void onInitialize(const QVariantMap &data) = 0;
+ virtual void onInitialize() = 0;
virtual void onCleanup() = 0;
virtual void onStartup();
diff --git a/src/core/aspects/qaspectengine.cpp b/src/core/aspects/qaspectengine.cpp
index 3aa2b0f95..7eb26e1d6 100644
--- a/src/core/aspects/qaspectengine.cpp
+++ b/src/core/aspects/qaspectengine.cpp
@@ -165,27 +165,16 @@ void QAspectEnginePrivate::shutdown()
qCDebug(Aspects) << Q_FUNC_INFO << "Shutdown complete";
}
-// Main thread
-void QAspectEngine::setData(const QVariantMap &data)
-{
- Q_D(QAspectEngine);
- // Note: setData in the AspectManager is called in the main thread
- // which in turns calls onInitialize on each aspects in the main thread
- // We should keep the call to onInitialize in the main thread
- QMetaObject::invokeMethod(d->m_aspectThread->aspectManager(),
- "setData",
- Qt::BlockingQueuedConnection,
- Q_ARG(const QVariantMap &, data));
-}
-
/*!
* Registers a new \a aspect to the AspectManager.
- * Passing as a QObject* as abstracts like AbstractAspect
- * cannot be registered as a meta type.
*/
void QAspectEngine::registerAspect(QAbstractAspect *aspect)
{
Q_D(QAspectEngine);
+ // The aspect is moved to the AspectThread
+ // AspectManager::registerAspect is called in the context
+ // of the AspectThread. This is turns call aspect->onInitialize
+ // still in the same AspectThread context
aspect->moveToThread(d->m_aspectThread);
d->m_aspects << aspect;
QMetaObject::invokeMethod(d->m_aspectThread->aspectManager(),
@@ -265,6 +254,7 @@ void QAspectEngine::setRootEntity(QEntity *root)
if (!d->m_root)
return;
+ // Set postman/scene/arbiter ...
d->initialize();
// The aspect engine takes ownership of the scene root. We also set the
diff --git a/src/core/aspects/qaspectengine.h b/src/core/aspects/qaspectengine.h
index b472e4130..bc9ee1bc6 100644
--- a/src/core/aspects/qaspectengine.h
+++ b/src/core/aspects/qaspectengine.h
@@ -62,7 +62,6 @@ public:
void setRootEntity(QEntity *root);
QSharedPointer<QEntity> rootEntity() const;
- void setData(const QVariantMap &data);
void registerAspect(QAbstractAspect *aspect);
void registerAspect(const QString &name);
diff --git a/src/core/aspects/qaspectmanager.cpp b/src/core/aspects/qaspectmanager.cpp
index 80faef768..01441df53 100644
--- a/src/core/aspects/qaspectmanager.cpp
+++ b/src/core/aspects/qaspectmanager.cpp
@@ -130,15 +130,6 @@ void QAspectManager::setRootEntity(Qt3DCore::QEntity *root)
}
}
-// Should be called after aspects are registered
-void QAspectManager::setData(const QVariantMap &data)
-{
- qCDebug(Aspects) << Q_FUNC_INFO;
- m_data = data;
- Q_FOREACH (QAbstractAspect *aspect, m_aspects)
- aspect->onInitialize(m_data);
-}
-
/*!
* Registers a new \a aspect.
*/
@@ -153,7 +144,8 @@ void QAspectManager::registerAspect(QAbstractAspect *aspect)
QAbstractAspectPrivate::get(aspect)->m_arbiter = m_changeArbiter;
// Register sceneObserver with the QChangeArbiter
m_changeArbiter->registerSceneObserver(aspect->d_func());
- aspect->onInitialize(m_data);
+ // Initialize the aspect in the main thread
+ aspect->onInitialize();
}
else {
qCWarning(Aspects) << "Failed to register aspect";
@@ -161,11 +153,6 @@ void QAspectManager::registerAspect(QAbstractAspect *aspect)
qCDebug(Aspects) << "Completed registering aspect";
}
-QVariantMap QAspectManager::data() const
-{
- return m_data;
-}
-
void QAspectManager::exec()
{
// Gentlemen, start your engines
diff --git a/src/core/aspects/qaspectmanager_p.h b/src/core/aspects/qaspectmanager_p.h
index 88ceceb29..cc3b91fff 100644
--- a/src/core/aspects/qaspectmanager_p.h
+++ b/src/core/aspects/qaspectmanager_p.h
@@ -84,9 +84,7 @@ public Q_SLOTS:
void shutdown();
void setRootEntity(Qt3DCore::QEntity *root);
- void setData(const QVariantMap &data);
void registerAspect(Qt3DCore::QAbstractAspect *aspect);
- QVariantMap data() const;
void exec();
void quit();
diff --git a/src/input/frontend/qinputaspect.cpp b/src/input/frontend/qinputaspect.cpp
index 7656924e4..41318e399 100644
--- a/src/input/frontend/qinputaspect.cpp
+++ b/src/input/frontend/qinputaspect.cpp
@@ -207,14 +207,14 @@ QVector<QAspectJobPtr> QInputAspect::jobsToExecute(qint64 time)
return jobs;
}
-// Called in main Thread
-void QInputAspect::onInitialize(const QVariantMap &)
+// Called in the aspectThread, we would need this to be called in the main Thread
+void QInputAspect::onInitialize()
{
Q_D(QInputAspect);
Qt3DCore::QEventFilterService *eventService = d->services()->eventFilterService();
Q_ASSERT(eventService);
- // Create event source setter helper in the main thread
+ // TO DO: Create event source setter helper in the main thread
Qt3DInput::Input::EventSourceSetterHelper *helper =
new Qt3DInput::Input::EventSourceSetterHelper(eventService,
d->m_inputHandler.data());
diff --git a/src/input/frontend/qinputaspect.h b/src/input/frontend/qinputaspect.h
index 91d8e25d9..6420c24cb 100644
--- a/src/input/frontend/qinputaspect.h
+++ b/src/input/frontend/qinputaspect.h
@@ -57,7 +57,7 @@ public:
QVector<Qt3DCore::QAspectJobPtr> jobsToExecute(qint64 time) Q_DECL_OVERRIDE;
private:
- void onInitialize(const QVariantMap &data) Q_DECL_OVERRIDE;
+ void onInitialize() Q_DECL_OVERRIDE;
void onCleanup() Q_DECL_OVERRIDE;
void loadInputDevicePlugins();
diff --git a/src/logic/qlogicaspect.cpp b/src/logic/qlogicaspect.cpp
index 9941f4b1f..2efa505e2 100644
--- a/src/logic/qlogicaspect.cpp
+++ b/src/logic/qlogicaspect.cpp
@@ -105,9 +105,8 @@ QVector<QAspectJobPtr> QLogicAspect::jobsToExecute(qint64 time)
return jobs;
}
-void QLogicAspect::onInitialize(const QVariantMap &data)
+void QLogicAspect::onInitialize()
{
- Q_UNUSED(data);
}
void QLogicAspect::onCleanup()
diff --git a/src/logic/qlogicaspect.h b/src/logic/qlogicaspect.h
index 3abc5e03b..b5323f25e 100644
--- a/src/logic/qlogicaspect.h
+++ b/src/logic/qlogicaspect.h
@@ -58,7 +58,7 @@ protected:
void registerBackendTypes();
private:
- void onInitialize(const QVariantMap &data) Q_DECL_OVERRIDE;
+ void onInitialize() Q_DECL_OVERRIDE;
void onStartup() Q_DECL_OVERRIDE;
void onShutdown() Q_DECL_OVERRIDE;
void onCleanup() Q_DECL_OVERRIDE;
diff --git a/src/quick3d/imports/scene3d/scene3ditem.cpp b/src/quick3d/imports/scene3d/scene3ditem.cpp
index a69a63ca6..ba6d6a888 100644
--- a/src/quick3d/imports/scene3d/scene3ditem.cpp
+++ b/src/quick3d/imports/scene3d/scene3ditem.cpp
@@ -80,10 +80,7 @@ Scene3DItem::Scene3DItem(QQuickItem *parent)
setAcceptedMouseButtons(Qt::MouseButtonMask);
setAcceptHoverEvents(true);
- // We need to register the event source in the main thread
- QVariantMap data;
- data.insert(QStringLiteral("eventSource"), QVariant::fromValue(this));
- m_aspectEngine->setData(data);
+ // TO DO: register the event source in the main thread
m_aspectEngine->registerAspect(m_renderAspect);
}
diff --git a/src/quick3d/imports/scene3d/scene3drenderer.cpp b/src/quick3d/imports/scene3d/scene3drenderer.cpp
index 6d69e72d6..9b1d85987 100644
--- a/src/quick3d/imports/scene3d/scene3drenderer.cpp
+++ b/src/quick3d/imports/scene3d/scene3drenderer.cpp
@@ -125,11 +125,6 @@ Scene3DRenderer::Scene3DRenderer(Scene3DItem *item, Qt3DCore::QAspectEngine *asp
QObject::connect(m_item, &QQuickItem::windowChanged, this, &Scene3DRenderer::onWindowChangedQueued, Qt::QueuedConnection);
ContextSaver saver;
-
- QVariantMap data;
- data.insert(QStringLiteral("surface"), QVariant::fromValue(saver.surface()));
- m_aspectEngine->setData(data);
-
m_renderAspect->renderInitialize(saver.context());
scheduleRootEntityChange();
}
diff --git a/src/render/backend/abstractrenderer_p.h b/src/render/backend/abstractrenderer_p.h
index 109fa5c16..a6ca80a78 100644
--- a/src/render/backend/abstractrenderer_p.h
+++ b/src/render/backend/abstractrenderer_p.h
@@ -89,16 +89,10 @@ public:
virtual qint64 time() const = 0;
virtual void setTime(qint64 time) = 0;
- virtual void setSurface(QSurface *surface) = 0;
- virtual void setSurfaceSize(const QSize& s) = 0;
- virtual void setDevicePixelRatio(qreal r) = 0;
virtual void setNodeManagers(NodeManagers *managers) = 0;
virtual void setServices(Qt3DCore::QServiceLocator *services) = 0;
virtual void setSurfaceExposed(bool exposed) = 0;
- virtual QSurface *surface() const = 0;
- virtual const QSize &surfaceSize() const = 0;
- virtual qreal devicePixelRatio() const = 0;
virtual NodeManagers *nodeManagers() const = 0;
virtual Qt3DCore::QServiceLocator *services() const = 0;
diff --git a/src/render/backend/platformsurfacefilter.cpp b/src/render/backend/platformsurfacefilter.cpp
index 1fe9f11be..e1a3de604 100644
--- a/src/render/backend/platformsurfacefilter.cpp
+++ b/src/render/backend/platformsurfacefilter.cpp
@@ -117,8 +117,8 @@ void PlatformSurfaceFilter::setRendererSurface(QSurface *surface)
// draw calls. Only when the frame finishes and the mutex is unlocked does
// this call to Renderer::setSurface continue. Thereby blocking the main
// thread from destroying the platform surface before we are ready.
- if (m_renderer != Q_NULLPTR)
- m_renderer->setSurface(surface);
+// if (m_renderer != Q_NULLPTR)
+// m_renderer->setSurface(surface);
}
} // namespace Render
diff --git a/src/render/backend/renderer.cpp b/src/render/backend/renderer.cpp
index 8aac0f6dd..ba0e28adb 100644
--- a/src/render/backend/renderer.cpp
+++ b/src/render/backend/renderer.cpp
@@ -84,7 +84,6 @@
#include <QStack>
#include <QSurface>
#include <QElapsedTimer>
-#include <QOpenGLDebugLogger>
#include <QLibraryInfo>
#include <QPluginLoader>
#include <QDir>
@@ -102,11 +101,6 @@ using namespace Qt3DCore;
namespace Qt3DRender {
namespace Render {
-static void logOpenGLDebugMessage(const QOpenGLDebugMessage &debugMessage)
-{
- qDebug() << "OpenGL debug message:" << debugMessage;
-}
-
const QString SCENE_PARSERS_PATH = QStringLiteral("/sceneparsers");
const RendererSettings Renderer::ms_defaultSettings;
@@ -135,18 +129,16 @@ Renderer::Renderer(QRenderAspect::RenderType type)
: m_services(Q_NULLPTR)
, m_nodesManager(Q_NULLPTR)
, m_graphicsContext(Q_NULLPTR)
- , m_surface(Q_NULLPTR)
- , m_devicePixelRatio(1.)
, m_renderQueue(new RenderQueue())
, m_renderThread(type == QRenderAspect::Threaded ? new RenderThread(this) : Q_NULLPTR)
, m_vsyncFrameAdvanceService(new VSyncFrameAdvanceService())
- , m_debugLogger(Q_NULLPTR)
, m_pickEventFilter(new PickEventFilter())
, m_exposed(0)
, m_glContext(Q_NULLPTR)
, m_pickBoundingVolumeJob(Q_NULLPTR)
, m_time(0)
, m_settings(const_cast<RendererSettings *>(&ms_defaultSettings))
+ , m_waitForInitializationToBeCompleted(0)
{
// Set renderer as running - it will wait in the context of the
// RenderThread for RenderViews to be submitted
@@ -323,53 +315,37 @@ void Renderer::destroyThreadLocalAllocator(void *renderer)
// method termintates
void Renderer::initialize()
{
- if (m_renderThread)
- m_waitForWindowToBeSetCondition.wait(mutex());
-
- QByteArray debugLoggingMode = qgetenv("QT3DRENDER_DEBUG_LOGGING");
- bool enableDebugLogging = !debugLoggingMode.isEmpty();
-
m_graphicsContext.reset(new GraphicsContext);
m_graphicsContext->setRenderer(this);
- QSurfaceFormat sf = m_surface->format();
- if (enableDebugLogging)
- sf.setOption(QSurfaceFormat::DebugContext);
-
QOpenGLContext* ctx = m_glContext ? m_glContext : new QOpenGLContext;
+
+ // If we are using our own context (not provided by QtQuick),
+ // we need to create it
if (!m_glContext) {
- qCDebug(Backend) << "Creating OpenGL context with format" << sf;
- ctx->setFormat(sf);
+ // TO DO: Shouldn't we use the highest context available and trust
+ // QOpenGLContext to fall back on the best lowest supported ?
+ const QByteArray debugLoggingMode = qgetenv("QT3DRENDER_DEBUG_LOGGING");
+
+ if (!debugLoggingMode.isEmpty()) {
+ QSurfaceFormat sf = ctx->format();
+ sf.setOption(QSurfaceFormat::DebugContext);
+ ctx->setFormat(sf);
+ }
+
+ // Create OpenGL context
if (ctx->create())
qCDebug(Backend) << "OpenGL context created with actual format" << ctx->format();
else
qCWarning(Backend) << Q_FUNC_INFO << "OpenGL context creation failed";
}
- m_graphicsContext->setOpenGLContext(ctx, m_surface);
-
- if (enableDebugLogging && ctx->makeCurrent(m_surface)) {
- bool supported = ctx->hasExtension("GL_KHR_debug");
- if (supported) {
- qCDebug(Backend) << "Qt3D: Enabling OpenGL debug logging";
- m_debugLogger.reset(new QOpenGLDebugLogger);
- if (m_debugLogger->initialize()) {
- QObject::connect(m_debugLogger.data(), &QOpenGLDebugLogger::messageLogged, &logOpenGLDebugMessage);
- QString mode = QString::fromLocal8Bit(debugLoggingMode);
- m_debugLogger->startLogging(mode.toLower().startsWith(QLatin1String("sync"))
- ? QOpenGLDebugLogger::SynchronousLogging
- : QOpenGLDebugLogger::AsynchronousLogging);
-
- Q_FOREACH (const QOpenGLDebugMessage &msg, m_debugLogger->loggedMessages())
- logOpenGLDebugMessage(msg);
- }
- } else {
- qCDebug(Backend) << "Qt3D: OpenGL debug logging requested but GL_KHR_debug not supported";
- }
- ctx->doneCurrent();
- }
+
+ // Note: we don't have a surface at this point
+ // The context will be made current later on (at render time)
+ m_graphicsContext->setOpenGLContext(ctx);
// Awake setScenegraphRoot in case it was waiting
- m_waitForInitializationToBeCompleted.wakeOne();
+ m_waitForInitializationToBeCompleted.release(1);
// Allow the aspect manager to proceed
m_vsyncFrameAdvanceService->proceedToNextFrame();
}
@@ -382,22 +358,9 @@ void Renderer::initialize()
*/
void Renderer::shutdown()
{
- // TO DO: Check that this works with iOs and other cases
- if (m_surface) {
- m_running.fetchAndStoreOrdered(0);
-
- m_graphicsContext->makeCurrent(m_surface);
- // Stop and destroy the OpenGL logger
- if (m_debugLogger) {
- m_debugLogger->stopLogging();
- m_debugLogger.reset(Q_NULLPTR);
- }
-
- // Clean up the graphics context
- m_graphicsContext.reset(Q_NULLPTR);
- m_surface = Q_NULLPTR;
- qCDebug(Backend) << Q_FUNC_INFO << "Renderer properly shutdown";
- }
+ // Clean up the graphics context
+ m_graphicsContext.reset(Q_NULLPTR);
+ qCDebug(Backend) << Q_FUNC_INFO << "Renderer properly shutdown";
}
void Renderer::setSurfaceExposed(bool exposed)
@@ -419,23 +382,27 @@ Render::FrameGraphNode *Renderer::frameGraphRoot() const
// QAspectThread context
// Order of execution :
-// 1) Initialize -> waiting for Window
-// 2) setWindow -> waking Initialize || setSceneGraphRoot waiting
-// 3) setWindow -> waking Initialize if setSceneGraphRoot was called before
-// 4) Initialize resuming, performing initialization and waking up setSceneGraphRoot
-// 5) setSceneGraphRoot called || setSceneGraphRoot resuming if it was waiting
+// 1) RenderThread is created -> release 1 of m_waitForInitializationToBeCompleted when started
+// 2) setSceneRoot waits to acquire initialization
+// 3) submitRenderView -> check for surface
+// -> make surface current + create proper glHelper if needed
void Renderer::setSceneRoot(QBackendNodeFactory *factory, Entity *sgRoot)
{
Q_ASSERT(sgRoot);
- QMutexLocker lock(&m_mutex); // This waits until initialize and setSurface have been called
- if (m_graphicsContext == Q_NULLPTR) // If initialization hasn't been completed we must wait
- m_waitForInitializationToBeCompleted.wait(&m_mutex);
+
+ // If initialization hasn't been completed we must wait
+ m_waitForInitializationToBeCompleted.acquire();
+
m_renderSceneRoot = sgRoot;
if (!m_renderSceneRoot)
qCWarning(Backend) << "Failed to build render scene";
m_renderSceneRoot->dump();
qCDebug(Backend) << Q_FUNC_INFO << "DUMPING SCENE";
+
+ // Create the default materials ....
+ // Needs a QOpenGLContext (for things like isOpenGLES ...)
+ // TO DO: Maybe this should be moved elsewhere
buildDefaultTechnique();
buildDefaultMaterial();
@@ -453,7 +420,6 @@ void Renderer::setSceneRoot(QBackendNodeFactory *factory, Entity *sgRoot)
Q_FOREACH (QParameter *p, m_defaultMaterial->effect()->parameters())
factory->createBackendNode(p);
-
m_defaultMaterialHandle = nodeManagers()->lookupHandle<Material, MaterialManager, HMaterial>(m_defaultMaterial->id());
m_defaultEffectHandle = nodeManagers()->lookupHandle<Effect, EffectManager, HEffect>(m_defaultMaterial->effect()->id());
m_defaultTechniqueHandle = nodeManagers()->lookupHandle<Technique, TechniqueManager, HTechnique>(m_defaultTechnique->id());
@@ -461,64 +427,6 @@ void Renderer::setSceneRoot(QBackendNodeFactory *factory, Entity *sgRoot)
m_defaultRenderShader = nodeManagers()->lookupResource<Shader, ShaderManager>(m_defaultTechnique->renderPasses().first()->shaderProgram()->id());
}
-// Called in RenderAspect Thread context
-// Cannot do OpenGLContext initialization here
-void Renderer::setSurface(QSurface* surface)
-{
- qCDebug(Backend) << Q_FUNC_INFO << QThread::currentThread();
- // Locking this mutex will wait until initialize() has been called by
- // RenderThread::run() and the RenderThread is waiting on the
- // m_waitForWindowToBeSetCondition condition.
- //
- // The first time this is called Renderer::setSurface will cause the
- // Renderer::initialize() function to continue execution in the context
- // of the Render Thread. On subsequent calls, just the surface will be
- // updated.
-
- // setSurface(Q_NULLPTR) is also called when the window is destroyed,
- // this is the opportunity to cleanup GL resources while we still have
- // a valid QGraphicContext
-
- // TODO: Remove the need for a valid surface from the renderer initialization
- // We can use an offscreen surface to create and assess the OpenGL context.
- // This should allow us to get rid of the "swapBuffers called on a non-exposed
- // window" warning that we sometimes see.
- QMutexLocker locker(&m_mutex);
-
- // We are about to be destroyed
- // cleanup GL now
- if (surface == Q_NULLPTR) {
- // Bail out of the main render loop. Ensure that even if the render thread
- // is waiting on RenderViews to be populated that we wake up the wait condition.
- // We check for termination immediately after being awaken.
- m_running.fetchAndStoreOrdered(0);
- if (m_renderThread) { // Pure Qt3D with RenderThread case
- m_submitRenderViewsSemaphore.release(1);
- m_renderThread->wait();
- // This will call shutdown on the Renderer and cleanup GL context
- // and then set the surface to Q_NULLPTR
- m_surface = surface;
- }
- // else we are dealing with the QtQuick2 / Scene3D in which case we
- // don't set the surface to Q_NULLPTR just yet as a call to
- // QRenderAspect::renderShutdown() -> Renderer::shutdown() should
- // follow and will take care of this
- } else { // Setting a valid window on initialization
- m_surface = surface;
- m_waitForWindowToBeSetCondition.wakeOne();
- }
-}
-
-void Renderer::setSurfaceSize(const QSize &s)
-{
- m_surfaceSize = s;
-}
-
-void Renderer::setDevicePixelRatio(qreal s)
-{
- m_devicePixelRatio = s;
-}
-
void Renderer::registerEventFilter(QEventFilterService *service)
{
qCDebug(Backend) << Q_FUNC_INFO << QThread::currentThread();
@@ -547,7 +455,7 @@ void Renderer::render()
// Camera, RenderTarget ...
// Utimately the renderer should be a framework
- // For the processing of the list of renderbins
+ // For the processing of the list of renderviews
// Matrice update, bounding volumes computation ...
// Should be jobs
@@ -557,10 +465,9 @@ void Renderer::render()
// One framegraph description
while (m_running.load() > 0) {
- if (m_exposed.load() > 0)
- doRender();
- else
- QThread::msleep(250);
+ doRender();
+ // TO DO: Restore windows exposed detection
+ // Probably needs to happens some place else though
}
}
@@ -634,12 +541,9 @@ bool Renderer::canRender() const
return false;
}
- // Make sure that the surface we are rendering too has not been unset
- // (probably due to the window being destroyed or changing QScreens).
- if (!m_surface) {
- qCDebug(Rendering) << "QSurface has been removed";
- return false;
- }
+ // TO DO: Check if all surfaces have been destroyed...
+ // It may be better if the last window to be closed trigger a call to shutdown
+ // Rather than having checks for the surface everywhere
return true;
}
@@ -708,6 +612,8 @@ bool Renderer::submitRenderViews()
// and make the context current on the new surface
surface = renderView->surface();
+ // TO DO: Make sure that the surface we are rendering too has not been unset
+
// For now, if we do not have a surface, skip this renderview
// TODO: Investigate if it's worth providing a fallback offscreen surface
// to use when surface is null. Or if we should instead expose an
@@ -715,7 +621,7 @@ bool Renderer::submitRenderViews()
if (!surface)
continue;
- if (i != 0 && surface != previousSurface && previousSurface)
+ if (surface != previousSurface && previousSurface)
m_graphicsContext->endDrawing(boundFboId == m_graphicsContext->defaultFBO());
if (surface != previousSurface) {
@@ -825,9 +731,11 @@ Qt3DCore::QAspectJobPtr Renderer::createRenderViewJob(FrameGraphNode *node, int
{
RenderViewJobPtr job(new RenderViewJob);
job->setRenderer(this);
- if (m_surface)
- job->setSurfaceSize(m_surfaceSize.isValid() ? m_surfaceSize : m_surface->size());
- job->setDevicePixelRatio(m_devicePixelRatio);
+ // if (m_surface)
+ // job->setSurfaceSize(m_surface->size());
+ // TO DO: the surface size can only be set by the RenderView
+ // since the only the RenderView will know about the surface
+ // it should be renderer onto
job->setFrameGraphLeafNode(node);
job->setSubmitOrderIndex(submitOrderIndex);
return job;
diff --git a/src/render/backend/renderer_p.h b/src/render/backend/renderer_p.h
index 7d7eb944a..dc619492e 100644
--- a/src/render/backend/renderer_p.h
+++ b/src/render/backend/renderer_p.h
@@ -76,7 +76,6 @@
QT_BEGIN_NAMESPACE
class QSurface;
-class QOpenGLDebugLogger;
class QMouseEvent;
namespace Qt3DCore {
@@ -127,16 +126,10 @@ public:
qint64 time() const Q_DECL_OVERRIDE;
void setTime(qint64 time) Q_DECL_OVERRIDE;
- void setSurface(QSurface *s) Q_DECL_OVERRIDE;
- void setSurfaceSize(const QSize& s) Q_DECL_OVERRIDE;
- void setDevicePixelRatio(qreal s) Q_DECL_OVERRIDE;
void setNodeManagers(NodeManagers *managers) Q_DECL_OVERRIDE { m_nodesManager = managers; }
void setServices(Qt3DCore::QServiceLocator *services) Q_DECL_OVERRIDE { m_services = services; }
void setSurfaceExposed(bool exposed) Q_DECL_OVERRIDE;
- QSurface *surface() const Q_DECL_OVERRIDE { return m_surface; }
- const QSize &surfaceSize() const Q_DECL_OVERRIDE { return m_surfaceSize; }
- qreal devicePixelRatio() const Q_DECL_OVERRIDE { return m_devicePixelRatio; }
NodeManagers *nodeManagers() const Q_DECL_OVERRIDE;
Qt3DCore::QServiceLocator *services() const Q_DECL_OVERRIDE { return m_services; }
@@ -230,10 +223,6 @@ private:
ShaderParameterPack m_defaultUniformPack;
QScopedPointer<GraphicsContext> m_graphicsContext;
- QSurface *m_surface;
- QSize m_surfaceSize;
- qreal m_devicePixelRatio;
-
RenderQueue *m_renderQueue;
QScopedPointer<RenderThread> m_renderThread;
@@ -244,8 +233,7 @@ private:
QMutex m_mutex;
QSemaphore m_submitRenderViewsSemaphore;
- QWaitCondition m_waitForWindowToBeSetCondition;
- QWaitCondition m_waitForInitializationToBeCompleted;
+ QSemaphore m_waitForInitializationToBeCompleted;
static void createThreadLocalAllocator(void *renderer);
static void destroyThreadLocalAllocator(void *renderer);
@@ -253,7 +241,6 @@ private:
QAtomicInt m_running;
- QScopedPointer<QOpenGLDebugLogger> m_debugLogger;
QScopedPointer<PickEventFilter> m_pickEventFilter;
QVector<Qt3DCore::QFrameAllocator *> m_allocators;
diff --git a/src/render/backend/renderview.cpp b/src/render/backend/renderview.cpp
index de7d0e5e8..2e1e2fce4 100644
--- a/src/render/backend/renderview.cpp
+++ b/src/render/backend/renderview.cpp
@@ -394,7 +394,6 @@ void RenderView::setRenderer(Renderer *renderer)
{
m_renderer = renderer;
m_manager = renderer->nodeManagers();
- m_surface = renderer->surface();
m_data->m_uniformBlockBuilder.shaderDataManager = m_manager->shaderDataManager();
}
diff --git a/src/render/frontend/qrenderaspect.cpp b/src/render/frontend/qrenderaspect.cpp
index 860445e48..bd14694cd 100644
--- a/src/render/frontend/qrenderaspect.cpp
+++ b/src/render/frontend/qrenderaspect.cpp
@@ -216,11 +216,8 @@ void QRenderAspectPrivate::setSurface(QSurface *surface)
m_surfaceSize = surface->size();
// If the window/offscreen surface has a native surface, tell the renderer
- if (hasPlatformSurface) {
- m_renderer->setSurface(surface);
- m_renderer->setSurfaceSize(m_surfaceSize);
- m_renderer->setDevicePixelRatio(m_devicePixelRatio);
- }
+ // if (hasPlatformSurface)
+ // m_renderer->setSurface(surface);
}
}
@@ -398,59 +395,31 @@ QVector<Qt3DCore::QAspectJobPtr> QRenderAspect::jobsToExecute(qint64 time)
// Clear any old dependencies from previous frames
d->m_cleanupJob->removeDependency(QWeakPointer<QAspectJob>());
- // Do not create any more RenderView jobs when the platform surface is gone.
- if (d->m_renderer->surface()) {
- // Traverse the current framegraph and create jobs to populate
- // RenderBins with RenderCommands
- QVector<QAspectJobPtr> renderBinJobs = d->m_renderer->renderBinJobs();
- // TODO: Add wrapper around ThreadWeaver::Collection
- for (int i = 0; i < renderBinJobs.size(); ++i) {
- QAspectJobPtr renderBinJob = renderBinJobs.at(i);
- renderBinJob->addDependency(d->m_updateBoundingVolumeJob);
- jobs.append(renderBinJob);
- d->m_cleanupJob->addDependency(renderBinJob);
- }
+ // Note: We need the RenderBinJobs to set the surface
+ // so we must create the RenderViews in all cases
+
+ // Traverse the current framegraph and create jobs to populate
+ // RenderBins with RenderCommands
+ QVector<QAspectJobPtr> renderBinJobs = d->m_renderer->renderBinJobs();
+ // TODO: Add wrapper around ThreadWeaver::Collection
+ for (int i = 0; i < renderBinJobs.size(); ++i) {
+ QAspectJobPtr renderBinJob = renderBinJobs.at(i);
+ renderBinJob->addDependency(d->m_updateBoundingVolumeJob);
+ jobs.append(renderBinJob);
+ d->m_cleanupJob->addDependency(renderBinJob);
}
jobs.append(d->m_cleanupJob);
}
return jobs;
}
-const QSize &QRenderAspect::surfaceSize() const
-{
- Q_D(const QRenderAspect);
- return d->m_surfaceSize;
-}
-
-void QRenderAspect::setSurfaceSize(const QSize &s)
-{
- Q_D(QRenderAspect);
- d->m_surfaceSize = s;
- if (d->m_renderer)
- d->m_renderer->setSurfaceSize(s);
-}
-
-qreal QRenderAspect::devicePixelRatio() const
-{
- Q_D(const QRenderAspect);
- return d->m_devicePixelRatio;
-}
-
-void QRenderAspect::setDevicePixelRatio(qreal r)
-{
- Q_D(QRenderAspect);
- d->m_devicePixelRatio = r;
- if (d->m_renderer)
- d->m_renderer->setDevicePixelRatio(r);
-}
-
void QRenderAspect::onRootEntityChanged(Qt3DCore::QEntity *rootEntity)
{
Q_D(QRenderAspect);
d->m_renderer->setSceneRoot(d, d->m_renderer->nodeManagers()->lookupResource<Render::Entity, Render::EntityManager>(rootEntity->id()));
}
-void QRenderAspect::onInitialize(const QVariantMap &data)
+void QRenderAspect::onInitialize()
{
// TODO: Remove the m_initialized variable and split out onInitialize()
// and setting a resource (the QSurface) on the aspects.
@@ -471,13 +440,13 @@ void QRenderAspect::onInitialize(const QVariantMap &data)
d->m_initialized = true;
}
- QSurface *surface = Q_NULLPTR;
- const QVariant &v = data.value(QStringLiteral("surface"));
- if (v.isValid())
- surface = v.value<QSurface *>();
+ // QSurface *surface = Q_NULLPTR;
+ // const QVariant &v = data.value(QStringLiteral("surface"));
+ // if (v.isValid())
+ // surface = v.value<QSurface *>();
- if (surface)
- d->setSurface(surface);
+ // if (surface)
+ // d->setSurface(surface);
if (d->m_aspectManager)
d->m_renderer->registerEventFilter(d->services()->eventFilterService());
diff --git a/src/render/frontend/qrenderaspect.h b/src/render/frontend/qrenderaspect.h
index 2a9cd0eed..6df8b20ff 100644
--- a/src/render/frontend/qrenderaspect.h
+++ b/src/render/frontend/qrenderaspect.h
@@ -70,18 +70,13 @@ public:
QVector<Qt3DCore::QAspectJobPtr> jobsToExecute(qint64 time) Q_DECL_OVERRIDE;
- const QSize &surfaceSize() const;
- void setSurfaceSize(const QSize &s);
- qreal devicePixelRatio() const;
- void setDevicePixelRatio(qreal r);
-
protected:
void registerBackendTypes();
QRenderAspect(QRenderAspectPrivate &dd, QObject *parent);
Q_DECLARE_PRIVATE(QRenderAspect)
void onRootEntityChanged(Qt3DCore::QEntity *rootObject) Q_DECL_OVERRIDE;
- void onInitialize(const QVariantMap &data) Q_DECL_OVERRIDE;
+ void onInitialize() Q_DECL_OVERRIDE;
void onCleanup() Q_DECL_OVERRIDE;
QVector<Qt3DCore::QAspectJobPtr> createRenderBufferJobs();
diff --git a/src/render/graphicshelpers/graphicscontext.cpp b/src/render/graphicshelpers/graphicscontext.cpp
index 53dcaaef6..a5d3d311e 100644
--- a/src/render/graphicshelpers/graphicscontext.cpp
+++ b/src/render/graphicshelpers/graphicscontext.cpp
@@ -71,6 +71,7 @@
#include <QSurface>
#include <QWindow>
#include <QOpenGLTexture>
+#include <QOpenGLDebugLogger>
QT_BEGIN_NAMESPACE
@@ -79,6 +80,11 @@ namespace Render {
static QHash<unsigned int, GraphicsContext*> static_contexts;
+static void logOpenGLDebugMessage(const QOpenGLDebugMessage &debugMessage)
+{
+ qDebug() << "OpenGL debug message:" << debugMessage;
+}
+
namespace {
GLBuffer::Type bufferTypeToGLBufferType(QBuffer::BufferType type)
@@ -130,6 +136,7 @@ GraphicsContext::GraphicsContext()
, m_contextInfo(new QGraphicsApiFilter())
, m_uboTempArray(QByteArray(1024, 0))
, m_supportsVAO(true)
+ , m_debugLogger(Q_NULLPTR)
{
static_contexts[m_id] = this;
}
@@ -176,11 +183,16 @@ bool GraphicsContext::beginDrawing(QSurface *surface, const QColor &color)
m_surface = surface;
- if (m_surface && m_surface->surfaceClass() == QSurface::Window) {
- if (!static_cast<QWindow *>(m_surface)->isExposed())
- return false;
- }
+ // TO DO: Find a way to make to pause work if the window is not exposed
+ // if (m_surface && m_surface->surfaceClass() == QSurface::Window) {
+ // qDebug() << Q_FUNC_INFO << 1;
+ // if (!static_cast<QWindow *>(m_surface)->isExposed())
+ // return false;
+ // qDebug() << Q_FUNC_INFO << 2;
+ // }
+ // Makes the surface current on the OpenGLContext
+ // and sets the right glHelper
m_ownCurrent = !(m_gl->surface() == m_surface);
if (m_ownCurrent && !makeCurrent(m_surface))
return false;
@@ -297,20 +309,21 @@ void GraphicsContext::releaseOpenGL()
{
m_renderShaderHash.clear();
m_renderBufferHash.clear();
+
+ // Stop and destroy the OpenGL logger
+ if (m_debugLogger) {
+ m_debugLogger->stopLogging();
+ m_debugLogger.reset(Q_NULLPTR);
+ }
}
-void GraphicsContext::setOpenGLContext(QOpenGLContext* ctx, QSurface *surface)
+// The OpenGLContext is not current on any surface at this point
+void GraphicsContext::setOpenGLContext(QOpenGLContext* ctx)
{
- Q_ASSERT(surface);
Q_ASSERT(ctx);
releaseOpenGL();
m_gl = ctx;
-
- if (makeCurrent(surface)) {
- resolveHighestOpenGLFunctions();
- m_gl->doneCurrent();
- }
}
void GraphicsContext::activateGLHelper()
@@ -331,6 +344,15 @@ bool GraphicsContext::makeCurrent(QSurface *surface)
qCWarning(Backend) << Q_FUNC_INFO << "makeCurrent failed";
return false;
}
+
+ // Set the correct GL Helper depending on the surface
+ // If no helper exists, create one
+
+ m_glHelper = m_glHelpers.value(surface);
+ if (!m_glHelper) {
+ m_glHelper = resolveHighestOpenGLFunctions();
+ m_glHelpers.insert(surface, m_glHelper);
+ }
return true;
}
@@ -547,13 +569,14 @@ void GraphicsContext::deactivateTexturesWithScope(TextureScope ts)
* Finds the highest supported opengl version and internally use the most optimized
* helper for a given version.
*/
-void GraphicsContext::resolveHighestOpenGLFunctions()
+GraphicsHelperInterface *GraphicsContext::resolveHighestOpenGLFunctions()
{
Q_ASSERT(m_gl);
+ GraphicsHelperInterface *glHelper = Q_NULLPTR;
if (m_gl->isOpenGLES()) {
- m_glHelper = new GraphicsHelperES2();
- m_glHelper->initializeHelper(m_gl, Q_NULLPTR);
+ glHelper = new GraphicsHelperES2();
+ glHelper->initializeHelper(m_gl, Q_NULLPTR);
qCDebug(Backend) << Q_FUNC_INFO << " Building OpenGL 2/ES2 Helper";
}
#ifndef QT_OPENGL_ES_2
@@ -561,23 +584,49 @@ void GraphicsContext::resolveHighestOpenGLFunctions()
QAbstractOpenGLFunctions *glFunctions = Q_NULLPTR;
if ((glFunctions = m_gl->versionFunctions<QOpenGLFunctions_4_3_Core>()) != Q_NULLPTR) {
qCDebug(Backend) << Q_FUNC_INFO << " Building OpenGL 4.3";
- m_glHelper = new GraphicsHelperGL4();
+ glHelper = new GraphicsHelperGL4();
} else if ((glFunctions = m_gl->versionFunctions<QOpenGLFunctions_3_3_Core>()) != Q_NULLPTR) {
qCDebug(Backend) << Q_FUNC_INFO << " Building OpenGL 3.3";
- m_glHelper = new GraphicsHelperGL3_3();
+ glHelper = new GraphicsHelperGL3_3();
} else if ((glFunctions = m_gl->versionFunctions<QOpenGLFunctions_3_2_Core>()) != Q_NULLPTR) {
qCDebug(Backend) << Q_FUNC_INFO << " Building OpenGL 3.2";
- m_glHelper = new GraphicsHelperGL3();
+ glHelper = new GraphicsHelperGL3();
} else if ((glFunctions = m_gl->versionFunctions<QOpenGLFunctions_2_0>()) != Q_NULLPTR) {
qCDebug(Backend) << Q_FUNC_INFO << " Building OpenGL 2 Helper";
- m_glHelper = new GraphicsHelperGL2();
+ glHelper = new GraphicsHelperGL2();
}
- Q_ASSERT_X(m_glHelper, "GraphicsContext::resolveHighestOpenGLFunctions", "unable to create valid helper for available OpenGL version");
- m_glHelper->initializeHelper(m_gl, glFunctions);
+ Q_ASSERT_X(glHelper, "GraphicsContext::resolveHighestOpenGLFunctions", "unable to create valid helper for available OpenGL version");
+ glHelper->initializeHelper(m_gl, glFunctions);
}
#endif
+ // Note: at this point we are certain the context (m_gl) is current with a surface
+ const QByteArray debugLoggingMode = qgetenv("QT3DRENDER_DEBUG_LOGGING");
+ const bool enableDebugLogging = !debugLoggingMode.isEmpty();
+
+ if (enableDebugLogging && !m_debugLogger) {
+ if (m_gl->hasExtension("GL_KHR_debug")) {
+ qCDebug(Backend) << "Qt3D: Enabling OpenGL debug logging";
+ m_debugLogger.reset(new QOpenGLDebugLogger);
+ if (m_debugLogger->initialize()) {
+ QObject::connect(m_debugLogger.data(), &QOpenGLDebugLogger::messageLogged, &logOpenGLDebugMessage);
+ const QString mode = QString::fromLocal8Bit(debugLoggingMode);
+ m_debugLogger->startLogging(mode.toLower().startsWith(QLatin1String("sync"))
+ ? QOpenGLDebugLogger::SynchronousLogging
+ : QOpenGLDebugLogger::AsynchronousLogging);
+
+ Q_FOREACH (const QOpenGLDebugMessage &msg, m_debugLogger->loggedMessages())
+ logOpenGLDebugMessage(msg);
+ }
+ } else {
+ qCDebug(Backend) << "Qt3D: OpenGL debug logging requested but GL_KHR_debug not supported";
+ }
+ }
+
+
// Set Vendor and Extensions of reference GraphicsApiFilter
+ // TO DO: would that vary like the glHelper ?
+
QStringList extensions;
Q_FOREACH (const QByteArray &ext, m_gl->extensions().values())
extensions << QString::fromUtf8(ext);
@@ -587,6 +636,8 @@ void GraphicsContext::resolveHighestOpenGLFunctions()
m_contextInfo->setProfile(static_cast<QGraphicsApiFilter::Profile>(m_gl->format().profile()));
m_contextInfo->setExtensions(extensions);
m_contextInfo->setVendor(QString::fromUtf8(reinterpret_cast<const char *>(m_gl->functions()->glGetString(GL_VENDOR))));
+
+ return glHelper;
}
void GraphicsContext::deactivateTexture(Texture* tex)
diff --git a/src/render/graphicshelpers/graphicscontext_p.h b/src/render/graphicshelpers/graphicscontext_p.h
index cf7e36e6b..39170567c 100644
--- a/src/render/graphicshelpers/graphicscontext_p.h
+++ b/src/render/graphicshelpers/graphicscontext_p.h
@@ -64,6 +64,7 @@
QT_BEGIN_NAMESPACE
+class QOpenGLDebugLogger;
class QOpenGLShaderProgram;
class QAbstractOpenGLFunctions;
@@ -114,7 +115,7 @@ public:
* this context
*/
void releaseOpenGL();
- void setOpenGLContext(QOpenGLContext* ctx, QSurface *surface);
+ void setOpenGLContext(QOpenGLContext* ctx);
QOpenGLContext *openGLContext() { return m_gl; }
bool makeCurrent(QSurface *surface);
void doneCurrent();
@@ -220,7 +221,7 @@ private:
GLint assignUnitForTexture(Texture* tex);
void deactivateTexturesWithScope(TextureScope ts);
- void resolveHighestOpenGLFunctions();
+ GraphicsHelperInterface *resolveHighestOpenGLFunctions();
void bindFrameBufferAttachmentHelper(GLuint fboId, const AttachmentPack &attachments);
void activateDrawBuffers(const AttachmentPack &attachments);
@@ -240,6 +241,8 @@ private:
QHash<Qt3DCore::QNodeId, GLuint> m_renderTargets;
QHash<GLuint, QSize> m_renderTargetsSize;
+ QHash<QSurface *, GraphicsHelperInterface*> m_glHelpers;
+
// active textures, indexed by texture unit
QVector<uint> m_activeTextures;
QBitArray m_pinnedTextureUnits;
@@ -262,6 +265,7 @@ private:
QByteArray m_uboTempArray;
bool m_supportsVAO;
+ QScopedPointer<QOpenGLDebugLogger> m_debugLogger;
};
} // namespace Render
diff --git a/src/render/jobs/pickboundingvolumejob.cpp b/src/render/jobs/pickboundingvolumejob.cpp
index 344d83bff..b0d0ab865 100644
--- a/src/render/jobs/pickboundingvolumejob.cpp
+++ b/src/render/jobs/pickboundingvolumejob.cpp
@@ -394,17 +394,18 @@ void PickBoundingVolumeJob::viewMatrixForCamera(const Qt3DCore::QNodeId &cameraI
QRect PickBoundingVolumeJob::windowViewport(const QRectF &relativeViewport) const
{
- // TO DO: find another way to retrieve the size since this won't work with Scene3D
- const QSize s = m_renderer->surfaceSize();
- if (s.isValid()) {
- const int surfaceWidth = s.width();
- const int surfaceHeight = s.height();
- return QRect(relativeViewport.x() * surfaceWidth,
- (1.0 - relativeViewport.y() - relativeViewport.height()) * surfaceHeight,
- relativeViewport.width() * surfaceWidth,
- relativeViewport.height() * surfaceHeight);
- }
- return relativeViewport.toRect();
+ // // TO DO: find another way to retrieve the size since this won't work with Scene3D
+ // const QSurface *s = m_renderer->surface();
+ // if (s) {
+ // const int surfaceWidth = s->size().width();
+ // const int surfaceHeight = s->size().height();
+ // return QRect(relativeViewport.x() * surfaceWidth,
+ // (1.0 - relativeViewport.y() - relativeViewport.height()) * surfaceHeight,
+ // relativeViewport.width() * surfaceWidth,
+ // relativeViewport.height() * surfaceHeight);
+ // }
+ // return relativeViewport.toRect();
+ return QRect();
}
@@ -419,10 +420,11 @@ QVector<Qt3DCore::QNodeId> PickBoundingVolumeJob::sphereHitsForViewportAndCamera
viewMatrixForCamera(cameraId, viewMatrix, projectionMatrix);
const QRect viewport = windowViewport(relativeViewport);
- const QSize s = m_renderer->surfaceSize();
+ // const QSurface *s = m_renderer->surface();
// TO DO: find another way to retrieve the size since this won't work with Scene3D
// In GL the y is inverted compared to Qt
- const QPoint glCorrectPos = s.isValid() ? QPoint(pos.x(), s.height() - pos.y()) : pos;
+ // const QPoint glCorrectPos = s ? QPoint(pos.x(), s->size().height() - pos.y()) : pos;
+ const QPoint glCorrectPos = pos;
const Qt3DCore::QRay3D ray = intersectionRay(glCorrectPos, viewMatrix, projectionMatrix, viewport);
const QQueryHandle rayCastingHandle = rayCasting->query(ray, QAbstractCollisionQueryService::AllHits, volumeProvider);
const QCollisionQueryResult queryResult = rayCasting->fetchResult(rayCastingHandle);
@@ -440,10 +442,11 @@ QVector<Qt3DCore::QNodeId> PickBoundingVolumeJob::triangleHitsForViewportAndCame
viewMatrixForCamera(cameraId, viewMatrix, projectionMatrix);
const QRect viewport = windowViewport(relativeViewport);
- const QSize s = m_renderer->surfaceSize();
+ // const QSurface *s = m_renderer->surface();
// TO DO: find another way to retrieve the size since this won't work with Scene3D
// In GL the y is inverted compared to Qt
- const QPoint glCorrectPos = s.isValid() ? QPoint(pos.x(), s.height() - pos.y()) : pos;
+ // const QPoint glCorrectPos = s ? QPoint(pos.x(), s->size().height() - pos.y()) : pos;
+ const QPoint glCorrectPos = pos;
const Qt3DCore::QRay3D ray = intersectionRay(glCorrectPos, viewMatrix, projectionMatrix, viewport);
// Note: improve this further to only compute this once and not every time
@@ -451,8 +454,8 @@ QVector<Qt3DCore::QNodeId> PickBoundingVolumeJob::triangleHitsForViewportAndCame
m_manager);
const QQueryHandle rayCastingHandle = rayCasting->query(ray,
- QAbstractCollisionQueryService::AllHits,
- &boundingVolumeProvider);
+ QAbstractCollisionQueryService::AllHits,
+ &boundingVolumeProvider);
const QCollisionQueryResult queryResult = rayCasting->fetchResult(rayCastingHandle);
return queryResult.entitiesHit();
}
diff --git a/tests/auto/core/qaspectengine/tst_qaspectengine.cpp b/tests/auto/core/qaspectengine/tst_qaspectengine.cpp
index 299c08f70..2591720a3 100644
--- a/tests/auto/core/qaspectengine/tst_qaspectengine.cpp
+++ b/tests/auto/core/qaspectengine/tst_qaspectengine.cpp
@@ -52,7 +52,7 @@ public: \
\
private: \
void onRootEntityChanged(QEntity *) Q_DECL_OVERRIDE {} \
- void onInitialize(const QVariantMap &) Q_DECL_OVERRIDE {} \
+ void onInitialize() Q_DECL_OVERRIDE {} \
void onStartup() Q_DECL_OVERRIDE {} \
void onShutdown() Q_DECL_OVERRIDE {} \
void onCleanup() Q_DECL_OVERRIDE {} \
diff --git a/tests/auto/core/qaspectfactory/tst_qaspectfactory.cpp b/tests/auto/core/qaspectfactory/tst_qaspectfactory.cpp
index c287bf0e8..c7d116023 100644
--- a/tests/auto/core/qaspectfactory/tst_qaspectfactory.cpp
+++ b/tests/auto/core/qaspectfactory/tst_qaspectfactory.cpp
@@ -50,7 +50,7 @@ public: \
\
private: \
void onRootEntityChanged(QEntity *) Q_DECL_OVERRIDE {} \
- void onInitialize(const QVariantMap &) Q_DECL_OVERRIDE {} \
+ void onInitialize() Q_DECL_OVERRIDE {} \
void onStartup() Q_DECL_OVERRIDE {} \
void onShutdown() Q_DECL_OVERRIDE {} \
void onCleanup() Q_DECL_OVERRIDE {} \
diff --git a/tests/benchmarks/render/jobs/tst_bench_jobs.cpp b/tests/benchmarks/render/jobs/tst_bench_jobs.cpp
index 2ba06e0fb..d5d9d2676 100644
--- a/tests/benchmarks/render/jobs/tst_bench_jobs.cpp
+++ b/tests/benchmarks/render/jobs/tst_bench_jobs.cpp
@@ -87,10 +87,7 @@ public:
m_window->setFormat(format);
m_window->create();
- QVariantMap data;
- data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(m_window.data())));
- data.insert(QStringLiteral("eventSource"), QVariant::fromValue(m_window.data()));
- QRenderAspect::onInitialize(data);
+ QRenderAspect::onInitialize();
}
}