From 67191c2b3213259c6eaf045154e9370faa085868 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 13 Jun 2019 10:20:49 +0200 Subject: Remove qqmlmemoryprofiler* I've never seen it used and I've never seen the companion library required to operate it. Change-Id: I5a0e6aed9a416f1bd26dea97def9667a11a4d77d Reviewed-by: Robin Burchell Reviewed-by: Fabian Kosmale Reviewed-by: Michael Brasser --- src/quick/items/qquickwindow.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/quick/items/qquickwindow.cpp') diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 24a17ce80f..7d1fa9c30d 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -75,7 +75,6 @@ #include -#include #include #include #if QT_CONFIG(opengl) @@ -420,7 +419,6 @@ void forceUpdate(QQuickItem *item) void QQuickWindowPrivate::syncSceneGraph() { - QML_MEMORY_SCOPE_STRING("SceneGraph"); Q_Q(QQuickWindow); animationController->beforeNodeSync(); @@ -455,7 +453,6 @@ void QQuickWindowPrivate::syncSceneGraph() void QQuickWindowPrivate::renderSceneGraph(const QSize &size) { - QML_MEMORY_SCOPE_STRING("SceneGraph"); Q_Q(QQuickWindow); if (!renderer) return; -- cgit v1.2.3 From 8927246572fd1ca08d632f4c9a887213bcfe682e Mon Sep 17 00:00:00 2001 From: Mikhail Svetkin Date: Tue, 11 Jun 2019 16:01:25 +0200 Subject: qtlite: Fix build with -no-feature-cursor Change-Id: I10140b5b2bb6c08e9de6c0300377466325ba4bde Reviewed-by: Timo Aarnipuro Reviewed-by: Tasuku Suzuki Reviewed-by: Shawn Rutledge --- src/quick/items/qquickwindow.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/quick/items/qquickwindow.cpp') diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 7d1fa9c30d..25bbc5da5a 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -1577,6 +1577,7 @@ bool QQuickWindowPrivate::clearHover(ulong timestamp) bool accepted = false; for (QQuickItem* item : qAsConst(hoverItems)) { accepted = sendHoverEvent(QEvent::HoverLeave, item, pos, pos, QGuiApplication::keyboardModifiers(), timestamp, true) || accepted; +#if QT_CONFIG(cursor) QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); if (itemPrivate->hasPointerHandlers()) { pos = q->mapFromGlobal(QCursor::pos()); @@ -1588,6 +1589,7 @@ bool QQuickWindowPrivate::clearHover(ulong timestamp) if (QQuickHoverHandler *hh = qmlobject_cast(h)) hh->handlePointerEvent(pointerEvent); } +#endif } hoverItems.clear(); return accepted; @@ -1626,7 +1628,9 @@ bool QQuickWindow::event(QEvent *e) QGuiApplication::keyboardModifiers(), 0L, accepted); d->lastMousePosition = enter->windowPos(); enter->setAccepted(accepted); +#if QT_CONFIG(cursor) d->updateCursor(mapFromGlobal(QCursor::pos())); +#endif return delivered; } break; -- cgit v1.2.3 From 341ab7708049b1a3f559b76f16393e688951a938 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 23 Apr 2019 09:40:59 +0200 Subject: Add the graphics api independent scenegraph port Opt in via environment variables: QSG_RHI=1 -> enable using QRhi instead of GL QSG_RHI_BACKEND -> set to vulkan, metal, d3d11, gl to override the default (the default is d3d11 on Windows, metal on Mac, gl elsewhere) Or force a given rhi backend via the existing QQuickWindow::setSceneGraphBackend(). Otherwise the default behavior is the same as before, the rhi code path is never active by default. -no-opengl builds are supported in the sense that they work and default to the software backend. However, the rhi code path cannot currently be used in such builds, even though QRhi from qtbase is fully functional with Vulkan, D3D, or Metal even when qtbase was configured with -no-opengl. This cannot be utilized by Quick atm due to OpenGL usage being all over the place in the sources corresponding to the default backend, and those host the rhi code path as well. This will be cleaned up hopefully in Qt 6, with the removal all direct OpenGL usage. Other env.vars.: QSG_RHI_DEBUG_LAYER=1 -> enable D3D debug or Vulkan validation layer (assuming the system is set up for this) QSG_RHI_SHADEREFFECT_DEBUG=1 -> print stuff from ShaderEffect QSG_SAMPLES=1,2,4,... -> MSAA sample count (but QSurfaceFormat works too) QT_D3D_ADAPTER_INDEX=0,1,... -> D3D adapter index QT_VK_PHYSICAL_DEVICE_INDEX=0,1,... -> Vulkan physical device index QSG_RHI_UINT32_INDEX=1 -> always use uint index data (both merged/unmerged, convert when needed - with some rhi backends this is implicit) QSG_RENDER_LOOP -> to override the render loop as usual. The default with RHI is threaded for Metal, threaded for Vulkan on Windows, basic for Vulkan on Linux and Android (to be checked later), while the existing rules apply for OpenGL. Not supported when running with QRhi: - particles - compressed atlases (though this is transparent to the apps) - QSGRenderNode - QQuickRenderControl - QQuickFramebufferObject - certain QQuickWindow functionality that depends directly on OpenGL - anisotropic filtering for textures - native text may lack some gamma correction - QSGEngine applicability unclear - some QML profiler logs may be incorrect or irrelevant Change-Id: I7822e99ad79e342e4166275da6e9e66498d76521 Reviewed-by: Lars Knoll --- src/quick/items/qquickwindow.cpp | 325 +++++++++++++++++++++++++++++++++++---- 1 file changed, 295 insertions(+), 30 deletions(-) (limited to 'src/quick/items/qquickwindow.cpp') diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 25bbc5da5a..0adfbdb922 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -52,8 +52,9 @@ #include #include -#include +#include #include +#include #include #include #include @@ -85,6 +86,8 @@ #include #endif +#include + QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(DBG_TOUCH, "qt.quick.touch") @@ -451,12 +454,35 @@ void QQuickWindowPrivate::syncSceneGraph() runAndClearJobs(&afterSynchronizingJobs); } -void QQuickWindowPrivate::renderSceneGraph(const QSize &size) +void QQuickWindowPrivate::emitBeforeRenderPassRecording(void *ud) +{ + QQuickWindow *w = reinterpret_cast(ud); + emit w->beforeRenderPassRecording(); +} + +void QQuickWindowPrivate::emitAfterRenderPassRecording(void *ud) +{ + QQuickWindow *w = reinterpret_cast(ud); + emit w->afterRenderPassRecording(); +} + +void QQuickWindowPrivate::renderSceneGraph(const QSize &size, const QSize &surfaceSize) { Q_Q(QQuickWindow); if (!renderer) return; + if (rhi) { + // ### no offscreen ("renderTargetId") support yet + context->beginRhiFrame(renderer, + swapchain->currentFrameRenderTarget(), + rpDescForSwapchain, + swapchain->currentFrameCommandBuffer(), + emitBeforeRenderPassRecording, + emitAfterRenderPassRecording, + q); + } + animationController->advance(); emit q->beforeRendering(); runAndClearJobs(&beforeRenderingJobs); @@ -469,24 +495,40 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size) renderer->setDeviceRect(rect); renderer->setViewportRect(rect); if (QQuickRenderControl::renderWindowFor(q)) { - renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size)); + renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size), false); renderer->setDevicePixelRatio(devicePixelRatio); } else { - renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), rect.size())); + renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), rect.size()), false); renderer->setDevicePixelRatio(1); } } else { - QRect rect(QPoint(0, 0), devicePixelRatio * size); + QSize pixelSize; + QSizeF logicalSize; + if (surfaceSize.isEmpty()) { + pixelSize = size * devicePixelRatio; + logicalSize = size; + } else { + pixelSize = surfaceSize; + logicalSize = QSizeF(surfaceSize) / devicePixelRatio; + } + QRect rect(QPoint(0, 0), pixelSize); renderer->setDeviceRect(rect); renderer->setViewportRect(rect); - renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size)); + const bool flipY = rhi ? !rhi->isYUpInNDC() : false; + renderer->setProjectionMatrixToRect(QRectF(QPoint(0, 0), logicalSize), flipY); renderer->setDevicePixelRatio(devicePixelRatio); } - context->renderNextFrame(renderer, fboId); + if (rhi) + context->renderNextRhiFrame(renderer); + else + context->renderNextFrame(renderer, fboId); } emit q->afterRendering(); runAndClearJobs(&afterRenderingJobs); + + if (rhi) + context->endRhiFrame(renderer); } QQuickWindowPrivate::QQuickWindowPrivate() @@ -522,6 +564,9 @@ QQuickWindowPrivate::QQuickWindowPrivate() , renderTargetId(0) , vaoHelper(nullptr) , incubationController(nullptr) + , hasActiveSwapchain(false) + , hasRenderableSwapchain(false) + , swapchainJustBecameRenderable(false) { #if QT_CONFIG(quick_draganddrop) dragGrabber = new QQuickDragGrabber; @@ -539,6 +584,7 @@ void QQuickWindowPrivate::init(QQuickWindow *c, QQuickRenderControl *control) { q_ptr = c; + Q_Q(QQuickWindow); contentItem = new QQuickRootItem; @@ -576,6 +622,10 @@ void QQuickWindowPrivate::init(QQuickWindow *c, QQuickRenderControl *control) q->setSurfaceType(windowManager ? windowManager->windowSurfaceType() : QSurface::OpenGLSurface); q->setFormat(sg->defaultSurfaceFormat()); +#if QT_CONFIG(vulkan) + if (q->surfaceType() == QSurface::VulkanSurface) + q->setVulkanInstance(QSGRhiSupport::vulkanInstance()); +#endif animationController = new QQuickAnimatorController(q); @@ -3628,24 +3678,20 @@ void QQuickWindow::setTransientParent_helper(QQuickWindow *window) /*! Returns the OpenGL context used for rendering. - If the scene graph is not ready, or the scene graph is not using OpenGL, - this function will return null. - - \note If using a scene graph adaptation other than OpenGL this - function will return nullptr. + \note If the scene graph is not ready, or the scene graph is not using + OpenGL (or RHI over OpenGL), this function will return null. \sa sceneGraphInitialized(), sceneGraphInvalidated() */ - QOpenGLContext *QQuickWindow::openglContext() const { #if QT_CONFIG(opengl) Q_D(const QQuickWindow); if (d->context && d->context->isValid()) { QSGRendererInterface *rif = d->context->sceneGraphContext()->rendererInterface(d->context); - if (rif && rif->graphicsApi() == QSGRendererInterface::OpenGL) { - auto openglRenderContext = static_cast(d->context); - return openglRenderContext->openglContext(); + if (rif) { + return reinterpret_cast(rif->getResource(const_cast(this), + QSGRendererInterface::OpenGLContextResource)); } } #endif @@ -3778,6 +3824,8 @@ bool QQuickWindow::isSceneGraphInitialized() const This function only has an effect when using the default OpenGL scene graph adaptation. + \note This function has no effect when running on the RHI graphics abstraction. + \warning This function can only be called from the thread doing the rendering. @@ -3786,6 +3834,9 @@ bool QQuickWindow::isSceneGraphInitialized() const void QQuickWindow::setRenderTarget(QOpenGLFramebufferObject *fbo) { Q_D(QQuickWindow); + if (d->rhi) + return; + if (d->context && QThread::currentThread() != d->context->thread()) { qWarning("QQuickWindow::setRenderTarget: Cannot set render target from outside the rendering thread"); return; @@ -3867,9 +3918,11 @@ QSize QQuickWindow::renderTargetSize() const The default is to render to the surface of the window, in which case the render target is 0. - \note - This function will return nullptr when not using the OpenGL scene + \note This function will return nullptr when not using the OpenGL scene graph adaptation. + + \note This function has no effect and returns nullptr when running on the + RHI graphics abstraction. */ QOpenGLFramebufferObject *QQuickWindow::renderTarget() const { @@ -3895,12 +3948,23 @@ QImage QQuickWindow::grabWindow() Q_D(QQuickWindow); if (!isVisible() && !d->renderControl) { + // backends like software and d3d12 can grab regardless of the window state if (d->windowManager && (d->windowManager->flags() & QSGRenderLoop::SupportsGrabWithoutExpose)) return d->windowManager->grab(this); } -#if QT_CONFIG(opengl) if (!isVisible() && !d->renderControl) { + if (d->rhi) { + // ### we may need a full offscreen round when non-exposed... + + if (d->renderControl) + return d->renderControl->grab(); + else if (d->windowManager) + return d->windowManager->grab(this); + return QImage(); + } + +#if QT_CONFIG(opengl) auto openglRenderContext = static_cast(d->context); if (!openglRenderContext->openglContext()) { if (!handle() || !size().isValid()) { @@ -3913,7 +3977,9 @@ QImage QQuickWindow::grabWindow() context.setShareContext(qt_gl_global_share_context()); context.create(); context.makeCurrent(this); - d->context->initialize(&context); + QSGDefaultRenderContext::InitParams rcParams; + rcParams.openGLContext = &context; + d->context->initialize(&rcParams); d->polishItems(); d->syncSceneGraph(); @@ -3928,8 +3994,9 @@ QImage QQuickWindow::grabWindow() return image; } - } #endif + } + if (d->renderControl) return d->renderControl->grab(); else if (d->windowManager) @@ -4067,6 +4134,17 @@ QQmlIncubationController *QQuickWindow::incubationController() const The OpenGL context used for rendering the scene graph will be bound at this point. + When using the RHI and a graphics API other than OpenGL, the signal is + emitted after the preparations for the frame have been done, meaning there + is a command buffer in recording mode, where applicable. If desired, the + slot function connected to this signal can query native resources like the + command before via QSGRendererInterface. Note however that the recording of + the main render pass is not yet started at this point and it is not + possible to add commands within that pass. Instead, use + beforeRenderPassRecording() for that. However, connecting to this signal is + still important if the recording of copy type of commands is desired since + those cannot be enqueued within a render pass. + \warning This signal is emitted from the scene graph rendering thread. If your slot function needs to finish before execution continues, you must make sure that the connection is direct (see Qt::ConnectionType). @@ -4088,6 +4166,15 @@ QQmlIncubationController *QQuickWindow::incubationController() const The OpenGL context used for rendering the scene graph will be bound at this point. + When using the RHI and a graphics API other than OpenGL, the signal is + emitted after scene graph has added its commands to the command buffer, + which is not yet submitted to the graphics queue. If desired, the slot + function connected to this signal can query native resources, like the + command buffer, before via QSGRendererInterface. Note however that the + render pass (or passes) are already recorded at this point and it is not + possible to add more commands within the scenegraph's pass. Instead, use + afterRenderPassRecording() for that. + \warning This signal is emitted from the scene graph rendering thread. If your slot function needs to finish before execution continues, you must make sure that the connection is direct (see Qt::ConnectionType). @@ -4099,15 +4186,69 @@ QQmlIncubationController *QQuickWindow::incubationController() const \sa resetOpenGLState() */ +/*! + \fn void QQuickWindow::beforeRenderPassRecording() + + This signal is emitted before the scenegraph starts recording commands for + the main render pass. (Layers have their own passes and are fully recorded + by the time this signal is emitted.) The render pass is already active on + the command buffer when the signal is emitted. + + This signal is applicable when using the RHI graphics abstraction with the + scenegraph. It is emitted later than beforeRendering() and it guarantees + that not just the frame, but also the recording of the scenegraph's main + render pass is active. This allows inserting commands without having to + generate an entire, separate render pass (which would typically clear the + attached images). The native graphics objects can be queried via + QSGRendererInterface. + + \note Resource updates (uploads, copies) typically cannot be enqueued from + within a render pass. Therefore, more complex user rendering will need to + connect to both the beforeRendering() and this signals. + + \warning This signal is emitted from the scene graph rendering thread. If your + slot function needs to finish before execution continues, you must make sure that + the connection is direct (see Qt::ConnectionType). + + \since 5.14 +*/ + +/*! + \fn void QQuickWindow::afterRenderPassRecording() + + This signal is emitted after the scenegraph has recorded the commands for + its main render pass, but the pass is not yet finalized on the command + buffer. + + This signal is applicable when using the RHI graphics abstraction with the + scenegraph. It is emitted earlier than afterRendering() and it guarantees + that not just the frame, but also the recording of the scenegraph's main + render pass is still active. This allows inserting commands without having + to generate an entire, separate render pass (which would typically clear + the attached images). The native graphics objects can be queried via + QSGRendererInterface. + + \note Resource updates (uploads, copies) typically cannot be enqueued from + within a render pass. Therefore, more complex user rendering will need to + connect to both the beforeRendering() and this signals. + + \warning This signal is emitted from the scene graph rendering thread. If your + slot function needs to finish before execution continues, you must make sure that + the connection is direct (see Qt::ConnectionType). + + \since 5.14 +*/ + /*! \fn void QQuickWindow::afterAnimating() This signal is emitted on the gui thread before requesting the render thread to perform the synchronization of the scene graph. - Unlike the other similar signals, this one is emitted on the gui thread instead - of the render thread. It can be used to synchronize external animation systems - with the QML content. + Unlike the other similar signals, this one is emitted on the gui thread + instead of the render thread. It can be used to synchronize external + animation systems with the QML content. At the same time this means that + this signal is not suitable for triggering graphics operations. \since 5.3 */ @@ -4167,7 +4308,15 @@ QQmlIncubationController *QQuickWindow::incubationController() const The color buffer is cleared by default. - \sa beforeRendering() + \warning This flag is ignored completely when running with the RHI graphics + abstraction instead of using OpenGL directly. As explicit clear commands + simply do not exist in some modern APIs, the scene graph cannot offer this + flexibility anymore. The images associated with a render target will always + get cleared when a render pass starts. As a solution, an alternative to + disabling scene graph issued clears is provided in form of the + beforeRenderPassRecording() signal. + + \sa beforeRendering(), beforeRenderPassRecording() */ void QQuickWindow::setClearBeforeRendering(bool enabled) @@ -4271,12 +4420,15 @@ QSGTexture *QQuickWindow::createTextureFromImage(const QImage &image, CreateText \note This function only has an effect when using the default OpenGL scene graph adaptation. + \note This function has no effect when running on the RHI graphics abstraction. + \sa sceneGraphInitialized(), QSGTexture */ QSGTexture *QQuickWindow::createTextureFromId(uint id, const QSize &size, CreateTextureOptions options) const { #if QT_CONFIG(opengl) - if (openglContext()) { + Q_D(const QQuickWindow); + if (!d->rhi && openglContext()) { QSGPlainTexture *texture = new QSGPlainTexture(); texture->setTextureId(id); texture->setHasAlphaChannel(options & TextureHasAlphaChannel); @@ -4379,15 +4531,19 @@ void QQuickWindow::setDefaultAlphaBuffer(bool useAlpha) \note This function only has an effect when using the default OpenGL scene graph adaptation. - \sa QQuickWindow::beforeRendering() + \note This function has no effect when running on the RHI graphics + abstraction. With the RHI, the functions to call when enqueuing native + graphics commands are beginExternalCommands() and endExternalCommands(). + + \sa QQuickWindow::beforeRendering(), beginExternalCommands(), endExternalCommands() */ void QQuickWindow::resetOpenGLState() { - if (!openglContext()) - return; - Q_D(QQuickWindow); + if (d->rhi || !openglContext()) + return; + QOpenGLContext *ctx = openglContext(); QOpenGLFunctions *gl = ctx->functions(); @@ -4434,6 +4590,111 @@ void QQuickWindow::resetOpenGLState() QOpenGLFramebufferObject::bindDefault(); } #endif + +/*! + \struct QQuickWindow::GraphicsStateInfo + \inmodule QtQuick + \since 5.14 + + \brief Describes some of the RHI's graphics state at the point of a + \l{QQuickWindow::beginExternalCommands()}{beginExternalCommands()} call. + */ + +/*! + \return a pointer to a GraphicsStateInfo struct describing some of the + RHI's internal state, in particular, the double or tripple buffering status + of the backend (such as, the Vulkan or Metal integrations). This is + relevant when the underlying graphics APIs is Vulkan or Metal, and the + external rendering code wishes to perform double or tripple buffering of + its own often-changing resources, such as, uniform buffers, in order to + avoid stalling the pipeline. + */ +const QQuickWindow::GraphicsStateInfo *QQuickWindow::graphicsStateInfo() +{ + Q_D(QQuickWindow); + if (d->rhi) { + d->rhiStateInfo.currentFrameSlot = d->rhi->currentFrameSlot(); + d->rhiStateInfo.framesInFlight = d->rhi->resourceLimit(QRhi::FramesInFlight); + } + return &d->rhiStateInfo; +} + +/*! + When mixing raw graphics (OpenGL, Vulkan, Metal, etc.) commands with scene + graph rendering, it is necessary to call this function before recording + commands to the command buffer used by the scene graph to render its main + render pass. This is to avoid clobbering state. + + In practice this function is often called from a slot connected to the + beforeRenderPassRecording() or afterRenderPassRecording() signals. + + The function does not need to be called when recording commands to the + application's own command buffer (such as, a VkCommandBuffer or + MTLCommandBuffer + MTLRenderCommandEncoder created and managed by the + application, not retrieved from the scene graph). With graphics APIs where + no native command buffer concept is exposed (OpenGL, Direct 3D 11), + beginExternalCommands() and endExternalCommands() together provide a + replacement for resetOpenGLState(). + + \note This function has no effect when the scene graph is using OpenGL + directly and the RHI graphics abstraction layer is not in use. Refer to + resetOpenGLState() in that case. + + \sa endExternalCommands() + + \since 5.14 + */ +void QQuickWindow::beginExternalCommands() +{ +#if QT_CONFIG(opengl) /* || QT_CONFIG(vulkan) || defined(Q_OS_WIN) || defined(Q_OS_DARWIN) */ + Q_D(QQuickWindow); + if (d->rhi && d->context && d->context->isValid()) { + QSGDefaultRenderContext *rc = static_cast(d->context); + QRhiCommandBuffer *cb = rc->currentFrameCommandBuffer(); + if (cb) + cb->beginExternal(); + } +#endif +} + +/*! + When mixing raw graphics (OpenGL, Vulkan, Metal, etc.) commands with scene + graph rendering, it is necessary to call this function after recording + commands to the command buffer used by the scene graph to render its main + render pass. This is to avoid clobbering state. + + In practice this function is often called from a slot connected to the + beforeRenderPassRecording() or afterRenderPassRecording() signals. + + The function does not need to be called when recording commands to the + application's own command buffer (such as, a VkCommandBuffer or + MTLCommandBuffer + MTLRenderCommandEncoder created and managed by the + application, not retrieved from the scene graph). With graphics APIs where + no native command buffer concept is exposed (OpenGL, Direct 3D 11), + beginExternalCommands() and endExternalCommands() together provide a + replacement for resetOpenGLState(). + + \note This function has no effect when the scene graph is using OpenGL + directly and the RHI graphics abstraction layer is not in use. Refer to + resetOpenGLState() in that case. + + \sa beginExternalCommands() + + \since 5.14 + */ +void QQuickWindow::endExternalCommands() +{ +#if QT_CONFIG(opengl) /* || QT_CONFIG(vulkan) || defined(Q_OS_WIN) || defined(Q_OS_DARWIN) */ + Q_D(QQuickWindow); + if (d->rhi && d->context && d->context->isValid()) { + QSGDefaultRenderContext *rc = static_cast(d->context); + QRhiCommandBuffer *cb = rc->currentFrameCommandBuffer(); + if (cb) + cb->endExternal(); + } +#endif +} + /*! \qmlproperty string Window::title @@ -5019,6 +5280,10 @@ void QQuickWindow::setSceneGraphBackend(QSGRendererInterface::GraphicsApi api) default: break; } +#if QT_CONFIG(opengl) /* || QT_CONFIG(vulkan) || defined(Q_OS_WIN) || defined(Q_OS_DARWIN) */ + if (QSGRendererInterface::isApiRhiBased(api)) + QSGRhiSupport::configure(api); +#endif } /*! -- cgit v1.2.3 From 192d4fa0af5f40f76979f195c4356b26eaed1696 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 25 Jun 2019 16:37:58 +0200 Subject: Make openglunderqml functional with and without the rhi It has to be written following the new split approach (beforeRendering for resource setup, beforeRenderPassRecording to issue the actual underlay draw calls), but it will then work both with and without QSG_RHI=1. Change-Id: I9b7b35434aa0caec543cae268064b2684256382d Reviewed-by: Lars Knoll --- src/quick/items/qquickwindow.cpp | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'src/quick/items/qquickwindow.cpp') diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 0adfbdb922..c51cfc8ac1 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -474,13 +474,18 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size, const QSize &surfa if (rhi) { // ### no offscreen ("renderTargetId") support yet - context->beginRhiFrame(renderer, - swapchain->currentFrameRenderTarget(), - rpDescForSwapchain, - swapchain->currentFrameCommandBuffer(), - emitBeforeRenderPassRecording, - emitAfterRenderPassRecording, - q); + context->beginNextRhiFrame(renderer, + swapchain->currentFrameRenderTarget(), + rpDescForSwapchain, + swapchain->currentFrameCommandBuffer(), + emitBeforeRenderPassRecording, + emitAfterRenderPassRecording, + q); + } else { + context->beginNextFrame(renderer, + emitBeforeRenderPassRecording, + emitAfterRenderPassRecording, + q); } animationController->advance(); @@ -528,7 +533,9 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size, const QSize &surfa runAndClearJobs(&afterRenderingJobs); if (rhi) - context->endRhiFrame(renderer); + context->endNextRhiFrame(renderer); + else + context->endNextFrame(renderer); } QQuickWindowPrivate::QQuickWindowPrivate() @@ -4202,6 +4209,11 @@ QQmlIncubationController *QQuickWindow::incubationController() const attached images). The native graphics objects can be queried via QSGRendererInterface. + When not running with the RHI (and using OpenGL directly), the signal is + emitted after the renderer has cleared the render target. This makes it + possible to create appliations that function identically both with and + without the RHI. + \note Resource updates (uploads, copies) typically cannot be enqueued from within a render pass. Therefore, more complex user rendering will need to connect to both the beforeRendering() and this signals. @@ -4228,6 +4240,11 @@ QQmlIncubationController *QQuickWindow::incubationController() const the attached images). The native graphics objects can be queried via QSGRendererInterface. + When not running with the RHI (and using OpenGL directly), the signal is + emitted after the renderer has finished its rendering, but before + afterRendering(). This makes it possible to create appliations that + function identically both with and without the RHI. + \note Resource updates (uploads, copies) typically cannot be enqueued from within a render pass. Therefore, more complex user rendering will need to connect to both the beforeRendering() and this signals. -- cgit v1.2.3 From 1c5c5f7aadc2dcc73a21eeb818e95c4e1b7de70f Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 26 Jun 2019 16:46:23 +0200 Subject: Fix Qt6 build in preparation of qt5 submodule update Fixes the QTextStream usages. Change-Id: I0c009a82fb644a9f3c3d42ec410d18b680977f23 Reviewed-by: Qt CI Bot Reviewed-by: Simon Hausmann --- src/quick/items/qquickwindow.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/quick/items/qquickwindow.cpp') diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 7d1fa9c30d..2543e867df 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -696,7 +696,7 @@ bool QQuickWindowPrivate::deliverTouchAsMouse(QQuickItem *item, QQuickPointerEve if (!item->contains(pos)) break; - qCDebug(DBG_TOUCH_TARGET) << "TP (mouse)" << hex << p.id() << "->" << item; + qCDebug(DBG_TOUCH_TARGET) << "TP (mouse)" << Qt::hex << p.id() << "->" << item; QScopedPointer mousePress(touchToMouseEvent(QEvent::MouseButtonPress, p, event.data(), item, false)); // Send a single press and see if that's accepted @@ -738,7 +738,7 @@ bool QQuickWindowPrivate::deliverTouchAsMouse(QQuickItem *item, QQuickPointerEve QCoreApplication::sendEvent(item, me.data()); event->setAccepted(me->isAccepted()); if (me->isAccepted()) { - qCDebug(DBG_TOUCH_TARGET) << "TP (mouse)" << hex << p.id() << "->" << mouseGrabberItem; + qCDebug(DBG_TOUCH_TARGET) << "TP (mouse)" << Qt::hex << p.id() << "->" << mouseGrabberItem; } return event->isAccepted(); } else { @@ -2465,7 +2465,7 @@ void QQuickWindowPrivate::deliverTouchEvent(QQuickPointerTouchEvent *event) QQuickEventPoint *point = event->point(i); if (point->state() == QQuickEventPoint::Released) { int id = point->pointId(); - qCDebug(DBG_TOUCH_TARGET) << "TP" << hex << id << "released"; + qCDebug(DBG_TOUCH_TARGET) << "TP" << Qt::hex << id << "released"; point->setGrabberItem(nullptr); if (id == touchMouseId) cancelTouchMouseSynthesis(); @@ -2562,7 +2562,7 @@ bool QQuickWindowPrivate::deliverPressOrReleaseEvent(QQuickPointerEvent *event, if (point->grabberPointerHandler()) cancelTouchMouseSynthesis(); } else { - qCWarning(DBG_TOUCH_TARGET) << "during delivery of touch press, synth-mouse ID" << hex << touchMouseId << "is missing from" << event; + qCWarning(DBG_TOUCH_TARGET) << "during delivery of touch press, synth-mouse ID" << Qt::hex << touchMouseId << "is missing from" << event; } } for (int i = 0; i < pointCount; ++i) { @@ -2704,7 +2704,7 @@ void QQuickWindowPrivate::deliverMatchingPointsToItem(QQuickItem *item, QQuickPo if (point.state() == Qt::TouchPointPressed) { if (auto *tp = ptEvent->pointById(point.id())) { if (tp->exclusiveGrabber() == item) { - qCDebug(DBG_TOUCH_TARGET) << "TP" << hex << point.id() << "disassociated"; + qCDebug(DBG_TOUCH_TARGET) << "TP" << Qt::hex << point.id() << "disassociated"; tp->setGrabberItem(nullptr); } } @@ -2983,7 +2983,7 @@ bool QQuickWindowPrivate::sendFilteredPointerEventImpl(QQuickPointerEvent *event qCDebug(DBG_TOUCH) << "touch event intercepted as synth mouse event by childMouseEventFilter of " << filteringParent; skipDelivery.append(filteringParent); if (t != QEvent::MouseButtonRelease) { - qCDebug(DBG_TOUCH_TARGET) << "TP (mouse)" << hex << tp.id() << "->" << filteringParent; + qCDebug(DBG_TOUCH_TARGET) << "TP (mouse)" << Qt::hex << tp.id() << "->" << filteringParent; pointerEventInstance(dev)->pointById(tp.id())->setGrabberItem(filteringParent); touchMouseUnset = false; // We want to leave touchMouseId and touchMouseDevice set if (mouseEvent->isAccepted()) -- cgit v1.2.3