Skip to content

Add TrackedRenderPass::inner method #3595

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions crates/bevy_render/src/render_phase/draw_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,4 +339,12 @@ impl<'a> TrackedRenderPass<'a> {
trace!("set blend constant: {:?}", color);
self.pass.set_blend_constant(wgpu::Color::from(color))
}

/// Get the underlying [`RenderPass`].
///
/// Resets all tracked state in the process.
pub fn inner(&mut self) -> &mut RenderPass<'a> {
self.state = Default::default();
Copy link
Contributor

Choose a reason for hiding this comment

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

How would this be used? It seems that this could be used to circumvent the checks that TrackedRenderPass is designed to prevent. Maybe it would be better to extend TrackedRenderPass.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I understand the rest of the code, the checks are specifically optimizations to avoid redundant calls on the underlying RenderPass. By clearing the tracked state, we prevent those checks from firing when they shouldn't and thereby force subsequent calls not to be deduplicated.

Copy link
Contributor

Choose a reason for hiding this comment

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

If so, I think it’s worth adding a comment that TrackedRenderPass is an optimization over RenderPass, and resetting the state shouldn’t break anything.

&mut self.pass
}
}