@@ -56,6 +56,15 @@ bitflags! {
5656pub trait GenericUsage {
5757 fn is_exclusive ( & self ) -> bool ;
5858}
59+ #[ derive( Clone , Copy , Debug , PartialEq ) ]
60+ pub struct DummyUsage ;
61+ impl BitOr for DummyUsage {
62+ type Output = Self ;
63+ fn bitor ( self , other : Self ) -> Self {
64+ other
65+ }
66+ }
67+
5968impl GenericUsage for BufferUsageFlags {
6069 fn is_exclusive ( & self ) -> bool {
6170 BufferUsageFlags :: WRITE_ALL . intersects ( * self )
@@ -66,6 +75,11 @@ impl GenericUsage for TextureUsageFlags {
6675 TextureUsageFlags :: WRITE_ALL . intersects ( * self )
6776 }
6877}
78+ impl GenericUsage for DummyUsage {
79+ fn is_exclusive ( & self ) -> bool {
80+ false
81+ }
82+ }
6983
7084#[ derive( Clone ) ]
7185struct Track < U > {
@@ -82,11 +96,7 @@ pub struct Tracker<I, U> {
8296}
8397pub type BufferTracker = Tracker < BufferId , BufferUsageFlags > ;
8498pub type TextureTracker = Tracker < TextureId , TextureUsageFlags > ;
85- pub struct DummyTracker < I > {
86- map : FastHashMap < Index , ( RefCount , Epoch ) > ,
87- _phantom : PhantomData < I > ,
88- }
89- pub type TextureViewTracker = DummyTracker < TextureViewId > ;
99+ pub type TextureViewTracker = Tracker < TextureViewId , DummyUsage > ;
90100
91101pub struct TrackerSet {
92102 pub buffers : BufferTracker ,
@@ -111,53 +121,9 @@ impl TrackerSet {
111121 self . textures
112122 . consume_by_extend ( & other. textures )
113123 . unwrap ( ) ;
114- self . views . consume ( & other. views ) ;
115- }
116- }
117-
118- impl < I : NewId > DummyTracker < I > {
119- pub fn new ( ) -> Self {
120- DummyTracker {
121- map : FastHashMap :: default ( ) ,
122- _phantom : PhantomData ,
123- }
124- }
125-
126- /// Remove an id from the tracked map.
127- pub ( crate ) fn remove ( & mut self , id : I ) -> bool {
128- match self . map . remove ( & id. index ( ) ) {
129- Some ( ( _, epoch) ) => {
130- assert_eq ! ( epoch, id. epoch( ) ) ;
131- true
132- }
133- None => false ,
134- }
135- }
136-
137- /// Get the last usage on a resource.
138- pub ( crate ) fn query ( & mut self , id : I , ref_count : & RefCount ) -> bool {
139- match self . map . entry ( id. index ( ) ) {
140- Entry :: Vacant ( e) => {
141- e. insert ( ( ref_count. clone ( ) , id. epoch ( ) ) ) ;
142- true
143- }
144- Entry :: Occupied ( e) => {
145- assert_eq ! ( e. get( ) . 1 , id. epoch( ) ) ;
146- false
147- }
148- }
149- }
150-
151- /// Consume another tacker.
152- pub fn consume ( & mut self , other : & Self ) {
153- for ( & index, & ( ref ref_count, epoch) ) in & other. map {
154- self . query ( I :: new ( index, epoch) , ref_count) ;
155- }
156- }
157-
158- /// Return an iterator over used resources keys.
159- pub fn used < ' a > ( & ' a self ) -> impl ' a + Iterator < Item = I > {
160- self . map . iter ( ) . map ( |( & index, & ( _, epoch) ) | I :: new ( index, epoch) )
124+ self . views
125+ . consume_by_extend ( & other. views )
126+ . unwrap ( ) ;
161127 }
162128}
163129
0 commit comments