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

[Merged by Bors] - Add main_texture_other #7343

Closed
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
14 changes: 14 additions & 0 deletions crates/bevy_render/src/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,20 @@ impl ViewTarget {
}
}

/// The _other_ "main" unsampled texture.
/// In most cases you should use [`Self::main_texture`] instead and never this.
/// The textures will naturally be swapped when [`Self::post_process_write`] is called.
///
/// A use case for this is to be able to prepare a bind group for all main textures
/// ahead of time.
pub fn main_texture_other(&self) -> &TextureView {
if self.main_texture.load(Ordering::SeqCst) == 0 {
&self.main_textures.b
} else {
&self.main_textures.a
}
}

/// The "main" sampled texture.
pub fn sampled_main_texture(&self) -> Option<&TextureView> {
self.main_textures.sampled.as_ref()
Expand Down