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

Early out when there's no image to replace in tonemapping example update_image_viewer #11515

Closed
wants to merge 2 commits into from

Conversation

atlv24
Copy link
Contributor

@atlv24 atlv24 commented Jan 24, 2024

Objective

update_image_viewer is iterating over every mesh material in the scene calling get_mut on the material every frame, and not doing anything with it unless theres an image event to replace the image in the material with. this triggers change detection unconditionally every single frame on every single mesh's material, which is obliterating performance.

Solution

early out when there's no image event


Unblocks #10610

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen labels Jan 24, 2024
@alice-i-cecile alice-i-cecile added the C-Examples An addition or correction to our examples label Jan 24, 2024
@rparrett
Copy link
Contributor

rparrett commented Jan 25, 2024

Added an alternative PR for your consideration here: #11519

But I can confirm that this PR doesn't break anything and seems to do what it says.

@atlv24
Copy link
Contributor Author

atlv24 commented Jan 25, 2024

I agree that this could be written better, I just figure its easier to get a very simple obvious fix merged for 0.13 than a more involved rewrite. I'll check over your PR later but at first glance it looks good

@rparrett
Copy link
Contributor

Sure, not fussed at all if this is merged first.

@atlv24
Copy link
Contributor Author

atlv24 commented Jan 27, 2024

Closing in favor of #11519 as this is no longer urgent thanks to #11383

@atlv24 atlv24 closed this Jan 27, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jan 27, 2024
…11519)

# Objective

Alternative to #11515.

Fixes change detection being triggered on the "image viewer image
material" every frame.

## Solution

- Split the megasystem into two separate systems: one to handle drop
events, and one to handle asset change events.
- Move the event reader iteration "outside." so that we're only doing
stuff when there are events.
- Flatten some of the more extreme nesting
- Other bits of cleanup, removing an unnecessary clone and unused
variable.

I think these systems can even run in parallel now, not that it
particularly matters.
tjamaan pushed a commit to tjamaan/bevy that referenced this pull request Feb 6, 2024
…evyengine#11519)

# Objective

Alternative to bevyengine#11515.

Fixes change detection being triggered on the "image viewer image
material" every frame.

## Solution

- Split the megasystem into two separate systems: one to handle drop
events, and one to handle asset change events.
- Move the event reader iteration "outside." so that we're only doing
stuff when there are events.
- Flatten some of the more extreme nesting
- Other bits of cleanup, removing an unnecessary clone and unused
variable.

I think these systems can even run in parallel now, not that it
particularly matters.
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-Bug An unexpected or incorrect behavior C-Examples An addition or correction to our examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants