Skip to content

Return early from EffectTransform methods if no effect bits are set #481

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

Conversation

adroitwhiz
Copy link
Contributor

Proposed Changes

This PR changes EffectTransform's transformColor and transformPoint methods to check if any effect bits are set, and if not, return their inputs before doing anything else (e.g. getting uniforms, copying the input to the output).

Reason for Changes

These functions are called inside tight loops, and optimizing them in this way appears to yield a ~25-30% performance improvement on "touching color" checks, according to this benchmark:

Current This PR
image image

@thisandagain
Copy link
Contributor

Copy link
Contributor

@mzgoddard mzgoddard left a comment

Choose a reason for hiding this comment

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

We need to move the if test and return an initialized dst but otherwise this looks good to me.

@adroitwhiz
Copy link
Contributor Author

@mzgoddard Good catch!

@adroitwhiz
Copy link
Contributor Author

Closing this PR in favor of a better one

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

Successfully merging this pull request may close these issues.

4 participants