Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devel #2976

Merged
merged 4 commits into from
Nov 26, 2023
Merged

Devel #2976

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 38 additions & 54 deletions OgreMain/src/OgreScriptTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3640,6 +3640,10 @@ namespace Ogre{
if(prog->isSupported() && params)
{
GpuProgramParametersSharedPtr ptr = prog->getDefaultParameters();

if(prog->hasCompileError())
return;

GpuProgramTranslator::translateProgramParameters(compiler, ptr, static_cast<ObjectAbstractNode*>(params.get()));
}
}
Expand Down Expand Up @@ -4347,72 +4351,52 @@ namespace Ogre{
if(i->type == ANT_PROPERTY)
{
PropertyAbstractNode *prop = static_cast<PropertyAbstractNode*>(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
{
Expand Down
25 changes: 14 additions & 11 deletions OgreMain/src/OgreTechnique.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,23 @@ 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;
}

// Check a few fixed-function options in texture layers
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";

Expand Down Expand Up @@ -140,17 +146,15 @@ 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())
{
// 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;
}
}
Expand Down Expand Up @@ -192,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;
}
}
Expand Down