Add main_texture_other (#7343)
# Objective ## Use Case A render node which calls `post_process_write()` on a `ViewTarget` multiple times during a single run of the node means both main textures of this view target is accessed. If the source texture (which alternate between main textures **a** and **b**) is accessed in a shader during those iterations it means that those textures have to be bound using bind groups. Preparing bind groups for both main textures ahead of time is desired, which means having access to the _other_ main texture is needed. ## Solution Add a method on `ViewTarget` for accessing the other main texture. --- ## Changelog ### Added - `main_texture_other` API on `ViewTarget`
This commit is contained in:
parent
0ff839be1d
commit
b6376ce654
@ -182,6 +182,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()
|
||||
|
Loading…
Reference in New Issue
Block a user