[Merged by Bors] - Only compute sprite color once per quad#7498
Closed
abnormalbrain wants to merge 1 commit intobevyengine:mainfrom
Closed
[Merged by Bors] - Only compute sprite color once per quad#7498abnormalbrain wants to merge 1 commit intobevyengine:mainfrom
abnormalbrain wants to merge 1 commit intobevyengine:mainfrom
Conversation
Contributor
|
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
Member
|
This seems to have the same effect as #7311 but for 2D sprites. Could you test the results with Tracy on one of the stress tests (i.e. |
james7132
approved these changes
Feb 4, 2023
alice-i-cecile
approved these changes
Feb 4, 2023
Contributor
Author
|
@james7132 Added tracy comparisons for |
superdump
approved these changes
Feb 4, 2023
Contributor
|
bors r+ |
bors bot
pushed a commit
that referenced
this pull request
Feb 4, 2023
# Objective This change substantially increased performance when drawing thousands of colored sprites. ## Solution The same color is used for each vertex in the quad sprites are drawn too, but the color is converted to a linear color each time. This computation only needs to be done once. The `as_linear_rgba_f32()` call was showing up in profiling the `basic` example in my [particle system library](https://github.com/abnormalbrain/bevy_particle_systems) as a hot path. This change added about 50 fps to the example, from about 150fps to about 200 fps, when rendering around 10k colored sprites. Tracy Results: "This trace" is with the change. Change in frame time:  Change in `queue_sprites`: 
Contributor
|
Pull request successfully merged into main. Build succeeded:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
This change substantially increased performance when drawing thousands of colored sprites.
Solution
The same color is used for each vertex in the quad sprites are drawn too, but the color is converted to a linear color each time. This computation only needs to be done once.
The
as_linear_rgba_f32()call was showing up in profiling thebasicexample in my particle system library as a hot path. This change added about 50 fps to the example, from about 150fps to about 200 fps, when rendering around 10k colored sprites.Tracy Results:
"This trace" is with the change.
Change in frame time:

Change in

queue_sprites: