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

Batching - fix item_batch_flags stale state #48992

Merged
merged 1 commit into from
May 23, 2021

Conversation

lawnjelly
Copy link
Member

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 the try_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

  • The bug in the linked issue was caused by reading here:
    render_joined_item_commands:
	if (bdata.joined_item_batch_flags & RasterizerStorageCommon::PREVENT_VERTEX_BAKING) {
		fill_state.extra_matrix_sent = true;
	}

Which caused the extra transform matrix to get out of sync.

Bugs could also have occurred due to incorrect reading here:
flush_render_batches:

			// only check whether to convert if there are quads (prevent divide by zero)
			// and we haven't decided to prevent color baking (due to e.g. MODULATE
			// being used in a shader)
			if (bdata.total_quads && !(bdata.joined_item_batch_flags & RasterizerStorageCommon::PREVENT_COLOR_BAKING)) {

Fixes bdata.joined_item_batch_flags not being kept up to date during the rendering pass.
@akien-mga akien-mga merged commit 714b4dc into godotengine:3.x May 23, 2021
@akien-mga
Copy link
Member

Thanks!

@lawnjelly lawnjelly deleted the ewok_fix_joined_item_flags branch May 23, 2021 14:59
@akien-mga
Copy link
Member

Cherry-picked for 3.3.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants