Skip to content

Commit 20fd8f4

Browse files
authored
Optimization to MslProgram::updateAttributeList (#2317)
This PR addresses #2309 introduce guard to avoid repeatedly setting the value and type string for the `_attributeList`.
1 parent 6ce8fd0 commit 20fd8f4

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

source/MaterialXRenderMsl/MslPipelineStateObject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,10 @@ class MX_RENDERMSL_API MslProgram
293293
// List of program input uniforms
294294
InputMap _uniformList;
295295
std::unordered_map<std::string, std::string> _globalUniformNameList;
296+
296297
// List of program input attributes
297298
InputMap _attributeList;
299+
bool _attributeListComplete = false;
298300

299301
std::unordered_map<std::string, ImagePtr> _explicitBoundImages;
300302

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)