-
Notifications
You must be signed in to change notification settings - Fork 358
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
Deterministic code generation #1376
Deterministic code generation #1376
Conversation
Thanks for this fix, @SShikhali, and let us know if you run into trouble with the EasyCLA process. The Linux Foundation is usually very responsive if you submit a support ticket using the links above. |
@jstone-lucasfilm should be fixed now, thanks :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting this fix together, @SShikhali!
To make sure we don't lose any efficiency with respect to the original version, it may be better to maintain both a vector and a set, as in the following:
std::set<ShaderNode*> usedNodeSet;
std::vector<ShaderNode*> usedNodeVec;
This would allow us to efficiently maintain a vector of unique nodes with logic like the following:
ShaderNode* node = edge.upstream->getNode();
if (usedNodeSet.count(node) == 0)
{
usedNodeSet.insert(node);
usedNodeVec.push_back(node);
}
An at the end of the function, we could then simply replace the resize
and assign
calls with the following:
_nodeOrder = usedNodeVec;
@jstone-lucasfilm yes, that's better. Pushed the improved version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, thanks @SShikhali!
I'm CC'ing @niklasharrysson for his thoughts before we merge, but I don't have any concerns on my side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks for the fix @SShikhali
These changes make code generation deterministic by changing std::set to std::vector when removing unused nodes
These changes make code generation deterministic by changing
std::set
tostd::vector
when removing unused nodes