aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgrhisupport.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Warn when requesting GL/Vulkan but Qt is not configured for thoseLaszlo Agocs2021-03-261-0/+5
| | | | | | | | | | | | On embedded and mobile it can happen that the Qt build has no Vulkan support (because it is not there or not detected in the sysroot), and while this is visible in the configure output, it is best to make it also clear at run time. Change-Id: I316671a04aba80d38d2f8514695f55b05fb94dbd Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit 4b83ae6472b30626c3492442a91125830ce28ebe) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Clean up QSGRhiSupport wrt static functionsLaszlo Agocs2021-03-201-14/+12
| | | | | | | | | | | Make static everything that can be static. At the same time, make configure() non-static. Does not change behavior in any way, but this is the more logical approach. Also more future proof. Change-Id: I601d59a0547106802f330a7551a97186cde481e0 Reviewed-by: Christian Strømme <christian.stromme@qt.io> (cherry picked from commit fb8ba3f7250f837dd29600d30108ba6f4470a727) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Remove Windows 7 VM workaround from rhi initLaszlo Agocs2021-02-191-11/+1
| | | | | | | | | There is no longer a Windows 7 configuration in CI. Change-Id: Ic190735301f03e84974132ed1183adfd9352187a Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit 4d9d5ab8187a2e1391afdcd0716bd43196040984) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add env.vars. to toggle pipeline cache load/saveLaszlo Agocs2021-01-251-3/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QRhi has APIs (but private ones) that allow retrieving and restoring the contents of the "pipeline cache". (which may map directly to VkPipelineCache, or may be a simulated, OpenGL program binary based solution) In many cases it is convenient if the saving of the cache blob to a file, and then, during subsequent runs of the application, the loading of cache contents, can be enabled via environment variables: QSG_RHI_PIPELINE_CACHE_SAVE=filename maps to setting the EnablePipelineCacheDataSave flag on the QRhi, and writing the collected data to file upon application exit. (more correctly, when the QRhi is about to be destroyed by the render loop) QSG_RHI_PIPELINE_CACHE_LOAD=filename maps to attempting to read the contents of the specified file, and, if successful, passing it to QRhi right after initialization. When supported and the data is not corrupt or incomplete, the result is likely improved pipeline creation times (the exact details depend on the driver with Vulkan, while with OpenGL it all maps to glProgramBinary instead of compiling from source) Setting QSG_INFO=1 can be useful to see what is happening when the above 2 env.vars. are set. With OpenGL the simulated "pipeline cache" is orthogonal to the Qt 5 era shader program disk cache: loading from both is supported transparently to the application. When QSG_RHI_PIPELINE_CACHE_SAVE is enabled, the disk cache will not be written to. Task-number: QTBUG-90398 Change-Id: I82d9a81e9dab39d3513a6aa7c6e1ff748a4ec6e5 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Query QRhi's desired Vulkan instance extensions instead of hardcodingLaszlo Agocs2021-01-211-2/+1
| | | | | Change-Id: I9859e1b2f786f1e578f3536bb3299c38a3a9a8b6 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Use the new, dedicated D3D surface type for QQuickWindowLaszlo Agocs2021-01-051-1/+1
| | | | | | | | | | This way any potential logic in the platform plugin that branches based on the surface type can now distinguish between OpenGL and D3D based windows. Fixes: QTBUG-89715 Change-Id: I01e9f8a525280982a9d4a18defb970e8a2fcc362 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Avoid unused parameter in QSGRhiSupport in certain configsLaszlo Agocs2020-12-071-0/+4
| | | | | | | Pick-to: 6.0 Fixes: QTBUG-88604 Change-Id: Id84faf648656993777f780e147917151ce05d3e0 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Silence unused warning in QSGRhiSupport in uncommon build configsLaszlo Agocs2020-11-091-4/+8
| | | | | | Fixes: QTBUG-88235 Change-Id: I47c20f46c77630c47a8bda7dfe6b080eafa8f4d7 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Have a depth buffer when doing the heavy offscreen readbackLaszlo Agocs2020-10-161-1/+8
| | | | | | | | | | | | | | The opaque pass will rely on it (by default at least). Not having a depth buffer will almost certainly lead to rendering errors, albeit silently since technically it's not an error not to have one. Just make sure there is one. The assumption is that the Z order problem mentioned in the comments in the referenced bug is caused by this. Task-number: QTBUG-87399 Change-Id: Ifbf5564848f17e7ce3498190d663c1ec693e86c9 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Fix multiple windows with Vulkan on basic render loopLaszlo Agocs2020-07-281-10/+22
| | | | | | | | | | | | | No problems with threaded, but when using QSG_RENDER_LOOP=basic with Vulkan we missed setting the Vulkan instance for the second, third, etc. window. The problem can be seen with the quick/window example, running it with QSG_RHI_BACKEND=vulkan QSG_RENDER_LOOP=basic makes it fail. With the patch it will function as expected. Change-Id: I98e7cb5ff960200dadb2fcbc30f771f9a7d9a9ae Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Make it possible to specify an adapter or physical device onlyLaszlo Agocs2020-06-291-2/+16
| | | | | | | | | As required by OpenXR. While we are at it, make the API a bit more type safe. Change-Id: I3c6152feeb71359056830ab02d35f8cb258722c0 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Add what-would-my-graphics-api-be getterLaszlo Agocs2020-06-261-0/+2
| | | | | Change-Id: I2bf50a46ea18fe06068192ad695652830c3a3861 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Defer setting a QVulkanInstance on the windowLaszlo Agocs2020-06-221-0/+9
| | | | | | | | ...to createRhi(). There is no need for the VkInstance before that point. Change-Id: I87f4e8154e96409bccd7844f1bf80b957bb54d69 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Rename setSceneGraphBackend to setGraphicsApiLaszlo Agocs2020-06-221-1/+1
| | | | | | | | | | | | | | | | ...and fix up the docs. The string-based setSceneGraphBackend() stays of course (the docs have been enhanced, however). The GraphicsApi enum-based overload is now renamed to setGraphicsApi(). Using the same name for both functions is a historical artifact, reflecting the evolution (5.0 - 5.8 - 5.14). In 6.0 we can give it a more appropriate name, since it does not have much to do with "backends" from the user's perspective. Change-Id: Id75dbf81f50a148797e5b5de9be4000153737473 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Add test for rendercontrol + rendererinterfaceLaszlo Agocs2020-06-221-5/+12
| | | | | | | | | | Also add support for doing QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Unknown). This becomes relevant especially in tests, where we may request a specific graphics API, but then want to switch back to the default behavior. Change-Id: Ib09c411432fc37bd4d36ce55d54d20af3f83860a Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Make it possible to specify device extensions in a future proof mannerLaszlo Agocs2020-06-191-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow the pattern of QQuickRenderTarget and QQuickGraphicsDevice. This makes it possible to integrate with real world frameworks, such as OpenXR, that, especially with Vulkan, expect this level of configurability. (i.e. one pulls the list of extensions to be enabled on the device, that then needs to be taken into account by Quick, otherwise it will end up with a VkDevice that is not usable by OpenXR) Same goes when integrating native Vulkan rendering into an application: if certain extensions need to be enabled on the VkDevice, today that can only be done with an environment variable which is not entirely ideal. These issues are now solved by a new simple (and extensible) container QQuickGraphicsConfiguration, which is associated with the QQuickWindow. When applicable, the scene graph will then pick up the relevant settings. Expand the related docs everywhere. Also rename the vulkanInstance() to defaultVulkanInstance() to emphasize that it is the instance that is used for normal QQuickWindows, and is not provided when redirecting via QQuickRenderControl. While we are at it, include another obvious candidate: the use-depth-buffer flag. It turns out that Quick3D's Overlay render mode can be pretty problematic if Quick writes to the depth buffer. In order to avoid relying on environment variables (QSG_NO_DEPTH_BUFFER), we now provide a proper API for controlling that as well. Change-Id: Iefdb62c1f53de8bd34e3f0d393b00c5020d6188a Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Fix up exposing the swapchain to Quick3DLaszlo Agocs2020-06-191-2/+15
| | | | | | | | | | Quick3D is broken in combination with QQuickRenderControl. This is because just exposing the swapchain is not enough - there is no swapchain with QQuickRenderControl. Rather, one needs access to the command buffer and render target then. Change-Id: I6c06ad3d83ab0018b9f985073757a3378dbce24b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Only enable opting in to rhi profiling when qml debugging is enabledLaszlo Agocs2020-06-181-0/+7
| | | | | | | | | For security reasons, QML debugging (e.g. QML Profiler) is only usable when the application had CONFIG+=qml_debug set. Follow the same approach in the QRhi profiling infrastructure and do nothing if this was not set. Change-Id: I46ea78a118d79e166a40722befbfc9263aac6680 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* Clean up QT_CONFIG(opengl)Paul Olav Tvete2020-06-171-22/+4
| | | | | | | | | | Accelerated graphics is now possible without OpenGL support. With this change, a Qt build with -no-opengl can still run Qt Quick with a Vulkan, Metal, or Direct3D backend. Fixes: QTBUG-84027 Change-Id: Ib63c733d28cfdf7de16b138df136fa7628e1747b Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Expose the QRhiSwapchain via QSGRendererInterfaceLaszlo Agocs2020-06-031-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...similarly to how we already do it for the QRhi itself. Just follow the same pattern. This allows Qt Quick 3D to stop peeking directly into QQuickWindowPrivate and accessing member variables in there. Code like the following QQuickWindowPrivate *wd = QQuickWindowPrivate::get(window); QRhiCommandBuffer *cb = wd->swapchain->currentFrameCommandBuffer(); QRhiRenderPassDescriptor *rp = wd->rpDescForSwapchain; can now be written ca. like this, without pulling in quick-private: QRhiSwapChain *swapchain = window->rendererInterface->getResource(window, RhiSwapchain) QRhiCommandBuffer *cb = swapchain->currentFrameCommandBuffer(); QRhiRenderPassDescriptor *rp = swapchain->renderPassDescriptor(); This provides a more stable interface between the scenegraph and Quick 3D. In addition, this is also handy for manual tests, external test applications, etc. in case they do QRhi-based rendering in a QQuickWindow. Now these are also fine with just gui-private, no need to access QQuickWindowPrivate anymore. Change-Id: I921fb1c33c2fc77081272b1f180fdc2c87ed3ab5 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Remove QSG_NO_RHILaszlo Agocs2020-06-031-4/+3
| | | | | | Task-number: QTBUG-79268 Change-Id: Ie7240fe7de4fcd73be65c8afec3466189d7d3f9a Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Fix build without openglSamuli Piippo2020-06-021-1/+6
| | | | | | | ifdef code that is not available without opengl. Change-Id: I200e95e4bcf1ee361e84819454eade0bbcbd6669 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Follow QRhi create-destroy API updateLaszlo Agocs2020-06-021-2/+2
| | | | | Change-Id: I0bc2cbce373febcb9073f15067eebbc1723462ba Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* rhi: Add support for grabbing non-exposed windowsLaszlo Agocs2020-05-181-3/+76
| | | | | | | | | tst_qquickwindow::grab is now expected to pass in all combinations (both direct GL and RHI with any backend). Task-number: QTBUG-78608 Change-Id: I8c1f2ff3d50144c7dd4498160818d0860b67db15 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devLiang Qi2020-05-151-4/+11
|\ | | | | | | | | | | | | Conflicts: tests/auto/quick/qquicktextedit/BLACKLIST Change-Id: If1868d27ea40fdc206971c2f7a24e91c5e62b1bf
| * Merge remote-tracking branch 'origin/5.15.0' into 5.15Qt Forward Merge Bot2020-05-141-4/+11
| |\ | | | | | | | | | Change-Id: I1f653fa9586e7d1e9c23acffba4512cfe9f951b8
| | * Make no-opengl builds succeed with Vulkan or MetalLaszlo Agocs2020-04-251-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Amends c83ca003248a21e368ebfbf799ef9580e0f4e6ac. In Qt 5.x we do not support using Qt Quick with the QRhi-based rendering path in -no-opengl builds. (such builds default to the software backend in fact) This is due to structural difficulties, such as QSGDefaultRenderContext (the .cpp) being tied to direct OpenGL. This will only get solved properly in Qt 6 when the direct OpenGL code path gets removed. However, compilation should not break in -no-opengl builds, regardless of which other conditions (QT_CONFIG(vulkan), Q_OS_MACOS, etc.) evaluate to true. The original patch missed the case when we have Vulkan enabled or we are on macOS or iOS (which implies enabling the Metal code path). This is now corrected by extending the scope of the condition. Change-Id: I0e87d8b033aed8fdfaca826bcd32596a532380a7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Inho Lee <inho.lee@qt.io>
| * | qsgrhisupport.cpp: Fix warningsFriedemann Kleint2020-05-061-2/+4
| |/ | | | | | | | | | | | | | | | | | | | | | | scenegraph/qsgrhisupport.cpp: In member function ‘void QSGRhiSupport::applySettings()’: warning: ‘QSting::QString(const QByteArray&)’ is deprecated scenegraph/qsgrhisupport.cpp:161:102: note: in expansion of macro ‘qPrintable’ scenegraph/qsgrhisupport.cpp:585:112: warning: ‘void QAbstractSocket::error(QAbstractSocket::SocketError)’ is deprecated Change-Id: I848e089f9d6d26fcb7f44e9e83883f5f971eba3e Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> (cherry picked from commit e3c64aff6579f04353608d4b218f031d9137d3f4)
* | Use QRhi by defaultLaszlo Agocs2020-05-111-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Flip it over and instead of having to do QSG_RHI=1 to enable, one can now do QSG_NO_RHI=1 to disable. (note that follow up patches are expected to break the direct GL path, so QSG_NO_RHI will likely not be useful in practice) Also clean up the unused rhi flag in the struct that is used by the C++ APIs like QQuickWindow::setSceneGraphBackend(). Disables the qquickwidget autotest since QQuickWidget is not functional at the moment. Also disables the 'zoom' case in the qqmlpreview test. No idea why the external process is crashing there. (and the infrastructure does not exactly make it easy to debug anything, hence postponing any further investigation) Task-number: QTBUG-79268 Change-Id: Ia877ebe039a1d98ce661add82a6822a313fd10e5 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* | Only alter rhi backend on Win7 and Metalless-macOS when not explicitly requestedLaszlo Agocs2020-05-111-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | When forcing a given backend from the C++ API or QSG_RHI_BACKEND, the user/application's request must be honored. Otherwise confusing situations arise. If the requested backend fails, let's just fail. It is the "just pick a platform specific default" case where we have the flexibility of choosing between the backends. Change-Id: If30c329bc7ce8ec26abee0ae2d4bcaef53df4718 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* | Pre-check for Metal support to please our CI VMsLaszlo Agocs2020-05-111-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An attempt to have a temporary solution for not having Metal support in the CI VMs. In order to run graphical Qt Quick autotests, we need to decide upfront if we want to go with Metal or try something else. Leaving the decision to the point of initializing the scenegraph (and so creating the QRhi instance) is not acceptable as that is way too late. If this works out, we can add a private helper in gui that does a more lightweight check directly via the Metal APIs. But for now, just create a QRhi temporarily. For qtbase autotests (like tst_qrhi) the problem does not apply because those simply go through all QRhi backends and exercise all that succeed to initialize, skipping the failing ones. But a real application, and so Qt Quick, does not work like that. Task-number: QTBUG-84067 Change-Id: I52f31871eb72c8d57bc604391963f0d022a3321c Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* | Please the broken Win 7 CI by forcing OpenGL over D3DLaszlo Agocs2020-05-111-0/+25
| | | | | | | | | | | | | | | | | | Not very interesting because Windows 7 is not supported in Qt 6, but as long as the CI for it is around, let's try to keep it functional. Task-number: QTBUG-84067 Change-Id: Ifae65355466ae6d372169974e6034b370b0e1328 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-04-221-2/+13
|\| | | | | | | Change-Id: Iafb7061945e011542fbf0f6ebe776f0a4187b0a4
| * RHI: Fix build with -no-openglFriedemann Kleint2020-04-171-2/+11
| | | | | | | | | | | | | | | | It is failing with a link error (missing QSGDefaultRenderContext). Task-number: QTBUG-83169 Change-Id: I0a3009a11269a7ffb142f2f51b6a1991d8ab3978 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
| * Fix some network related deprecation warningsFabian Kosmale2020-03-161-1/+1
| | | | | | | | | | Change-Id: I0e5e9e42b7c81e1fa5d6abde6bd6346dbc2f14ff Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Allow redirecting QRhi-based rendering via QQuickRenderControlLaszlo Agocs2020-04-111-18/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement the Qt 6 TODO for using an externally-provided render target when rendering the scene via QRhi. And say hello to QQuickRenderTarget. This class exists to allow potentially extending later what a "render target" consists of. Instead of hard-coding taking a single void * in the setRenderTarget() function, it takes a (implicitly shared, d-pointered) QQuickRenderTarget, which in turn can be created via static factory functions - of which new ones can be added later on. The new version of QQuickWindow::setRenderTarget() takes a QQuickRenderTarget. QQuickRenderControl gets a new initialize() variant, and a few extra functions (beginFrame(), endFrame()). This allows it to, by using QSGRhiSupport internally, create a QRhi under the hood. As a bonus, this also fixes an existing scenegraph resource leak when destroying the QQuickRenderControl. The qquickrendercontrol autotest is extended, with a QRhi-based test case that is executed for all of the QRhi backends that succeed to initialize. This is the internal verification. In addition, there is a Vulkan-based one that creates its own VkDevice, VkImage, and friends, and then uses Qt Quick with the same Vulkan device, targeting the VkImage. This test verifies the typical application use case. (sadly, life is too short to waste it on writing Vulkan boilerplate for an on-screen version of this, but we have the D3D11 example instead) What QQuickRenderControl loses, when used in combination with QRhi, is the grab() function. This never made much sense as a public API: QQuickWindow::grabWindow() call this when the window is associated with a rendercontrol, so as a public API QQuickRenderControl::grab() is redundant, because one gets the same result via the standard QQuickWindow API. It is now made private. More importantly, reading back the content is no longer supported, unless the 'software' backend is in use. The reasoning here is that, if the client of the API manages and provides the render target (as abstracted by QQuickRenderTarget), it is then expected to be capable of reading back the content in whatever way it sees fit, because it owns and manages the resource (e.g. the texture) in the first place. Providing fragile convenience functions for this is not reasonable anymore, and was questionable even with OpenGL, given that it is not future proof - what if the target is suddenly a floating point texture, for instance? The software backend case makes sense because that relies on private APIs - and has no render target concept either - so there the same cannot be achieved by applications by relying on public APIs only. Another new class is QQuickGraphicsDevice. This is very similar to QQuickRenderTarget, it is a simple container capable of holding a set of of native objects, mostly in the form of void*s, with future extensibility thanks to the static factory functions. (examples of native object sets would be a ID3D11Device + ID3D11DeviceContext, or a QOpenGLContext, or a MTLDevice + MTLCommandQueue, or a number of Vulkan device-related objects, etc.) This allows one to specify that the QRhi created under the hood (either by QQuickRenderControl or by the render loop) should use an existing graphics device (i.e. it is basically a public wrapper for values that go into a QRhi*InitParams under the hood). QQuickRenderTarget and QQuickGraphicsDevice are both demonstrated in a new example: rendercontrol_d3d11. We choose D3D11 because it is reasonably simple to set up a renderer with a window, and, because there is known user demand for Qt Quick - external D3D engine interop. Passing in the custom engine's own ID3D11Device and ID3D11DeviceContext is essential: the texture (ID3D11Texture2D) Qt Quick is targeting would not be usable if Qt Quick's QRhi was using a different ID3D11Device. Task-number: QTBUG-78595 Change-Id: I5dfe7f6cf1540daffc2f11136be114a08e87202b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* | qsgrhisupport.cpp: Fix warningsFriedemann Kleint2020-03-171-3/+5
|/ | | | | | | | | | | scenegraph/qsgrhisupport.cpp: In member function ‘void QSGRhiSupport::applySettings()’: warning: ‘QSting::QString(const QByteArray&)’ is deprecated scenegraph/qsgrhisupport.cpp:161:102: note: in expansion of macro ‘qPrintable’ scenegraph/qsgrhisupport.cpp:585:112: warning: ‘void QAbstractSocket::error(QAbstractSocket::SocketError)’ is deprecated Change-Id: I848e089f9d6d26fcb7f44e9e83883f5f971eba3e Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Warn when requesting unknown RHI backendJohan Klokkhammer Helsing2020-02-241-0/+2
| | | | | | | When QSG_RHI_BACKEND is set to something we don't recognize. Change-Id: Ifa18cf38bc110e3a96b94fa89abac5bdfd70ba8a Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Liang Qi2019-12-171-0/+6
|\ | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/qml/jsruntime/qv4engine.cpp src/qml/parser/qqmljs.g Change-Id: I5f89199ef7a846032a3118cba1298de992c22f8f
| * rhi: Mark window as unused when neededLaszlo Agocs2019-12-111-0/+4
| | | | | | | | | | | | | | | | This is a bit more convoluted, but boils down to no-opengl + no-vulkan. Task-number: QTBUG-80692 Change-Id: I508116721ae8ea5013546f20ac89b67929305b52 Reviewed-by: Liang Qi <liang.qi@qt.io>
| * Fix unused var in no-opengl buildsLaszlo Agocs2019-12-111-0/+2
| | | | | | | | | | | | Change-Id: I9c436f408562faaf74e2301ae93e25a0c4e9b22e Fixes: QTBUG-80692 Reviewed-by: Johan Helsing <johan.helsing@qt.io>
* | Make the initialization failure dialog sensible with QRhiLaszlo Agocs2019-11-281-21/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So on Windows one now gets a message box with a reasonable message, instead of the OpenGL nonsense. Then the application closes when pressing Abort etc. On other platforms there is a qFatal, printing the same message. Involves simplifying the OpenGL version a bit since passing isES type of flags through multiple layers is not justified here. Task-number: QTBUG-80365 Change-Id: Ie3ea1e9395a283f7e95eda78c1d3894797ff0acf Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* | Fix Metal usage on iOSLaszlo Agocs2019-11-271-4/+4
| | | | | | | | | | | | | | | | Also enable the two Metal-specific scenegraph examples on iOS. Change-Id: I0e1e6d527544ea4a5bfb0d08ca2d32c762d3c699 Reviewed-by: Andy Nichols <andy.nichols@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | Avoid initializing QFlags with 0 or nullptrAllan Sandfeld Jensen2019-11-221-1/+1
|/ | | | | | | | | It is being deprecated. Change-Id: I844bd92af85bc53a8fc0371408d05277bd49f511 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add a QSG env var for QRhi::PreferSoftwareRendererLaszlo Agocs2019-09-271-5/+12
| | | | | | | | | Also extend the docs. And while we are at it get rid of some clang warnings. Task-number: QTBUG-78669 Change-Id: I4ef15d2d066098ba7bbbd34e80d4e61efe7fba23 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* Add an env var to periodically kill the device on d3dLaszlo Agocs2019-09-231-0/+8
| | | | | | | | | | | | | | | | | ...in order to test the handling of losing the device. The D3D11 backend of QRhi provides a convenient way to test this. Hook it up to a QSG_RHI_SIMULATE_DEVICE_LOSS environment variable. The value is the number of frames to wait before breaking the ID3D11Device. We cannot currently recover from a device loss. Hence the importance of being able to test in a simple way. The rhi code path needs to be brought up to the level of the direct OpenGL path in this respect, in separate patches. Change-Id: I66d6315dc60a9673903da9bed36de0cdd115f4a7 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* Expose renderpass from QSGRendererInterfaceLaszlo Agocs2019-09-081-3/+15
| | | | | | | Important for Vulkan and (upcoming) examples like vulkanunderqml. Change-Id: I5b6c978f38175eca76efe059aa83bb7158724752 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Fix not printing logs with QSG_INFO when forcing rhi backend from C++Laszlo Agocs2019-08-291-0/+13
| | | | | | | | | | | | | | | QQuickWindow::setScenegraphBackend() may be called before QQuickWindow gets a chance to create a render loop. If QSG_INFO (the env.var.) is used instead of the logging category (qt.scenegraph.general), some logs are not printed because the code that enables the logging category is not yet run. To prevent confusion, make sure the logging category gets enabled before the first potential qCDebug. In the worst case we check twice but that's fine. Change-Id: Ibfc0af05050adc9766c30a2d15c778b2a51823fe Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Change rhi-related debug prints to categorized loggingLaszlo Agocs2019-08-021-5/+6
| | | | | Change-Id: I4e8d3111a2f3b77e984756cc9eef49d42f0b647c Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Add the graphics api independent scenegraph portLaszlo Agocs2019-07-041-0/+567
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 <lars.knoll@qt.io>