Batching - fix item_batch_flags stale state #48992
Merged
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.
Fixes
bdata.joined_item_batch_flags
not being kept up to date during the rendering pass.The batch flags for a joined item were stored in a state variable
bdata.joined_item_batch_flags
during thetry_join_item
phase. This was then stored into each joined item (p_bij.flags
).During the rendering phase however, this meant that while the joined item flags were correct, the state variable contained stale data from the last item in the
try_join_item
phase. This caused problems because this was incorrectly read from the state in the render pass in a couple of places.To fix this I have made sure the state is up to date in the render phase. Alternatively I could have fixed the two places to read from the joined item directly, but this was an easy bug to miss, and the same mistake could have been made again in future, so keeping both up to date seems the most sensible approach.
Fixes #48981
Notes
render_joined_item_commands
:Which caused the extra transform matrix to get out of sync.
Bugs could also have occurred due to incorrect reading here:
flush_render_batches
: