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