Skip to content

Commit 8bf12f6

Browse files
committed
guard MslProgram::updateAttributeList() to only run once per MslProgram build() invocation - instead of repeatedly
1 parent dcd0285 commit 8bf12f6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

source/MaterialXRenderMsl/MslPipelineStateObject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ class MX_RENDERMSL_API MslProgram
294294
InputMap _uniformList;
295295
std::unordered_map<std::string, std::string> _globalUniformNameList;
296296
// List of program input attributes
297+
bool _attributeListComplete{false};
297298
InputMap _attributeList;
298299

299300
std::unordered_map<std::string, ImagePtr> _explicitBoundImages;

source/MaterialXRenderMsl/MslPipelineStateObject.mm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ int GetStrideOfMetalType(MTLDataType type)
301301
throw ExceptionRenderError(errorType, errors);
302302
}
303303

304+
_attributeListComplete = false;
305+
304306
// If we encountered any errors while trying to create return list
305307
// of all errors. That is we collect all errors per stage plus any
306308
// errors during linking and throw one exception for them all so that
@@ -1518,6 +1520,11 @@ throw ExceptionRenderError(
15181520
throw ExceptionRenderError(errorType, errors);
15191521
}
15201522

1523+
if (_attributeListComplete)
1524+
{
1525+
return _attributeList;
1526+
}
1527+
15211528
if (_shader)
15221529
{
15231530
const ShaderStage& vs = _shader->getStage(Stage::VERTEX);
@@ -1559,6 +1566,8 @@ throw ExceptionRenderError(
15591566
}
15601567
}
15611568

1569+
_attributeListComplete = true;
1570+
15621571
// Throw an error if any type mismatches were found
15631572
if (uniformTypeMismatchFound)
15641573
{

0 commit comments

Comments
 (0)