summaryrefslogtreecommitdiffstats
path: root/src/render/jobs
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/jobs')
-rw-r--r--src/render/jobs/loadscenejob.cpp36
-rw-r--r--src/render/jobs/loadscenejob_p.h8
-rw-r--r--src/render/jobs/renderviewjobutils.cpp21
-rw-r--r--src/render/jobs/renderviewjobutils_p.h10
4 files changed, 57 insertions, 18 deletions
diff --git a/src/render/jobs/loadscenejob.cpp b/src/render/jobs/loadscenejob.cpp
index 3111e1ba3..701942976 100644
--- a/src/render/jobs/loadscenejob.cpp
+++ b/src/render/jobs/loadscenejob.cpp
@@ -60,6 +60,26 @@ LoadSceneJob::LoadSceneJob(const QUrl &source, Qt3DCore::QNodeId m_sceneComponen
SET_JOB_RUN_STAT_TYPE(this, JobTypes::LoadScene, 0);
}
+NodeManagers *LoadSceneJob::nodeManagers() const
+{
+ return m_managers;
+}
+
+QList<QSceneIOHandler *> LoadSceneJob::sceneIOHandlers() const
+{
+ return m_sceneIOHandlers;
+}
+
+QUrl LoadSceneJob::source() const
+{
+ return m_source;
+}
+
+Qt3DCore::QNodeId LoadSceneJob::sceneComponentId() const
+{
+ return m_sceneComponent;
+}
+
void LoadSceneJob::run()
{
// Iterate scene IO handlers until we find one that can handle this file type
@@ -70,9 +90,11 @@ void LoadSceneJob::run()
// Reset status
scene->setStatus(QSceneLoader::None);
+ QSceneLoader::Status finalStatus = QSceneLoader::None;
// Perform the loading only if the source wasn't explicitly set to empty
if (!m_source.isEmpty()) {
+ finalStatus = QSceneLoader::Error;
for (QSceneIOHandler *sceneIOHandler : qAsConst(m_sceneIOHandlers)) {
if (!sceneIOHandler->isFileTypeSupported(m_source))
continue;
@@ -82,15 +104,11 @@ void LoadSceneJob::run()
// File type is supported, try to load it
sceneIOHandler->setSource(m_source);
- Qt3DCore::QEntity *sub = sceneIOHandler->scene();
- if (sub) {
- sceneSubTree = sub;
+ sceneSubTree = sceneIOHandler->scene();
+ if (sceneSubTree != nullptr) {
// Successfully built a subtree
- scene->setStatus(QSceneLoader::Ready);
+ finalStatus = QSceneLoader::Ready;
break;
- } else {
- // Tree wasn't build so something went wrong obviously
- scene->setStatus(QSceneLoader::Error);
}
}
}
@@ -100,6 +118,10 @@ void LoadSceneJob::run()
// Set clone of sceneTree in sceneComponent. This will move the sceneSubTree
// to the QCoreApplication thread which is where the frontend object tree lives.
scene->setSceneSubtree(sceneSubTree);
+
+ // Note: the status is set after the subtree so that bindinds depending on the status
+ // in the frontend will be consistent
+ scene->setStatus(finalStatus);
}
} // namespace Render
diff --git a/src/render/jobs/loadscenejob_p.h b/src/render/jobs/loadscenejob_p.h
index bc122d705..0ed0d2c83 100644
--- a/src/render/jobs/loadscenejob_p.h
+++ b/src/render/jobs/loadscenejob_p.h
@@ -66,14 +66,18 @@ namespace Render {
class NodeManagers;
-class LoadSceneJob : public Qt3DCore::QAspectJob
+class Q_AUTOTEST_EXPORT LoadSceneJob : public Qt3DCore::QAspectJob
{
public:
explicit LoadSceneJob(const QUrl &source, Qt3DCore::QNodeId sceneComponent);
void setNodeManagers(NodeManagers *managers) { m_managers = managers; }
void setSceneIOHandlers(const QList<QSceneIOHandler *> sceneIOHandlers) { m_sceneIOHandlers = sceneIOHandlers; }
-protected:
+ NodeManagers *nodeManagers() const;
+ QList<QSceneIOHandler *> sceneIOHandlers() const;
+ QUrl source() const;
+ Qt3DCore::QNodeId sceneComponentId() const;
+
void run() Q_DECL_OVERRIDE;
private:
diff --git a/src/render/jobs/renderviewjobutils.cpp b/src/render/jobs/renderviewjobutils.cpp
index e5b763fcf..3face7197 100644
--- a/src/render/jobs/renderviewjobutils.cpp
+++ b/src/render/jobs/renderviewjobutils.cpp
@@ -391,7 +391,7 @@ void addParametersForIds(ParameterInfoList *params, ParameterManager *manager,
Parameter *param = manager->lookupResource(paramId);
ParameterInfoList::iterator it = std::lower_bound(params->begin(), params->end(), param->nameId());
if (it == params->end() || it->nameId != param->nameId())
- params->insert(it, ParameterInfo(param->nameId(), param->value()));
+ params->insert(it, ParameterInfo(param->nameId(), param->uniformValue()));
}
}
@@ -438,7 +438,7 @@ UniformBlockValueBuilder::~UniformBlockValueBuilder()
{
}
-void UniformBlockValueBuilder::buildActiveUniformNameValueMapHelper(const QString &blockName, const QString &qmlPropertyName, const QVariant &value)
+void UniformBlockValueBuilder::buildActiveUniformNameValueMapHelper(ShaderData *currentShaderData, const QString &blockName, const QString &qmlPropertyName, const QVariant &value)
{
// In the end, values are either scalar or a scalar array
// Composed elements (structs, structs array) are simplified into simple scalars
@@ -471,27 +471,36 @@ void UniformBlockValueBuilder::buildActiveUniformNameValueMapHelper(const QStrin
QString varName = blockName + QLatin1Char('.') + qmlPropertyName;
if (uniforms.contains(varName)) {
qCDebug(Shaders) << "UBO scalar member " << varName << " set for update";
- activeUniformNamesToValue.insert(StringToInt::lookupId(varName), value);
+
+ // If the property needs to be transformed, we transform it here as
+ // the shaderdata cannot hold transformed properties for multiple
+ // thread contexts at once
+ if (currentShaderData->propertyTransformType(qmlPropertyName) != ShaderData::NoTransform)
+ activeUniformNamesToValue.insert(StringToInt::lookupId(varName),
+ currentShaderData->getTransformedProperty(qmlPropertyName, viewMatrix));
+ else
+ activeUniformNamesToValue.insert(StringToInt::lookupId(varName), value);
}
}
}
void UniformBlockValueBuilder::buildActiveUniformNameValueMapStructHelper(ShaderData *rShaderData, const QString &blockName, const QString &qmlPropertyName)
{
- const QHash<QString, QVariant> &properties = updatedPropertiesOnly ? rShaderData->updatedProperties() : rShaderData->properties();
+ const QHash<QString, QVariant> &properties = rShaderData->properties();
QHash<QString, QVariant>::const_iterator it = properties.begin();
const QHash<QString, QVariant>::const_iterator end = properties.end();
while (it != end) {
const auto prefix = qmlPropertyName.isEmpty() ? QLatin1String("") : QLatin1String(".");
- buildActiveUniformNameValueMapHelper(blockName + prefix + qmlPropertyName,
+ buildActiveUniformNameValueMapHelper(rShaderData,
+ blockName + prefix + qmlPropertyName,
it.key(),
it.value());
++it;
}
}
-ParameterInfo::ParameterInfo(const int nameId, const QVariant &value)
+ParameterInfo::ParameterInfo(const int nameId, const UniformValue &value)
: nameId(nameId)
, value(value)
{}
diff --git a/src/render/jobs/renderviewjobutils_p.h b/src/render/jobs/renderviewjobutils_p.h
index 7f70690d7..c08083494 100644
--- a/src/render/jobs/renderviewjobutils_p.h
+++ b/src/render/jobs/renderviewjobutils_p.h
@@ -55,6 +55,8 @@
#include <Qt3DCore/qnodeid.h>
#include <QtCore/qhash.h>
#include <QtCore/qvariant.h>
+#include <QMatrix4x4>
+#include <Qt3DRender/private/uniform_p.h>
QT_BEGIN_NAMESPACE
@@ -106,10 +108,10 @@ Q_AUTOTEST_EXPORT inline T variant_value(const QVariant &v)
struct ParameterInfo
{
- explicit ParameterInfo(const int nameId = -1, const QVariant &value = QVariant());
+ explicit ParameterInfo(const int nameId = -1, const UniformValue &value = UniformValue());
int nameId;
- QVariant value;
+ UniformValue value;
bool operator<(const int otherNameId) const Q_DECL_NOEXCEPT;
bool operator<(const ParameterInfo &other) const Q_DECL_NOEXCEPT;
@@ -157,7 +159,8 @@ struct Q_AUTOTEST_EXPORT UniformBlockValueBuilder
UniformBlockValueBuilder();
~UniformBlockValueBuilder();
- void buildActiveUniformNameValueMapHelper(const QString &blockName,
+ void buildActiveUniformNameValueMapHelper(ShaderData *currentShaderData,
+ const QString &blockName,
const QString &qmlPropertyName,
const QVariant &value);
void buildActiveUniformNameValueMapStructHelper(ShaderData *rShaderData,
@@ -168,6 +171,7 @@ struct Q_AUTOTEST_EXPORT UniformBlockValueBuilder
QHash<QString, ShaderUniform> uniforms;
UniformBlockValueBuilderHash activeUniformNamesToValue;
ShaderDataManager *shaderDataManager;
+ QMatrix4x4 viewMatrix;
};
} // namespace Render