summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2018-07-20 09:17:18 +0200
committerPaul Lemire <paul.lemire@kdab.com>2018-08-08 13:41:13 +0000
commit85f8e910fa484296afd19a4568ba939502d562f7 (patch)
tree253c300a1266c5cd1b5997c90796bbb1af0f9369
parent0b10ab797fea863ff2c4897b1c4eb993b21b153d (diff)
Properly update properties from Backend to Frontend textures
Taking into account we have texture sharing in the backend, we can only update frontend texture properties once we have created the shared backend texture. Code was adjusted to retrieve these properties when creating the GLTexture. Such changes are stored and sent on the next run loop from a job where they are distributed to all referenced frontend Texture. The status property handling has also been updated to send status changes to all shared textures instead of just the texture whose data generator is used to gather the data. A manual test checking texture property updates, sharing and remote url sharing has also been added. Change-Id: I8ed2449fe57c9d7337580b0f7561f974cbd5006d Task-number: QTBUG-65775 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--src/render/backend/resourceaccessor.cpp2
-rw-r--r--src/render/jobs/job_common_p.h3
-rw-r--r--src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp2
-rw-r--r--src/render/renderers/opengl/renderer/renderer.cpp40
-rw-r--r--src/render/renderers/opengl/renderer/renderer_p.h5
-rw-r--r--src/render/renderers/opengl/textures/gltexture.cpp33
-rw-r--r--src/render/renderers/opengl/textures/gltexture_p.h8
-rw-r--r--src/render/texture/texture.cpp87
-rw-r--r--src/render/texture/texture_p.h6
-rw-r--r--tests/manual/manual.pro3
-rw-r--r--tests/manual/texture_property_updates/image.jpgbin0 -> 6173 bytes
-rw-r--r--tests/manual/texture_property_updates/image2.jpgbin0 -> 3983 bytes
-rw-r--r--tests/manual/texture_property_updates/main.cpp102
-rw-r--r--tests/manual/texture_property_updates/main.qml187
-rw-r--r--tests/manual/texture_property_updates/texture_property_updates.pro10
-rw-r--r--tests/manual/texture_property_updates/texture_property_updates.qrc7
16 files changed, 423 insertions, 72 deletions
diff --git a/src/render/backend/resourceaccessor.cpp b/src/render/backend/resourceaccessor.cpp
index 8ca11e7a7..e69907f3f 100644
--- a/src/render/backend/resourceaccessor.cpp
+++ b/src/render/backend/resourceaccessor.cpp
@@ -87,7 +87,7 @@ bool ResourceAccessor::accessResource(ResourceType type, Qt3DCore::QNodeId nodeI
glTex->setExternalRenderingEnabled(true);
QOpenGLTexture **glTextureHandle = reinterpret_cast<QOpenGLTexture **>(handle);
- *glTextureHandle = glTex->getOrCreateGLTexture();
+ *glTextureHandle = glTex->getGLTexture();
*lock = glTex->externalRenderingLock();
return true;
}
diff --git a/src/render/jobs/job_common_p.h b/src/render/jobs/job_common_p.h
index 03e2cc90e..2ae7d81ff 100644
--- a/src/render/jobs/job_common_p.h
+++ b/src/render/jobs/job_common_p.h
@@ -106,7 +106,8 @@ namespace JobTypes {
ProximityFiltering,
SyncFilterEntityByLayer,
SyncMaterialGatherer,
- UpdateLayerEntity
+ UpdateLayerEntity,
+ SendTextureChangesToFrontend
};
} // JobTypes
diff --git a/src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp b/src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp
index cdc895f4d..6e1cd5d47 100644
--- a/src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp
+++ b/src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp
@@ -863,7 +863,7 @@ void SubmissionContext::bindFrameBufferAttachmentHelper(GLuint fboId, const Atta
for (const Attachment &attachment : attachments_) {
GLTexture *rTex = glTextureManager->lookupResource(attachment.m_textureUuid);
if (!m_glHelper->frameBufferNeedsRenderBuffer(attachment)) {
- QOpenGLTexture *glTex = rTex ? rTex->getOrCreateGLTexture() : nullptr;
+ QOpenGLTexture *glTex = rTex ? rTex->getGLTexture() : nullptr;
if (glTex != nullptr) {
// The texture can not be rendered simultaniously by another renderer
Q_ASSERT(!rTex->isExternalRenderingEnabled());
diff --git a/src/render/renderers/opengl/renderer/renderer.cpp b/src/render/renderers/opengl/renderer/renderer.cpp
index a970a0479..fd4e7bed4 100644
--- a/src/render/renderers/opengl/renderer/renderer.cpp
+++ b/src/render/renderers/opengl/renderer/renderer.cpp
@@ -194,6 +194,7 @@ Renderer::Renderer(QRenderAspect::RenderType type)
, m_bufferGathererJob(Render::GenericLambdaJobPtr<std::function<void ()>>::create([this] { lookForDirtyBuffers(); }, JobTypes::DirtyBufferGathering))
, m_vaoGathererJob(Render::GenericLambdaJobPtr<std::function<void ()>>::create([this] { lookForAbandonedVaos(); }, JobTypes::DirtyVaoGathering))
, m_textureGathererJob(Render::GenericLambdaJobPtr<std::function<void ()>>::create([this] { lookForDirtyTextures(); }, JobTypes::DirtyTextureGathering))
+ , m_sendTextureChangesToFrontendJob(Render::GenericLambdaJobPtr<std::function<void ()>>::create([this] { sendTextureChangesToFrontend(); }, JobTypes::SendTextureChangesToFrontend))
, m_introspectShaderJob(Render::GenericLambdaJobPtr<std::function<void ()>>::create([this] { reloadDirtyShaders(); }, JobTypes::DirtyShaderGathering))
, m_syncTextureLoadingJob(Render::GenericLambdaJobPtr<std::function<void ()>>::create([] {}, JobTypes::SyncTextureLoading))
, m_ownedContext(false)
@@ -1170,6 +1171,28 @@ void Renderer::reloadDirtyShaders()
}
}
+// Executed in a job
+void Renderer::sendTextureChangesToFrontend()
+{
+ const QVector<QPair<TextureProperties, Qt3DCore::QNodeIdVector>> updateTextureProperties = std::move(m_updatedTextureProperties);
+ for (const auto &pair : updateTextureProperties) {
+ // Prepare change notification
+
+ const Qt3DCore::QNodeIdVector targetIds = pair.second;
+ for (const Qt3DCore::QNodeId targetId: targetIds) {
+ // Lookup texture
+ Texture *t = m_nodesManager->textureManager()->lookupResource(targetId);
+
+ // Texture might have been deleted between previous and current frame
+ if (t == nullptr)
+ continue;
+
+ // Send change and update backend
+ t->updatePropertiesAndNotify(pair.first);
+ }
+ }
+}
+
// Render Thread (or QtQuick RenderThread when using Scene3D)
// Scene3D: When using Scene3D rendering, we can't assume that when
// updateGLResources is called, the resource handles points to still existing
@@ -1230,7 +1253,7 @@ void Renderer::updateGLResources()
if (texture == nullptr)
continue;
- // Update texture properties
+ // Create or Update GLTexture
updateTexture(texture);
}
// We want to upload textures data at this point as the SubmissionThread and
@@ -1240,8 +1263,16 @@ void Renderer::updateGLResources()
GLTextureManager *glTextureManager = m_nodesManager->glTextureManager();
const QVector<GLTexture *> glTextures = glTextureManager->activeResources();
// Upload texture data
- for (GLTexture *glTexture : glTextures)
- glTexture->getOrCreateGLTexture();
+ for (GLTexture *glTexture : glTextures) {
+ const GLTexture::TextureUpdateInfo info = glTexture->createOrUpdateGLTexture();
+
+ // GLTexture creation provides us width/height/format ... information
+ // for textures which had not initially specified these information (TargetAutomatic...)
+ // Gather these information and store them to be distributed by a change next frame
+ const QNodeIdVector referenceTextureIds = glTextureManager->referencedTextureIds(glTexture);
+ // Store properties and referenceTextureIds
+ m_updatedTextureProperties.push_back({info.properties, referenceTextureIds});
+ }
}
}
// When Textures are cleaned up, their id is saved so that they can be
@@ -1664,6 +1695,9 @@ QVector<Qt3DCore::QAspectJobPtr> Renderer::renderBinJobs()
renderBinJobs.push_back(m_sendRenderCaptureJob);
}
+ // Do we need to notify any texture about property changes?
+ if (m_updatedTextureProperties.size() > 0)
+ renderBinJobs.push_back(m_sendTextureChangesToFrontendJob);
renderBinJobs.push_back(m_sendBufferCaptureJob);
renderBinJobs.append(bufferJobs);
diff --git a/src/render/renderers/opengl/renderer/renderer_p.h b/src/render/renderers/opengl/renderer/renderer_p.h
index b501fe6a0..23708e3e8 100644
--- a/src/render/renderers/opengl/renderer/renderer_p.h
+++ b/src/render/renderers/opengl/renderer/renderer_p.h
@@ -79,6 +79,7 @@
#include <Qt3DRender/private/updateskinningpalettejob_p.h>
#include <Qt3DRender/private/updateentitylayersjob_p.h>
#include <Qt3DRender/private/renderercache_p.h>
+#include <Qt3DRender/private/texture_p.h>
#include <QHash>
#include <QMatrix4x4>
@@ -216,6 +217,7 @@ public:
inline IntrospectShadersJobPtr introspectShadersJob() const { return m_introspectShaderJob; }
inline Qt3DCore::QAspectJobPtr bufferGathererJob() const { return m_bufferGathererJob; }
inline Qt3DCore::QAspectJobPtr textureGathererJob() const { return m_textureGathererJob; }
+ inline Qt3DCore::QAspectJobPtr sendTextureChangesToFrontendJob() const { return m_sendTextureChangesToFrontendJob; }
inline UpdateEntityLayersJobPtr updateEntityLayersJob() const { return m_updateEntityLayersJob; }
Qt3DCore::QAbstractFrameAdvanceService *frameAdvanceService() const override;
@@ -370,6 +372,7 @@ private:
GenericLambdaJobPtr<std::function<void ()>> m_bufferGathererJob;
GenericLambdaJobPtr<std::function<void ()>> m_vaoGathererJob;
GenericLambdaJobPtr<std::function<void ()>> m_textureGathererJob;
+ GenericLambdaJobPtr<std::function<void ()>> m_sendTextureChangesToFrontendJob;
IntrospectShadersJobPtr m_introspectShaderJob;
SynchronizerJobPtr m_syncTextureLoadingJob;
@@ -379,6 +382,7 @@ private:
void lookForDownloadableBuffers();
void lookForDirtyTextures();
void reloadDirtyShaders();
+ void sendTextureChangesToFrontend();
QMutex m_abandonedVaosMutex;
QVector<HVao> m_abandonedVaos;
@@ -387,6 +391,7 @@ private:
QVector<HBuffer> m_downloadableBuffers;
QVector<HShader> m_dirtyShaders;
QVector<HTexture> m_dirtyTextures;
+ QVector<QPair<TextureProperties, Qt3DCore::QNodeIdVector>> m_updatedTextureProperties;
bool m_ownedContext;
diff --git a/src/render/renderers/opengl/textures/gltexture.cpp b/src/render/renderers/opengl/textures/gltexture.cpp
index 3d8664e78..bb7e06e60 100644
--- a/src/render/renderers/opengl/textures/gltexture.cpp
+++ b/src/render/renderers/opengl/textures/gltexture.cpp
@@ -105,10 +105,13 @@ void GLTexture::destroyGLTexture()
destroyResources();
}
-QOpenGLTexture* GLTexture::getOrCreateGLTexture()
+GLTexture::TextureUpdateInfo GLTexture::createOrUpdateGLTexture()
{
QMutexLocker locker(&m_textureMutex);
bool needUpload = false;
+ TextureUpdateInfo textureInfo;
+
+ m_properties.status = QAbstractTexture::Error;
// on the first invocation in the render thread, make sure to
// evaluate the texture data generator output
@@ -140,7 +143,8 @@ QOpenGLTexture* GLTexture::getOrCreateGLTexture()
needUpload = true;
} else {
qWarning() << "[Qt3DRender::GLTexture] No QTextureData generated from Texture Generator yet. Texture will be invalid for this frame";
- return nullptr;
+ textureInfo.properties.status = QAbstractTexture::Loading;
+ return textureInfo;
}
}
@@ -188,8 +192,10 @@ QOpenGLTexture* GLTexture::getOrCreateGLTexture()
}
// don't try to create the texture if the format was not set
- if (m_properties.format == QAbstractTexture::Automatic)
- return nullptr;
+ if (m_properties.format == QAbstractTexture::Automatic) {
+ textureInfo.properties.status = QAbstractTexture::Error;
+ return textureInfo;
+ }
// if the properties changed, we need to re-allocate the texture
if (testDirtyFlag(Properties)) {
@@ -197,15 +203,24 @@ QOpenGLTexture* GLTexture::getOrCreateGLTexture()
m_gl = nullptr;
}
+
if (!m_gl) {
m_gl = buildGLTexture();
- if (!m_gl)
- return nullptr;
+ if (!m_gl) {
+ textureInfo.properties.status = QAbstractTexture::Error;
+ return textureInfo;
+ }
+
m_gl->allocateStorage();
if (!m_gl->isStorageAllocated()) {
- return nullptr;
+ textureInfo.properties.status = QAbstractTexture::Error;
+ return textureInfo;
}
}
+ m_properties.status = QAbstractTexture::Ready;
+
+ textureInfo.properties = m_properties;
+ textureInfo.texture = m_gl;
// need to (re-)upload texture data?
if (needUpload) {
@@ -223,7 +238,7 @@ QOpenGLTexture* GLTexture::getOrCreateGLTexture()
setDirtyFlag(Properties, false);
setDirtyFlag(Parameters, false);
- return m_gl;
+ return textureInfo;
}
RenderBuffer *GLTexture::getOrCreateRenderBuffer()
@@ -442,7 +457,7 @@ void GLTexture::uploadGLTextureData()
}
// Upload all QTexImageData references by the TextureImages
- for (int i = 0; i < m_images.size(); i++) {
+ for (int i = 0; i < std::min(m_images.size(), m_imageData.size()); i++) {
const QTextureImageDataPtr &imgData = m_imageData.at(i);
// Here the bytes in the QTextureImageData contain data for a single
// layer, face or mip level, unlike the QTextureGenerator case where
diff --git a/src/render/renderers/opengl/textures/gltexture_p.h b/src/render/renderers/opengl/textures/gltexture_p.h
index 5f4a20d30..e26fdf397 100644
--- a/src/render/renderers/opengl/textures/gltexture_p.h
+++ b/src/render/renderers/opengl/textures/gltexture_p.h
@@ -140,7 +140,13 @@ public:
* If the texture properties or parameters have changed, these changes
* will be applied to the resulting OpenGL texture.
*/
- QOpenGLTexture* getOrCreateGLTexture();
+ struct TextureUpdateInfo
+ {
+ QOpenGLTexture *texture = nullptr;
+ TextureProperties properties;
+ };
+
+ TextureUpdateInfo createOrUpdateGLTexture();
/**
* @brief
diff --git a/src/render/texture/texture.cpp b/src/render/texture/texture.cpp
index 440a08e26..d8008b60c 100644
--- a/src/render/texture/texture.cpp
+++ b/src/render/texture/texture.cpp
@@ -117,24 +117,8 @@ void Texture::cleanup()
m_textureImageIds.clear();
// set default values
- m_properties.width = 1;
- m_properties.height = 1;
- m_properties.depth = 1;
- m_properties.layers = 1;
- m_properties.mipLevels = 1;
- m_properties.samples = 1;
- m_properties.generateMipMaps = false;
- m_properties.format = QAbstractTexture::RGBA8_UNorm;
- m_properties.target = QAbstractTexture::Target2D;
-
- m_parameters.magnificationFilter = QAbstractTexture::Nearest;
- m_parameters.minificationFilter = QAbstractTexture::Nearest;
- m_parameters.wrapModeX = QTextureWrapMode::ClampToEdge;
- m_parameters.wrapModeY = QTextureWrapMode::ClampToEdge;
- m_parameters.wrapModeZ = QTextureWrapMode::ClampToEdge;
- m_parameters.maximumAnisotropy = 1.0f;
- m_parameters.comparisonFunction = QAbstractTexture::CompareLessEqual;
- m_parameters.comparisonMode = QAbstractTexture::CompareNone;
+ m_properties = {};
+ m_parameters = {};
m_dirty = NotDirty;
}
@@ -229,80 +213,79 @@ void Texture::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
BackendNode::sceneChangeEvent(e);
}
-void Texture::notifyStatus(QAbstractTexture::Status status)
+// Called by sceneChangeEvent or TextureDownloadRequest (both in AspectThread context)
+void Texture::setDataGenerator(const QTextureGeneratorPtr &generator)
{
- auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
- change->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
- change->setPropertyName("status");
- change->setValue(status);
- notifyObservers(change);
+ m_dataFunctor = generator;
+ addDirtyFlag(DirtyDataGenerator);
}
-void Texture::updateFromData(QTextureDataPtr data)
+// Called by sendTextureChangesToFrontendJob once GLTexture and sharing
+// has been performed
+void Texture::updatePropertiesAndNotify(const TextureProperties &properties)
{
- if (data->width() != m_properties.width) {
- m_properties.width = data->width();
+ // If we are Dirty, some property has changed and the properties we have
+ // received are potentially already outdated
+ if (m_dirty != NotDirty)
+ return;
+
+ // Note we don't update target has it is constant for frontend nodes
+
+ if (properties.width != m_properties.width) {
+ m_properties.width = properties.width;
auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
change->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
change->setPropertyName("width");
- change->setValue(data->width());
+ change->setValue(properties.width);
notifyObservers(change);
}
- if (data->height() != m_properties.height) {
- m_properties.height = data->height();
+ if (properties.height != m_properties.height) {
+ m_properties.height = properties.height;
auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
change->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
change->setPropertyName("height");
- change->setValue(data->height());
+ change->setValue(properties.height);
notifyObservers(change);
}
- if (data->depth() != m_properties.depth) {
- m_properties.depth = data->depth();
+ if (properties.depth != m_properties.depth) {
+ m_properties.depth = properties.depth;
auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
change->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
change->setPropertyName("depth");
- change->setValue(data->depth());
+ change->setValue(properties.depth);
notifyObservers(change);
}
- if (data->layers() != m_properties.layers) {
- m_properties.layers = data->layers();
+ if (properties.layers != m_properties.layers) {
+ m_properties.layers = properties.layers;
auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
change->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
change->setPropertyName("layers");
- change->setValue(data->layers());
+ change->setValue(properties.layers);
notifyObservers(change);
}
- if (data->format() != m_properties.format) {
- m_properties.format = data->format();
+ if (properties.format != m_properties.format) {
+ m_properties.format = properties.format;
auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
change->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
change->setPropertyName("format");
- change->setValue(data->format());
+ change->setValue(properties.format);
notifyObservers(change);
}
- if (data->target() != m_properties.target) {
- // TODO frontend property is actually constant
- m_properties.target = data->target();
+ if (properties.status != m_properties.status) {
+ m_properties.status = properties.status;
auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
change->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
- change->setPropertyName("target");
- change->setValue(data->target());
+ change->setPropertyName("status");
+ change->setValue(properties.status);
notifyObservers(change);
}
}
-// Called by sceneChangeEvent or TextureDownloadRequest (both in AspectThread context)
-void Texture::setDataGenerator(const QTextureGeneratorPtr &generator)
-{
- m_dataFunctor = generator;
- addDirtyFlag(DirtyDataGenerator);
-}
-
bool Texture::isValid(TextureImageManager *manager) const
{
for (const QNodeId id : m_textureImageIds) {
diff --git a/src/render/texture/texture_p.h b/src/render/texture/texture_p.h
index b9ef0385f..9e385cefe 100644
--- a/src/render/texture/texture_p.h
+++ b/src/render/texture/texture_p.h
@@ -86,12 +86,13 @@ struct TextureProperties
QAbstractTexture::Target target = QAbstractTexture::Target2D;
QAbstractTexture::TextureFormat format = QAbstractTexture::RGBA8_UNorm;
bool generateMipMaps = false;
+ QAbstractTexture::Status status = QAbstractTexture::None;
bool operator==(const TextureProperties &o) const {
return (width == o.width) && (height == o.height) && (depth == o.depth)
&& (layers == o.layers) && (mipLevels == o.mipLevels) && (target == o.target)
&& (format == o.format) && (generateMipMaps == o.generateMipMaps)
- && (samples == o.samples);
+ && (samples == o.samples) && (status == o.status);
}
inline bool operator!=(const TextureProperties &o) const { return !(*this == o); }
};
@@ -155,9 +156,8 @@ public:
inline const Qt3DCore::QNodeIdVector textureImageIds() const { return m_textureImageIds; }
inline const QTextureGeneratorPtr& dataGenerator() const { return m_dataFunctor; }
- void notifyStatus(QAbstractTexture::Status status);
- void updateFromData(QTextureDataPtr data);
void setDataGenerator(const QTextureGeneratorPtr &generator);
+ void updatePropertiesAndNotify(const TextureProperties &propreties);
bool isValid(TextureImageManager *manager) const;
private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro
index f5f60f6cb..643d03e6e 100644
--- a/tests/manual/manual.pro
+++ b/tests/manual/manual.pro
@@ -58,7 +58,8 @@ SUBDIRS += \
rendercapture-qml-fbo \
blitframebuffer-qml \
raycasting-qml \
- shared_texture_image
+ shared_texture_image \
+ texture_property_updates
qtHaveModule(widgets): {
SUBDIRS += \
diff --git a/tests/manual/texture_property_updates/image.jpg b/tests/manual/texture_property_updates/image.jpg
new file mode 100644
index 000000000..495afa5ce
--- /dev/null
+++ b/tests/manual/texture_property_updates/image.jpg
Binary files differ
diff --git a/tests/manual/texture_property_updates/image2.jpg b/tests/manual/texture_property_updates/image2.jpg
new file mode 100644
index 000000000..37f6de3e5
--- /dev/null
+++ b/tests/manual/texture_property_updates/image2.jpg
Binary files differ
diff --git a/tests/manual/texture_property_updates/main.cpp b/tests/manual/texture_property_updates/main.cpp
new file mode 100644
index 000000000..e145b0a26
--- /dev/null
+++ b/tests/manual/texture_property_updates/main.cpp
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QQuickView>
+#include <QGuiApplication>
+#include <QQmlContext>
+#include <Qt3DRender/QAbstractTexture>
+
+template<typename Obj>
+QHash<int, QString> enumToNameMap(const char *enumName)
+{
+ const QMetaObject metaObj = Obj::staticMetaObject;
+ const int indexOfEnum = metaObj.indexOfEnumerator(enumName);
+ const QMetaEnum metaEnum = metaObj.enumerator(indexOfEnum);
+ const int keysCount = metaEnum.keyCount();
+
+ QHash<int, QString> v;
+ v.reserve(keysCount);
+ for (int i = 0; i < keysCount; ++i)
+ v[metaEnum.value(i)] = metaEnum.key(i);
+ return v;
+}
+
+
+class EnumNameMapper : public QObject
+{
+ Q_OBJECT
+
+public:
+ Q_INVOKABLE QString statusName(int v) const { return m_statusMap.value(v); }
+ Q_INVOKABLE QString formatName(int v) const { return m_formatMap.value(v); }
+ Q_INVOKABLE QString targetName(int v) const { return m_targetMap.value(v); }
+
+private:
+ const QHash<int, QString> m_statusMap = enumToNameMap<Qt3DRender::QAbstractTexture>("Status");
+ const QHash<int, QString> m_formatMap = enumToNameMap<Qt3DRender::QAbstractTexture>("TextureFormat");
+ const QHash<int, QString> m_targetMap = enumToNameMap<Qt3DRender::QAbstractTexture>("Target");
+};
+
+int main(int argc, char* argv[])
+{
+ QGuiApplication app(argc, argv);
+ QQuickView view;
+
+ QQmlContext *ctx =view.rootContext();
+ EnumNameMapper mapper;
+ ctx->setContextProperty(QStringLiteral("nameMapper"), &mapper);
+
+ view.setSource(QUrl("qrc:/main.qml"));
+ view.show();
+
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/tests/manual/texture_property_updates/main.qml b/tests/manual/texture_property_updates/main.qml
new file mode 100644
index 000000000..ebefdc725
--- /dev/null
+++ b/tests/manual/texture_property_updates/main.qml
@@ -0,0 +1,187 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2 as QQ2
+import QtQuick.Scene3D 2.0
+import Qt3D.Core 2.0
+import Qt3D.Render 2.0
+import Qt3D.Input 2.0
+import Qt3D.Extras 2.0
+
+QQ2.Item {
+ id: root
+ width: 1280
+ height: 720
+
+ property int i: 0
+ readonly property var sources: ["https://codereview.qt-project.org/gitweb?p=qt/qt3d.git;a=blob_plain;hb=refs/heads/dev;f=examples/qt3d/planets-qml/images/solarsystemscope/earthmap2k.jpg", "qrc:/image.jpg", "qrc:/image2.jpg", "qrc:/wrongpath.jpg"]
+ readonly property url textureSource: sources[i]
+
+ QQ2.Timer {
+ interval: 3000
+ repeat: true
+ running: true
+ onTriggered: i = (i + 1) % sources.length
+ }
+
+ Scene3D {
+ anchors.fill: parent
+ focus: true
+
+ aspects: ["input", "logic"]
+
+ Entity {
+ id: sceneRoot
+
+ readonly property var textureModel: [texture1, texture2, texture3, texture4]
+
+ readonly property Texture texture1: TextureLoader {
+ source: textureSource
+ }
+
+ readonly property Texture texture2: TextureLoader {
+ source: textureSource
+ }
+
+ readonly property Texture texture3: Texture2D {
+ textureImages: TextureImage {
+ source: textureSource
+ }
+ }
+
+ readonly property Texture texture4: Texture2D {
+ textureImages: TextureImage {
+ source: textureSource
+ }
+ }
+
+ Camera {
+ id: camera
+ projectionType: CameraLens.PerspectiveProjection
+ fieldOfView: 45
+ aspectRatio: 16/9
+ nearPlane : 0.1
+ farPlane : 1000.0
+ position: Qt.vector3d( 0.0, 20.0, -40.0 )
+ upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
+ viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
+ }
+
+ OrbitCameraController {
+ camera: camera
+ }
+
+ components: [
+ RenderSettings {
+ activeFrameGraph: ForwardRenderer {
+ clearColor: Qt.rgba(0, 0.5, 1, 1)
+ camera: camera
+ }
+ },
+ // Event Source will be set by the Qt3DQuickWindow
+ InputSettings { }
+ ]
+
+ CuboidMesh { id: mesh }
+
+ NodeInstantiator {
+ id: instantiator
+ model: sceneRoot.textureModel
+
+ Entity {
+ readonly property Transform transform: Transform {
+ readonly property real angle: model.index / instantiator.count * Math.PI * 2
+ translation: Qt.vector3d(Math.cos(angle) * 10, 0, Math.sin(angle) * 10)
+ scale: 10
+ }
+
+ readonly property DiffuseMapMaterial material: DiffuseMapMaterial {
+ diffuse: model.modelData
+ }
+ components: [ mesh, material, transform ]
+ }
+ }
+ }
+ }
+
+ QQ2.Text {
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ bottom: parent.bottom
+ }
+ font.pointSize: 20
+ text: "Source (" + (i + 1) + " of " + sources.length + "): " + textureSource
+ }
+
+ QQ2.ListView {
+ anchors {
+ left: parent.left
+ top: parent.top
+ bottom: parent.bottom
+ }
+ readonly property var targets: []
+ readonly property var status: []
+
+ spacing: 30
+ model: sceneRoot.textureModel
+ width: parent.width / 4
+ delegate: QQ2.Grid {
+ spacing: 10
+ columns: 2
+ QQ2.Text { text: "Target: " + nameMapper.targetName(model.modelData.target) }
+ QQ2.Text { text: "Format: " + nameMapper.formatName(model.modelData.format.toString()) }
+ QQ2.Text { text: "Width: " + model.modelData.width }
+ QQ2.Text { text: "Height: " + model.modelData.height }
+ QQ2.Text { text: "Depth: " + model.modelData.depth}
+ QQ2.Text { text: "Layers: " + model.modelData.layers}
+ QQ2.Text { text: "Status: " + nameMapper.statusName(model.modelData.status.toString()) }
+ }
+ }
+}
diff --git a/tests/manual/texture_property_updates/texture_property_updates.pro b/tests/manual/texture_property_updates/texture_property_updates.pro
new file mode 100644
index 000000000..33d72da68
--- /dev/null
+++ b/tests/manual/texture_property_updates/texture_property_updates.pro
@@ -0,0 +1,10 @@
+QT += 3dcore 3drender 3dinput 3dquick 3dlogic qml quick 3dquickextras
+
+SOURCES += \
+ main.cpp
+
+OTHER_FILES += \
+ main.qml
+
+RESOURCES += \
+ texture_property_updates.qrc
diff --git a/tests/manual/texture_property_updates/texture_property_updates.qrc b/tests/manual/texture_property_updates/texture_property_updates.qrc
new file mode 100644
index 000000000..eb086cd72
--- /dev/null
+++ b/tests/manual/texture_property_updates/texture_property_updates.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>image.jpg</file>
+ <file>image2.jpg</file>
+ </qresource>
+</RCC>