diff options
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 16 | ||||
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h | 1 | ||||
-rw-r--r-- | tests/auto/quick/rendernode/data/glsimple_only.qml | 19 | ||||
-rw-r--r-- | tests/auto/quick/rendernode/tst_rendernode.cpp | 9 |
4 files changed, 40 insertions, 5 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index e7b1c5b954..8d1bd28da1 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -3599,20 +3599,16 @@ void Renderer::renderUnmergedBatch(PreparedRenderBatch *renderBatch, bool depthP } } -void Renderer::setGraphicsPipeline(QRhiCommandBuffer *cb, const Batch *batch, Element *e, bool depthPostPass) +void Renderer::setViewportAndScissors(QRhiCommandBuffer *cb, const Batch *batch) { - cb->setGraphicsPipeline(depthPostPass ? e->depthPostPassPs : e->ps); - if (!m_pstate.viewportSet) { m_pstate.viewportSet = true; cb->setViewport(m_pstate.viewport); } if (batch->clipState.type & ClipState::ScissorClip) { - Q_ASSERT(e->ps->flags().testFlag(QRhiGraphicsPipeline::UsesScissor)); m_pstate.scissorSet = true; cb->setScissor(batch->clipState.scissor); } else { - Q_ASSERT(!e->ps->flags().testFlag(QRhiGraphicsPipeline::UsesScissor)); // Regardless of the ps not using scissor, the scissor may need to be // reset, depending on the backend. So set the viewport again, which in // turn also sets the scissor on backends where a scissor rect is @@ -3622,6 +3618,15 @@ void Renderer::setGraphicsPipeline(QRhiCommandBuffer *cb, const Batch *batch, El cb->setViewport(m_pstate.viewport); } } +} + + +void Renderer::setGraphicsPipeline(QRhiCommandBuffer *cb, const Batch *batch, Element *e, bool depthPostPass) +{ + cb->setGraphicsPipeline(depthPostPass ? e->depthPostPassPs : e->ps); + + setViewportAndScissors(cb, batch); + if (batch->clipState.type & ClipState::StencilClip) { Q_ASSERT(e->ps->flags().testFlag(QRhiGraphicsPipeline::UsesStencilRef)); cb->setStencilRef(batch->clipState.stencilRef); @@ -4168,6 +4173,7 @@ void Renderer::renderRhiRenderNode(const Batch *batch) const QSGRenderNode::StateFlags changes = e->renderNode->changedStates(); QRhiCommandBuffer *cb = renderTarget().cb; + setViewportAndScissors(cb, batch); const bool needsExternal = !e->renderNode->flags().testFlag(QSGRenderNode::NoExternalRendering); if (needsExternal) cb->beginExternal(); diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h index b51a2d523a..15cff4caec 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h @@ -827,6 +827,7 @@ private: void renderMergedBatch(PreparedRenderBatch *renderBatch, bool depthPostPass = false); bool prepareRenderUnmergedBatch(Batch *batch, PreparedRenderBatch *renderBatch); void renderUnmergedBatch(PreparedRenderBatch *renderBatch, bool depthPostPass = false); + void setViewportAndScissors(QRhiCommandBuffer *cb, const Batch *batch); void setGraphicsPipeline(QRhiCommandBuffer *cb, const Batch *batch, Element *e, bool depthPostPass = false); ClipState::ClipType updateStencilClip(const QSGClipNode *clip); void updateClip(const QSGClipNode *clipList, const Batch *batch); diff --git a/tests/auto/quick/rendernode/data/glsimple_only.qml b/tests/auto/quick/rendernode/data/glsimple_only.qml new file mode 100644 index 0000000000..11ceff8a4a --- /dev/null +++ b/tests/auto/quick/rendernode/data/glsimple_only.qml @@ -0,0 +1,19 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import Test + +Item { + width: 100 + height: 100 + GLSimpleItem { + anchors.fill: parent + Rectangle { + color: "gray" + width: 50 + height: 50 + anchors.centerIn: parent + } + } +} diff --git a/tests/auto/quick/rendernode/tst_rendernode.cpp b/tests/auto/quick/rendernode/tst_rendernode.cpp index 45d643e53e..855bdca612 100644 --- a/tests/auto/quick/rendernode/tst_rendernode.cpp +++ b/tests/auto/quick/rendernode/tst_rendernode.cpp @@ -232,6 +232,14 @@ public: QVERIFY(QOpenGLContext::currentContext()); QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); QVERIFY(f); + + GLint viewport[4]; + f->glGetIntegerv(GL_VIEWPORT, viewport); + QCOMPARE(viewport[0], 0); + QCOMPARE(viewport[1], 0); + QCOMPARE(viewport[2], 320); + QCOMPARE(viewport[3], 200); + f->glClearColor(0.0f, 1.0f, 0.0f, 1.0f); f->glClear(GL_COLOR_BUFFER_BIT); } @@ -337,6 +345,7 @@ void tst_rendernode::gltest_data() QTest::addColumn<QString>("file"); QTest::newRow("simple") << QStringLiteral("glsimple.qml"); + QTest::newRow("rendernode only") << QStringLiteral("glsimple_only.qml"); } void tst_rendernode::gltest() |