Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qsgrhisupport_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSGRHISUPPORT_P_H
5#define QSGRHISUPPORT_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qsgrenderloop_p.h"
20
21#include <rhi/qrhi.h>
22
24
28
29// Opting in/out of QRhi and choosing the default/requested backend is managed
30// by this singleton. This is because this information may be needed before
31// creating a render loop. A well-written render loop sets up its QRhi and
32// related machinery using the helper functions in here.
33//
34// In addition, the class provides handy conversion and query stuff for the
35// renderloop and the QSGRendererInterface implementations.
36//
37class Q_QUICK_PRIVATE_EXPORT QSGRhiSupport
38{
39public:
40 static QSGRhiSupport *instance_internal();
41 static QSGRhiSupport *instance();
42 static int chooseSampleCount(int samples, QRhi *rhi);
43 static int chooseSampleCountForWindowWithRhi(QWindow *window, QRhi *rhi);
44 static QImage grabAndBlockInCurrentFrame(QRhi *rhi, QRhiCommandBuffer *cb, QRhiTexture *src = nullptr);
45 static void checkEnvQSgInfo();
46
47#if QT_CONFIG(opengl)
48 static QRhiTexture::Format toRhiTextureFormatFromGL(uint format);
49#endif
50
51#if QT_CONFIG(vulkan)
52 static QRhiTexture::Format toRhiTextureFormatFromVulkan(uint format, QRhiTexture::Flags *flags);
53#endif
54
55#if defined(Q_OS_WIN)
56 static QRhiTexture::Format toRhiTextureFormatFromDXGI(uint format, QRhiTexture::Flags *flags);
57#endif
58
59#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
60 static QRhiTexture::Format toRhiTextureFormatFromMetal(uint format, QRhiTexture::Flags *flags);
61#endif
62
63 void configure(QSGRendererInterface::GraphicsApi api);
64
65 QRhi::Implementation rhiBackend() const { return m_rhiBackend; }
66 QString rhiBackendName() const;
67 QSGRendererInterface::GraphicsApi graphicsApi() const;
68
69 QSurface::SurfaceType windowSurfaceType() const;
70
71 const void *rifResource(QSGRendererInterface::Resource res,
73 const QQuickWindow *w);
74
75 QOffscreenSurface *maybeCreateOffscreenSurface(QWindow *window);
78 bool own;
79 };
80 RhiCreateResult createRhi(QQuickWindow *window, QSurface *offscreenSurface);
81 void destroyRhi(QRhi *rhi, const QQuickGraphicsConfiguration &config);
82 void prepareWindowForRhi(QQuickWindow *window);
83
84 QImage grabOffscreen(QQuickWindow *window);
85#ifdef Q_OS_WEBOS
86 QImage grabOffscreenForProtectedContent(QQuickWindow *window);
87#endif
88
89 void applySwapChainFormat(QRhiSwapChain *scWithWindowSet, QQuickWindow *window);
90
91 QRhiTexture::Format toRhiTextureFormat(uint nativeFormat, QRhiTexture::Flags *flags) const;
92
93private:
95 void applySettings();
97 void preparePipelineCache(QRhi *rhi, QQuickWindow *window);
98 void finalizePipelineCache(QRhi *rhi, const QQuickGraphicsConfiguration &config);
99 struct {
100 bool valid = false;
102 } m_requested;
103 bool m_settingsApplied = false;
104 QRhi::Implementation m_rhiBackend = QRhi::Null;
105};
106
108
109#endif // QSGRHISUPPORT_P_H
\inmodule QtGui
Definition qimage.h:37
\inmodule QtGui
QQuickGraphicsConfiguration controls lower level graphics settings for the QQuickWindow.
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtGui
Definition qrhi.h:1614
\inmodule QtGui
Definition qrhi.h:1513
\inmodule QtGui
Definition qrhi.h:883
Format
Specifies the texture format.
Definition qrhi.h:902
\inmodule QtGui
Definition qrhi.h:1767
Implementation
Describes which graphics API-specific backend gets used by a QRhi instance.
Definition qrhi.h:1769
@ Null
Definition qrhi.h:1770
Resource
\value DeviceResource The resource is a pointer to the graphics device, when applicable.
GraphicsApi
\value Unknown An unknown graphics API is in use \value Software The Qt Quick 2D Renderer is in use \...
QSGRendererInterface::GraphicsApi api
QRhi::Implementation rhiBackend() const
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtGui
Definition qsurface.h:21
SurfaceType
The SurfaceType enum describes what type of surface this is.
Definition qsurface.h:30
\inmodule QtGui
Definition qwindow.h:63
Combined button and popup list for selecting options.
EGLConfig config
GLsizei samples
GLfloat GLfloat GLfloat w
[0]
GLenum src
GLbitfield flags
GLint GLsizei GLsizei GLenum format
GLuint res
static QRhiTexture::Format toRhiTextureFormat(QQuickShaderEffectSource::Format format)
void adjustToPlatformQuirks(QRhi::Implementation &impl)
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
unsigned int uint
Definition qtypes.h:29
aWidget window() -> setWindowTitle("New Window Title")
[2]