From ecfe8f06a1ea08e2a283cf091bfc7194ec3ddf6d Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sun, 26 Nov 2023 17:18:00 +0100 Subject: [PATCH 1/4] Main: Technique - also check RSC_WIDE_LINES for compatibility --- OgreMain/src/OgreTechnique.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/OgreMain/src/OgreTechnique.cpp b/OgreMain/src/OgreTechnique.cpp index 7a1bef92e20..1ba36ff7151 100644 --- a/OgreMain/src/OgreTechnique.cpp +++ b/OgreMain/src/OgreTechnique.cpp @@ -99,9 +99,16 @@ namespace Ogre { // Adjust pass index currPass->_notifyIndex(passNum); - if(currPass->getPointSpritesEnabled() && !caps->hasCapability(RSC_POINT_SPRITES)) + const char* err = 0; + + if(currPass->getLineWidth() != 1 && !caps->hasCapability(RSC_WIDE_LINES)) + err = "line_width > 1"; + else if(currPass->getPointSize() != 1 && !caps->hasCapability(RSC_POINT_SPRITES)) + err = "point_size > 1"; + + if(err) { - compileErrors << "Pass " << passNum << ": Point sprites not supported by RenderSystem"; + compileErrors << "Pass " << passNum << ": " << err << " not supported by RenderSystem"; return false; } @@ -109,7 +116,6 @@ namespace Ogre { size_t texUnit = 0; for(const TextureUnitState* tex : currPass->getTextureUnitStates()) { - const char* err = 0; if ((tex->getTextureType() == TEX_TYPE_3D) && !caps->hasCapability(RSC_TEXTURE_3D)) err = "Volume"; From 59a6fb9222af357e3df4d8a6e68c33a537cb47a9 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sun, 26 Nov 2023 19:59:01 +0100 Subject: [PATCH 2/4] Main: simplify ParticleSystemTranslator --- OgreMain/src/OgreScriptTranslator.cpp | 88 +++++++++++---------------- 1 file changed, 34 insertions(+), 54 deletions(-) diff --git a/OgreMain/src/OgreScriptTranslator.cpp b/OgreMain/src/OgreScriptTranslator.cpp index ce1beba4e6a..20332bd97b2 100644 --- a/OgreMain/src/OgreScriptTranslator.cpp +++ b/OgreMain/src/OgreScriptTranslator.cpp @@ -4347,72 +4347,52 @@ namespace Ogre{ if(i->type == ANT_PROPERTY) { PropertyAbstractNode *prop = static_cast(i.get()); - switch(prop->id) + if(prop->values.empty()) { - case ID_MATERIAL: - if(prop->values.empty()) - { - compiler->addError(ScriptCompiler::CE_STRINGEXPECTED, prop->file, prop->line); - return; - } - else - { - if(prop->values.front()->type == ANT_ATOM) - { - String name = ((AtomAbstractNode*)prop->values.front().get())->value; - - ProcessResourceNameScriptCompilerEvent locEvt(ProcessResourceNameScriptCompilerEvent::MATERIAL, name); - compiler->_fireEvent(&locEvt, 0); + compiler->addError(ScriptCompiler::CE_STRINGEXPECTED, prop->file, prop->line); + return; + } - if(!mSystem->setParameter("material", locEvt.mName)) - { - if(mSystem->getRenderer()) - { - if(!mSystem->getRenderer()->setParameter("material", locEvt.mName)) - compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line, - "material property could not be set with material \"" + locEvt.mName + "\""); - } - } - } - } - break; - default: - if(prop->values.empty()) + String value; + if(prop->id == ID_MATERIAL) + { + if(prop->values.front()->type == ANT_ATOM) { - compiler->addError(ScriptCompiler::CE_STRINGEXPECTED, prop->file, prop->line); - return; + value = ((AtomAbstractNode*)prop->values.front().get())->value; + + ProcessResourceNameScriptCompilerEvent locEvt(ProcessResourceNameScriptCompilerEvent::MATERIAL, value); + compiler->_fireEvent(&locEvt, 0); + value = locEvt.mName; } - else + } + else + { + // Glob the values together + for(auto& v : prop->values) { - String name = prop->name, value; - - // Glob the values together - for(auto& v : prop->values) + if(v->type == ANT_ATOM) { - if(v->type == ANT_ATOM) - { - if(value.empty()) - value = ((AtomAbstractNode*)v.get())->value; - else - value = value + " " + ((AtomAbstractNode*)v.get())->value; - } + if(value.empty()) + value = ((AtomAbstractNode*)v.get())->value; else - { - compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line); - return; - } + value = value + " " + ((AtomAbstractNode*)v.get())->value; } - - if(!mSystem->setParameter(name, value)) + else { - if(mSystem->getRenderer()) - { - if(!mSystem->getRenderer()->setParameter(name, value)) - compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line); - } + compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line); + return; } } } + + if(!mSystem->setParameter(prop->name, value)) + { + if(auto renderer = mSystem->getRenderer()) + { + if(!renderer->setParameter(prop->name, value)) + compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line); + } + } } else { From 63d8af7b4a4be4a7e3503ac0f5a942412465c99f Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sun, 26 Nov 2023 20:11:21 +0100 Subject: [PATCH 3/4] Main: Technique - do not add superfluous newline to compileErrors --- OgreMain/src/OgreTechnique.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/OgreMain/src/OgreTechnique.cpp b/OgreMain/src/OgreTechnique.cpp index 1ba36ff7151..7536912053d 100644 --- a/OgreMain/src/OgreTechnique.cpp +++ b/OgreMain/src/OgreTechnique.cpp @@ -146,8 +146,7 @@ namespace Ogre { { // The user disabled auto pass split compileErrors << "Pass " << passNum << - ": Too many texture units for the current hardware and no splitting allowed." - << std::endl; + ": Too many texture units for the current hardware and no splitting allowed"; return false; } else if (currPass->hasVertexProgram()) @@ -155,8 +154,7 @@ namespace Ogre { // Can't do this one, and can't split a programmable pass compileErrors << "Pass " << passNum << ": Too many texture units for the current hardware and " - "cannot split programmable passes." - << std::endl; + "cannot split programmable passes"; return false; } } @@ -198,13 +196,12 @@ namespace Ogre { ": " << GpuProgram::getProgramTypeName(programType) + " program " << program->getName() << " cannot be used - "; if (program->hasCompileError() && program->getSource().empty()) - compileErrors << "resource not found."; + compileErrors << "resource not found"; else if (program->hasCompileError()) - compileErrors << "compile error."; + compileErrors << "compile error"; else - compileErrors << "not supported."; + compileErrors << "not supported"; - compileErrors << std::endl; return false; } } From 71a10ee3ed79bb15484d072cf170e1947d1b4ff7 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sun, 26 Nov 2023 20:12:14 +0100 Subject: [PATCH 4/4] Main: GpuProgramTranslator - skip params on programs that failed to load --- OgreMain/src/OgreScriptTranslator.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OgreMain/src/OgreScriptTranslator.cpp b/OgreMain/src/OgreScriptTranslator.cpp index 20332bd97b2..32c41f44c3b 100644 --- a/OgreMain/src/OgreScriptTranslator.cpp +++ b/OgreMain/src/OgreScriptTranslator.cpp @@ -3640,6 +3640,10 @@ namespace Ogre{ if(prog->isSupported() && params) { GpuProgramParametersSharedPtr ptr = prog->getDefaultParameters(); + + if(prog->hasCompileError()) + return; + GpuProgramTranslator::translateProgramParameters(compiler, ptr, static_cast(params.get())); } }