Skip to content
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

Add fallbacks for findUniform methods #2150

Merged

Conversation

jstone-lucasfilm
Copy link
Member

This changelist adds fallbacks to the GlslMaterial::findUniform and MslMaterial::findUniform methods, allowing them to find matches for uniforms that don't yet have a full path.

This addresses issue #1782.

This changelist adds fallbacks to the GlslMaterial::findUniform and MslMaterial::findUniform methods, allowing them to find matches for uniforms that don't yet have a full path.

This addresses issue AcademySoftwareFoundation#1782.
@jstone-lucasfilm jstone-lucasfilm merged commit af74b61 into AcademySoftwareFoundation:main Dec 17, 2024
34 checks passed
{
port = publicUniforms->find([path](ShaderPort* port)
{
return (port && stringEndsWith(path, port->getName()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering if this might be cleaner (and more efficient?) if we folded this check inside the one above?

        port = publicUniforms->find([path](ShaderPort* port)
        {
            return (port && (stringEndsWith(port->getPath(), path) || stringEndsWith(path, port->getName()));
        });

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good instinct from an efficiency perspective, though in this case it would alter the results of the function in a way that we don't intend, allowing the fallback logic to affect searches that already successfully found matches.

As this logic is currently written, if the first search succeeds, then the fallback logic is entirely skipped, making it so that only failure cases for the original function are extended by the fallback behavior.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense - thanks for the clarification.

I wonder if it's helpful to add a code comment to that effect - to avoid someone thinking there is a potential optimization here in the future?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants