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

Faster Particle & Cuboid vertex build #2960

Closed
wants to merge 3 commits into from

Conversation

MoePus
Copy link
Contributor

@MoePus MoePus commented Jan 1, 2025

For particles: use camera's left vector and up vector to build vertices to avoid Quat transfroms.
For cuboids: use vectors to calc vertices to avoid some muls

@jellysquid3
Copy link
Member

Hi. Thanks for the pull request.

Your changes look interesting. These floating point ops are a rather significant part of the runtime (as Java can't vectorize or schedule the instructions correctly) and I would expect this patch set improves meshing performance quite a bit.

@jellysquid3 jellysquid3 self-requested a review January 1, 2025 18:39
@MoePus
Copy link
Contributor Author

MoePus commented Jan 2, 2025

Hi,

I’m really glad to see that my code contributes to improving Minecraft's performance. The changes I submitted originate from my addon project for the Forge Sodium port on 1.20.1. The addon includes both non-aggressive optimizations, which are designed to be safe and should be side-effect-free, and some more aggressive changes that focus on maximizing FPS improvements.

I plan to upstream all non-aggressive optimizations to Sodium, while continuing to maintain the aggressive changes in my addon. Additionally, I’ll be updating the addon to support Sodium on 1.21.x Neoforge.

Would it be possible to incorporate some of Sodium’s recent improvements into my addon to further enhance compatibility and performance for Forge users?

Thank you for your time and consideration!

Best regards

@jellysquid3
Copy link
Member

I've merged the changes you've proposed separately and with some further modification. (7f25220, 1b0f7b9)

The entity rendering patches did not seem to improve performance on my machine, because of bad code generation from the compiler. There was a lot of work needed to optimize the existing code to help free the bottleneck and make your optimizations take effect. After everything, entity rendering is anywhere from 8 to 15% faster on my machine, with the trick you suggested being about ~40% of that runtime improvement.

As for the billboard particle rendering patches, no further changes were made, and they seemed to help the rendering performance by around ~10% (though lighting calculations are still by far the slowest thing.)

@jellysquid3 jellysquid3 closed this Jan 2, 2025
@jellysquid3
Copy link
Member

jellysquid3 commented Jan 2, 2025

Would it be possible to incorporate some of Sodium’s recent improvements into my addon to further enhance compatibility and performance for Forge users?

Sodium 0.6+ is licensed under the Polyform Shield, which only stipulates that you cannot use our code to compete with upstream. If your addon depends on Sodium to run, then it probably wouldn't be competition.

That said, Sodium also has an official port for NeoForge, so if your addon is installed alongside Sodium, you would probably not need to incorporate anything into your mod. Of course, you still retain the original copyright of any code you submit to our project, so you can license it for your own needs however you see fit.

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.

None yet

2 participants