2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2024-02-22 14:51:16 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
2012-02-14 11:31:11 +00:00
|
|
|
|
|
|
|
#include <qtest.h>
|
|
|
|
|
|
|
|
#include <QtQuick/qquickitem.h>
|
|
|
|
#include <QtQuick/qquickview.h>
|
|
|
|
#include <private/qsgrendernode_p.h>
|
2023-04-27 12:32:59 +00:00
|
|
|
#include <rhi/qrhi.h>
|
2012-02-14 11:31:11 +00:00
|
|
|
|
2021-08-06 10:27:35 +00:00
|
|
|
#include <QtQuickTestUtils/private/qmlutils_p.h>
|
2024-11-21 07:06:47 +00:00
|
|
|
#include <QtQuickTestUtils/private/visualtestutils_p.h>
|
2012-02-14 11:31:11 +00:00
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
#if QT_CONFIG(opengl)
|
|
|
|
#include <QOpenGLContext>
|
|
|
|
#include <QOpenGLFunctions>
|
|
|
|
#endif
|
|
|
|
|
2012-02-16 04:43:03 +00:00
|
|
|
class tst_rendernode: public QQmlDataTest
|
2012-02-14 11:31:11 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
|
2012-02-14 11:31:11 +00:00
|
|
|
public:
|
|
|
|
tst_rendernode();
|
|
|
|
|
|
|
|
private slots:
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
void test_data();
|
|
|
|
void test();
|
|
|
|
#if QT_CONFIG(opengl)
|
|
|
|
void gltest_data();
|
|
|
|
void gltest();
|
|
|
|
#endif
|
Add the graphics api independent scenegraph port
Opt in via environment variables:
QSG_RHI=1 -> enable using QRhi instead of GL
QSG_RHI_BACKEND -> set to vulkan, metal, d3d11, gl to override the default
(the default is d3d11 on Windows, metal on Mac, gl elsewhere)
Or force a given rhi backend via the existing
QQuickWindow::setSceneGraphBackend().
Otherwise the default behavior is the same as before, the rhi code path
is never active by default.
-no-opengl builds are supported in the sense that they work and default
to the software backend. However, the rhi code path cannot currently be
used in such builds, even though QRhi from qtbase is fully functional
with Vulkan, D3D, or Metal even when qtbase was configured with
-no-opengl. This cannot be utilized by Quick atm due to OpenGL usage
being all over the place in the sources corresponding to the default
backend, and those host the rhi code path as well. This will be cleaned up
hopefully in Qt 6, with the removal all direct OpenGL usage.
Other env.vars.:
QSG_RHI_DEBUG_LAYER=1 -> enable D3D debug or Vulkan validation layer
(assuming the system is set up for this)
QSG_RHI_SHADEREFFECT_DEBUG=1 -> print stuff from ShaderEffect
QSG_SAMPLES=1,2,4,... -> MSAA sample count (but QSurfaceFormat works too)
QT_D3D_ADAPTER_INDEX=0,1,... -> D3D adapter index
QT_VK_PHYSICAL_DEVICE_INDEX=0,1,... -> Vulkan physical device index
QSG_RHI_UINT32_INDEX=1 -> always use uint index data (both
merged/unmerged, convert when needed - with some rhi backends this is
implicit)
QSG_RENDER_LOOP -> to override the render loop as usual. The default
with RHI is threaded for Metal, threaded for Vulkan on Windows, basic
for Vulkan on Linux and Android (to be checked later), while the existing
rules apply for OpenGL.
Not supported when running with QRhi:
- particles
- compressed atlases (though this is transparent to the apps)
- QSGRenderNode
- QQuickRenderControl
- QQuickFramebufferObject
- certain QQuickWindow functionality that depends directly on OpenGL
- anisotropic filtering for textures
- native text may lack some gamma correction
- QSGEngine applicability unclear
- some QML profiler logs may be incorrect or irrelevant
Change-Id: I7822e99ad79e342e4166275da6e9e66498d76521
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2019-04-23 07:40:59 +00:00
|
|
|
|
|
|
|
private:
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
QQuickView *createView(const QString &file, QWindow *parent, int x, int y, int w, int h);
|
Add the graphics api independent scenegraph port
Opt in via environment variables:
QSG_RHI=1 -> enable using QRhi instead of GL
QSG_RHI_BACKEND -> set to vulkan, metal, d3d11, gl to override the default
(the default is d3d11 on Windows, metal on Mac, gl elsewhere)
Or force a given rhi backend via the existing
QQuickWindow::setSceneGraphBackend().
Otherwise the default behavior is the same as before, the rhi code path
is never active by default.
-no-opengl builds are supported in the sense that they work and default
to the software backend. However, the rhi code path cannot currently be
used in such builds, even though QRhi from qtbase is fully functional
with Vulkan, D3D, or Metal even when qtbase was configured with
-no-opengl. This cannot be utilized by Quick atm due to OpenGL usage
being all over the place in the sources corresponding to the default
backend, and those host the rhi code path as well. This will be cleaned up
hopefully in Qt 6, with the removal all direct OpenGL usage.
Other env.vars.:
QSG_RHI_DEBUG_LAYER=1 -> enable D3D debug or Vulkan validation layer
(assuming the system is set up for this)
QSG_RHI_SHADEREFFECT_DEBUG=1 -> print stuff from ShaderEffect
QSG_SAMPLES=1,2,4,... -> MSAA sample count (but QSurfaceFormat works too)
QT_D3D_ADAPTER_INDEX=0,1,... -> D3D adapter index
QT_VK_PHYSICAL_DEVICE_INDEX=0,1,... -> Vulkan physical device index
QSG_RHI_UINT32_INDEX=1 -> always use uint index data (both
merged/unmerged, convert when needed - with some rhi backends this is
implicit)
QSG_RENDER_LOOP -> to override the render loop as usual. The default
with RHI is threaded for Metal, threaded for Vulkan on Windows, basic
for Vulkan on Linux and Android (to be checked later), while the existing
rules apply for OpenGL.
Not supported when running with QRhi:
- particles
- compressed atlases (though this is transparent to the apps)
- QSGRenderNode
- QQuickRenderControl
- QQuickFramebufferObject
- certain QQuickWindow functionality that depends directly on OpenGL
- anisotropic filtering for textures
- native text may lack some gamma correction
- QSGEngine applicability unclear
- some QML profiler logs may be incorrect or irrelevant
Change-Id: I7822e99ad79e342e4166275da6e9e66498d76521
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2019-04-23 07:40:59 +00:00
|
|
|
bool isRunningOnRhi() const;
|
2012-02-14 11:31:11 +00:00
|
|
|
};
|
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
static QShader getShader(const QString &name)
|
|
|
|
{
|
|
|
|
QFile f(name);
|
|
|
|
if (f.open(QIODevice::ReadOnly))
|
|
|
|
return QShader::fromSerialized(f.readAll());
|
|
|
|
|
|
|
|
return QShader();
|
|
|
|
}
|
|
|
|
|
|
|
|
// *****
|
|
|
|
// * *
|
|
|
|
// * *
|
|
|
|
// *
|
|
|
|
// assumes the top-left scenegraph coordinate system, will be scaled to the item size
|
|
|
|
static float vertexData[] = {
|
|
|
|
0, 0, 0, 0, 1, // blue
|
|
|
|
0, 1, 0, 0, 1,
|
|
|
|
1, 0, 0, 0, 1
|
|
|
|
};
|
|
|
|
|
|
|
|
class SimpleNode : public QSGRenderNode
|
2012-02-14 11:31:11 +00:00
|
|
|
{
|
|
|
|
public:
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
SimpleNode(QQuickWindow *window)
|
|
|
|
: m_window(window)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-04-20 08:38:30 +00:00
|
|
|
StateFlags changedStates() const override
|
2012-02-14 11:31:11 +00:00
|
|
|
{
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
return ViewportState; // nothing else matters in Qt 6
|
|
|
|
}
|
|
|
|
|
|
|
|
RenderingFlags flags() const override
|
|
|
|
{
|
|
|
|
// this node uses QRhi directly and is also well behaving depth-wise
|
|
|
|
return NoExternalRendering | DepthAwareRendering;
|
|
|
|
}
|
|
|
|
|
|
|
|
void prepare() override
|
|
|
|
{
|
|
|
|
QSGRendererInterface *rif = m_window->rendererInterface();
|
|
|
|
QRhi *rhi = static_cast<QRhi *>(rif->getResource(m_window, QSGRendererInterface::RhiResource));
|
|
|
|
QVERIFY(rhi);
|
|
|
|
|
|
|
|
QSGRenderNodePrivate *d = QSGRenderNodePrivate::get(this);
|
|
|
|
QRhiRenderTarget *rt = d->m_rt.rt;
|
|
|
|
QRhiCommandBuffer *cb = d->m_rt.cb;
|
|
|
|
|
|
|
|
QRhiResourceUpdateBatch *u = rhi->nextResourceUpdateBatch();
|
|
|
|
|
|
|
|
if (!m_vbuf) {
|
|
|
|
m_vbuf.reset(rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, sizeof(vertexData)));
|
|
|
|
QVERIFY(m_vbuf->create());
|
|
|
|
u->uploadStaticBuffer(m_vbuf.data(), vertexData);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_ubuf) {
|
|
|
|
m_ubuf.reset(rhi->newBuffer(QRhiBuffer::Dynamic, QRhiBuffer::UniformBuffer, 68));
|
|
|
|
QVERIFY(m_ubuf->create());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_srb) {
|
|
|
|
m_srb.reset(rhi->newShaderResourceBindings());
|
|
|
|
m_srb->setBindings({
|
|
|
|
QRhiShaderResourceBinding::uniformBuffer(0,
|
|
|
|
QRhiShaderResourceBinding::VertexStage | QRhiShaderResourceBinding::FragmentStage,
|
|
|
|
m_ubuf.get())
|
|
|
|
});
|
|
|
|
m_srb->create();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_ps) {
|
|
|
|
m_ps.reset(rhi->newGraphicsPipeline());
|
|
|
|
|
|
|
|
const QShader vs = getShader(QLatin1String(":/shaders/color.vert.qsb"));
|
|
|
|
if (!vs.isValid())
|
|
|
|
qFatal("Failed to load shader pack (vertex)");
|
|
|
|
const QShader fs = getShader(QLatin1String(":/shaders/color.frag.qsb"));
|
|
|
|
if (!fs.isValid())
|
|
|
|
qFatal("Failed to load shader pack (fragment)");
|
|
|
|
|
|
|
|
m_ps->setShaderStages({
|
|
|
|
{ QRhiShaderStage::Vertex, vs },
|
|
|
|
{ QRhiShaderStage::Fragment, fs }
|
|
|
|
});
|
|
|
|
|
|
|
|
m_ps->setCullMode(QRhiGraphicsPipeline::Back);
|
|
|
|
// important to test against what's already in the depth buffer from the opaque pass
|
|
|
|
m_ps->setDepthTest(true);
|
|
|
|
m_ps->setDepthOp(QRhiGraphicsPipeline::LessOrEqual);
|
|
|
|
// we are in the alpha pass always so not writing out the depth
|
|
|
|
m_ps->setDepthWrite(false);
|
|
|
|
|
|
|
|
QRhiVertexInputLayout inputLayout;
|
|
|
|
inputLayout.setBindings({
|
|
|
|
{ 5 * sizeof(float) }
|
|
|
|
});
|
|
|
|
inputLayout.setAttributes({
|
|
|
|
{ 0, 0, QRhiVertexInputAttribute::Float2, 0 },
|
|
|
|
{ 0, 1, QRhiVertexInputAttribute::Float3, 2 * sizeof(float) }
|
|
|
|
});
|
|
|
|
|
|
|
|
m_ps->setVertexInputLayout(inputLayout);
|
|
|
|
m_ps->setShaderResourceBindings(m_srb.data());
|
|
|
|
m_ps->setRenderPassDescriptor(rt->renderPassDescriptor());
|
|
|
|
|
|
|
|
QVERIFY(m_ps->create());
|
|
|
|
}
|
|
|
|
|
|
|
|
// follow what the scenegraph tells us, hence DepthAwareRendering from
|
|
|
|
// flags, the downside is that we are stuck with the scenegraph
|
|
|
|
// coordinate system but that's enough for this test.
|
|
|
|
QMatrix4x4 mvp = *projectionMatrix() * *matrix();
|
|
|
|
|
|
|
|
mvp.scale(m_itemSize.width(), m_itemSize.height());
|
|
|
|
u->updateDynamicBuffer(m_ubuf.data(), 0, 64, mvp.constData());
|
|
|
|
|
|
|
|
const float opacity = inheritedOpacity();
|
|
|
|
u->updateDynamicBuffer(m_ubuf.data(), 64, 4, &opacity);
|
|
|
|
|
|
|
|
cb->resourceUpdate(u);
|
2012-02-14 11:31:11 +00:00
|
|
|
}
|
|
|
|
|
2016-04-20 08:38:30 +00:00
|
|
|
void render(const RenderState *) override
|
2012-02-14 11:31:11 +00:00
|
|
|
{
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
QSGRenderNodePrivate *d = QSGRenderNodePrivate::get(this);
|
|
|
|
QRhiRenderTarget *rt = d->m_rt.rt;
|
|
|
|
QRhiCommandBuffer *cb = d->m_rt.cb;
|
|
|
|
|
|
|
|
cb->setGraphicsPipeline(m_ps.data());
|
|
|
|
cb->setViewport({ 0, 0, float(rt->pixelSize().width()), float(rt->pixelSize().height()) });
|
|
|
|
cb->setShaderResources();
|
|
|
|
const QRhiCommandBuffer::VertexInput vbufBinding(m_vbuf.get(), 0);
|
|
|
|
cb->setVertexInput(0, 1, &vbufBinding);
|
|
|
|
cb->draw(3);
|
2012-02-14 11:31:11 +00:00
|
|
|
}
|
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
QQuickWindow *m_window;
|
|
|
|
QScopedPointer<QRhiBuffer> m_vbuf;
|
|
|
|
QScopedPointer<QRhiBuffer> m_ubuf;
|
|
|
|
QScopedPointer<QRhiShaderResourceBindings> m_srb;
|
|
|
|
QScopedPointer<QRhiGraphicsPipeline> m_ps;
|
|
|
|
QSizeF m_itemSize;
|
2012-02-14 11:31:11 +00:00
|
|
|
};
|
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
class SimpleItem : public QQuickItem
|
2012-02-14 11:31:11 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
SimpleItem()
|
2012-02-14 11:31:11 +00:00
|
|
|
{
|
|
|
|
setFlag(ItemHasContents, true);
|
|
|
|
}
|
|
|
|
protected:
|
2021-03-25 13:44:04 +00:00
|
|
|
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override
|
2012-02-14 11:31:11 +00:00
|
|
|
{
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
if (size().isEmpty()) {
|
|
|
|
delete oldNode;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleNode *node = static_cast<SimpleNode *>(oldNode);
|
2012-02-14 11:31:11 +00:00
|
|
|
if (!node)
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
node = new SimpleNode(window());
|
2012-02-14 11:31:11 +00:00
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
node->m_itemSize = size();
|
2012-02-14 11:31:11 +00:00
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
return node;
|
|
|
|
}
|
2012-02-14 11:31:11 +00:00
|
|
|
};
|
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
#if QT_CONFIG(opengl)
|
|
|
|
class GLNode : public QSGRenderNode
|
2012-02-14 11:31:11 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-04-20 08:38:30 +00:00
|
|
|
StateFlags changedStates() const override
|
2012-02-14 11:31:11 +00:00
|
|
|
{
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
return ViewportState; // nothing else matters in Qt 6
|
2012-02-14 11:31:11 +00:00
|
|
|
}
|
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
RenderingFlags flags() const override
|
2012-02-14 11:31:11 +00:00
|
|
|
{
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
return {};
|
2012-02-14 11:31:11 +00:00
|
|
|
}
|
2014-06-26 13:08:47 +00:00
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
void prepare() override
|
|
|
|
{
|
|
|
|
QVERIFY(QOpenGLContext::currentContext());
|
|
|
|
}
|
|
|
|
|
|
|
|
void render(const RenderState *) override
|
|
|
|
{
|
|
|
|
QVERIFY(QOpenGLContext::currentContext());
|
|
|
|
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
|
|
|
|
QVERIFY(f);
|
2025-07-15 12:44:47 +00:00
|
|
|
|
|
|
|
GLint viewport[4];
|
|
|
|
f->glGetIntegerv(GL_VIEWPORT, viewport);
|
|
|
|
QCOMPARE(viewport[0], 0);
|
|
|
|
QCOMPARE(viewport[1], 0);
|
|
|
|
QCOMPARE(viewport[2], 320);
|
|
|
|
QCOMPARE(viewport[3], 200);
|
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
f->glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
|
|
|
|
f->glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
}
|
2012-02-14 11:31:11 +00:00
|
|
|
};
|
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
class GLItem : public QQuickItem
|
2012-02-14 11:31:11 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
GLItem()
|
2012-02-14 11:31:11 +00:00
|
|
|
{
|
|
|
|
setFlag(ItemHasContents, true);
|
|
|
|
}
|
|
|
|
protected:
|
2021-03-25 13:44:04 +00:00
|
|
|
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override
|
2012-02-14 11:31:11 +00:00
|
|
|
{
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
if (size().isEmpty()) {
|
|
|
|
delete oldNode;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLNode *node = static_cast<GLNode *>(oldNode);
|
2012-02-14 11:31:11 +00:00
|
|
|
if (!node)
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
node = new GLNode;
|
|
|
|
|
2012-02-14 11:31:11 +00:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
};
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
#endif // QT_CONFIG(opengl)
|
2012-02-14 11:31:11 +00:00
|
|
|
|
|
|
|
tst_rendernode::tst_rendernode()
|
2021-08-06 10:27:35 +00:00
|
|
|
: QQmlDataTest(QT_QMLTEST_DATADIR)
|
2012-02-14 11:31:11 +00:00
|
|
|
{
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
qmlRegisterType<SimpleItem>("Test", 1, 0, "SimpleItem");
|
|
|
|
#if QT_CONFIG(opengl)
|
|
|
|
qmlRegisterType<GLItem>("Test", 1, 0, "GLSimpleItem");
|
|
|
|
#endif
|
2012-02-14 11:31:11 +00:00
|
|
|
}
|
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
void tst_rendernode::test_data()
|
2012-02-14 11:31:11 +00:00
|
|
|
{
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
QTest::addColumn<QString>("file");
|
2013-08-30 11:18:49 +00:00
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
QTest::newRow("simple") << QStringLiteral("simple.qml");
|
2012-02-14 11:31:11 +00:00
|
|
|
}
|
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
void tst_rendernode::test()
|
2012-02-14 11:31:11 +00:00
|
|
|
{
|
2024-11-21 07:06:47 +00:00
|
|
|
SKIP_IF_NO_WINDOW_GRAB;
|
2017-08-30 12:39:28 +00:00
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
if (!isRunningOnRhi())
|
|
|
|
QSKIP("Skipping QSGRenderNode test due to not running with QRhi");
|
|
|
|
|
|
|
|
QFETCH(QString, file);
|
|
|
|
|
|
|
|
QScopedPointer<QQuickView> view(createView(file, nullptr, 100, 100, 320, 200));
|
|
|
|
QVERIFY(QTest::qWaitForWindowExposed(view.data()));
|
|
|
|
QImage result = view->grabWindow();
|
|
|
|
|
|
|
|
const int maxFuzz = 5;
|
|
|
|
// red background
|
|
|
|
int x = 10, y = 10;
|
|
|
|
QVERIFY(qAbs(qRed(result.pixel(x, y)) - 255) < maxFuzz);
|
|
|
|
QVERIFY(qAbs(qGreen(result.pixel(x, y))) < maxFuzz);
|
|
|
|
QVERIFY(qAbs(qBlue(result.pixel(x, y))) < maxFuzz);
|
|
|
|
|
|
|
|
// gray rectangle in the middle
|
|
|
|
x = result.width() / 2;
|
|
|
|
y = result.height() / 2;
|
|
|
|
QVERIFY(qAbs(qRed(result.pixel(x, y)) - 128) < maxFuzz);
|
|
|
|
QVERIFY(qAbs(qGreen(result.pixel(x, y)) - 128) < maxFuzz);
|
|
|
|
QVERIFY(qAbs(qBlue(result.pixel(x, y)) - 128) < maxFuzz);
|
|
|
|
|
|
|
|
// check a bit up and left, this catches if the triangle is not depth
|
|
|
|
// tested correctly and so appears above the gray rect, not below as it should
|
|
|
|
x = result.width() / 2 - 5;
|
|
|
|
y = result.height() / 2 - 5;
|
|
|
|
QVERIFY(qAbs(qRed(result.pixel(x, y)) - 128) < maxFuzz);
|
|
|
|
QVERIFY(qAbs(qGreen(result.pixel(x, y)) - 128) < maxFuzz);
|
|
|
|
QVERIFY(qAbs(qBlue(result.pixel(x, y)) - 128) < maxFuzz);
|
|
|
|
|
|
|
|
// in search for blue pixels
|
|
|
|
int blueCount = 0;
|
|
|
|
for (y = 0; y < result.height(); ++y) {
|
|
|
|
for (x = 0; x < result.width(); ++x) {
|
|
|
|
if (qAbs(qRed(result.pixel(x, y))) < maxFuzz
|
|
|
|
&& qAbs(qGreen(result.pixel(x, y))) < maxFuzz
|
|
|
|
&& qAbs(qBlue(result.pixel(x, y)) - 255) < maxFuzz)
|
|
|
|
{
|
|
|
|
++blueCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-10-24 18:44:17 +00:00
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
// if the blue triangle is rendered by SimpleNode, there should be lots of
|
|
|
|
// blue pixels present
|
|
|
|
QVERIFY(blueCount > 5000);
|
|
|
|
}
|
2013-10-24 18:44:17 +00:00
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
#if QT_CONFIG(opengl)
|
|
|
|
void tst_rendernode::gltest_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<QString>("file");
|
2012-02-14 11:31:11 +00:00
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
QTest::newRow("simple") << QStringLiteral("glsimple.qml");
|
2025-07-15 12:44:47 +00:00
|
|
|
QTest::newRow("rendernode only") << QStringLiteral("glsimple_only.qml");
|
2012-02-14 11:31:11 +00:00
|
|
|
}
|
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
void tst_rendernode::gltest()
|
2012-02-14 11:31:11 +00:00
|
|
|
{
|
2024-11-21 07:06:47 +00:00
|
|
|
SKIP_IF_NO_WINDOW_GRAB;
|
2017-08-30 12:39:28 +00:00
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
if (!isRunningOnRhi())
|
|
|
|
QSKIP("Skipping QSGRenderNode test due to not running with QRhi");
|
2012-02-14 11:31:11 +00:00
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
if (QQuickWindow::graphicsApi() != QSGRendererInterface::OpenGL)
|
|
|
|
QSKIP("Skipping test due to not using OpenGL");
|
2014-05-06 12:54:52 +00:00
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
QFETCH(QString, file);
|
2014-05-06 12:54:52 +00:00
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
QScopedPointer<QQuickView> view(createView(file, nullptr, 100, 100, 320, 200));
|
|
|
|
QVERIFY(QTest::qWaitForWindowExposed(view.data()));
|
|
|
|
QImage result = view->grabWindow();
|
2014-05-06 12:54:52 +00:00
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
const int maxFuzz = 5;
|
2014-05-06 12:54:52 +00:00
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
// green
|
|
|
|
int x = 10, y = 10;
|
|
|
|
QVERIFY(qAbs(qRed(result.pixel(x, y))) < maxFuzz);
|
|
|
|
QVERIFY(qAbs(qGreen(result.pixel(x, y)) - 255) < maxFuzz);
|
|
|
|
QVERIFY(qAbs(qBlue(result.pixel(x, y))) < maxFuzz);
|
2014-05-06 12:54:52 +00:00
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
// gray rectangle in the middle
|
|
|
|
x = result.width() / 2;
|
|
|
|
y = result.height() / 2;
|
|
|
|
QVERIFY(qAbs(qRed(result.pixel(x, y)) - 128) < maxFuzz);
|
|
|
|
QVERIFY(qAbs(qGreen(result.pixel(x, y)) - 128) < maxFuzz);
|
|
|
|
QVERIFY(qAbs(qBlue(result.pixel(x, y)) - 128) < maxFuzz);
|
|
|
|
}
|
|
|
|
#endif // QT_CONFIG(opengl)
|
2014-05-06 12:54:52 +00:00
|
|
|
|
Renew tst_rendernode
For one, the Qt 5 autotest remained entirely disabled (with individual
cases all skipped) in Qt 6. Two, most of it is meaningless in Qt 6,
the state changes and the associated flags which are mostly ignored by
the renderer due to the QRhi-based architecture.
Replace the whole test. Start small, and have a test case that renders
using QRhi while exercising the modern QSGRenderNode features, such as
taking the projectionMatrix() into account and specifying
DepthAwareRendering, accessing the QRhiRenderTarget/QRhiCommandBuffer,
etc. This ensures that the basic functionality is not completely broken,
which is important for Qt Quick 3D for example.
For now have just one additional test, a very basic OpenGL one, to make
sure there is an OpenGL context current.
Fixes: QTBUG-105468
Change-Id: I05f4651e2d6b4b0760929aecdd32841ca69fa55c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-08-08 13:26:48 +00:00
|
|
|
QQuickView *tst_rendernode::createView(const QString &file, QWindow *parent, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
QQuickView *view = new QQuickView(parent);
|
|
|
|
view->setResizeMode(QQuickView::SizeRootObjectToView);
|
|
|
|
view->setSource(testFileUrl(file));
|
|
|
|
if (x >= 0 && y >= 0)
|
|
|
|
view->setPosition(x, y);
|
|
|
|
if (w >= 0 && h >= 0)
|
|
|
|
view->resize(w, h);
|
|
|
|
view->show();
|
|
|
|
return view;
|
2014-05-06 12:54:52 +00:00
|
|
|
}
|
|
|
|
|
Add the graphics api independent scenegraph port
Opt in via environment variables:
QSG_RHI=1 -> enable using QRhi instead of GL
QSG_RHI_BACKEND -> set to vulkan, metal, d3d11, gl to override the default
(the default is d3d11 on Windows, metal on Mac, gl elsewhere)
Or force a given rhi backend via the existing
QQuickWindow::setSceneGraphBackend().
Otherwise the default behavior is the same as before, the rhi code path
is never active by default.
-no-opengl builds are supported in the sense that they work and default
to the software backend. However, the rhi code path cannot currently be
used in such builds, even though QRhi from qtbase is fully functional
with Vulkan, D3D, or Metal even when qtbase was configured with
-no-opengl. This cannot be utilized by Quick atm due to OpenGL usage
being all over the place in the sources corresponding to the default
backend, and those host the rhi code path as well. This will be cleaned up
hopefully in Qt 6, with the removal all direct OpenGL usage.
Other env.vars.:
QSG_RHI_DEBUG_LAYER=1 -> enable D3D debug or Vulkan validation layer
(assuming the system is set up for this)
QSG_RHI_SHADEREFFECT_DEBUG=1 -> print stuff from ShaderEffect
QSG_SAMPLES=1,2,4,... -> MSAA sample count (but QSurfaceFormat works too)
QT_D3D_ADAPTER_INDEX=0,1,... -> D3D adapter index
QT_VK_PHYSICAL_DEVICE_INDEX=0,1,... -> Vulkan physical device index
QSG_RHI_UINT32_INDEX=1 -> always use uint index data (both
merged/unmerged, convert when needed - with some rhi backends this is
implicit)
QSG_RENDER_LOOP -> to override the render loop as usual. The default
with RHI is threaded for Metal, threaded for Vulkan on Windows, basic
for Vulkan on Linux and Android (to be checked later), while the existing
rules apply for OpenGL.
Not supported when running with QRhi:
- particles
- compressed atlases (though this is transparent to the apps)
- QSGRenderNode
- QQuickRenderControl
- QQuickFramebufferObject
- certain QQuickWindow functionality that depends directly on OpenGL
- anisotropic filtering for textures
- native text may lack some gamma correction
- QSGEngine applicability unclear
- some QML profiler logs may be incorrect or irrelevant
Change-Id: I7822e99ad79e342e4166275da6e9e66498d76521
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2019-04-23 07:40:59 +00:00
|
|
|
bool tst_rendernode::isRunningOnRhi() const
|
|
|
|
{
|
|
|
|
static bool retval = false;
|
|
|
|
static bool decided = false;
|
|
|
|
if (!decided) {
|
|
|
|
decided = true;
|
|
|
|
QQuickView dummy;
|
|
|
|
dummy.show();
|
2019-07-12 11:17:02 +00:00
|
|
|
if (QTest::qWaitForWindowExposed(&dummy)) {
|
|
|
|
QSGRendererInterface::GraphicsApi api = dummy.rendererInterface()->graphicsApi();
|
|
|
|
retval = QSGRendererInterface::isApiRhiBased(api);
|
|
|
|
}
|
Add the graphics api independent scenegraph port
Opt in via environment variables:
QSG_RHI=1 -> enable using QRhi instead of GL
QSG_RHI_BACKEND -> set to vulkan, metal, d3d11, gl to override the default
(the default is d3d11 on Windows, metal on Mac, gl elsewhere)
Or force a given rhi backend via the existing
QQuickWindow::setSceneGraphBackend().
Otherwise the default behavior is the same as before, the rhi code path
is never active by default.
-no-opengl builds are supported in the sense that they work and default
to the software backend. However, the rhi code path cannot currently be
used in such builds, even though QRhi from qtbase is fully functional
with Vulkan, D3D, or Metal even when qtbase was configured with
-no-opengl. This cannot be utilized by Quick atm due to OpenGL usage
being all over the place in the sources corresponding to the default
backend, and those host the rhi code path as well. This will be cleaned up
hopefully in Qt 6, with the removal all direct OpenGL usage.
Other env.vars.:
QSG_RHI_DEBUG_LAYER=1 -> enable D3D debug or Vulkan validation layer
(assuming the system is set up for this)
QSG_RHI_SHADEREFFECT_DEBUG=1 -> print stuff from ShaderEffect
QSG_SAMPLES=1,2,4,... -> MSAA sample count (but QSurfaceFormat works too)
QT_D3D_ADAPTER_INDEX=0,1,... -> D3D adapter index
QT_VK_PHYSICAL_DEVICE_INDEX=0,1,... -> Vulkan physical device index
QSG_RHI_UINT32_INDEX=1 -> always use uint index data (both
merged/unmerged, convert when needed - with some rhi backends this is
implicit)
QSG_RENDER_LOOP -> to override the render loop as usual. The default
with RHI is threaded for Metal, threaded for Vulkan on Windows, basic
for Vulkan on Linux and Android (to be checked later), while the existing
rules apply for OpenGL.
Not supported when running with QRhi:
- particles
- compressed atlases (though this is transparent to the apps)
- QSGRenderNode
- QQuickRenderControl
- QQuickFramebufferObject
- certain QQuickWindow functionality that depends directly on OpenGL
- anisotropic filtering for textures
- native text may lack some gamma correction
- QSGEngine applicability unclear
- some QML profiler logs may be incorrect or irrelevant
Change-Id: I7822e99ad79e342e4166275da6e9e66498d76521
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2019-04-23 07:40:59 +00:00
|
|
|
dummy.hide();
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
2012-02-14 11:31:11 +00:00
|
|
|
|
|
|
|
QTEST_MAIN(tst_rendernode)
|
|
|
|
|
|
|
|
#include "tst_rendernode.moc"
|