aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix crash with the software renderer and windows with QObject parentSimon Hausmann2018-02-151-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a QQuickWindow is a child of another QObject (such as a Loader) and is scheduled for deletion using a deferred delete event, then a deletion via the parent ends up calling the window's destructor, which will finally end up in ~QObject(), which takes care of removing the posted deferred deletion event from the event queue. In the case of QQuickWindow, the destructor - called before ~QObject - calls windowDestroyed(this) on the SG render loop. The implementation in the software renderer calls QCoreApplication::sendPostedEvents() with QEvent::DeferedDelete, which ends up deleting the same window a second time and resulting in a crash. I can't see a good reason for the existence of the sendPostedEvents() call there. It is not present in the other render loops and according to git blame it stems from the very early first implementation of the software renderer where surely copy & paste from other render loop code was involved back then. The same fix is applied to the single-threaded VG and D3D12 render loops, as they are most likely copy & paste from the software render loop implementation. ASAN trace for tst_qquickwindow::unloadSubWindow() on 5.11 branch that shows invalid access to the QObjectPrivate/QQuickWindowPrivate, which follows the QObject in terms of life-cycle: ==4736==ERROR: AddressSanitizer: heap-use-after-free on address 0x617000011778 at pc 0x7fdd211cfbb3 bp 0x7fffecb47ea0 sp 0x7fffecb47e90 READ of size 8 at 0x617000011778 thread T0 #0 0x7fdd211cfbb2 in QQuickWindow::~QQuickWindow() items/qquickwindow.cpp:1308 #1 0x7fdd21470974 in QQuickWindowQmlImpl::~QQuickWindowQmlImpl() items/qquickwindowmodule_p.h:63 #2 0x7fdd21470974 in QQmlPrivate::QQmlElement<QQuickWindowQmlImpl>::~QQmlElement() .../qqmlprivate.h:103 #3 0x7fdd21470974 in QQmlPrivate::QQmlElement<QQuickWindowQmlImpl>::~QQmlElement() .../qqmlprivate.h:103 #4 0x7fdd1e24da24 in qDeleteInEventHandler(QObject*) kernel/qobject.cpp:4601 #5 0x7fdd1e253d2f in QObject::event(QEvent*) kernel/qobject.cpp:1240 #6 0x7fdd1fbd1d41 in QWindow::event(QEvent*) kernel/qwindow.cpp:2356 #7 0x7fdd211f778e in QQuickWindow::event(QEvent*) items/qquickwindow.cpp:1628 #8 0x7fdd1e1a4e3c in QCoreApplicationPrivate::notify_helper(QObject*, QEvent*) kernel/qcoreapplication.cpp:1216 #9 0x7fdd1e1a508b in doNotify kernel/qcoreapplication.cpp:1157 #10 0x7fdd1e1a555a in QCoreApplication::notify(QObject*, QEvent*) kernel/qcoreapplication.cpp:1143 #11 0x7fdd1fb87665 in QGuiApplication::notify(QObject*, QEvent*) kernel/qguiapplication.cpp:1723 #12 0x7fdd1e1a52fa in QCoreApplication::notifyInternal2(QObject*, QEvent*) kernel/qcoreapplication.cpp:1067 #13 0x7fdd1e1b6ed2 in QCoreApplication::sendEvent(QObject*, QEvent*) ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:234 #14 0x7fdd1e1b6ed2 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) kernel/qcoreapplication.cpp:1764 #15 0x7fdd1e1b8cda in QCoreApplication::sendPostedEvents(QObject*, int) kernel/qcoreapplication.cpp:1618 #16 0x7fdd210cb034 in QSGSoftwareRenderLoop::windowDestroyed(QQuickWindow*) scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp:100 #17 0x7fdd211cfb8c in QQuickWindow::~QQuickWindow() items/qquickwindow.cpp:1305 [...] 0x617000011778 is located 632 bytes inside of 704-byte region [0x617000011500,0x6170000117c0) freed by thread T0 here: #0 0x7fdd21a8a9d8 in operator delete(void*, unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe19d8) #1 0x7fdd2146fa3c in QQuickWindowQmlImplPrivate::~QQuickWindowQmlImplPrivate() items/qquickwindowmodule.cpp:57 #2 0x7fdd1e26b252 in QScopedPointerDeleter<QObjectData>::cleanup(QObjectData*) [...] #3 0x7fdd1e26b252 in QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> >::~QScopedPointer() [...] #4 0x7fdd1e26b252 in QObject::~QObject() kernel/qobject.cpp:882 #5 0x7fdd1fbcf51c in QWindow::~QWindow() kernel/qwindow.cpp:211 #6 0x7fdd211d0466 in QQuickWindow::~QQuickWindow() items/qquickwindow.cpp:1297 #7 0x7fdd211d0644 in QQuickWindow::~QQuickWindow() items/qquickwindow.cpp:1335 #8 0x7fdd1e2666b4 in QObjectPrivate::deleteChildren() kernel/qobject.cpp:1995 #9 0x7fdd1e26b329 in QObject::~QObject() kernel/qobject.cpp:1023 [...] Change-Id: Iffa90d365d02b074e2a78c5be2895c9f86a4b80e Task-number: QTBUG-66381 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Delay the deletion of QSGTextures until all windows are synchronizedDominik Holland2017-06-161-0/+1
| | | | | | | | | | | | | | | | With the 'basic' and the 'windows' render loop the scene graph context is shared. Because of this we cannot start deleting textures after the first window is synchronized as it may contain textures needed by the another window, which is not yet synchronized. QWindowPrivate::syncSceneGraph() is not calling endSync() anymore as it doesn't know whether it is the last window or not. Instead the renderloop is now responsible for calling endSync() once this is safe to do. Change-Id: Icb50ebfb447c928e38b41df7e26f3bfafdb4a811 Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com> Reviewed-by: Gunnar Sletta <gunnar@crimson.no>
* Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-11-281-4/+8
| | | | | | | | | | | | | | | | The renderers added in 5.8 had to be adapted to the changed profiling macros from 5.6. Conflicts: src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp src/quick/util/qquickprofiler_p.h tests/auto/qml/qjsengine/tst_qjsengine.cpp tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp Change-Id: Icb370b7c95aab12589ad73881ac6d178759a5c6b
* software: Add support for QSGRenderNodeLaszlo Agocs2016-07-191-0/+2
| | | | | | | | | | | | | | | | | Have to change getResource() a bit since it turns out it is not suitable currently for backends that do not have a per-window rendercontext and do not implement the interface on the rendercontext. Pass in the window to make sure it can always figure out which window we want the resources for. (we do not want rendererInterface() to return window-specific instances created on the fly, with ownership issues, so stick with the simple model where backends implement the interface on one of their existing classes) To support clipping, QSGRenderNode::RenderState is extended accordingly. Also updated the docs since some claims in the rendernode docs are not true since Qt 5.3. Change-Id: I34779c83926f5231b888fcab7131e873ae97964f Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* D3D12: Fix unused var warnings in release buildsLaszlo Agocs2016-07-151-0/+1
| | | | | Change-Id: I83c3582ca7cb9523fb0e90627f2575992e84694c Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* D3D12: Support translucent windows via DirectCompositionLaszlo Agocs2016-07-141-4/+6
| | | | | Change-Id: I1b63db07ade1ae43c67352b4d875d5a3e55105f2 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* D3D12: Advance anims in sync with vsync in the RLLaszlo Agocs2016-07-011-43/+169
| | | | | | | | | | Make the default render loop behave like the 'windows' one does with OpenGL: advance animations manually after each render step. This provides much better results than the previous approach (i.e. 'basic') where the animations became quite jerky with heavier workloads. Change-Id: Ic933e136479d2a04036af15212669027ef2408c3 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* D3D12: Fix expose handlingLaszlo Agocs2016-07-011-4/+17
| | | | | | | | | | | | to avoid unnecessary rendering attempts when closing windows containing certain Quick Controls (1). Basically this introduces a condition that is there in the threaded loop's polishAndSync but was missing from renderWindow. When the window is not "exposed" either normally or via grab(), it should just return. Change-Id: I42602e33ba144a1c56586a4b92fa088e85099d0d Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* D3D12: Fix grabbing with the new gui thread render loopLaszlo Agocs2016-07-011-20/+34
| | | | | | | | | Grabbing was not completely ported from the separate render thread based version, and so some of the grab tests in tst_qquickwindow did not pass. This is now corrected. Change-Id: I830d9b439082cf8ebc1bfe75ce756ef5dd7c54c0 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* D3D12: Avoid multiple invalidated signalsLaszlo Agocs2016-07-011-5/+1
| | | | | | | | | | Calling invalidate() multiple times for any reason should only result in doing cleanup and emitting signals once. The somewhat weird manual pending flag is also removed now. Change-Id: I46eca63a300fe9acb4ebd0bd9b601d8583dced1c Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* D3D12: Reintroduce the single threaded render loopLaszlo Agocs2016-06-241-965/+178
| | | | | | | | | ...and use it by default. Use QSG_RENDER_LOOP=threaded to request the threaded one (but prepare for potential DXGI deadlocks, usually when multiple windows are involved). Change-Id: I1372b4a8f2388e08515899792e2a9c347b31faf8 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Merge remote-tracking branch 'origin/dev' into scenegraphngAndy Nichols2016-05-311-1/+1
| | | | Change-Id: I35715e07b6f837f21cd8e8898f19d97af92c6b69
* D3D12: Add a way to test device loss and fix discovered issuesLaszlo Agocs2016-05-081-0/+14
| | | | | | | | | | | | | Set QT_D3D_DEVICE_LOSS_TEST to a number N > 0 to trigger a device reset N times in 5 second intervals. Cinematic is able to survive now which is excellent news. Also tested a real driver update which worked as well, Cinematic kept running all the time (unlike Creator). Change-Id: Ib59c7dece6b90321e6bd7e01c0687c51d5b61333 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* D3D12: Massage tst_qquickwindow and some sg semanticsLaszlo Agocs2016-05-081-2/+22
| | | | | Change-Id: Ic4cc9ae5c1df2ab7e1da50ac414dc3d7f264e691 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* D3D12: Implement grabWindowLaszlo Agocs2016-05-061-3/+28
| | | | | Change-Id: Icb8151f26bad68795eb2e1f920297267c880b40b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* D3D12: Long Live Wobble!Laszlo Agocs2016-04-291-0/+3
| | | | | | | | | | | | | D3D12 shader effect node. Cull mode, atlas (qt_SubRect_*) support, and some nice-to-haves are currently missing. The built-in shaders won't yet work due to not sending 'source' down the stack so both have to be application-supplied. Nonetheless..the wobble test works! Change-Id: If4cd0143fa5794a8d5f89b576ffcfb084efeb343 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Make rendernode suitable for public consumptionLaszlo Agocs2016-04-201-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For non-OpenGL APIs the primary (and likely the only) way to add custom rendering into the Qt Quick scene is via the render node. Other approaches,like the before/afterRendering signals, QQuickFramebufferObject, remain OpenGL-only. (although QQuickFramebufferObject may get a multi-API replacement based on QSGRenderNode at a later time) Note that this is not a generic 3D content integration enabler. It targets creating 2D and 2.5D Quick items with custom rendering via the graphics API in use. Make QSGRenderNode public, enhance the docs a bit and add a releaseResources(). Add a QSGRendererInterface with a query function in QQuickWindow and QSGEngine. The scenegraph adaptation can then return a custom implementation of the interface. This will be necessary to query API-specific values, f.ex. the ID3D12Device and ID3D12CommandList when running with the d3d12 backend. The interface allows querying the API and void* resources. Resources that we know about in advance are enum-based to prevent the QPlatformNativeInterface-like ugliness of string keys. Support is there in the batch renderer already, fix this up according to the new public API, and implement the corresponding bits for the D3D12 renderer. For D3D12, fix also an issue with QSGNode destruction where graphics resources in use were attempted to be final-released without a proper wait. The semantics of changedStates() in QSGRenderNode is changed so that it can be called at any time, including before render(). This is very useful since we can implement some state restoring in a more efficient manner. Added a new example as well. Documentation for QSGRenderNode is heavily expanded. Change-Id: I4c4a261c55791d0e38743a784bc4c05a53b3462d Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Convert d3d12 backend into a pluginLaszlo Agocs2016-04-131-0/+1101
Change-Id: I4300ba81800e44c0b5e2a86e72b1cf96434c323d Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>