574\l {Scene Graph - Metal Texture Import} example.
575
576\section3 The inline approach
577
578Using \l QSGRenderNode the custom draw calls are injected not at the beginning
579or the end of the recording of the scene graph's render pass, but rather during
580the scene graph's rendering process. This is achieved by creating a custom \l
581QQuickItem based by an instance of \l QSGRenderNode, a scene graph node that
582exists specifically to allow issuing graphics commands either via \l QRhi or a
583native 3D API such as OpenGL, Vulkan, Metal, or Direct 3D.
584
585The \l {Scene Graph - Custom QSGRenderNode} example gives a demonstration of
586this approach.
587
588\section2 Custom Items using QPainter
589
590The QQuickItem provides a subclass, QQuickPaintedItem, which allows
591the users to render content using QPainter.
592
593\warning Using QQuickPaintedItem uses an indirect 2D surface to render
594its content, either using software rasterization or using an OpenGL
595framebuffer object (FBO), so the rendering is a two-step
596operation. First rasterize the surface, then draw the surface. Using
597scene graph API directly is always significantly faster.
598
599\section1 Logging Support
600
601The scene graph has support for a number of logging categories. These
602can be useful in tracking down both performance issues and bugs in
603addition to being helpful to Qt contributors.
604
605\list
606
607\li \c {qt.scenegraph.time.texture} - logs the time spent doing texture uploads
608
609\li \c {qt.scenegraph.time.compilation} - logs the time spent doing shader compilation
610
611\li \c {qt.scenegraph.time.renderer} - logs the time spent in the various steps of the renderer
612
613\li \c {qt.scenegraph.time.renderloop} - logs the time spent in the various
614steps of the render loop. With the \c threaded render loop this gives an
615insight into the time elapsed between the various frame preparation steps both
616on the GUI and the render thread. It can therefore also be a useful
617troubleshooting tool, for example, to confirm how vsync-based throttling and
618other low-level Qt enablers, such as QWindow::requestUpdate(), affect the
619rendering and presentation pipeline.
620
621\li \c {qt.scenegraph.time.glyph} - logs the time spent preparing distance field glyphs
622
623\li \c {qt.scenegraph.general} - logs general information about various parts of the scene graph and the graphics stack
624
625\li \c {qt.scenegraph.renderloop} - creates a detailed log of the various stages involved in rendering. This log mode is primarily useful for developers working on Qt.
626
627\endlist
628
629The legacy \c{QSG_INFO} environment variable is also available. Setting it to a
630non-zero value enables the \c{qt.scenegraph.general} category.
631
632\note When encountering graphics problems, or when in doubt which render loop
633or graphics API is in use, always start the application with at least
634\c{qt.scenegraph.general} and \c{qt.rhi.*} enabled, or \c{QSG_INFO=1} set. This
635will then print some essential information onto the debug output during
636initialization.
637
638\section1 Scene Graph Backend
639
640In addition to the public API, the scene graph has an adaptation layer
641which opens up the implementation to do hardware specific
642adaptations. This is an undocumented, internal and private plugin API,
643which lets hardware adaptation teams make the most of their hardware.
644It includes:
645
646\list
647
648\li Custom textures; specifically the implementation of
649QQuickWindow::createTextureFromImage and the internal representation
650of the texture used by \l Image and \l BorderImage types.
651
652\li Custom renderer; the adaptation layer lets the plugin decide how
653the scene graph is traversed and rendered, making it possible to
654optimize the rendering algorithm for a specific hardware or to make
655use of extensions which improve performance.
656
657\li Custom scene graph implementation of many of the default QML
658types, including its text and font rendering.
659
660\li Custom animation driver; allows the animation system to hook
661into the low-level display vertical refresh to get smooth rendering.
662
663\li Custom render loop; allows better control over how QML deals