Skip to content

Rename SortedRenderPhase add to add_retained#24404

Open
kristoff3r wants to merge 1 commit into
bevyengine:mainfrom
kristoff3r:ks/rename-render-phase-add
Open

Rename SortedRenderPhase add to add_retained#24404
kristoff3r wants to merge 1 commit into
bevyengine:mainfrom
kristoff3r:ks/rename-render-phase-add

Conversation

@kristoff3r
Copy link
Copy Markdown
Contributor

@kristoff3r kristoff3r commented May 23, 2026

Objective

In #22966 the semantics of the add method on SortedRenderPhase was changed from the items being cleared at the end of the frame, to items being retained until they are removed. A new add_transient method was added with the old functionality, but this is a big migration hazard because it's a major semantic change that doesn't give any compiler errors or warnings.

I discovered this after updating bevy_vector_shapes to the RC and seeing drawings not being cleared properly.

Solution

Rename add to add_retained both for clarity and to make old uses not compile, so the affected users will know to look in the migration guide.

A sentence about this should be added to the migration guide if/when this is backported to the 0.19 release branch.

Testing

It compiles (hopefully).

@kristoff3r kristoff3r added A-Rendering Drawing game state to the screen D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels May 23, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in Rendering May 23, 2026
@kristoff3r kristoff3r added this to the 0.19 milestone May 23, 2026
Copy link
Copy Markdown
Contributor

@eswartz eswartz left a comment

Choose a reason for hiding this comment

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

The rationale for the renaming and forcing users to accommodate the change makes sense to me. I think it warrants an explanatory note in the docs, though.

@@ -1809,7 +1809,7 @@ where
{
/// Adds a [`PhaseItem`] to this render phase.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps add a comment here to explain what "retained" means, vs. add_transient?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For this data structure specifically it doesn't mean much except that the item is not automatically removed. I don't know enough about the change list machinery to give a succinct explanation here, and in principle you could use it in other ways as well.

I guess I could add a "Unlike add_transient, the item is not removed by the end of the frame and needs to be updated by an external system"?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess I could add a "Unlike add_transient, the item is not removed by the end of the frame and needs to be updated by an external system"?

Right, though I just meant the bare minimum to explain what "retained" means :). Wording it positively, it could be Adds a [PhaseItem] to this render phase, which will persist between frames until removed.

Then the add_transient doc -- which I see is a bit odd to read, could also be reworded to Adds a [PhaseItem] to this render phase, which will be removed automatically after this frame.

@kfc35 kfc35 added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label May 23, 2026
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 D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

4 participants