diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-12-12 01:00:07 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-12-12 10:06:06 +0100 |
commit | 1196b1ef6c5d2cb05ceba5d6f178dc7e2432ed61 (patch) | |
tree | 2a99ee28d15d8ee51fc28096e5559bfc2d453e3f /src/quick/scenegraph | |
parent | fb54af6638dcbeae8ad21249fe234ef4d82c005b (diff) | |
parent | ca206bceaff3667469986402e6143bf4c666b228 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
src/qml/types/qqmlbind.cpp
Change-Id: Ib992d1a7ac6c1a96d39819be6f23955dc31b44b2
Diffstat (limited to 'src/quick/scenegraph')
79 files changed, 177 insertions, 106 deletions
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp index 7b5ee66df6..f1d0e28fc8 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp @@ -206,12 +206,12 @@ QSGRendererInterface::ShaderType QSGSoftwareContext::shaderType() const QSGRendererInterface::ShaderCompilationTypes QSGSoftwareContext::shaderCompilationType() const { - return nullptr; + return {}; } QSGRendererInterface::ShaderSourceTypes QSGSoftwareContext::shaderSourceType() const { - return nullptr; + return {}; } void *QSGSoftwareContext::getResource(QQuickWindow *window, Resource resource) const diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp index da5d39db20..214f7d790b 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp @@ -465,7 +465,7 @@ void QSGSoftwareInternalImageNode::paint(QPainter *painter) m_targetRect.right() - m_innerTargetRect.right(), m_targetRect.bottom() - m_innerTargetRect.bottom()); QSGSoftwareHelpers::QTileRules tilerules(getTileRule(m_subSourceRect.width()), getTileRule(m_subSourceRect.height())); QSGSoftwareHelpers::qDrawBorderPixmap(painter, m_targetRect.toRect(), margins, pm, QRect(0, 0, pm.width(), pm.height()), - margins, tilerules, QSGSoftwareHelpers::QDrawBorderPixmap::DrawingHints(nullptr)); + margins, tilerules, QSGSoftwareHelpers::QDrawBorderPixmap::DrawingHints{}); return; } diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarepublicnodes.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarepublicnodes.cpp index 141d8f3c6d..a10a94125c 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarepublicnodes.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarepublicnodes.cpp @@ -205,7 +205,7 @@ void QSGSoftwareNinePatchNode::paint(QPainter *painter) painter->drawPixmap(m_bounds, m_pixmap, QRectF(0, 0, m_pixmap.width(), m_pixmap.height())); else QSGSoftwareHelpers::qDrawBorderPixmap(painter, m_bounds.toRect(), m_margins, m_pixmap, QRect(0, 0, m_pixmap.width(), m_pixmap.height()), - m_margins, Qt::StretchTile, QSGSoftwareHelpers::QDrawBorderPixmap::DrawingHints(nullptr)); + m_margins, Qt::StretchTile, QSGSoftwareHelpers::QDrawBorderPixmap::DrawingHints{}); } QRectF QSGSoftwareNinePatchNode::bounds() const diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp b/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp index 1a8bddaa6e..65abb2a1af 100644 --- a/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp +++ b/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp @@ -296,7 +296,7 @@ void QSGCompressedTexturePrivate::updateRhiTexture(QRhi *rhi, QRhiResourceUpdate return; } - QRhiTexture::Flags texFlags = 0; + QRhiTexture::Flags texFlags; if (fmt.second) texFlags |= QRhiTexture::sRGB; diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 45b00d43c4..9ccf483622 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -546,7 +546,7 @@ void Updater::visitNode(Node *n) m_added = count; m_force_update = force; - n->dirtyState = nullptr; + n->dirtyState = {}; } void Updater::visitClipNode(Node *n) @@ -2627,7 +2627,7 @@ QRhiGraphicsPipeline *Renderer::buildStencilPipeline(const Batch *batch, bool fi QRhiGraphicsPipeline *ps = m_rhi->newGraphicsPipeline(); ps->setFlags(QRhiGraphicsPipeline::UsesStencilRef); QRhiGraphicsPipeline::TargetBlend blend; - blend.colorWrite = 0; + blend.colorWrite = {}; ps->setTargetBlends({ blend }); ps->setSampleCount(renderTarget()->sampleCount()); ps->setStencilTest(true); @@ -3257,7 +3257,7 @@ bool Renderer::ensurePipelineState(Element *e, const ShaderManager::Shader *sms) ps->setShaderResourceBindings(e->srb); ps->setRenderPassDescriptor(renderPassDescriptor()); - QRhiGraphicsPipeline::Flags flags = 0; + QRhiGraphicsPipeline::Flags flags; if (needsBlendConstant(m_gstate.srcColor) || needsBlendConstant(m_gstate.dstColor)) flags |= QRhiGraphicsPipeline::UsesBlendConstants; if (m_gstate.usesScissor) diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.cpp b/src/quick/scenegraph/coreapi/qsgmaterial.cpp index c8ae26311b..087c3c4cbf 100644 --- a/src/quick/scenegraph/coreapi/qsgmaterial.cpp +++ b/src/quick/scenegraph/coreapi/qsgmaterial.cpp @@ -153,7 +153,6 @@ static void qt_print_material_count() */ QSGMaterial::QSGMaterial() - : m_flags(nullptr) { Q_UNUSED(m_reserved); #ifndef QT_NO_DEBUG diff --git a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp b/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp index 117d477f9a..c5cbd0c979 100644 --- a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp +++ b/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp @@ -97,14 +97,14 @@ static inline QRhiShaderResourceBinding::StageFlags toSrbStage(QShader::Stage st Q_UNREACHABLE(); break; } - return 0; + return { }; } void QSGMaterialRhiShaderPrivate::prepare(QShader::Variant vertexShaderVariant) { ubufBinding = -1; ubufSize = 0; - ubufStages = 0; + ubufStages = { }; memset(combinedImageSamplerBindings, 0, sizeof(combinedImageSamplerBindings)); vertexShader = fragmentShader = nullptr; masterUniformData.clear(); @@ -319,7 +319,7 @@ bool QSGMaterialRhiShader::updateUniformData(RenderState &state, each variable in the material's shaders' \l{QShaderDescription::combinedImageSamplers()}. - When \c{*texture} is null, it must be set to a QSGTexture pointer before + When *\a{texture} is null, it must be set to a QSGTexture pointer before returning. When non-null, it is up to the material to decide if a new \c{QSGTexture *} is stored to it, or if it updates some parameters on the already known QSGTexture. The ownership of the QSGTexture is not diff --git a/src/quick/scenegraph/coreapi/qsgnode.cpp b/src/quick/scenegraph/coreapi/qsgnode.cpp index 7d9b74bc2b..a35629d874 100644 --- a/src/quick/scenegraph/coreapi/qsgnode.cpp +++ b/src/quick/scenegraph/coreapi/qsgnode.cpp @@ -245,7 +245,6 @@ static void qt_print_node_count() */ QSGNode::QSGNode() : m_nodeFlags(OwnedByParent) - , m_dirtyState(nullptr) { init(); } @@ -264,7 +263,6 @@ QSGNode::QSGNode(NodeType type) , m_previousSibling(nullptr) , m_subtreeRenderableCount(type == GeometryNodeType || type == RenderNodeType ? 1 : 0) , m_nodeFlags(OwnedByParent) - , m_dirtyState(nullptr) { init(); } @@ -283,7 +281,6 @@ QSGNode::QSGNode(QSGNodePrivate &dd, NodeType type) , m_previousSibling(nullptr) , m_subtreeRenderableCount(type == GeometryNodeType || type == RenderNodeType ? 1 : 0) , m_nodeFlags(OwnedByParent) - , m_dirtyState(nullptr) , d_ptr(&dd) { init(); diff --git a/src/quick/scenegraph/coreapi/qsgnode.h b/src/quick/scenegraph/coreapi/qsgnode.h index cb677de030..5a7faed5e0 100644 --- a/src/quick/scenegraph/coreapi/qsgnode.h +++ b/src/quick/scenegraph/coreapi/qsgnode.h @@ -146,7 +146,7 @@ public: QT_DEPRECATED void clearDirty() { } void markDirty(DirtyState bits); - QT_DEPRECATED DirtyState dirtyState() const { return nullptr; } + QT_DEPRECATED DirtyState dirtyState() const { return { }; } virtual bool isSubtreeBlocked() const; diff --git a/src/quick/scenegraph/coreapi/qsgopenglvisualizer.cpp b/src/quick/scenegraph/coreapi/qsgopenglvisualizer.cpp index 6c2ff0b176..9282b6c308 100644 --- a/src/quick/scenegraph/coreapi/qsgopenglvisualizer.cpp +++ b/src/quick/scenegraph/coreapi/qsgopenglvisualizer.cpp @@ -202,7 +202,7 @@ void OpenGLVisualizer::visualizeChanges(Node *n) // This is because many changes don't propegate their dirty state to the // parent so the node updater will not unset these states. They are // not used for anything so, unsetting it should have no side effects. - n->dirtyState = nullptr; + n->dirtyState = {}; } SHADOWNODE_TRAVERSE(n) { diff --git a/src/quick/scenegraph/coreapi/qsgrendernode.cpp b/src/quick/scenegraph/coreapi/qsgrendernode.cpp index 2892f2f966..63878954bf 100644 --- a/src/quick/scenegraph/coreapi/qsgrendernode.cpp +++ b/src/quick/scenegraph/coreapi/qsgrendernode.cpp @@ -131,7 +131,7 @@ QSGRenderNodePrivate::QSGRenderNodePrivate() */ QSGRenderNode::StateFlags QSGRenderNode::changedStates() const { - return nullptr; + return {}; } /*! @@ -311,7 +311,7 @@ void QSGRenderNode::releaseResources() */ QSGRenderNode::RenderingFlags QSGRenderNode::flags() const { - return nullptr; + return {}; } /*! diff --git a/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp b/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp index 38d4c4440f..a0131a3f67 100644 --- a/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp +++ b/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp @@ -400,7 +400,7 @@ void RhiVisualizer::ChangeVis::gather(Node *n) // This is because many changes don't propegate their dirty state to the // parent so the node updater will not unset these states. They are // not used for anything so, unsetting it should have no side effects. - n->dirtyState = nullptr; + n->dirtyState = { }; } SHADOWNODE_TRAVERSE(n) { diff --git a/src/quick/scenegraph/coreapi/qsgtexture.cpp b/src/quick/scenegraph/coreapi/qsgtexture.cpp index edcee96bdb..58b42e4094 100644 --- a/src/quick/scenegraph/coreapi/qsgtexture.cpp +++ b/src/quick/scenegraph/coreapi/qsgtexture.cpp @@ -395,6 +395,9 @@ QSGTexture::~QSGTexture() Binding a texture may also include uploading the texture data from a previously set QImage. + \warning This function should only be called when running with the + direct OpenGL rendering path. + \warning This function can only be called from the rendering thread. */ @@ -701,8 +704,8 @@ void QSGTexture::updateBindOptions(bool force) // legacy (GL-only) data (for example, because there was no setImage() since the last call to this function), the function does nothing. - Materials involving textures are expected to call this function from their - updateSampledImage() implementation, typically without any conditions. + Materials involving \a rhi textures are expected to call this function from + their updateSampledImage() implementation, typically without any conditions. \note This function is only used when running the graphics API independent rendering path of the scene graph. diff --git a/src/quick/scenegraph/qsgcontextplugin.cpp b/src/quick/scenegraph/qsgcontextplugin.cpp index 66add51c55..7dfb8488ae 100644 --- a/src/quick/scenegraph/qsgcontextplugin.cpp +++ b/src/quick/scenegraph/qsgcontextplugin.cpp @@ -87,7 +87,6 @@ struct QSGAdaptationBackendData }; QSGAdaptationBackendData::QSGAdaptationBackendData() - : flags(nullptr) { // Fill in the table with the built-in adaptations. builtIns.append(new QSGSoftwareAdaptation); diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index f609055677..fb460f28d6 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -195,8 +195,16 @@ public: bool eventFilter(QObject *watched, QEvent *event) override; struct WindowData { + WindowData() + : updatePending(false), + grabOnly(false), + rhiDeviceLost(false), + rhiDoomed(false) + { } bool updatePending : 1; bool grabOnly : 1; + bool rhiDeviceLost : 1; + bool rhiDoomed : 1; }; QHash<QQuickWindow *, WindowData> m_windows; @@ -316,15 +324,19 @@ void QSGRenderLoop::setInstance(QSGRenderLoop *instance) s_instance = instance; } -void QSGRenderLoop::handleContextCreationFailure(QQuickWindow *window, - bool isEs) +void QSGRenderLoop::handleContextCreationFailure(QQuickWindow *window) { QString translatedMessage; QString untranslatedMessage; - QQuickWindowPrivate::contextCreationFailureMessage(window->requestedFormat(), + if (QSGRhiSupport::instance()->isRhiEnabled()) { + QQuickWindowPrivate::rhiCreationFailureMessage(QSGRhiSupport::instance()->rhiBackendName(), &translatedMessage, - &untranslatedMessage, - isEs); + &untranslatedMessage); + } else { + QQuickWindowPrivate::contextCreationFailureMessage(window->requestedFormat(), + &translatedMessage, + &untranslatedMessage); + } // If there is a slot connected to the error signal, emit it and leave it to // the application to do something with the message. If nothing is connected, // show a message on our own and terminate. @@ -362,10 +374,7 @@ QSGGuiThreadRenderLoop::~QSGGuiThreadRenderLoop() void QSGGuiThreadRenderLoop::show(QQuickWindow *window) { - WindowData data; - data.updatePending = false; - data.grabOnly = false; - m_windows[window] = data; + m_windows[window] = WindowData(); maybeUpdate(window); } @@ -451,8 +460,10 @@ void QSGGuiThreadRenderLoop::handleDeviceLoss() rc->invalidate(); - for (auto it = m_windows.constBegin(), itEnd = m_windows.constEnd(); it != itEnd; ++it) + for (auto it = m_windows.begin(), itEnd = m_windows.end(); it != itEnd; ++it) { releaseSwapchain(it.key()); + it->rhiDeviceLost = true; + } delete rhi; rhi = nullptr; @@ -508,6 +519,13 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) const bool enableRhi = rhiSupport->isRhiEnabled(); if (enableRhi && !rhi) { + // This block below handles both the initial QRhi initialization and + // also the subsequent reinitialization attempts after a device lost + // (reset) situation. + + if (data.rhiDoomed) // no repeated attempts if the initial attempt failed + return; + if (!offscreenSurface) offscreenSurface = rhiSupport->maybeCreateOffscreenSurface(window); @@ -517,6 +535,8 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) if (rhiSupport->isProfilingRequested()) QSGRhiProfileConnection::instance()->initialize(rhi); + data.rhiDeviceLost = false; + current = true; rhi->makeThreadLocalNativeContextCurrent(); @@ -533,7 +553,11 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) rcParams.maybeSurface = window; cd->context->initialize(&rcParams); } else { - handleContextCreationFailure(window, false); + if (!data.rhiDeviceLost) { + data.rhiDoomed = true; + handleContextCreationFailure(window); + } + // otherwise no error, will retry on a subsequent rendering attempt } } else if (!enableRhi && !gl) { gl = new QOpenGLContext(); @@ -542,10 +566,9 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) if (qt_gl_global_share_context()) gl->setShareContext(qt_gl_global_share_context()); if (!gl->create()) { - const bool isEs = gl->isOpenGLES(); delete gl; gl = nullptr; - handleContextCreationFailure(window, isEs); + handleContextCreationFailure(window); } else { if (!offscreenSurface) { offscreenSurface = new QOffscreenSurface; @@ -619,7 +642,7 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) i++; } - // Check for context loss. + // Check for context loss. (legacy GL only) if (!current && !rhi && !gl->isValid()) { for (auto it = m_windows.constBegin() ; it != m_windows.constEnd(); it++) { QQuickWindowPrivate *windowPrivate = QQuickWindowPrivate::get(it.key()); @@ -747,7 +770,7 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) const bool needsPresent = alsoSwap && window->isVisible(); if (cd->swapchain) { - QRhi::EndFrameFlags flags = 0; + QRhi::EndFrameFlags flags; if (!needsPresent) flags |= QRhi::SkipPresent; QRhi::FrameOpResult frameResult = rhi->endFrame(cd->swapchain, flags); diff --git a/src/quick/scenegraph/qsgrenderloop_p.h b/src/quick/scenegraph/qsgrenderloop_p.h index 02d0b84de1..9fd0ab02f5 100644 --- a/src/quick/scenegraph/qsgrenderloop_p.h +++ b/src/quick/scenegraph/qsgrenderloop_p.h @@ -112,12 +112,11 @@ public: static void cleanup(); + void handleContextCreationFailure(QQuickWindow *window); + Q_SIGNALS: void timeToIncubate(); -protected: - void handleContextCreationFailure(QQuickWindow *window, bool isEs); - private: static QSGRenderLoop *s_instance; diff --git a/src/quick/scenegraph/qsgrhilayer.cpp b/src/quick/scenegraph/qsgrhilayer.cpp index 757410eded..952279a3ff 100644 --- a/src/quick/scenegraph/qsgrhilayer.cpp +++ b/src/quick/scenegraph/qsgrhilayer.cpp @@ -388,7 +388,7 @@ void QSGRhiLayer::grab() m_mirrorHorizontal ? -m_rect.width() : m_rect.width(), m_mirrorVertical ? m_rect.height() : -m_rect.height()); } - QSGAbstractRenderer::MatrixTransformFlags matrixFlags = 0; + QSGAbstractRenderer::MatrixTransformFlags matrixFlags; if (!m_rhi->isYUpInNDC()) matrixFlags |= QSGAbstractRenderer::MatrixTransformFlipY; m_renderer->setProjectionMatrixToRect(mirrored, matrixFlags); diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp index 12c6742342..afcfa53e83 100644 --- a/src/quick/scenegraph/qsgrhisupport.cpp +++ b/src/quick/scenegraph/qsgrhisupport.cpp @@ -159,7 +159,7 @@ void QSGRhiSupport::applySettings() } else { #if defined(Q_OS_WIN) m_rhiBackend = QRhi::D3D11; -#elif defined(Q_OS_DARWIN) +#elif defined(Q_OS_MACOS) || defined(Q_OS_IOS) m_rhiBackend = QRhi::Metal; #else m_rhiBackend = QRhi::OpenGLES2; @@ -185,29 +185,10 @@ void QSGRhiSupport::applySettings() if (m_killDeviceFrameCount > 0 && m_rhiBackend == QRhi::D3D11) qDebug("Graphics device will be reset every %d frames", m_killDeviceFrameCount); - const char *backendName = "unknown"; - switch (m_rhiBackend) { - case QRhi::Null: - backendName = "Null"; - break; - case QRhi::Vulkan: - backendName = "Vulkan"; - break; - case QRhi::OpenGLES2: - backendName = "OpenGL"; - break; - case QRhi::D3D11: - backendName = "D3D11"; - break; - case QRhi::Metal: - backendName = "Metal"; - break; - default: - break; - } + const QString backendName = rhiBackendName(); qCDebug(QSG_LOG_INFO, "Using QRhi with backend %s\n graphics API debug/validation layers: %d\n QRhi profiling and debug markers: %d", - backendName, m_debugLayer, m_profile); + qPrintable(backendName), m_debugLayer, m_profile); if (m_preferSoftwareRenderer) qCDebug(QSG_LOG_INFO, "Prioritizing software renderers"); } @@ -247,6 +228,27 @@ QSGRhiSupport *QSGRhiSupport::instance() return inst; } +QString QSGRhiSupport::rhiBackendName() const +{ + if (m_enableRhi) { + switch (m_rhiBackend) { + case QRhi::Null: + return QLatin1String("Null"); + case QRhi::Vulkan: + return QLatin1String("Vulkan"); + case QRhi::OpenGLES2: + return QLatin1String("OpenGL"); + case QRhi::D3D11: + return QLatin1String("D3D11"); + case QRhi::Metal: + return QLatin1String("Metal"); + default: + return QLatin1String("Unknown"); + } + } + return QLatin1String("Unknown (RHI not enabled)"); +} + QSGRendererInterface::GraphicsApi QSGRhiSupport::graphicsApi() const { if (!m_enableRhi) @@ -350,7 +352,7 @@ static const void *qsgrhi_d3d11_rifResource(QSGRendererInterface::Resource res, } #endif -#ifdef Q_OS_DARWIN +#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) static const void *qsgrhi_mtl_rifResource(QSGRendererInterface::Resource res, const QRhiNativeHandles *nat, const QRhiNativeHandles *cbNat) { @@ -408,7 +410,7 @@ const void *QSGRhiSupport::rifResource(QSGRendererInterface::Resource res, const case QRhi::D3D11: return qsgrhi_d3d11_rifResource(res, nat); #endif -#ifdef Q_OS_DARWIN +#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) case QRhi::Metal: { QRhiCommandBuffer *cb = rc->currentFrameCommandBuffer(); @@ -465,7 +467,7 @@ QRhi *QSGRhiSupport::createRhi(QWindow *window, QOffscreenSurface *offscreenSurf { QRhi *rhi = nullptr; - QRhi::Flags flags = 0; + QRhi::Flags flags; if (isProfilingRequested()) flags |= QRhi::EnableProfiling | QRhi::EnableDebugMarkers; if (isSoftwareRendererRequested()) @@ -507,7 +509,7 @@ QRhi *QSGRhiSupport::createRhi(QWindow *window, QOffscreenSurface *offscreenSurf rhi = QRhi::create(backend, &rhiParams, flags); } #endif -#ifdef Q_OS_DARWIN +#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) if (backend == QRhi::Metal) { QRhiMetalInitParams rhiParams; rhi = QRhi::create(backend, &rhiParams, flags); diff --git a/src/quick/scenegraph/qsgrhisupport_p.h b/src/quick/scenegraph/qsgrhisupport_p.h index d008ecd0af..0a95a09ad2 100644 --- a/src/quick/scenegraph/qsgrhisupport_p.h +++ b/src/quick/scenegraph/qsgrhisupport_p.h @@ -70,7 +70,7 @@ #include <QtGui/private/qrhid3d11_p.h> #endif -#ifdef Q_OS_DARWIN +#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) #include <QtGui/private/qrhimetal_p.h> #endif @@ -109,6 +109,7 @@ public: bool isRhiEnabled() const { return m_enableRhi; } QRhi::Implementation rhiBackend() const { return m_rhiBackend; } + QString rhiBackendName() const; QSGRendererInterface::GraphicsApi graphicsApi() const; bool isDebugLayerRequested() const { return m_debugLayer; } diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index dc1f97de54..a213c6efd4 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -368,6 +368,9 @@ public: QSize windowSize; float dpr = 1; int rhiSampleCount = 1; + bool rhiDeviceLost = false; + bool rhiDoomed = false; + bool guiNotifiedAboutRhiFailure = false; // Local event queue stuff... bool stopEventProcessing; @@ -622,13 +625,15 @@ void QSGRenderThread::sync(bool inExpose, bool inGrab) sgrc->initialize(&rcParams); } } - } else { + } else if (rhi) { // With the rhi making the (OpenGL) context current serves only one // purpose: to enable external OpenGL rendering connected to one of // the QQuickWindow signals (beforeSynchronizing, beforeRendering, // etc.) to function like it did on the direct OpenGL path. For our // own rendering this call would not be necessary. rhi->makeThreadLocalNativeContextCurrent(); + } else { + current = false; } if (current) { QQuickWindowPrivate *d = QQuickWindowPrivate::get(window); @@ -669,6 +674,7 @@ void QSGRenderThread::handleDeviceLoss() QQuickWindowPrivate::get(window)->cleanupNodesOnShutdown(); sgrc->invalidate(); wm->releaseSwapchain(window); + rhiDeviceLost = true; delete rhi; rhi = nullptr; } @@ -693,8 +699,9 @@ void QSGRenderThread::syncAndRender(QImage *grabImage) const bool repaintRequested = (pendingUpdate & RepaintRequest) || d->customRenderStage || grabImage; const bool syncRequested = (pendingUpdate & SyncRequest) || grabImage; const bool exposeRequested = (pendingUpdate & ExposeRequest) == ExposeRequest; - pendingUpdate = 0; const bool grabRequested = grabImage != nullptr; + if (!grabRequested) + pendingUpdate = 0; QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window); // Begin the frame before syncing -> sync is where we may invoke @@ -770,30 +777,40 @@ void QSGRenderThread::syncAndRender(QImage *grabImage) Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame, QQuickProfiler::SceneGraphRenderLoopSync); - if (!syncResultedInChanges && !repaintRequested && sgrc->isValid() && !grabImage) { - if (gl || !rhi->isRecordingFrame()) { - qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- no changes, render aborted"); - int waitTime = vsyncDelta - (int) waitTimer.elapsed(); - if (waitTime > 0) - msleep(waitTime); - return; - } + if (!syncResultedInChanges + && !repaintRequested + && !(pendingUpdate & RepaintRequest) // may have been set in sync() + && sgrc->isValid() + && !grabRequested + && (gl || (rhi && !rhi->isRecordingFrame()))) + { + qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- no changes, render aborted"); + int waitTime = vsyncDelta - (int) waitTimer.elapsed(); + if (waitTime > 0) + msleep(waitTime); + return; } qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- rendering started"); + // RepaintRequest may have been set in pendingUpdate in an + // updatePaintNode() invoked from sync(). We are about to do a repaint + // right now, so reset the flag. (bits other than RepaintRequest cannot + // be set in pendingUpdate at this point) + if (!grabRequested) + pendingUpdate = 0; - if (animatorDriver->isRunning() && !grabImage) { + if (animatorDriver->isRunning() && !grabRequested) { d->animationController->lock(); animatorDriver->advance(); d->animationController->unlock(); } bool current = true; - if (d->renderer && windowSize.width() > 0 && windowSize.height() > 0) { + if (d->renderer && windowSize.width() > 0 && windowSize.height() > 0 && (gl || rhi)) { if (gl) current = gl->makeCurrent(window); - else if (rhi) + else rhi->makeThreadLocalNativeContextCurrent(); } else { current = false; @@ -818,14 +835,14 @@ void QSGRenderThread::syncAndRender(QImage *grabImage) // blocking in a real frame. The legacy GL path never gets here with // grabs as it rather invokes sync/render directly without going // through syncAndRender(). - if (grabImage) { + if (grabRequested) { Q_ASSERT(rhi && !gl && cd->swapchain); *grabImage = QSGRhiSupport::instance()->grabAndBlockInCurrentFrame(rhi, cd->swapchain); } if (cd->swapchain) { - QRhi::EndFrameFlags flags = 0; - if (grabImage) + QRhi::EndFrameFlags flags; + if (grabRequested) flags |= QRhi::SkipPresent; QRhi::FrameOpResult frameResult = rhi->endFrame(cd->swapchain, flags); if (frameResult != QRhi::FrameOpSuccess) { @@ -841,7 +858,7 @@ void QSGRenderThread::syncAndRender(QImage *grabImage) gl->swapBuffers(window); } - if (!grabImage) + if (!grabRequested) d->fireFrameSwapped(); } else { @@ -912,14 +929,21 @@ void QSGRenderThread::processEventsAndWaitForMore() void QSGRenderThread::ensureRhi() { if (!rhi) { + if (rhiDoomed) // no repeated attempts if the initial attempt failed + return; QSGRhiSupport *rhiSupport = QSGRhiSupport::instance(); rhi = rhiSupport->createRhi(window, offscreenSurface); if (rhi) { + rhiDeviceLost = false; rhiSampleCount = rhiSupport->chooseSampleCountForWindowWithRhi(window, rhi); if (rhiSupport->isProfilingRequested()) QSGRhiProfileConnection::instance()->initialize(rhi); // ### this breaks down with multiple windows } else { - qWarning("Failed to create QRhi on the render thread; scenegraph is not functional"); + if (!rhiDeviceLost) { + rhiDoomed = true; + qWarning("Failed to create QRhi on the render thread; scenegraph is not functional"); + } + // otherwise no error, will retry on a subsequent rendering attempt return; } } @@ -975,9 +999,24 @@ void QSGRenderThread::run() if (window) { if (enableRhi) { + ensureRhi(); - if (rhi) - syncAndRender(); + + // We absolutely have to syncAndRender() here, even when QRhi + // failed to initialize otherwise the gui thread will be left + // in a blocked state. It is up to syncAndRender() to + // gracefully skip all graphics stuff when rhi is null. + + syncAndRender(); + + // Now we can do something about rhi init failures. (reinit + // failure after device reset does not count) + if (rhiDoomed && !guiNotifiedAboutRhiFailure) { + guiNotifiedAboutRhiFailure = true; + QEvent *e = new QEvent(QEvent::Type(QQuickWindowPrivate::TriggerContextCreationFailure)); + QCoreApplication::postEvent(window, e); + } + } else { if (!sgrc->openglContext() && windowSize.width() > 0 && windowSize.height() > 0 && gl->makeCurrent(window)) { QSGDefaultRenderContext::InitParams rcParams; @@ -1282,10 +1321,9 @@ void QSGThreadedRenderLoop::handleExposure(QQuickWindow *window) w->thread->gl->setFormat(w->window->requestedFormat()); w->thread->gl->setScreen(w->window->screen()); if (!w->thread->gl->create()) { - const bool isEs = w->thread->gl->isOpenGLES(); delete w->thread->gl; w->thread->gl = nullptr; - handleContextCreationFailure(w->window, isEs); + handleContextCreationFailure(w->window); return; } diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp index 5b48b86568..b1c9b71c05 100644 --- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp +++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp @@ -180,10 +180,9 @@ void QSGWindowsRenderLoop::show(QQuickWindow *window) m_gl->setShareContext(qt_gl_global_share_context()); bool created = m_gl->create(); if (!created) { - const bool isEs = m_gl->isOpenGLES(); delete m_gl; m_gl = nullptr; - handleContextCreationFailure(window, isEs); + handleContextCreationFailure(window); return; } diff --git a/src/quick/scenegraph/shaders/outlinedtext.vert b/src/quick/scenegraph/shaders/outlinedtext.vert index ced8afd034..9df832de3c 100644 --- a/src/quick/scenegraph/shaders/outlinedtext.vert +++ b/src/quick/scenegraph/shaders/outlinedtext.vert @@ -1,6 +1,7 @@ uniform highp mat4 matrix; uniform highp vec2 textureScale; uniform highp vec2 shift; +uniform highp float dpr; attribute highp vec4 vCoord; attribute highp vec2 tCoord; @@ -18,5 +19,6 @@ void main() sCoordDown = (tCoord - vec2(0.0, 1.0)) * textureScale; sCoordLeft = (tCoord - vec2(-1.0, 0.0)) * textureScale; sCoordRight = (tCoord - vec2(1.0, 0.0)) * textureScale; - gl_Position = matrix * vCoord; + vec3 dprSnapPos = floor(vCoord.xyz * dpr + 0.5) / dpr; + gl_Position = matrix * vec4(dprSnapPos, vCoord.w); }
\ No newline at end of file diff --git a/src/quick/scenegraph/shaders/outlinedtext_core.vert b/src/quick/scenegraph/shaders/outlinedtext_core.vert index 4aa13101fd..ae945b013a 100644 --- a/src/quick/scenegraph/shaders/outlinedtext_core.vert +++ b/src/quick/scenegraph/shaders/outlinedtext_core.vert @@ -12,6 +12,7 @@ out vec2 sCoordRight; uniform mat4 matrix; uniform vec2 textureScale; uniform vec2 shift; +uniform float dpr; void main() { @@ -20,5 +21,6 @@ void main() sCoordDown = (tCoord - vec2(0.0, 1.0)) * textureScale; sCoordLeft = (tCoord - vec2(-1.0, 0.0)) * textureScale; sCoordRight = (tCoord - vec2(1.0, 0.0)) * textureScale; - gl_Position = matrix * vCoord; + vec3 dprSnapPos = round(vCoord.xyz * dpr + 0.5) / dpr; + gl_Position = matrix * vec4(dprSnapPos, vCoord.w); }
\ No newline at end of file diff --git a/src/quick/scenegraph/shaders/styledtext.vert b/src/quick/scenegraph/shaders/styledtext.vert index 7001bbc262..29c9902609 100644 --- a/src/quick/scenegraph/shaders/styledtext.vert +++ b/src/quick/scenegraph/shaders/styledtext.vert @@ -13,5 +13,6 @@ void main() { sampleCoord = tCoord * textureScale; shiftedSampleCoord = (tCoord - shift) * textureScale; - gl_Position = matrix * floor(vCoord * dpr + 0.5) / dpr; + vec3 dprSnapPos = floor(vCoord.xyz * dpr + 0.5) / dpr; + gl_Position = matrix * vec4(dprSnapPos, vCoord.w); } diff --git a/src/quick/scenegraph/shaders/styledtext_core.vert b/src/quick/scenegraph/shaders/styledtext_core.vert index c522877bb3..7e313eb797 100644 --- a/src/quick/scenegraph/shaders/styledtext_core.vert +++ b/src/quick/scenegraph/shaders/styledtext_core.vert @@ -15,5 +15,6 @@ void main() { sampleCoord = tCoord * textureScale; shiftedSampleCoord = (tCoord - shift) * textureScale; - gl_Position = matrix * round(vCoord * dpr) / dpr; + vec3 dprSnapPos = round(vCoord.xyz * dpr + 0.5) / dpr; + gl_Position = matrix * vec4(dprSnapPos, vCoord.w); } diff --git a/src/quick/scenegraph/shaders/textmask.vert b/src/quick/scenegraph/shaders/textmask.vert index 4c678270d0..1692159d2c 100644 --- a/src/quick/scenegraph/shaders/textmask.vert +++ b/src/quick/scenegraph/shaders/textmask.vert @@ -10,5 +10,6 @@ varying highp vec2 sampleCoord; void main() { sampleCoord = tCoord * textureScale; - gl_Position = matrix * floor(vCoord * dpr + 0.5) / dpr; + vec3 dprSnapPos = floor(vCoord.xyz * dpr + 0.5) / dpr; + gl_Position = matrix * vec4(dprSnapPos, vCoord.w); } diff --git a/src/quick/scenegraph/shaders/textmask_core.vert b/src/quick/scenegraph/shaders/textmask_core.vert index f996040f70..5c510a2d23 100644 --- a/src/quick/scenegraph/shaders/textmask_core.vert +++ b/src/quick/scenegraph/shaders/textmask_core.vert @@ -12,5 +12,6 @@ uniform float dpr; void main() { sampleCoord = tCoord * textureScale; - gl_Position = matrix * round(vCoord * dpr) / dpr; + vec3 dprSnapPos = round(vCoord.xyz * dpr + 0.5) / dpr; + gl_Position = matrix * vec4(dprSnapPos, vCoord.w); } diff --git a/src/quick/scenegraph/shaders_ng/24bittextmask.frag.qsb b/src/quick/scenegraph/shaders_ng/24bittextmask.frag.qsb Binary files differindex b16da4d76a..c49cf9a6d8 100644 --- a/src/quick/scenegraph/shaders_ng/24bittextmask.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/24bittextmask.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/32bitcolortext.frag.qsb b/src/quick/scenegraph/shaders_ng/32bitcolortext.frag.qsb Binary files differindex 1a12a35b49..f5b3cf91e5 100644 --- a/src/quick/scenegraph/shaders_ng/32bitcolortext.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/32bitcolortext.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/8bittextmask.frag.qsb b/src/quick/scenegraph/shaders_ng/8bittextmask.frag.qsb Binary files differindex 2d0d23d813..3e0731802d 100644 --- a/src/quick/scenegraph/shaders_ng/8bittextmask.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/8bittextmask.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/8bittextmask_a.frag.qsb b/src/quick/scenegraph/shaders_ng/8bittextmask_a.frag.qsb Binary files differindex 65d9af4736..51cfa99402 100644 --- a/src/quick/scenegraph/shaders_ng/8bittextmask_a.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/8bittextmask_a.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag.qsb Binary files differindex 5753794649..aecf6ef18d 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.vert.qsb b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.vert.qsb Binary files differindex 6026960d68..e62ec89964 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag.qsb Binary files differindex 451ccbac5b..c6e5d2d102 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.frag.qsb Binary files differindex 41ebc12abf..bf6e902f5a 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.vert.qsb b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.vert.qsb Binary files differindex 0c37ccb6ed..398b6adaa2 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_a.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_a.frag.qsb Binary files differindex b92235eec3..e243f3300a 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_a.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_a.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/distancefieldtext.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldtext.frag.qsb Binary files differindex 28ba15e3de..504d586915 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldtext.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/distancefieldtext.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/distancefieldtext.vert.qsb b/src/quick/scenegraph/shaders_ng/distancefieldtext.vert.qsb Binary files differindex 2877ab92db..f020de9f8c 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldtext.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/distancefieldtext.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/distancefieldtext_a.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldtext_a.frag.qsb Binary files differindex 2e6085aa39..0c80f6dbc4 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldtext_a.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/distancefieldtext_a.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/flatcolor.frag.qsb b/src/quick/scenegraph/shaders_ng/flatcolor.frag.qsb Binary files differindex a528c667fd..7bc588b806 100644 --- a/src/quick/scenegraph/shaders_ng/flatcolor.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/flatcolor.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/flatcolor.vert.qsb b/src/quick/scenegraph/shaders_ng/flatcolor.vert.qsb Binary files differindex e83de529e6..7ad211c5cf 100644 --- a/src/quick/scenegraph/shaders_ng/flatcolor.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/flatcolor.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.frag.qsb b/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.frag.qsb Binary files differindex 81c51321bb..3d31b99fca 100644 --- a/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.vert.qsb b/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.vert.qsb Binary files differindex 6bf01658a1..82b4a63b65 100644 --- a/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext_a.frag.qsb b/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext_a.frag.qsb Binary files differindex 4a9ac900a6..ab27f73163 100644 --- a/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext_a.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext_a.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.frag.qsb b/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.frag.qsb Binary files differindex 76c2459edf..9fae9961c7 100644 --- a/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.vert.qsb b/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.vert.qsb Binary files differindex 7bfa7ccd4a..53c8c3ef48 100644 --- a/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext_a.frag.qsb b/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext_a.frag.qsb Binary files differindex 8f8304fb49..f7ab8301f3 100644 --- a/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext_a.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext_a.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/opaquetexture.frag.qsb b/src/quick/scenegraph/shaders_ng/opaquetexture.frag.qsb Binary files differindex 0b4554568b..a30e7868c7 100644 --- a/src/quick/scenegraph/shaders_ng/opaquetexture.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/opaquetexture.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/opaquetexture.vert.qsb b/src/quick/scenegraph/shaders_ng/opaquetexture.vert.qsb Binary files differindex 2872af0200..8a62c79ba4 100644 --- a/src/quick/scenegraph/shaders_ng/opaquetexture.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/opaquetexture.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/outlinedtext.frag.qsb b/src/quick/scenegraph/shaders_ng/outlinedtext.frag.qsb Binary files differindex 5ab92fecca..bec0a086af 100644 --- a/src/quick/scenegraph/shaders_ng/outlinedtext.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/outlinedtext.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/outlinedtext.vert b/src/quick/scenegraph/shaders_ng/outlinedtext.vert index c683a4273c..023f9dfdc2 100644 --- a/src/quick/scenegraph/shaders_ng/outlinedtext.vert +++ b/src/quick/scenegraph/shaders_ng/outlinedtext.vert @@ -28,5 +28,6 @@ void main() sCoordDown = (tCoord - vec2(0.0, 1.0)) * ubuf.textureScale; sCoordLeft = (tCoord - vec2(-1.0, 0.0)) * ubuf.textureScale; sCoordRight = (tCoord - vec2(1.0, 0.0)) * ubuf.textureScale; - gl_Position = ubuf.matrix * vCoord; + vec3 dprSnapPos = floor(vCoord.xyz * ubuf.dpr + 0.5) / ubuf.dpr; + gl_Position = ubuf.matrix * vec4(dprSnapPos, vCoord.w); } diff --git a/src/quick/scenegraph/shaders_ng/outlinedtext.vert.qsb b/src/quick/scenegraph/shaders_ng/outlinedtext.vert.qsb Binary files differindex 6aee048faa..3f9464dd7c 100644 --- a/src/quick/scenegraph/shaders_ng/outlinedtext.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/outlinedtext.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag.qsb b/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag.qsb Binary files differindex 6e6b1ab6c2..7f08bcee9e 100644 --- a/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/shadereffect.frag.qsb b/src/quick/scenegraph/shaders_ng/shadereffect.frag.qsb Binary files differindex 4b08ee2ce4..dc3b174553 100644 --- a/src/quick/scenegraph/shaders_ng/shadereffect.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/shadereffect.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/shadereffect.vert.qsb b/src/quick/scenegraph/shaders_ng/shadereffect.vert.qsb Binary files differindex 4a8c646a21..06e1e3704a 100644 --- a/src/quick/scenegraph/shaders_ng/shadereffect.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/shadereffect.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/smoothcolor.frag.qsb b/src/quick/scenegraph/shaders_ng/smoothcolor.frag.qsb Binary files differindex f99cdf1176..2ad3229e4a 100644 --- a/src/quick/scenegraph/shaders_ng/smoothcolor.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/smoothcolor.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/smoothcolor.vert.qsb b/src/quick/scenegraph/shaders_ng/smoothcolor.vert.qsb Binary files differindex 59c4104a2c..7d3a742650 100644 --- a/src/quick/scenegraph/shaders_ng/smoothcolor.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/smoothcolor.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/smoothtexture.frag.qsb b/src/quick/scenegraph/shaders_ng/smoothtexture.frag.qsb Binary files differindex ffaecbb56c..d5b738cc38 100644 --- a/src/quick/scenegraph/shaders_ng/smoothtexture.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/smoothtexture.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/smoothtexture.vert.qsb b/src/quick/scenegraph/shaders_ng/smoothtexture.vert.qsb Binary files differindex b7715d4dd5..50be6d62e0 100644 --- a/src/quick/scenegraph/shaders_ng/smoothtexture.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/smoothtexture.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/sprite.frag.qsb b/src/quick/scenegraph/shaders_ng/sprite.frag.qsb Binary files differindex 45d5bc14ee..f6a7913054 100644 --- a/src/quick/scenegraph/shaders_ng/sprite.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/sprite.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/sprite.vert.qsb b/src/quick/scenegraph/shaders_ng/sprite.vert.qsb Binary files differindex b55f881734..c11191feef 100644 --- a/src/quick/scenegraph/shaders_ng/sprite.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/sprite.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/stencilclip.frag.qsb b/src/quick/scenegraph/shaders_ng/stencilclip.frag.qsb Binary files differindex 6ae7a51f7a..0fcd1d3f80 100644 --- a/src/quick/scenegraph/shaders_ng/stencilclip.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/stencilclip.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/stencilclip.vert.qsb b/src/quick/scenegraph/shaders_ng/stencilclip.vert.qsb Binary files differindex ce2ed3c5b3..6381f6c8d9 100644 --- a/src/quick/scenegraph/shaders_ng/stencilclip.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/stencilclip.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/styledtext.frag.qsb b/src/quick/scenegraph/shaders_ng/styledtext.frag.qsb Binary files differindex 66ebc5f827..ff7eceba83 100644 --- a/src/quick/scenegraph/shaders_ng/styledtext.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/styledtext.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/styledtext.vert b/src/quick/scenegraph/shaders_ng/styledtext.vert index 10565107c6..beadf07c79 100644 --- a/src/quick/scenegraph/shaders_ng/styledtext.vert +++ b/src/quick/scenegraph/shaders_ng/styledtext.vert @@ -22,5 +22,6 @@ void main() { sampleCoord = tCoord * ubuf.textureScale; shiftedSampleCoord = (tCoord - ubuf.shift) * ubuf.textureScale; - gl_Position = ubuf.matrix * floor((vCoord * ubuf.dpr) + 0.5) / ubuf.dpr; + vec3 dprSnapPos = floor(vCoord.xyz * ubuf.dpr + 0.5) / ubuf.dpr; + gl_Position = ubuf.matrix * vec4(dprSnapPos, vCoord.w); } diff --git a/src/quick/scenegraph/shaders_ng/styledtext.vert.qsb b/src/quick/scenegraph/shaders_ng/styledtext.vert.qsb Binary files differindex 9a27ed0eb8..26f791be7f 100644 --- a/src/quick/scenegraph/shaders_ng/styledtext.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/styledtext.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/styledtext_a.frag.qsb b/src/quick/scenegraph/shaders_ng/styledtext_a.frag.qsb Binary files differindex 9dd4137072..5e023b086b 100644 --- a/src/quick/scenegraph/shaders_ng/styledtext_a.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/styledtext_a.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/textmask.frag.qsb b/src/quick/scenegraph/shaders_ng/textmask.frag.qsb Binary files differindex b16da4d76a..4cc598c5f8 100644 --- a/src/quick/scenegraph/shaders_ng/textmask.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/textmask.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/textmask.vert b/src/quick/scenegraph/shaders_ng/textmask.vert index d7d3bf892e..9d80d5dadb 100644 --- a/src/quick/scenegraph/shaders_ng/textmask.vert +++ b/src/quick/scenegraph/shaders_ng/textmask.vert @@ -17,5 +17,6 @@ out gl_PerVertex { vec4 gl_Position; }; void main() { sampleCoord = tCoord * ubuf.textureScale; - gl_Position = ubuf.matrix * floor((vCoord * ubuf.dpr) + 0.5) / ubuf.dpr; + vec3 dprSnapPos = floor(vCoord.xyz * ubuf.dpr + 0.5) / ubuf.dpr; + gl_Position = ubuf.matrix * vec4(dprSnapPos, vCoord.w); } diff --git a/src/quick/scenegraph/shaders_ng/textmask.vert.qsb b/src/quick/scenegraph/shaders_ng/textmask.vert.qsb Binary files differindex ae196ed0ad..03be2e457d 100644 --- a/src/quick/scenegraph/shaders_ng/textmask.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/textmask.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/texture.frag.qsb b/src/quick/scenegraph/shaders_ng/texture.frag.qsb Binary files differindex 3f4aa3713c..55e8c23335 100644 --- a/src/quick/scenegraph/shaders_ng/texture.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/texture.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/texture.vert.qsb b/src/quick/scenegraph/shaders_ng/texture.vert.qsb Binary files differindex bf0bc7d9fa..7ce3600447 100644 --- a/src/quick/scenegraph/shaders_ng/texture.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/texture.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/vertexcolor.frag.qsb b/src/quick/scenegraph/shaders_ng/vertexcolor.frag.qsb Binary files differindex 93965a55dd..2ad3229e4a 100644 --- a/src/quick/scenegraph/shaders_ng/vertexcolor.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/vertexcolor.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/vertexcolor.vert.qsb b/src/quick/scenegraph/shaders_ng/vertexcolor.vert.qsb Binary files differindex 98abe4ef6f..1bea18c036 100644 --- a/src/quick/scenegraph/shaders_ng/vertexcolor.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/vertexcolor.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/visualization.frag.qsb b/src/quick/scenegraph/shaders_ng/visualization.frag.qsb Binary files differindex eadad927dc..6b1a6a6c74 100644 --- a/src/quick/scenegraph/shaders_ng/visualization.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/visualization.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/visualization.vert.qsb b/src/quick/scenegraph/shaders_ng/visualization.vert.qsb Binary files differindex 7ba27cb4b5..5f64c84705 100644 --- a/src/quick/scenegraph/shaders_ng/visualization.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/visualization.vert.qsb diff --git a/src/quick/scenegraph/util/qsgplaintexture.cpp b/src/quick/scenegraph/util/qsgplaintexture.cpp index fdebe03494..0361a941db 100644 --- a/src/quick/scenegraph/util/qsgplaintexture.cpp +++ b/src/quick/scenegraph/util/qsgplaintexture.cpp @@ -281,7 +281,7 @@ void QSGPlainTexture::setTextureFromNativeObject(QRhi *rhi, QQuickWindow::Native { Q_UNUSED(type); - QRhiTexture::Flags flags = 0; + QRhiTexture::Flags flags; if (mipmap) flags |= QRhiTexture::MipMapped | QRhiTexture::UsedWithGenerateMips; @@ -421,7 +421,7 @@ void QSGPlainTexturePrivate::updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch } if (!q->m_texture) { - QRhiTexture::Flags f = 0; + QRhiTexture::Flags f; if (hasMipMaps) f |= QRhiTexture::MipMapped | QRhiTexture::UsedWithGenerateMips; diff --git a/src/quick/scenegraph/util/qsgrhinativetextureimporter.cpp b/src/quick/scenegraph/util/qsgrhinativetextureimporter.cpp index 7a7c19f587..85a88326ca 100644 --- a/src/quick/scenegraph/util/qsgrhinativetextureimporter.cpp +++ b/src/quick/scenegraph/util/qsgrhinativetextureimporter.cpp @@ -48,7 +48,7 @@ void QSGRhiNativeTextureImporter::buildWrapper(QRhi *rhi, QRhiTexture *t, #if !QT_CONFIG(vulkan) Q_UNUSED(nativeLayout); #endif -#if !QT_CONFIG(opengl) && !QT_CONFIG(vulkan) && !defined(Q_OS_WIN) && !defined(Q_OS_DARWIN) +#if !QT_CONFIG(opengl) && !QT_CONFIG(vulkan) && !defined(Q_OS_WIN) && !defined(Q_OS_MACOS) && !defined(Q_OS_IOS) Q_UNUSED(nativeObjectPtr); #endif @@ -83,7 +83,7 @@ void QSGRhiNativeTextureImporter::buildWrapper(QRhi *rhi, QRhiTexture *t, break; case QRhi::Metal: { -#ifdef Q_OS_DARWIN +#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) QRhiMetalTextureNativeHandles h; h.texture = *reinterpret_cast<void * const *>(nativeObjectPtr); t->buildFrom(&h); |