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 bevy_anti_aliasing #18323

Merged
merged 13 commits into from
Mar 19, 2025
Merged

Conversation

IceSentry
Copy link
Contributor

@IceSentry IceSentry commented Mar 15, 2025

Objective

  • bevy_core_pipeline is getting really big and it's a big bottleneck for compilation time. A lot of parts of it can be broken up

Solution

  • Add a new bevy_anti_aliasing crate that contains all the anti_aliasing implementations
  • I didn't move any MSAA related code to this new crate because that's a lot more invasive

Testing

  • Tested the anti_aliasing example to make sure all methods still worked

Showcase

before:
image

after:
image

Notice that now bevy_core_pipeline is 1s shorter and bevy_anti_aliasing now compiles in parallel with bevy_pbr.

Migration Guide

When using anti aliasing features, you now need to import them from bevy::anti_aliasing instead of bevy::core_pipeline

@IceSentry IceSentry added A-Rendering Drawing game state to the screen C-Performance A change motivated by improving speed, memory usage or compile times S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Mar 15, 2025
@alice-i-cecile alice-i-cecile added M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide X-Controversial There is active debate or serious implications around merging this PR labels Mar 15, 2025
@alice-i-cecile alice-i-cecile requested a review from cart March 15, 2025 05:15
@alice-i-cecile
Copy link
Member

That's a very sensible split. I would prefer this even with no impact on compilation.

@IceSentry
Copy link
Contributor Author

Yeah, I've wanted this split for a long time for various reasons, but compile time started to be a big enough issue that it kinda forced me to do it.

@JMS55
Copy link
Contributor

JMS55 commented Mar 15, 2025

Why move RCAS to the AA crate too? I don't dislike it, but I'm not sure I like it either.

Also DLSS will added here shortly too, I suppose.

@IceSentry
Copy link
Contributor Author

Why move RCAS to the AA crate too?

The main reason is that it depends on the FXAA node to be added first and since after this change that node only gets added in the new crate which is after the core_pipeline crate. This means it needs to live there for now. I'm also looking at making a bevy_post_processing crate where this could be moved to, but it kinda make sense to keep it with AA considering it's the main reason to use it.

An alternative solution would be to have a generic AntiAliasingNode that is just a label defined in core_pipeline and depend on that instead of the fxaa node directly.

@JMS55
Copy link
Contributor

JMS55 commented Mar 15, 2025

An alternative solution would be to have a generic AntiAliasingNode that is just a label defined in core_pipeline and depend on that instead of the fxaa node directly.

Don't think that's a good idea, unless we split it up between AA and TAA marker nodes. Lots of post processing effects need to go before/after TAA/DLSS/FSR/etc.

@hukasu
Copy link
Contributor

hukasu commented Mar 16, 2025

I'm also looking at making a bevy_post_processing crate where this could be moved to

how many post processing methods does bevy offer today? if it is just RCAS, then having it by itself now would be too much IMO

i would go as far as having each individual algorithm behind a feature flag (bevy_anti_aliasing/fxaa, bevy_anti_aliasing/taa, etc), each of them have a internal asset for the shader and that is a few bytes you can shave off the binary

@IceSentry
Copy link
Contributor Author

IceSentry commented Mar 16, 2025

how many post processing methods does bevy offer today?

bloom, motion blur, depth of field, chromatic aberration, auto exposure. RCAS is kinda post processing too, but it's heavily tied to AA. There's also tonemapping but it's used in core pipelines so it's easier to keep it there and it's kinda a core part of pbr.

The goal isn't to reduce the binary size, it's to group things together that go together and also try to parallelize compilation a bit more.

We could feature flag each technique for people that really want to lean out their app, but most app should offer different AA techniques and let users decide what they prefer.

@JMS55
Copy link
Contributor

JMS55 commented Mar 16, 2025

Tonemapping I want to combine with our UpscaleNode into a new ResolveRenderTargetNode fyi, just haven't gotten around to it yet.

@JMS55
Copy link
Contributor

JMS55 commented Mar 17, 2025

In reference to my previous comment: #16721

Copy link
Contributor

@kristoff3r kristoff3r left a comment

Choose a reason for hiding this comment

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

Seems like a reasonable split, tested the anti_aliasing example and it works

Copy link
Member

@cart cart left a comment

Choose a reason for hiding this comment

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

I'm on board for this! I'm also fine with RCAS being in here for now. Maybe not its perfect forever home, but I don't think it is (currently) a high-traffic enough feature that we need to worry too much about breaking people (especially given that path changes are easy fixes).

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Mar 19, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Mar 19, 2025
Merged via the queue into bevyengine:main with commit 06bae05 Mar 19, 2025
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Performance A change motivated by improving speed, memory usage or compile times M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Controversial There is active debate or serious implications around merging this PR
Projects
Status: Responded
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants