-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Retained Gizmo
s
#15473
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
Retained Gizmo
s
#15473
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
.linestrip_2d(strip.map(|v| self.relative(v)), color); | ||
] | ||
.map(|v| self.relative(v)); | ||
self.draw.linestrip_2d(strip, color); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shows an instance where the use of DerefMut
can cause compilation errors.
This issue of partial borrows is already a problem for the Mut
returned by mutable query items for example. (Polonius pls 🙏)
I kinda like |
We just don't use FooAsset anywhere else, do we? |
This comment was marked as outdated.
This comment was marked as outdated.
None, but I think Gizmo is a good idea to follow. |
…e-retained-gizmos
I've thought about it a bit more and decided to go through with removing the 'line' naming from this PR, see the |
Bumping to 0.16, sorry. Rendering's stability is too poor to merge this right now. |
This is really nice. I realize this is a bikeshed, but I'd like to point out that the name Gizmo truly makes no sense any more. This is just polyline rendering with an immediate and retained API, and helpers to convert primitive shapes into polylines. |
@tim-blackbird I like this and it's well-reviewed. Can you resolve merge conflicts and ping me to merge please? |
…e-retained-gizmos
…e-retained-gizmos
# Objective Add a way to use the gizmo API in a retained manner, for increased performance. ## Solution - Move gizmo API from `Gizmos` to `GizmoBuffer`, ~ab~using `Deref` to keep usage the same as before. - Merge non-strip and strip variant of `LineGizmo` into one, storing the data in a `GizmoBuffer` to have the same API for retained `LineGizmo`s. ### Review guide - The meat of the changes are in `lib.rs`, `retained.rs`, `gizmos.rs`, `pipeline_3d.rs` and `pipeline_2d.rs` - The other files contain almost exclusively the churn from moving the gizmo API from `Gizmos` to `GizmoBuffer` ## Testing ### Performance Performance compared to the immediate mode API is from 65 to 80 times better for static lines. ``` 7900 XTX, 3700X 1707.9k lines/ms: gizmos_retained (21.3ms) 3488.5k lines/ms: gizmos_retained_continuous_polyline (31.3ms) 0.5k lines/ms: gizmos_retained_separate (97.7ms) 3054.9k lines/ms: bevy_polyline_retained_nan (16.8ms) 3596.3k lines/ms: bevy_polyline_retained_continuous_polyline (14.2ms) 0.6k lines/ms: bevy_polyline_retained_separate (78.9ms) 26.9k lines/ms: gizmos_immediate (14.9ms) 43.8k lines/ms: gizmos_immediate_continuous_polyline (18.3ms) ``` Looks like performance is good enough, being close to par with `bevy_polyline`. Benchmarks can be found here: This branch: https://github.com/tim-blackbird/line_racing/tree/retained-gizmos Bevy 0.14: https://github.com/DGriffin91/line_racing ## Showcase ```rust fn setup( mut commands: Commands, mut gizmo_assets: ResMut<Assets<GizmoAsset>> ) { let mut gizmo = GizmoAsset::default(); // A sphere made out of one million lines! gizmo .sphere(default(), 1., CRIMSON) .resolution(1_000_000 / 3); commands.spawn(Gizmo { handle: gizmo_assets.add(gizmo), ..default() }); } ``` ## Follow-up work - Port over to the retained rendering world proper - Calculate visibility and cull `Gizmo`s
Thank you to everyone involved with the authoring or reviewing of this PR! This work is relatively important and needs release notes! Head over to bevyengine/bevy-website#1963 if you'd like to help out. |
Objective
Add a way to use the gizmo API in a retained manner, for increased performance.
Solution
Gizmos
toGizmoBuffer
,abusingDeref
to keep usage the same as before.LineGizmo
into one, storing the data in aGizmoBuffer
to have the same API for retainedLineGizmo
s.Review guide
lib.rs
,retained.rs
,gizmos.rs
,pipeline_3d.rs
andpipeline_2d.rs
Gizmos
toGizmoBuffer
Testing
Performance
Performance compared to the immediate mode API is from 65 to 80 times better for static lines.
Looks like performance is good enough, being close to par with
bevy_polyline
.Benchmarks can be found here:
This branch: https://github.com/tim-blackbird/line_racing/tree/retained-gizmos
Bevy 0.14: https://github.com/DGriffin91/line_racing
Showcase
Follow-up work
Gizmo
s