Skip to content

Commit 3a98031

Browse files
committed
guard MslProgram::updateAttributeList() to only run once per MslProgram build() invocation - instead of repeatedly
1 parent e1b6197 commit 3a98031

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
@@ -298,6 +298,8 @@ int GetStrideOfMetalType(MTLDataType type)
298298
throw ExceptionRenderError(errorType, errors);
299299
}
300300

301+
_attributeListComplete = false;
302+
301303
// If we encountered any errors while trying to create return list
302304
// of all errors. That is we collect all errors per stage plus any
303305
// errors during linking and throw one exception for them all so that
@@ -1515,6 +1517,11 @@ throw ExceptionRenderError(
15151517
throw ExceptionRenderError(errorType, errors);
15161518
}
15171519

1520+
if (_attributeListComplete)
1521+
{
1522+
return _attributeList;
1523+
}
1524+
15181525
if (_shader)
15191526
{
15201527
const ShaderStage& vs = _shader->getStage(Stage::VERTEX);
@@ -1556,6 +1563,8 @@ throw ExceptionRenderError(
15561563
}
15571564
}
15581565

1566+
_attributeListComplete = true;
1567+
15591568
// Throw an error if any type mismatches were found
15601569
if (uniformTypeMismatchFound)
15611570
{

0 commit comments

Comments
 (0)