-
Notifications
You must be signed in to change notification settings - Fork 1
Optim: Misc math optimizations #2
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
base: main
Are you sure you want to change the base?
Conversation
|
Commit #1: Don't need to 0 out these bytes due to right shift For the R value, since we're only getting the top level bits of RGB, the bits afterward are irrelevant, and we don't need to 0 them out. Commit #2: calcPos() faster Numerous optimizations have been made to calcPos(). For one, width/2 has been moved into a variable. The line I also improved the logic so cosine is no longer calculated twice in some scenarios. The most complicated change (and what I expect to be the most controversial) is the new cosine approximation. Rather than using libc's built in cos() function, I changed it to a different approximation formula that was thought of in the 7th Century by Bhaskara the First. This was done as Bhaskara's formula, at least to my testing on my x86_64 mac, seems consistently faster than libc's cos() function. I know this is slightly less accurate, but I believe for our use case it's accurate enough. I also made calcPos() no longer need to calculate the sin() and instead just get it from the cosine. Also, not part of calcPos(), but doublePi has been moved down in calcAngle() :P. Commit #3: Faster sin approximation I also implemented Bhaskara's sin approximation formula to be used over libc's. This speeds up wave(). Commit #4 (and 5 and 6): Remove unused arg in wave() Remove the height arg in wave as it is unused. |
|
Commit #7 (and 8 and 9): Change width arg to unsigned int in wave(). Commit #10: Remove unreachable code path in ScrollRecognizer Commit #11: Not tested but hopefully caching those as local variables should boost speed... |
|
Commit #12: Implemented my custom atan approx which is faster than libc |
No description provided.