5#include <qpa/qplatformintegration.h>
6#include <private/qguiapplication_p.h>
9#include <QtGui/qoffscreensurface.h>
10#include <QtGui/private/qopenglcontext_p.h>
14#include <QtGui/private/qvulkandefaultinstance_p.h>
26void QBackingStoreRhiSupport::SwapchainData::reset()
29 delete renderPassDescriptor;
36 for (SwapchainData &
d : m_swapchains)
44 delete m_openGLFallbackSurface;
45 m_openGLFallbackSurface =
nullptr;
74 surface = QRhiGles2InitParams::newFallbackSurface(m_format);
76 params.fallbackSurface = surface;
91 qCDebug(lcQpaBackingStore,
"Failed to create a D3D11 device with default settings; "
92 "attempting to get a software rasterizer backed device instead");
97 QRhiD3D12InitParams
params;
101 qCDebug(lcQpaBackingStore,
"Failed to create a D3D12 device with default settings; "
102 "attempting to get a software rasterizer backed device instead");
117 qCDebug(lcQpaBackingStore,
"Metal does not seem to be supported. Falling back to OpenGL.");
126 QVulkanDefaultInstance::setFlag(QVulkanDefaultInstance::EnableValidation);
129 if (!m_window->vulkanInstance())
130 m_window->setVulkanInstance(QVulkanDefaultInstance::instance());
131 params.inst = m_window->vulkanInstance();
133 params.inst = QVulkanDefaultInstance::instance();
136 qWarning(
"No QVulkanInstance set for the top-level window, this is wrong.");
145 qWarning(
"Failed to create QRhi for QBackingStoreRhiSupport");
151 m_openGLFallbackSurface = surface;
159 return it.value().swapchain;
164 QRhiSwapChain::Flags
flags;
166 if (
format.swapInterval() == 0)
168 if (
format.alphaBufferSize() > 0)
172 window->setVulkanInstance(QVulkanDefaultInstance::instance());
174 qCDebug(lcQpaBackingStore) <<
"Creating swapchain for window" <<
window;
181 qWarning(
"Failed to create swapchain for window flushed with an RHI-enabled backingstore");
188 d.swapchain = swapchain;
192 window->installEventFilter(
d.windowWatcher);
205 if (
it != m_rhiSupport->m_swapchains.
end()) {
206 qCDebug(lcQpaBackingStore) <<
event <<
"received for" <<
window <<
"- cleaning up swapchain";
208 m_rhiSupport->m_swapchains.
erase(
it);
262 static bool checked =
false;
275#elif QT_CONFIG(metal)
277#elif QT_CONFIG(opengl)
279#elif QT_CONFIG(vulkan)
282 qWarning(
"QT_WIDGETS_RHI is set but no backend is available; ignoring");
310 config.setDebugLayer(
true);
313 qCDebug(lcQpaBackingStore) <<
"Check for forced use of QRhi resulted in enable"
bool eventFilter(QObject *obj, QEvent *ev) override
Filters events if this object has been installed as an event filter for the watched object.
static QSurface::SurfaceType surfaceTypeForConfig(const QPlatformBackingStoreRhiConfig &config)
static bool checkForceRhi(QPlatformBackingStoreRhiConfig *outConfig, QSurface::SurfaceType *outType)
friend class QBackingStoreRhiSupportWindowWatcher
QRhiSwapChain * swapChainForWindow(QWindow *window)
static QRhi::Implementation apiToRhiBackend(QPlatformBackingStoreRhiConfig::Api api)
@ WindowAboutToChangeInternal
static QPlatformIntegration * platformIntegration()
const_iterator constFind(const Key &key) const noexcept
const_iterator constEnd() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
virtual QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor()=0
virtual bool createOrResize()=0
Creates the swapchain if not already done and resizes the swapchain buffers to match the current size...
@ SurfaceHasNonPreMulAlpha
void setFlags(Flags f)
Sets the flags f.
QRhiRenderPassDescriptor * renderPassDescriptor() const
void setWindow(QWindow *window)
Sets the window.
void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc)
Associates with the QRhiRenderPassDescriptor desc.
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Implementation
Describes which graphics API-specific backend gets used by a QRhi instance.
QRhiSwapChain * newSwapChain()
const char * backendName() const
static bool probe(Implementation impl, QRhiInitParams *params)
static QRhi * create(Implementation impl, QRhiInitParams *params, Flags flags={}, QRhiNativeHandles *importDevice=nullptr)
iterator erase(const_iterator i)
iterator find(const T &value)
\macro QT_RESTRICTED_CAST_FROM_ASCII
SurfaceType
The SurfaceType enum describes what type of surface this is.
QSurfaceFormat format() const override
Returns the actual format of this window.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
QOpenGLContext * qt_gl_global_share_context()
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei GLsizei GLenum format
#define QStringLiteral(str)
QString qEnvironmentVariable(const char *varName, const QString &defaultValue)
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
QWindow * qobject_cast< QWindow * >(QObject *o)
QNetworkRequestFactory api
[0]