From c3bedfb6ae3f22ff39d2d5c4dccad83d14ae9952 Mon Sep 17 00:00:00 2001 From: Torstein Grindvik Date: Mon, 23 Jan 2023 18:27:45 +0100 Subject: [PATCH 1/2] Add main_texture_other Signed-off-by: Torstein Grindvik --- crates/bevy_render/src/view/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/bevy_render/src/view/mod.rs b/crates/bevy_render/src/view/mod.rs index 4584f5359f6e8..69dba60127a86 100644 --- a/crates/bevy_render/src/view/mod.rs +++ b/crates/bevy_render/src/view/mod.rs @@ -178,6 +178,19 @@ impl ViewTarget { } } + /// The _other_ "main" unsampled texture. + /// In most cases you should use [`Self::main_texture`] instead. + /// + /// 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() From c1ff22c31372855c96e0f59117e331cc15e1d2eb Mon Sep 17 00:00:00 2001 From: Torstein Grindvik Date: Tue, 24 Jan 2023 19:13:55 +0100 Subject: [PATCH 2/2] Make language stricter Signed-off-by: Torstein Grindvik --- crates/bevy_render/src/view/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/bevy_render/src/view/mod.rs b/crates/bevy_render/src/view/mod.rs index 69dba60127a86..0f8e6171593f3 100644 --- a/crates/bevy_render/src/view/mod.rs +++ b/crates/bevy_render/src/view/mod.rs @@ -179,7 +179,8 @@ impl ViewTarget { } /// The _other_ "main" unsampled texture. - /// In most cases you should use [`Self::main_texture`] instead. + /// 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.