Skip to content

Commit

Permalink
Refactor goto statement (#1799)
Browse files Browse the repository at this point in the history
Refactoring Metal rendering code path to remove goto statement.
  • Loading branch information
ld-kerley authored May 1, 2024
1 parent fd5f66c commit 19c0108
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions source/MaterialXRenderMsl/MslPipelineStateObject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1019,9 +1019,20 @@ int GetStrideOfMetalType(MTLDataType type)
continue;
}

int tries = 0;
auto inputIt = _uniformList.find(v->getVariable());
try_again: if (inputIt != _uniformList.end())
if (inputIt == _uniformList.end())
{
if (v->getType() == Type::FILENAME)
{
inputIt = _uniformList.find(TEXTURE_NAME(v->getVariable()));
}
else
{
inputIt = _uniformList.find(uniforms.getInstance() + "." + v->getVariable());
}
}

if (inputIt != _uniformList.end())
{
Input* input = inputIt->second.get();
input->path = v->getPath();
Expand All @@ -1043,22 +1054,6 @@ int GetStrideOfMetalType(MTLDataType type)
uniformTypeMismatchFound = true;
}
}
else
{
if(tries == 0)
{
++tries;
if(v->getType() == Type::FILENAME)
{
inputIt = _uniformList.find(TEXTURE_NAME(v->getVariable()));
}
else
{
inputIt = _uniformList.find(uniforms.getInstance() + "." + v->getVariable());
}
goto try_again;
}
}
}
}

Expand Down

0 comments on commit 19c0108

Please sign in to comment.