summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Kangas <janne.kangas@qt.io>2019-07-26 14:49:10 +0300
committerJanne Kangas <janne.kangas@qt.io>2019-10-02 14:09:06 +0300
commit3af0e80dbd23ff6ad4d18093ab7aa065b16727ac (patch)
tree53e818f6eb56793cac6e35db29ea1535059fd3a7
parent3c53d50068768bc574b80ecb865eeb9aeb1c2356 (diff)
Indicate material shader errors in Editor
Task-id: QT3DS-3964 Change-Id: Ifac1df41862821c7220c3e9c88d34ceceaacbb0f Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Antti Määttä <antti.maatta@qt.io>
-rw-r--r--src/runtimerender/Qt3DSRenderCustomMaterialRenderContext.h4
-rw-r--r--src/runtimerender/Qt3DSRenderCustomMaterialShaderGenerator.cpp24
-rw-r--r--src/runtimerender/Qt3DSRenderCustomMaterialShaderGenerator.h10
-rw-r--r--src/runtimerender/Qt3DSRenderCustomMaterialSystem.cpp24
-rw-r--r--src/runtimerender/Qt3DSRenderCustomMaterialSystem.h1
-rw-r--r--src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.cpp17
-rw-r--r--src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.h10
-rw-r--r--src/runtimerender/Qt3DSRenderDynamicObjectSystem.cpp2
-rw-r--r--src/runtimerender/Qt3DSRenderMaterialShaderGenerator.h7
-rw-r--r--src/runtimerender/Qt3DSRenderShaderCache.cpp6
-rw-r--r--src/runtimerender/Qt3DSRenderShaderCache.h13
-rw-r--r--src/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.cpp12
-rw-r--r--src/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.h19
-rw-r--r--src/runtimerender/graphobjects/Qt3DSRenderCustomMaterial.h13
-rw-r--r--src/runtimerender/rendererimpl/Qt3DSRenderableObjects.h12
15 files changed, 144 insertions, 30 deletions
diff --git a/src/runtimerender/Qt3DSRenderCustomMaterialRenderContext.h b/src/runtimerender/Qt3DSRenderCustomMaterialRenderContext.h
index 5283660..06267d2 100644
--- a/src/runtimerender/Qt3DSRenderCustomMaterialRenderContext.h
+++ b/src/runtimerender/Qt3DSRenderCustomMaterialRenderContext.h
@@ -56,7 +56,7 @@ namespace render {
const QT3DSMat44 &m_ModelViewProjection;
const QT3DSMat44 &m_ModelMatrix; ///< model to world transformation
const QT3DSMat33 &m_NormalMatrix;
- const SCustomMaterial &m_Material;
+ SCustomMaterial &m_Material;
const NVRenderTexture2D *m_DepthTexture;
const NVRenderTexture2D *m_AOTexture;
SShaderDefaultMaterialKey m_MaterialKey;
@@ -66,7 +66,7 @@ namespace render {
SCustomMaterialRenderContext(
const SLayer &layer, const SLayerRenderData &data, NVDataRef<SLight *> lights,
const SCamera &cam, const SModel &m, const SRenderSubset &subset, const QT3DSMat44 &mvp,
- const QT3DSMat44 &world, const QT3DSMat33 &nm, const SCustomMaterial &material,
+ const QT3DSMat44 &world, const QT3DSMat33 &nm, SCustomMaterial &material,
const NVRenderTexture2D *depthTex, const NVRenderTexture2D *aoTex,
SShaderDefaultMaterialKey inMaterialKey, SRenderableImage *inFirstImage = NULL,
QT3DSF32 opacity = 1.0)
diff --git a/src/runtimerender/Qt3DSRenderCustomMaterialShaderGenerator.cpp b/src/runtimerender/Qt3DSRenderCustomMaterialShaderGenerator.cpp
index 1b0b304..82a4d73 100644
--- a/src/runtimerender/Qt3DSRenderCustomMaterialShaderGenerator.cpp
+++ b/src/runtimerender/Qt3DSRenderCustomMaterialShaderGenerator.cpp
@@ -1200,7 +1200,8 @@ struct SShaderGenerator : public ICustomMaterialShaderGenerator
}
NVRenderShaderProgram *GenerateCustomMaterialShader(const char8_t *inShaderPrefix,
- const char8_t *inCustomMaterialName)
+ const char8_t *inCustomMaterialName,
+ QString &errors)
{
// build a string that allows us to print out the shader we are generating to the log.
// This is time consuming but I feel like it doesn't happen all that often and is very
@@ -1231,7 +1232,8 @@ struct SShaderGenerator : public ICustomMaterialShaderGenerator
VertexGenerator().EndFragmentGeneration(hasCustomFragmentShader);
NVRenderShaderProgram *program = ProgramGenerator().CompileGeneratedShader(
- m_GeneratedShaderString.c_str(), SShaderCacheProgramFlags(), FeatureSet());
+ m_GeneratedShaderString.c_str(), SShaderCacheProgramFlags(), FeatureSet(),
+ errors);
if (program && hasCustomVertexShader) {
// Change uniforms names to match runtime 2.x uniforms
SShaderGeneratorGeneratedShader &shader(GetShaderForProgram(*program));
@@ -1255,7 +1257,7 @@ struct SShaderGenerator : public ICustomMaterialShaderGenerator
GenerateShader(const SGraphObject &inMaterial, SShaderDefaultMaterialKey inShaderDescription,
IShaderStageGenerator &inVertexPipeline, TShaderFeatureSet inFeatureSet,
NVDataRef<SLight *> inLights, SRenderableImage *inFirstImage,
- bool inHasTransparency, const char8_t *inShaderPrefix,
+ bool inHasTransparency, const char8_t *inShaderPrefix, QString &error,
const char8_t *inCustomMaterialName) override
{
QT3DS_ASSERT(inMaterial.m_Type == GraphObjectTypes::CustomMaterial);
@@ -1267,7 +1269,21 @@ struct SShaderGenerator : public ICustomMaterialShaderGenerator
m_FirstImage = inFirstImage;
m_HasTransparency = inHasTransparency;
- return GenerateCustomMaterialShader(inShaderPrefix, inCustomMaterialName);
+ return GenerateCustomMaterialShader(inShaderPrefix, inCustomMaterialName, error);
+ }
+
+ virtual NVRenderShaderProgram *
+ GenerateShader(const SGraphObject &inMaterial, SShaderDefaultMaterialKey inShaderDescription,
+ IShaderStageGenerator &inVertexPipeline, TShaderFeatureSet inFeatureSet,
+ NVDataRef<SLight *> inLights, SRenderableImage *inFirstImage,
+ bool inHasTransparency, const char8_t *inShaderPrefix,
+ const char8_t *inCustomMaterialName) override
+ {
+ QString error;
+
+ return GenerateShader(inMaterial, inShaderDescription, inVertexPipeline, inFeatureSet,
+ inLights, inFirstImage, inHasTransparency, inShaderPrefix,
+ error, inCustomMaterialName);
}
};
}
diff --git a/src/runtimerender/Qt3DSRenderCustomMaterialShaderGenerator.h b/src/runtimerender/Qt3DSRenderCustomMaterialShaderGenerator.h
index 29c31ff..7a3cfad 100644
--- a/src/runtimerender/Qt3DSRenderCustomMaterialShaderGenerator.h
+++ b/src/runtimerender/Qt3DSRenderCustomMaterialShaderGenerator.h
@@ -50,7 +50,15 @@ namespace render {
const SGraphObject &inMaterial, SShaderDefaultMaterialKey inShaderDescription,
IShaderStageGenerator &inVertexPipeline, TShaderFeatureSet inFeatureSet,
NVDataRef<SLight *> inLights, SRenderableImage *inFirstImage, bool inHasTransparency,
- const char8_t *inVertexPipelineName, const char8_t *inCustomMaterialName = "") override = 0;
+ const char8_t *inVertexPipelineName, QString &error,
+ const char8_t *inCustomMaterialName = "") override = 0;
+
+ NVRenderShaderProgram *GenerateShader(
+ const SGraphObject &inMaterial, SShaderDefaultMaterialKey inShaderDescription,
+ IShaderStageGenerator &inVertexPipeline, TShaderFeatureSet inFeatureSet,
+ NVDataRef<SLight *> inLights, SRenderableImage *inFirstImage, bool inHasTransparency,
+ const char8_t *inVertexPipelineName,
+ const char8_t *inCustomMaterialName = "") override = 0;
// Also sets the blend function on the render context.
virtual void
diff --git a/src/runtimerender/Qt3DSRenderCustomMaterialSystem.cpp b/src/runtimerender/Qt3DSRenderCustomMaterialSystem.cpp
index 62d9805..b40e10e 100644
--- a/src/runtimerender/Qt3DSRenderCustomMaterialSystem.cpp
+++ b/src/runtimerender/Qt3DSRenderCustomMaterialSystem.cpp
@@ -1208,7 +1208,8 @@ struct SMaterialSystem : public ICustomMaterialSystem
NVRenderShaderProgram *GetShader(SCustomMaterialRenderContext &inRenderContext,
const SCustomMaterial &inMaterial,
const SBindShader &inCommand, TShaderFeatureSet inFeatureSet,
- const dynamic::SDynamicShaderProgramFlags &inFlags)
+ const dynamic::SDynamicShaderProgramFlags &inFlags,
+ QString &errors)
{
ICustomMaterialShaderGenerator &theMaterialGenerator(
m_Context->GetCustomMaterialShaderGenerator());
@@ -1225,7 +1226,7 @@ struct SMaterialSystem : public ICustomMaterialSystem
inMaterial, inRenderContext.m_MaterialKey, thePipeline, inFeatureSet,
inRenderContext.m_Lights, inRenderContext.m_FirstImage,
(inMaterial.m_hasTransparency || inMaterial.m_hasRefraction),
- "custom material pipeline-- ", inCommand.m_ShaderPath.c_str());
+ "custom material pipeline-- ", errors, inCommand.m_ShaderPath.c_str());
return theProgram;
}
@@ -1233,7 +1234,8 @@ struct SMaterialSystem : public ICustomMaterialSystem
SMaterialOrComputeShader BindShader(SCustomMaterialRenderContext &inRenderContext,
const SCustomMaterial &inMaterial,
const SBindShader &inCommand,
- TShaderFeatureSet inFeatureSet)
+ TShaderFeatureSet inFeatureSet,
+ QString &errors)
{
NVRenderShaderProgram *theProgram = NULL;
eastl::vector<SShaderPreprocessorFeature> features;
@@ -1256,7 +1258,8 @@ struct SMaterialSystem : public ICustomMaterialSystem
eastl::make_pair(skey, NVScopedRefCounted<SCustomMaterialShader>(NULL))));
if (theInsertResult.second || requiresCompilation(inMaterial.m_ClassName)) {
- theProgram = GetShader(inRenderContext, inMaterial, inCommand, featureSet, theFlags);
+ theProgram = GetShader(inRenderContext, inMaterial, inCommand, featureSet, theFlags,
+ errors);
if (theProgram) {
theInsertResult.first->second =
@@ -1264,7 +1267,6 @@ struct SMaterialSystem : public ICustomMaterialSystem
}
} else if (theInsertResult.first->second)
theProgram = theInsertResult.first->second->m_Shader;
-
setRequiresCompilation(inMaterial.m_ClassName, false);
if (theProgram) {
@@ -1741,7 +1743,7 @@ struct SMaterialSystem : public ICustomMaterialSystem
}
void DoRenderCustomMaterial(SCustomMaterialRenderContext &inRenderContext,
- const SCustomMaterial &inMaterial, SMaterialClass &inClass,
+ SCustomMaterial &inMaterial, SMaterialClass &inClass,
NVRenderFrameBuffer *inTarget, TShaderFeatureSet inFeatureSet)
{
NVRenderContext &theContext = m_Context->GetRenderContext();
@@ -1766,6 +1768,7 @@ struct SMaterialSystem : public ICustomMaterialSystem
bool theRenderTargetNeedsClear = false;
NVConstDataRef<dynamic::SCommand *> theCommands(inClass.m_Class->GetRenderCommands());
+ QString errors;
for (QT3DSU32 commandIdx = 0, commandEnd = theCommands.size(); commandIdx < commandEnd;
++commandIdx) {
const SCommand &theCommand(*theCommands[commandIdx]);
@@ -1788,9 +1791,11 @@ struct SMaterialSystem : public ICustomMaterialSystem
theCurrentShader = NULL;
SMaterialOrComputeShader theBindResult =
BindShader(inRenderContext, inMaterial,
- static_cast<const SBindShader &>(theCommand), inFeatureSet);
+ static_cast<const SBindShader &>(theCommand), inFeatureSet, errors);
if (theBindResult.IsMaterialShader())
theCurrentShader = &theBindResult.MaterialShader();
+ if (!errors.isEmpty())
+ inMaterial.SetError(m_CoreContext.GetStringTable().RegisterStr(errors));
} break;
case CommandTypes::ApplyInstanceValue:
// we apply the property update explicitly at the render pass
@@ -2135,6 +2140,11 @@ struct SMaterialSystem : public ICustomMaterialSystem
m_LastFrameTime = currentFrameTime;
}
+ IQt3DSRenderContext *getContext() override
+ {
+ return m_Context;
+ }
+
void Save(qt3ds::render::SWriteBuffer &ioBuffer,
const qt3ds::render::SStrRemapMap &inRemapMap,
const char8_t * /*inProjectDir*/) const override
diff --git a/src/runtimerender/Qt3DSRenderCustomMaterialSystem.h b/src/runtimerender/Qt3DSRenderCustomMaterialSystem.h
index 6bf422c..0f87533 100644
--- a/src/runtimerender/Qt3DSRenderCustomMaterialSystem.h
+++ b/src/runtimerender/Qt3DSRenderCustomMaterialSystem.h
@@ -133,6 +133,7 @@ namespace render {
virtual bool requiresCompilation(const CRegisteredString &name) const = 0;
// Called by the uiccontext so this system can clear any per-frame render information.
virtual void EndFrame() = 0;
+ virtual IQt3DSRenderContext *getContext() = 0;
};
struct QT3DS_AUTOTEST_EXPORT SCustomMaterialVertexPipeline : public SVertexPipelineImpl
diff --git a/src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.cpp b/src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.cpp
index 4a1f6e3..0789d51 100644
--- a/src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.cpp
+++ b/src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.cpp
@@ -1877,8 +1877,23 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
GenerateShader(const SGraphObject &inMaterial, SShaderDefaultMaterialKey inShaderDescription,
IShaderStageGenerator &inVertexPipeline, TShaderFeatureSet inFeatureSet,
NVDataRef<SLight *> inLights, SRenderableImage *inFirstImage,
- bool inHasTransparency, const char8_t *inVertexPipelineName, const char8_t *) override
+ bool inHasTransparency, const char8_t *inVertexPipelineName,
+ const char8_t *) override
{
+ QString error;
+ return GenerateShader(inMaterial, inShaderDescription, inVertexPipeline, inFeatureSet,
+ inLights, inFirstImage, inHasTransparency, inVertexPipelineName,
+ error, "");
+ }
+
+ virtual NVRenderShaderProgram *
+ GenerateShader(const SGraphObject &inMaterial, SShaderDefaultMaterialKey inShaderDescription,
+ IShaderStageGenerator &inVertexPipeline, TShaderFeatureSet inFeatureSet,
+ NVDataRef<SLight *> inLights, SRenderableImage *inFirstImage,
+ bool inHasTransparency, const char8_t *inVertexPipelineName, QString &error,
+ const char8_t *) override
+ {
+ Q_UNUSED(error)
QT3DS_ASSERT(inMaterial.m_Type == GraphObjectTypes::DefaultMaterial);
m_CurrentMaterial = static_cast<const SDefaultMaterial *>(&inMaterial);
m_CurrentKey = &inShaderDescription;
diff --git a/src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.h b/src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.h
index 871ab1b..4d82f4c 100644
--- a/src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.h
+++ b/src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.h
@@ -101,7 +101,15 @@ namespace render {
const SGraphObject &inMaterial, SShaderDefaultMaterialKey inShaderDescription,
IShaderStageGenerator &inVertexPipeline, TShaderFeatureSet inFeatureSet,
NVDataRef<SLight *> inLights, SRenderableImage *inFirstImage, bool inHasTransparency,
- const char8_t *inVertexPipelineName, const char8_t *inCustomMaterialName = "") override = 0;
+ const char8_t *inVertexPipelineName, QString &error,
+ const char8_t *inCustomMaterialName = "") override = 0;
+
+ NVRenderShaderProgram *GenerateShader(
+ const SGraphObject &inMaterial, SShaderDefaultMaterialKey inShaderDescription,
+ IShaderStageGenerator &inVertexPipeline, TShaderFeatureSet inFeatureSet,
+ NVDataRef<SLight *> inLights, SRenderableImage *inFirstImage, bool inHasTransparency,
+ const char8_t *inVertexPipelineName,
+ const char8_t *inCustomMaterialName = "") override = 0;
// generate default material shader for depth only pass
virtual NVRenderShaderProgram *GenerateDepthPassShader(
diff --git a/src/runtimerender/Qt3DSRenderDynamicObjectSystem.cpp b/src/runtimerender/Qt3DSRenderDynamicObjectSystem.cpp
index 378b59b..cb629cc 100644
--- a/src/runtimerender/Qt3DSRenderDynamicObjectSystem.cpp
+++ b/src/runtimerender/Qt3DSRenderDynamicObjectSystem.cpp
@@ -1390,7 +1390,7 @@ struct SDynamicObjectSystemImpl : public IDynamicObjectSystem
}
return theShaderCache.CompileProgram(theKey, m_VertShader.c_str(), m_FragShader.c_str(),
NULL, NULL, m_GeometryShader.c_str(), theFlags,
- inFeatureSet);
+ inFeatureSet, errors);
}
// This just returns the custom material shader source without compiling
diff --git a/src/runtimerender/Qt3DSRenderMaterialShaderGenerator.h b/src/runtimerender/Qt3DSRenderMaterialShaderGenerator.h
index 88858bd..5d70931 100644
--- a/src/runtimerender/Qt3DSRenderMaterialShaderGenerator.h
+++ b/src/runtimerender/Qt3DSRenderMaterialShaderGenerator.h
@@ -136,6 +136,13 @@ namespace render {
const SGraphObject &inMaterial, SShaderDefaultMaterialKey inShaderDescription,
IShaderStageGenerator &inVertexPipeline, TShaderFeatureSet inFeatureSet,
NVDataRef<SLight *> inLights, SRenderableImage *inFirstImage, bool inHasTransparency,
+ const char8_t *inVertexPipelineName, QString &error,
+ const char8_t *inCustomMaterialName = "") = 0;
+
+ virtual NVRenderShaderProgram *GenerateShader(
+ const SGraphObject &inMaterial, SShaderDefaultMaterialKey inShaderDescription,
+ IShaderStageGenerator &inVertexPipeline, TShaderFeatureSet inFeatureSet,
+ NVDataRef<SLight *> inLights, SRenderableImage *inFirstImage, bool inHasTransparency,
const char8_t *inVertexPipelineName, const char8_t *inCustomMaterialName = "") = 0;
// Also sets the blend function on the render context.
diff --git a/src/runtimerender/Qt3DSRenderShaderCache.cpp b/src/runtimerender/Qt3DSRenderShaderCache.cpp
index fd2c669..21d2247 100644
--- a/src/runtimerender/Qt3DSRenderShaderCache.cpp
+++ b/src/runtimerender/Qt3DSRenderShaderCache.cpp
@@ -457,16 +457,16 @@ struct ShaderCache : public IShaderCache
CompileProgram(CRegisteredString inKey, const char8_t *inVert, const char8_t *inFrag,
const char8_t *inTessCtrl, const char8_t *inTessEval, const char8_t *inGeom,
const SShaderCacheProgramFlags &inFlags,
- NVConstDataRef<SShaderPreprocessorFeature> inFeatures, bool separableProgram) override
+ NVConstDataRef<SShaderPreprocessorFeature> inFeatures,
+ QString &errors, bool separableProgram) override
{
NVRenderShaderProgram *theProgram = GetProgram(inKey, inFeatures);
if (theProgram)
return theProgram;
- QString error;
NVRenderShaderProgram *retval =
ForceCompileProgram(inKey, inVert, inFrag, inTessCtrl, inTessEval, inGeom, inFlags,
- inFeatures, error, separableProgram);
+ inFeatures, errors, separableProgram);
return retval;
}
diff --git a/src/runtimerender/Qt3DSRenderShaderCache.h b/src/runtimerender/Qt3DSRenderShaderCache.h
index 94080ed..d03bc65 100644
--- a/src/runtimerender/Qt3DSRenderShaderCache.h
+++ b/src/runtimerender/Qt3DSRenderShaderCache.h
@@ -132,7 +132,18 @@ namespace render {
CompileProgram(CRegisteredString inKey, const char8_t *inVert, const char8_t *inFrag,
const char8_t *inTessCtrl, const char8_t *inTessEval, const char8_t *inGeom,
const SShaderCacheProgramFlags &inFlags, TShaderFeatureSet inFeatures,
- bool separableProgram = false) = 0;
+ QString &errors, bool separableProgram = false) = 0;
+
+ virtual NVRenderShaderProgram *
+ CompileProgram(CRegisteredString inKey, const char8_t *inVert, const char8_t *inFrag,
+ const char8_t *inTessCtrl, const char8_t *inTessEval, const char8_t *inGeom,
+ const SShaderCacheProgramFlags &inFlags, TShaderFeatureSet inFeatures,
+ bool separableProgram = false)
+ {
+ QString errors;
+ return CompileProgram(inKey, inVert, inFrag, inTessCtrl, inTessEval, inGeom, inFlags,
+ inFeatures, errors, separableProgram);
+ }
// Used to disable any shader compilation during loading. This is used when we are just
// interested in going from uia->binary
diff --git a/src/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.cpp b/src/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.cpp
index cfdf47a..74af857 100644
--- a/src/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.cpp
+++ b/src/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.cpp
@@ -511,6 +511,16 @@ struct SProgramGenerator : public IShaderProgramGenerator
CompileGeneratedShader(const char *inShaderName, const SShaderCacheProgramFlags &inFlags,
TShaderFeatureSet inFeatureSet, bool separableProgram) override
{
+ QString errors;
+ return CompileGeneratedShader(inShaderName, inFlags, inFeatureSet, errors,
+ separableProgram);
+ }
+
+ qt3ds::render::NVRenderShaderProgram *
+ CompileGeneratedShader(const char *inShaderName, const SShaderCacheProgramFlags &inFlags,
+ TShaderFeatureSet inFeatureSet, QString &errors,
+ bool separableProgram) override
+ {
// No stages enabled
if (((QT3DSU32)m_EnabledStages) == 0) {
QT3DS_ASSERT(false);
@@ -542,7 +552,7 @@ struct SProgramGenerator : public IShaderProgramGenerator
CRegisteredString theCacheKey = m_Context.GetStringTable().RegisterStr(inShaderName);
return theCache.CompileProgram(theCacheKey, vertexShaderSource, fragmentShaderSource,
tcShaderSource, teShaderSource, geShaderSource,
- theCacheFlags, inFeatureSet, separableProgram);
+ theCacheFlags, inFeatureSet, errors, separableProgram);
}
};
};
diff --git a/src/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.h b/src/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.h
index 6a6e967..676f00b 100644
--- a/src/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.h
+++ b/src/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.h
@@ -115,11 +115,26 @@ namespace render {
CompileGeneratedShader(const char *inShaderName, const SShaderCacheProgramFlags &inFlags,
TShaderFeatureSet inFeatureSet, bool separableProgram = false) = 0;
+ virtual qt3ds::render::NVRenderShaderProgram *
+ CompileGeneratedShader(const char *inShaderName, const SShaderCacheProgramFlags &inFlags,
+ TShaderFeatureSet inFeatureSet, QString &errors,
+ bool separableProgram = false) = 0;
+
+
+ qt3ds::render::NVRenderShaderProgram *CompileGeneratedShader(const char *inShaderName,
+ bool separableProgram = false)
+ {
+ QString errors;
+ return CompileGeneratedShader(inShaderName, SShaderCacheProgramFlags(),
+ TShaderFeatureSet(), errors, separableProgram);
+ }
+
qt3ds::render::NVRenderShaderProgram *CompileGeneratedShader(const char *inShaderName,
- bool separableProgram = false)
+ QString &errors,
+ bool separableProgram = false)
{
return CompileGeneratedShader(inShaderName, SShaderCacheProgramFlags(),
- TShaderFeatureSet(), separableProgram);
+ TShaderFeatureSet(), errors, separableProgram);
}
static IShaderProgramGenerator &CreateProgramGenerator(IQt3DSRenderContext &inContext);
diff --git a/src/runtimerender/graphobjects/Qt3DSRenderCustomMaterial.h b/src/runtimerender/graphobjects/Qt3DSRenderCustomMaterial.h
index 1202c7c..7c6b10e 100644
--- a/src/runtimerender/graphobjects/Qt3DSRenderCustomMaterial.h
+++ b/src/runtimerender/graphobjects/Qt3DSRenderCustomMaterial.h
@@ -86,6 +86,8 @@ namespace render {
SCustomMaterialShaderKeyFlags m_ShaderKeyValues; ///< input from MDL files
QT3DSU32 m_LayerCount; ///< input from MDL files
+ CRegisteredString m_error; // shader compile error
+
void Initialize(QT3DSU32 inKey, QT3DSU32 inLayerCount)
{
m_Lightmaps.m_LightmapIndirect = NULL;
@@ -103,6 +105,7 @@ namespace render {
m_ShaderKeyValues = (SCustomMaterialShaderKeyFlags)inKey;
m_LayerCount = inLayerCount;
m_imageMaps = nullptr;
+ m_error = CRegisteredString();
}
bool IsDielectric() const
@@ -127,6 +130,16 @@ namespace render {
}
bool HasLighting() const { return true; }
+ CRegisteredString GetError() const
+ {
+ return m_error;
+ }
+
+ void SetError(const CRegisteredString &error)
+ {
+ m_error = error;
+ }
+
template <typename TRemapperType>
void Remap(TRemapperType &inRemapper)
{
diff --git a/src/runtimerender/rendererimpl/Qt3DSRenderableObjects.h b/src/runtimerender/rendererimpl/Qt3DSRenderableObjects.h
index 6dbc624..abc8143 100644
--- a/src/runtimerender/rendererimpl/Qt3DSRenderableObjects.h
+++ b/src/runtimerender/rendererimpl/Qt3DSRenderableObjects.h
@@ -296,14 +296,14 @@ namespace render {
*/
struct SSubsetRenderable : public SSubsetRenderableBase
{
- const SDefaultMaterial &m_Material;
+ SDefaultMaterial &m_Material;
SRenderableImage *m_FirstImage;
SShaderDefaultMaterialKey m_ShaderDescription;
NVConstDataRef<QT3DSMat44> m_Bones;
SSubsetRenderable(SRenderableObjectFlags inFlags, QT3DSVec3 inWorldCenterPt,
Qt3DSRendererImpl &gen, const SRenderSubset &subset,
- const SDefaultMaterial &mat, const SModelContext &modelContext,
+ SDefaultMaterial &mat, const SModelContext &modelContext,
QT3DSF32 inOpacity, SRenderableImage *inFirstImage,
SShaderDefaultMaterialKey inShaderKey,
NVConstDataRef<QT3DSMat44> inBoneGlobals)
@@ -334,13 +334,13 @@ namespace render {
struct SCustomMaterialRenderable : public SSubsetRenderableBase
{
- const SCustomMaterial &m_Material;
+ SCustomMaterial &m_Material;
SRenderableImage *m_FirstImage;
SShaderDefaultMaterialKey m_ShaderDescription;
SCustomMaterialRenderable(SRenderableObjectFlags inFlags, QT3DSVec3 inWorldCenterPt,
Qt3DSRendererImpl &gen, const SRenderSubset &subset,
- const SCustomMaterial &mat, const SModelContext &modelContext,
+ SCustomMaterial &mat, const SModelContext &modelContext,
QT3DSF32 inOpacity, SRenderableImage *inFirstImage,
SShaderDefaultMaterialKey inShaderKey)
: SSubsetRenderableBase(inFlags, inWorldCenterPt, gen, subset, modelContext, inOpacity)
@@ -451,8 +451,8 @@ namespace render {
SPathRenderable(SRenderableObjectFlags inFlags, QT3DSVec3 inWorldCenterPt,
Qt3DSRendererImpl &gen, const QT3DSMat44 &inGlobalTransform,
NVBounds3 &inBounds, SPath &inPath, const QT3DSMat44 &inModelViewProjection,
- const QT3DSMat33 inNormalMat, const SGraphObject &inMaterial, QT3DSF32 inOpacity,
- SShaderDefaultMaterialKey inShaderKey, bool inIsStroke)
+ const QT3DSMat33 inNormalMat, const SGraphObject &inMaterial,
+ QT3DSF32 inOpacity, SShaderDefaultMaterialKey inShaderKey, bool inIsStroke)
: SRenderableObject(inFlags, inWorldCenterPt, inGlobalTransform, m_Bounds)
, m_Generator(gen)