@@ -98,6 +98,16 @@ pub type BufferTracker = Tracker<BufferId, BufferUsageFlags>;
9898pub type TextureTracker = Tracker < TextureId , TextureUsageFlags > ;
9999pub type TextureViewTracker = Tracker < TextureViewId , DummyUsage > ;
100100
101+ //TODO: make this a generic parameter.
102+ /// Mode of stitching to states together.
103+ #[ derive( Clone , Copy , Debug ) ]
104+ pub enum Stitch {
105+ /// Stitch to the init state of the other resource.
106+ Init ,
107+ /// Stitch to the last sttate of the other resource.
108+ Last ,
109+ }
110+
101111pub struct TrackerSet {
102112 pub buffers : BufferTracker ,
103113 pub textures : TextureTracker ,
@@ -209,7 +219,11 @@ impl<I: NewId, U: Copy + GenericUsage + BitOr<Output = U> + PartialEq> Tracker<I
209219
210220 /// Consume another tacker, adding it's transitions to `self`.
211221 /// Transitions the current usage to the new one.
212- pub fn consume_by_replace < ' a > ( & ' a mut self , other : & ' a Self ) -> impl ' a + Iterator < Item = ( I , Range < U > ) > {
222+ pub fn consume_by_replace < ' a > (
223+ & ' a mut self ,
224+ other : & ' a Self ,
225+ stitch : Stitch ,
226+ ) -> impl ' a + Iterator < Item = ( I , Range < U > ) > {
213227 other. map . iter ( ) . flat_map ( move |( & index, new) | {
214228 match self . map . entry ( index) {
215229 Entry :: Vacant ( e) => {
@@ -222,7 +236,11 @@ impl<I: NewId, U: Copy + GenericUsage + BitOr<Output = U> + PartialEq> Tracker<I
222236 if old == new. init {
223237 None
224238 } else {
225- Some ( ( I :: new ( index, new. epoch ) , old .. new. last ) )
239+ let state = match stitch {
240+ Stitch :: Init => new. init ,
241+ Stitch :: Last => new. last ,
242+ } ;
243+ Some ( ( I :: new ( index, new. epoch ) , old .. state) )
226244 }
227245 }
228246 }
0 commit comments