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;
61 surface = QRhiGles2InitParams::newFallbackSurface(m_format);
63 params.fallbackSurface = surface;
78 qCDebug(lcQpaBackingStore,
"Failed to create a D3D device with default settings; "
79 "attempting to get a software rasterizer backed device instead");
84 QRhiD3D12InitParams
params;
91#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
98 qCDebug(lcQpaBackingStore,
"Metal does not seem to be supported. Falling back to OpenGL.");
107 QVulkanDefaultInstance::setFlag(QVulkanDefaultInstance::EnableValidation);
110 if (!m_window->vulkanInstance())
111 m_window->setVulkanInstance(QVulkanDefaultInstance::instance());
112 params.inst = m_window->vulkanInstance();
114 params.inst = QVulkanDefaultInstance::instance();
117 qWarning(
"No QVulkanInstance set for the top-level window, this is wrong.");
126 qWarning(
"Failed to create QRhi for QBackingStoreRhiSupport");
132 m_openGLFallbackSurface = surface;
140 return it.value().swapchain;
145 QRhiSwapChain::Flags
flags;
147 if (
format.swapInterval() == 0)
149 if (
format.alphaBufferSize() > 0)
153 window->setVulkanInstance(QVulkanDefaultInstance::instance());
155 qCDebug(lcQpaBackingStore) <<
"Creating swapchain for window" <<
window;
162 qWarning(
"Failed to create swapchain for window flushed with an RHI-enabled backingstore");
169 d.swapchain = swapchain;
170 d.renderPassDescriptor = rp;
173 window->installEventFilter(
d.windowWatcher);
185 if (
it != m_rhiSupport->m_swapchains.
end()) {
186 qCDebug(lcQpaBackingStore) <<
"SurfaceAboutToBeDestroyed received for tracked window" <<
window <<
"cleaning up swapchain";
188 m_rhiSupport->m_swapchains.
erase(
it);
242 static bool checked =
false;
255#elif defined(Q_OS_MACOS) || defined(Q_OS_IOS)
257#elif QT_CONFIG(opengl)
259#elif QT_CONFIG(vulkan)
262 qWarning(
"QT_WIDGETS_RHI is set but no backend is available; ignoring");
275#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
290 config.setDebugLayer(
true);
293 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)
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 ...
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
iterator erase(const_iterator it)
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
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.
void setWindow(QWindow *window)
Sets the window.
void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc)
Associates with the QRhiRenderPassDescriptor desc.
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)
\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)