diff options
author | Janne Kangas <janne.kangas@qt.io> | 2019-08-21 13:02:14 +0300 |
---|---|---|
committer | Janne Kangas <janne.kangas@qt.io> | 2019-10-01 10:46:43 +0300 |
commit | fdc856278f325a3a41f9db2f706df5332ebd4d5c (patch) | |
tree | 75ac8e5d6566e94c741f694133065d42d62237d9 | |
parent | ea7d213f61d7784d9dad00d40dcf017f15a021e0 (diff) |
Indicate shader errors in Editor
Show a pop-up if a shader fails to compile. Compilation takes place when
the effect is added to a object in timeline.
Requires both editor and runtime commits.
Task-id: QT3DS-3598
Change-Id: Icfd43cd77c72c929b0a88edf3655da818c78df5e
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
9 files changed, 55 insertions, 0 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp index c487d1ae..3a90b0f5 100644 --- a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp +++ b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp @@ -1505,6 +1505,14 @@ std::set<QString> CClientDataModelBridge::GetDynamicObjectTextureList() const return theSourcePathList; } +TInstanceHandleList CClientDataModelBridge::GetEffectList() const +{ + TInstanceHandleList theEffectInstances; + m_DataCore->GetInstancesDerivedFrom(theEffectInstances, m_Effect.m_Instance); + + return theEffectInstances; +} + std::set<QString> CClientDataModelBridge::getRenderableList() const { std::vector<SValue> valueList diff --git a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h index 3233bd42..71ca2a81 100644 --- a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h +++ b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h @@ -360,6 +360,7 @@ public: std::set<QString> GetSourcePathList() const; std::set<QString> GetFontFileList() const; std::set<QString> GetDynamicObjectTextureList() const; + qt3dsdm::TInstanceHandleList GetEffectList() const; std::set<QString> getRenderableList() const; bool IsLockedAtAll(qt3dsdm::Qt3DSDMInstanceHandle inInstance); bool IsDuplicateable(qt3dsdm::Qt3DSDMInstanceHandle inInstance); diff --git a/src/Authoring/Qt3DStudio/Application/StudioApp.cpp b/src/Authoring/Qt3DStudio/Application/StudioApp.cpp index 2dc51e26..1eec20a9 100644 --- a/src/Authoring/Qt3DStudio/Application/StudioApp.cpp +++ b/src/Authoring/Qt3DStudio/Application/StudioApp.cpp @@ -2057,6 +2057,13 @@ void CStudioApp::showPresentationIdEmptyWarning() Qt3DSMessageBox::ICON_WARNING, false); } +void CStudioApp::showShaderCompileError(QString &error) +{ + m_dialogs->DisplayMessageBox(tr("Warning"), + tr("Shader compile error.\n\n") + error, + Qt3DSMessageBox::ICON_WARNING, false); +} + void CStudioApp::showInvalidFilenameWarning() { m_dialogs->DisplayMessageBox(tr("Invalid filename"), diff --git a/src/Authoring/Qt3DStudio/Application/StudioApp.h b/src/Authoring/Qt3DStudio/Application/StudioApp.h index 8fccafcf..c4b9f553 100644 --- a/src/Authoring/Qt3DStudio/Application/StudioApp.h +++ b/src/Authoring/Qt3DStudio/Application/StudioApp.h @@ -219,6 +219,7 @@ public: void showPresentationIdUniqueWarning(); void showPresentationIdEmptyWarning(); void showInvalidFilenameWarning(); + void showShaderCompileError(QString &error); void checkDeletedDatainputs(bool askFromUser); void saveDataInputsToProjectFile(); void verifyDatainputBindings(); diff --git a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.cpp b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.cpp index ab7d3e45..f11893b7 100644 --- a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.cpp +++ b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.cpp @@ -50,6 +50,7 @@ #include "IDragable.h" #include "IObjectReferenceHelper.h" #include "IDirectoryWatchingSystem.h" +#include "IStudioRenderer.h" ProjectFileSystemModel::ProjectFileSystemModel(QObject *parent) : QAbstractListModel(parent) , m_model(new QFileSystemModel(this)) @@ -207,6 +208,16 @@ void ProjectFileSystemModel::updateReferences() std::for_each(effectTextureList.begin(), effectTextureList.end(), addReferencesPresentation); std::for_each(renderableList.begin(), renderableList.end(), addReferencesRenderable); + qt3dsdm::TInstanceHandleList theEffectInstances(bridge->GetEffectList()); + + for (const auto instance : theEffectInstances) { + auto err = g_StudioApp.getRenderer().getShaderError(instance); + if (!err.isEmpty()) { + err.prepend(bridge->GetSourcePath(instance) + QStringLiteral("\n\n")); + g_StudioApp.showShaderCompileError(err); + } + } + m_references.insert(projectPath); updateRoles({IsReferencedRole, Qt::DecorationRole}); diff --git a/src/Authoring/Qt3DStudio/Render/IStudioRenderer.h b/src/Authoring/Qt3DStudio/Render/IStudioRenderer.h index fc543a89..f3ccb163 100644 --- a/src/Authoring/Qt3DStudio/Render/IStudioRenderer.h +++ b/src/Authoring/Qt3DStudio/Render/IStudioRenderer.h @@ -67,6 +67,7 @@ public: virtual void SetGuidesEnabled(bool val) = 0; virtual bool AreGuidesEditable() const = 0; virtual void SetGuidesEditable(bool val) = 0; + virtual QString getShaderError(qt3dsdm::Qt3DSDMInstanceHandle theInstance) const = 0; // Setting the camera to -1 disables the edit cameras // So setting the camera to 0- (numcameras - 1) will set change the active // edit camera. diff --git a/src/Authoring/Qt3DStudio/Render/StudioRenderer.cpp b/src/Authoring/Qt3DStudio/Render/StudioRenderer.cpp index 320bca23..2b52a323 100644 --- a/src/Authoring/Qt3DStudio/Render/StudioRenderer.cpp +++ b/src/Authoring/Qt3DStudio/Render/StudioRenderer.cpp @@ -417,6 +417,17 @@ struct SRendererImpl : public IStudioRenderer, Render(); } + QString getShaderError(qt3dsdm::Qt3DSDMInstanceHandle theInstance) const + { + SGraphObjectTranslator *translator + = static_cast<SGraphObjectTranslator *>( + m_Translation->GetOrCreateTranslator(theInstance)); + if (translator) + return translator->GetError(); + else + return {}; + } + void getPreviewFbo(QSize &outFboDim, qt3ds::QT3DSU32 &outFboTexture) override { if (m_Translation) { diff --git a/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.cpp b/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.cpp index c710dcd9..c90fcb93 100644 --- a/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.cpp +++ b/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.cpp @@ -1173,6 +1173,19 @@ struct SEffectTranslator : public SDynamicObjectTranslator if (m_EffectSystem) theItem.Reset(*m_EffectSystem); } + + const QString GetError() override + { + SEffect &theItem = static_cast<SEffect &>(GetGraphObject()); + return QString::fromUtf8(theItem.GetError().c_str()); + } + + void SetError(const QString &error) override + { + SEffect &theItem = static_cast<SEffect &>(GetGraphObject()); + theItem.SetError(m_EffectSystem->GetResourceManager().GetRenderContext() + .GetStringTable().RegisterStr(error)); + } }; struct SCustomMaterialTranslator : public SDynamicObjectTranslator { diff --git a/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.h b/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.h index 3dd9134f..71b4112b 100644 --- a/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.h +++ b/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.h @@ -96,6 +96,8 @@ namespace studio { virtual void ClearChildren() = 0; virtual void AppendChild(SGraphObject &inChild) = 0; virtual void ResetEffect() {} + virtual void SetError(const QString &error) { Q_UNUSED(error); } + virtual const QString GetError() { return {}; } virtual SGraphObject &GetGraphObject() { return *m_GraphObject; } virtual SGraphObject &GetNonAliasedGraphObject() { return *m_GraphObject; } virtual qt3dsdm::Qt3DSDMInstanceHandle GetInstanceHandle() { return m_InstanceHandle; } |