Ver código fonte

GPU: replay pending descriptors before publishing the host heap

FIocker 3 dias atrás
pai
commit
a4e7f1d004
1 arquivos alterados com 12 adições e 9 exclusões
  1. 12 9
      crates/victory-gpu/src/descriptor.rs

+ 12 - 9
crates/victory-gpu/src/descriptor.rs

@@ -85,15 +85,18 @@ impl Heap {
             return None;
         }
         let mut pending = self.pending.lock().unwrap_or_else(|e| e.into_inner());
-        let h = self
-            .host
-            .get_or_init(|| host::HostHeap::new(self.samplers(), self.desc.count))
-            .as_ref()?;
-        let step = u64::from(increment(self.desc.kind)?);
-        for i in pending.drain(..) {
-            h.mirror(i, self.start + u64::from(i) * step, false);
-        }
-        Some(h)
+        // A recorder can take the fast path as soon as the OnceLock is
+        // initialized. Publish only after replaying the queued writes.
+        self.host
+            .get_or_init(|| {
+                let step = u64::from(increment(self.desc.kind)?);
+                let h = host::HostHeap::new(self.samplers(), self.desc.count)?;
+                for i in pending.drain(..) {
+                    h.mirror(i, self.start + u64::from(i) * step, false);
+                }
+                Some(h)
+            })
+            .as_ref()
     }
 
     /// The descriptor index of `handle` in this heap, if it lies in it.