diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-12-25 03:01:56 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-12-25 03:01:56 +0100 |
commit | 59c18801b129ee81487ebd842641cecd0ce18508 (patch) | |
tree | d21482daf90ad75897b1957090de35b92bd41976 | |
parent | cc4c126d29e43c51e16a1c3fdcc0c7987e84ee42 (diff) | |
parent | 080f9d0b99b0d2e7e179a41d901096e595000448 (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I13dfef5918cada019dfa29a28a8eee6a6efa7e27
-rw-r--r-- | src/core/transforms/qskeletonloader.cpp | 1 | ||||
-rw-r--r-- | src/quick3d/imports/scene3d/importsscene3d.pro | 1 | ||||
-rw-r--r-- | src/quick3d/imports/scene3d/scene3ditem.cpp | 14 | ||||
-rw-r--r-- | src/render/lights/qenvironmentlight.cpp | 50 | ||||
-rw-r--r-- | src/render/lights/qenvironmentlight.h | 2 | ||||
-rw-r--r-- | src/render/lights/qenvironmentlight_p.h | 3 | ||||
-rw-r--r-- | src/render/texture/qtexture.cpp | 8 | ||||
-rw-r--r-- | src/render/texture/qtexturedata.cpp | 2 | ||||
-rw-r--r-- | src/render/texture/qtextureimagedata.cpp | 2 | ||||
-rw-r--r-- | src/render/texture/texture_p.h | 2 | ||||
-rw-r--r-- | src/src.pro | 1 | ||||
-rw-r--r-- | tests/auto/render/qenvironmentlight/tst_qenvironmentlight.cpp | 98 | ||||
-rw-r--r-- | tests/auto/render/qtextureimagedata/tst_qtextureimagedata.cpp | 2 | ||||
-rw-r--r-- | tests/auto/render/texture/tst_texture.cpp | 23 | ||||
-rw-r--r-- | tests/manual/texture_property_updates/main.qml | 2 |
15 files changed, 199 insertions, 12 deletions
diff --git a/src/core/transforms/qskeletonloader.cpp b/src/core/transforms/qskeletonloader.cpp index a917252d9..d5296ecc9 100644 --- a/src/core/transforms/qskeletonloader.cpp +++ b/src/core/transforms/qskeletonloader.cpp @@ -124,6 +124,7 @@ void QSkeletonLoaderPrivate::setStatus(QSkeletonLoader::Status status) \property Qt3DCore::QSkeletonLoader::createJointsEnabled \brief A boolean to indicate whether createJoints is enabled or not. +*/ /*! Constructs a new QSkeletonLoader with \a parent. */ diff --git a/src/quick3d/imports/scene3d/importsscene3d.pro b/src/quick3d/imports/scene3d/importsscene3d.pro index cf8d7cacf..a8ad8f417 100644 --- a/src/quick3d/imports/scene3d/importsscene3d.pro +++ b/src/quick3d/imports/scene3d/importsscene3d.pro @@ -7,6 +7,7 @@ QT += qml quick 3dcore 3drender 3drender-private qtConfig(qt3d-input): QT += 3dinput qtConfig(qt3d-logic): QT += 3dlogic +qtConfig(qt3d-animation): QT += 3danimation # Qt3D is free of Q_FOREACH - make sure it stays that way: DEFINES += QT_NO_FOREACH diff --git a/src/quick3d/imports/scene3d/scene3ditem.cpp b/src/quick3d/imports/scene3d/scene3ditem.cpp index ddb25777c..ffb1d9112 100644 --- a/src/quick3d/imports/scene3d/scene3ditem.cpp +++ b/src/quick3d/imports/scene3d/scene3ditem.cpp @@ -52,6 +52,10 @@ #include <Qt3DLogic/qlogicaspect.h> #endif +#if QT_CONFIG(qt3d_animation) +#include <Qt3DAnimation/qanimationaspect.h> +#endif + #include <Qt3DRender/QRenderAspect> #include <Qt3DRender/qcamera.h> #include <Qt3DRender/qrendersurfaceselector.h> @@ -169,7 +173,15 @@ void Scene3DItem::setAspects(const QStringList &aspects) m_aspectEngine->registerAspect(new Qt3DLogic::QLogicAspect); continue; #else - qFatal("Scene3D requested the Qt 3D input aspect but Qt 3D wasn't configured to build the Qt 3D Input aspect"); + qFatal("Scene3D requested the Qt 3D logic aspect but Qt 3D wasn't configured to build the Qt 3D Logic aspect"); +#endif + } + if (aspect == QLatin1String("animation")) { +#if QT_CONFIG(qt3d_animation) + m_aspectEngine->registerAspect(new Qt3DAnimation::QAnimationAspect); + continue; +#else + qFatal("Scene3D requested the Qt 3D animation aspect but Qt 3D wasn't configured to build the Qt 3D Animation aspect"); #endif } m_aspectEngine->registerAspect(aspect); diff --git a/src/render/lights/qenvironmentlight.cpp b/src/render/lights/qenvironmentlight.cpp index a094af7b2..866905fb6 100644 --- a/src/render/lights/qenvironmentlight.cpp +++ b/src/render/lights/qenvironmentlight.cpp @@ -40,6 +40,7 @@ #include "qenvironmentlight.h" #include "qenvironmentlight_p.h" #include "qabstracttexture.h" +#include <QVector3D> QT_BEGIN_NAMESPACE @@ -65,6 +66,23 @@ QEnvironmentLightPrivate::~QEnvironmentLightPrivate() { } +void QEnvironmentLightPrivate::_q_updateEnvMapsSize() +{ + QVector3D irradianceSize; + if (m_irradiance != nullptr) + irradianceSize = QVector3D(m_irradiance->width(), + m_irradiance->height(), + m_irradiance->depth()); + m_shaderData->setProperty("irradianceSize", QVariant::fromValue(irradianceSize)); + + QVector3D specularSize; + if (m_specular != nullptr) + specularSize = QVector3D(m_specular->width(), + m_specular->height(), + m_specular->depth()); + m_shaderData->setProperty("specularSize", QVariant::fromValue(specularSize)); +} + Qt3DCore::QNodeCreatedChangeBasePtr QEnvironmentLight::createNodeCreationChange() const { auto creationChange = Qt3DCore::QNodeCreatedChangePtr<QEnvironmentLightData>::create(this); @@ -148,17 +166,26 @@ void QEnvironmentLight::setIrradiance(QAbstractTexture *i) if (irradiance() == i) return; - if (irradiance()) - d->unregisterDestructionHelper(irradiance()); + if (irradiance()) { + d->unregisterDestructionHelper(d->m_irradiance); + QObject::disconnect(d->m_irradiance, SIGNAL(widthChanged(int)), this, SLOT(_q_updateEnvMapsSize())); + QObject::disconnect(d->m_irradiance, SIGNAL(heightChanged(int)), this, SLOT(_q_updateEnvMapsSize())); + QObject::disconnect(d->m_irradiance, SIGNAL(depthChanged(int)), this, SLOT(_q_updateEnvMapsSize())); + } if (i && !i->parent()) i->setParent(this); d->m_irradiance = i; d->m_shaderData->setProperty("irradiance", QVariant::fromValue(i)); + d->_q_updateEnvMapsSize(); - if (i) + if (i) { d->registerDestructionHelper(i, &QEnvironmentLight::setIrradiance, i); + QObject::connect(d->m_irradiance, SIGNAL(widthChanged(int)), this, SLOT(_q_updateEnvMapsSize())); + QObject::connect(d->m_irradiance, SIGNAL(heightChanged(int)), this, SLOT(_q_updateEnvMapsSize())); + QObject::connect(d->m_irradiance, SIGNAL(depthChanged(int)), this, SLOT(_q_updateEnvMapsSize())); + } emit irradianceChanged(i); } @@ -169,17 +196,26 @@ void QEnvironmentLight::setSpecular(QAbstractTexture *s) if (specular() == s) return; - if (irradiance()) - d->unregisterDestructionHelper(specular()); + if (specular()) { + d->unregisterDestructionHelper(d->m_specular); + QObject::disconnect(d->m_specular, SIGNAL(widthChanged(int)), this, SLOT(_q_updateEnvMapsSize())); + QObject::disconnect(d->m_specular, SIGNAL(heightChanged(int)), this, SLOT(_q_updateEnvMapsSize())); + QObject::disconnect(d->m_specular, SIGNAL(depthChanged(int)), this, SLOT(_q_updateEnvMapsSize())); + } if (s && !s->parent()) s->setParent(this); d->m_specular = s; d->m_shaderData->setProperty("specular", QVariant::fromValue(s)); + d->_q_updateEnvMapsSize(); - if (s) + if (s) { d->registerDestructionHelper(s, &QEnvironmentLight::setSpecular, s); + QObject::connect(d->m_specular, SIGNAL(widthChanged(int)), this, SLOT(_q_updateEnvMapsSize())); + QObject::connect(d->m_specular, SIGNAL(heightChanged(int)), this, SLOT(_q_updateEnvMapsSize())); + QObject::connect(d->m_specular, SIGNAL(depthChanged(int)), this, SLOT(_q_updateEnvMapsSize())); + } emit specularChanged(s); } @@ -187,3 +223,5 @@ void QEnvironmentLight::setSpecular(QAbstractTexture *s) } // namespace Qt3DRender QT_END_NAMESPACE + +#include "moc_qenvironmentlight.cpp" diff --git a/src/render/lights/qenvironmentlight.h b/src/render/lights/qenvironmentlight.h index c3d180233..995768d3c 100644 --- a/src/render/lights/qenvironmentlight.h +++ b/src/render/lights/qenvironmentlight.h @@ -77,6 +77,8 @@ Q_SIGNALS: private: Q_DECLARE_PRIVATE(QEnvironmentLight) Qt3DCore::QNodeCreatedChangeBasePtr createNodeCreationChange() const override; + + Q_PRIVATE_SLOT(d_func(), void _q_updateEnvMapsSize()) }; } // namespace Qt3DRender diff --git a/src/render/lights/qenvironmentlight_p.h b/src/render/lights/qenvironmentlight_p.h index 02358dafc..f4fa97b5a 100644 --- a/src/render/lights/qenvironmentlight_p.h +++ b/src/render/lights/qenvironmentlight_p.h @@ -72,6 +72,9 @@ public: QShaderData *m_shaderData; QAbstractTexture *m_irradiance; QAbstractTexture *m_specular; + +private: + void _q_updateEnvMapsSize(); }; struct QEnvironmentLightData diff --git a/src/render/texture/qtexture.cpp b/src/render/texture/qtexture.cpp index 110df30e3..cf93f872f 100644 --- a/src/render/texture/qtexture.cpp +++ b/src/render/texture/qtexture.cpp @@ -317,6 +317,12 @@ const struct FourCCFormat { DdsFourCC<'D','X','T','5'>::value, { QOpenGLTexture::NoSourceFormat, QOpenGLTexture::RGBA_DXT5, QOpenGLTexture::NoPixelType, 16, true } }, { DdsFourCC<'A','T','I','1'>::value, { QOpenGLTexture::NoSourceFormat, QOpenGLTexture::R_ATI1N_UNorm, QOpenGLTexture::NoPixelType, 8, true } }, { DdsFourCC<'A','T','I','2'>::value, { QOpenGLTexture::NoSourceFormat, QOpenGLTexture::RG_ATI2N_UNorm, QOpenGLTexture::NoPixelType, 16, true } }, +{ /* DXGI_FORMAT_R16_FLOAT */ 111, { QOpenGLTexture::Red, QOpenGLTexture::R16F, QOpenGLTexture::Float16, 2, false } }, +{ /* DXGI_FORMAT_R16_FLOAT */ 112, { QOpenGLTexture::RG, QOpenGLTexture::RG16F, QOpenGLTexture::Float16, 4, false } }, +{ /* DXGI_FORMAT_R16G16B16A16_FLOAT */113, { QOpenGLTexture::RGBA, QOpenGLTexture::RGBA16F, QOpenGLTexture::Float16, 8, false } }, +{ /* DXGI_FORMAT_R32_FLOAT */ 114, { QOpenGLTexture::Red, QOpenGLTexture::R32F, QOpenGLTexture::Float32, 4, false } }, +{ /* DXGI_FORMAT_R32G32_FLOAT */ 115, { QOpenGLTexture::RG, QOpenGLTexture::RG32F, QOpenGLTexture::Float32, 8, false } }, +{ /* DXGI_FORMAT_R32G32B32A32_FLOAT */116, { QOpenGLTexture::RGBA, QOpenGLTexture::RGBA32F, QOpenGLTexture::Float32, 16, false } } }; const struct DX10Format @@ -1413,7 +1419,7 @@ QTextureFromSourceGenerator::QTextureFromSourceGenerator(QTextureLoader *texture , m_mirrored() , m_texture(textureId) , m_engine(engine) - , m_format(QAbstractTexture::RGBA8_UNorm) + , m_format(QAbstractTexture::NoFormat) { Q_ASSERT(textureLoader); diff --git a/src/render/texture/qtexturedata.cpp b/src/render/texture/qtexturedata.cpp index b7bb75242..ac4ca80c0 100644 --- a/src/render/texture/qtexturedata.cpp +++ b/src/render/texture/qtexturedata.cpp @@ -57,7 +57,7 @@ class QTextureDataPrivate { public: QAbstractTexture::Target m_target; - QAbstractTexture::TextureFormat m_format; + QAbstractTexture::TextureFormat m_format = QAbstractTexture::NoFormat; int m_width = 0; int m_height = 0; int m_depth = 0; diff --git a/src/render/texture/qtextureimagedata.cpp b/src/render/texture/qtextureimagedata.cpp index c31f272a8..bf43a6e16 100644 --- a/src/render/texture/qtextureimagedata.cpp +++ b/src/render/texture/qtextureimagedata.cpp @@ -55,7 +55,7 @@ QTextureImageDataPrivate::QTextureImageDataPrivate() , m_mipLevels(-1) , m_blockSize(-1) , m_target(QOpenGLTexture::Target2D) - , m_format(QOpenGLTexture::RGBA8_UNorm) + , m_format(QOpenGLTexture::NoFormat) , m_pixelFormat(QOpenGLTexture::RGBA) , m_pixelType(QOpenGLTexture::UInt8) , m_isCompressed(false) diff --git a/src/render/texture/texture_p.h b/src/render/texture/texture_p.h index 705d86e68..c60e90181 100644 --- a/src/render/texture/texture_p.h +++ b/src/render/texture/texture_p.h @@ -84,7 +84,7 @@ struct TextureProperties int mipLevels = 1; int samples = 1; QAbstractTexture::Target target = QAbstractTexture::Target2D; - QAbstractTexture::TextureFormat format = QAbstractTexture::RGBA8_UNorm; + QAbstractTexture::TextureFormat format = QAbstractTexture::NoFormat; bool generateMipMaps = false; QAbstractTexture::Status status = QAbstractTexture::None; diff --git a/src/src.pro b/src/src.pro index c3c8d6291..853ae8fb5 100644 --- a/src/src.pro +++ b/src/src.pro @@ -147,6 +147,7 @@ qtHaveModule(quick) { src_quick3d_imports_scene2d } qtConfig(qt3d-logic): src_quick3d_imports_scene3d.depends += src_logic + qtConfig(qt3d-animation): src_quick3d_imports_scene3d.depends += src_animation } qtConfig(qt3d-animation) { SUBDIRS += \ diff --git a/tests/auto/render/qenvironmentlight/tst_qenvironmentlight.cpp b/tests/auto/render/qenvironmentlight/tst_qenvironmentlight.cpp index 76b3603c9..97375b647 100644 --- a/tests/auto/render/qenvironmentlight/tst_qenvironmentlight.cpp +++ b/tests/auto/render/qenvironmentlight/tst_qenvironmentlight.cpp @@ -170,6 +170,55 @@ private Q_SLOTS: } { auto texture = new Qt3DRender::QTexture2D(&light); + QSignalSpy spy(&light, &Qt3DRender::QEnvironmentLight::irradianceChanged); + + // WHEN + light.setIrradiance(texture); + + // THEN + QCOMPARE(light.irradiance(), texture); + QCOMPARE(shaderData->property("irradiance").value<Qt3DRender::QAbstractTexture*>(), texture); + QCOMPARE(shaderData->property("irradianceSize").value<QVector3D>(), + QVector3D(texture->width(), texture->height(), texture->depth())); + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.takeFirst().first().value<Qt3DRender::QAbstractTexture*>(), texture); + + // WHEN + texture->setWidth(883); + + // THEN + QCOMPARE(shaderData->property("irradianceSize").value<QVector3D>(), + QVector3D(883.0f, texture->height(), texture->depth())); + + // WHEN + texture->setHeight(1340); + + // THEN + QCOMPARE(shaderData->property("irradianceSize").value<QVector3D>(), + QVector3D(883.0f, 1340.0f, texture->depth())); + + // WHEN + texture->setDepth(1584); + + // THEN + QCOMPARE(shaderData->property("irradianceSize").value<QVector3D>(), + QVector3D(883.0f, 1340.0f, 1584.0f)); + + // WHEN + delete texture; + + // THEN + QCOMPARE(light.irradiance(), nullptr); + QCOMPARE(shaderData->property("irradiance").value<Qt3DRender::QAbstractTexture*>(), nullptr); + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.takeFirst().first().value<Qt3DRender::QAbstractTexture*>(), nullptr); + + // THEN + QCOMPARE(shaderData->property("irradianceSize").value<QVector3D>(), + QVector3D()); + } + { + auto texture = new Qt3DRender::QTexture2D(&light); QSignalSpy spy(&light, &Qt3DRender::QEnvironmentLight::specularChanged); // WHEN @@ -242,6 +291,55 @@ private Q_SLOTS: QCOMPARE(spy.count(), 1); QCOMPARE(spy.takeFirst().first().value<Qt3DRender::QAbstractTexture*>(), nullptr); } + { + auto texture = new Qt3DRender::QTexture2D(&light); + QSignalSpy spy(&light, &Qt3DRender::QEnvironmentLight::specularChanged); + + // WHEN + light.setSpecular(texture); + + // THEN + QCOMPARE(light.specular(), texture); + QCOMPARE(shaderData->property("specular").value<Qt3DRender::QAbstractTexture*>(), texture); + QCOMPARE(shaderData->property("specularSize").value<QVector3D>(), + QVector3D(texture->width(), texture->height(), texture->depth())); + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.takeFirst().first().value<Qt3DRender::QAbstractTexture*>(), texture); + + // WHEN + texture->setWidth(883); + + // THEN + QCOMPARE(shaderData->property("specularSize").value<QVector3D>(), + QVector3D(883.0f, texture->height(), texture->depth())); + + // WHEN + texture->setHeight(1340); + + // THEN + QCOMPARE(shaderData->property("specularSize").value<QVector3D>(), + QVector3D(883.0f, 1340.0f, texture->depth())); + + // WHEN + texture->setDepth(1584); + + // THEN + QCOMPARE(shaderData->property("specularSize").value<QVector3D>(), + QVector3D(883.0f, 1340.0f, 1584.0f)); + + // WHEN + delete texture; + + // THEN + QCOMPARE(light.specular(), nullptr); + QCOMPARE(shaderData->property("specular").value<Qt3DRender::QAbstractTexture*>(), nullptr); + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.takeFirst().first().value<Qt3DRender::QAbstractTexture*>(), nullptr); + + // THEN + QCOMPARE(shaderData->property("specularSize").value<QVector3D>(), + QVector3D()); + } } void checkCreationData() diff --git a/tests/auto/render/qtextureimagedata/tst_qtextureimagedata.cpp b/tests/auto/render/qtextureimagedata/tst_qtextureimagedata.cpp index dec816a5e..ba0c9a9bf 100644 --- a/tests/auto/render/qtextureimagedata/tst_qtextureimagedata.cpp +++ b/tests/auto/render/qtextureimagedata/tst_qtextureimagedata.cpp @@ -55,7 +55,7 @@ private Q_SLOTS: QCOMPARE(tid->layers(), -1); QCOMPARE(tid->mipLevels(), -1); QCOMPARE(tid->target(), QOpenGLTexture::Target2D); - QCOMPARE(tid->format(), QOpenGLTexture::RGBA8_UNorm); + QCOMPARE(tid->format(), QOpenGLTexture::NoFormat); QCOMPARE(tid->pixelFormat(), QOpenGLTexture::RGBA); QCOMPARE(tid->pixelType(), QOpenGLTexture::UInt8); QCOMPARE(tid->isCompressed(), false); diff --git a/tests/auto/render/texture/tst_texture.cpp b/tests/auto/render/texture/tst_texture.cpp index 3231f76d9..b0ce782a0 100644 --- a/tests/auto/render/texture/tst_texture.cpp +++ b/tests/auto/render/texture/tst_texture.cpp @@ -72,12 +72,35 @@ private: void checkPropertyMirroring(); private slots: + void checkDefaults(); void checkFrontendPropertyNotifications(); void checkPropertyMirroring(); void checkPropertyChanges(); void checkTextureImageBookeeping(); }; +void tst_RenderTexture::checkDefaults() +{ + Qt3DRender::Render::Texture backend; + + QCOMPARE(backend.properties().format, Qt3DRender::QAbstractTexture::NoFormat); + QCOMPARE(backend.properties().width, 1); + QCOMPARE(backend.properties().height, 1); + QCOMPARE(backend.properties().depth, 1); + QCOMPARE(backend.properties().layers, 1); + QCOMPARE(backend.properties().mipLevels, 1); + QCOMPARE(backend.properties().samples, 1); + QCOMPARE(backend.properties().generateMipMaps, false); + QCOMPARE(backend.parameters().magnificationFilter, Qt3DRender::QAbstractTexture::Nearest); + QCOMPARE(backend.parameters().minificationFilter, Qt3DRender::QAbstractTexture::Nearest); + QCOMPARE(backend.parameters().wrapModeX, Qt3DRender::QTextureWrapMode::ClampToEdge); + QCOMPARE(backend.parameters().wrapModeY, Qt3DRender::QTextureWrapMode::ClampToEdge); + QCOMPARE(backend.parameters().wrapModeZ, Qt3DRender::QTextureWrapMode::ClampToEdge); + QCOMPARE(backend.parameters().maximumAnisotropy, 1.0f); + QCOMPARE(backend.parameters().comparisonFunction, Qt3DRender::QAbstractTexture::CompareLessEqual); + QCOMPARE(backend.parameters().comparisonMode, Qt3DRender::QAbstractTexture::CompareNone); +} + void tst_RenderTexture::checkFrontendPropertyNotifications() { // GIVEN diff --git a/tests/manual/texture_property_updates/main.qml b/tests/manual/texture_property_updates/main.qml index fb68862a6..7794dab55 100644 --- a/tests/manual/texture_property_updates/main.qml +++ b/tests/manual/texture_property_updates/main.qml @@ -91,12 +91,14 @@ QQ2.Item { } readonly property Texture texture3: Texture2D { + format: Texture.RGBA8_UNorm textureImages: TextureImage { source: textureSource } } readonly property Texture texture4: Texture2D { + format: Texture.RGBA8_UNorm textureImages: TextureImage { source: textureSource } |