Fix 2D flicker by always dequeueing retained phase items (#25163) - #25253
Open
morr wants to merge 1 commit into
Open
Fix 2D flicker by always dequeueing retained phase items (#25163)#25253morr wants to merge 1 commit into
morr wants to merge 1 commit into
Conversation
…25163) Fixes bevyengine#25163. `queue_material2d_meshes` is the only system that takes items out of the retained 2D phases, and it returns early when `render_material_instances` is empty. That is the frame the last entity using that material type gets despawned, so its items never get removed and stay in the phase for good. Move the check below the dequeue loop and make it a `continue`. There is still nothing to queue when no entity uses the material, but removal now always happens.
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
Fixes #25163.
queue_material2d_meshesis the only system that takes items out of theretained 2D phases, and it returns early when
render_material_instancesis empty. That is the frame the last entity using that material type gets
despawned, so its items never get removed and stay in the phase for good.
They also keep the
batch_rangethey had when they were last batched,since
batch_and_prepare_sorted_render_phaseonly rewrites the range ofitems that still have a
RenderMesh2dInstance.render_rangeadvances theindex by
batch_range.len()after every draw, so an item left over from abatch of three hides the two live items behind it. With equal sort keys the
order changes from frame to frame, which is why it shows up as flicker
instead of something permanently missing.
The early return is older than the dequeue loop (#17567 added it back when
the system only queued, #23083 added the removal). The 3D
queue_material_meshesdoesn't have one.Solution
Move the check below the dequeue loop and make it a
continue. There isstill nothing to queue when no entity uses the material, but removal now
always happens.
Testing
In my own app after applying the patch tree shadows stopped flickering
