소스 검색

A root constant buffer not 256-byte aligned is copied into scratch memory once for the draws of a list that bind it (from Belobug 84ea9c12, romainhedouin)

Until the list next writes title memory, as for refreshes: up to 64 KiB of
fill less for every repeat. How often this title binds one was not measured.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
local 1 일 전
부모
커밋
c96525dbb2
2개의 변경된 파일과 20개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 3
      crates/victory-gpu/src/draw.rs
  2. 19 0
      crates/victory-gpu/src/host.rs

+ 1 - 3
crates/victory-gpu/src/draw.rs

@@ -713,9 +713,7 @@ fn root_view(list: &HostList, address: u64, srv: bool) -> Option<u64> {
         crate::book::root(gpu, len);
         return Some(gpu);
     }
-    let (gpu, to) = list.scratch(len)?;
-    list.defer_fill(to, address as *const u8, len as usize);
-    Some(gpu)
+    list.fill_scratch(address as *const u8, len)
 }
 
 macro_rules! once {

+ 19 - 0
crates/victory-gpu/src/host.rs

@@ -2190,6 +2190,9 @@ struct Deferred {
     /// memory (host copy, address, bytes): declaring them again would
     /// change nothing.
     gpu_written: std::collections::HashSet<(usize, usize, usize), std::hash::BuildHasherDefault<AddressHash>>,
+    /// Scratch memory [`HostList::fill_scratch`] fills since the list last
+    /// wrote title memory (source, bytes): its host address.
+    filled: std::collections::HashMap<(usize, usize), u64, std::hash::BuildHasherDefault<AddressHash>>,
     /// Textures whose contents the list brings up to date.
     textures: std::collections::HashSet<usize>,
     /// Bottom-of-pipe writes, done once the list has run: address, what,
@@ -2230,6 +2233,7 @@ impl Deferred {
     fn title_written(&mut self) {
         self.refreshed.clear();
         self.gpu_written.clear();
+        self.filled.clear();
     }
 }
 
@@ -6676,6 +6680,21 @@ impl HostList {
             .push(Step::Fill(dst as usize, src as usize, len, None));
     }
 
+    /// The host address of `len` bytes of scratch memory that hold the title
+    /// memory at `src` as of the list's submission: one fill for every ask
+    /// until the list next writes title memory.
+    pub(crate) fn fill_scratch(&self, src: *const u8, len: u64) -> Option<u64> {
+        let key = (src as usize, len as usize);
+        let known = self.deferred().filled.get(&key).copied();
+        if known.is_some() {
+            return known;
+        }
+        let (gpu, to) = self.scratch(len)?;
+        self.defer_fill(to, src, len as usize);
+        self.deferred().filled.insert(key, gpu);
+        Some(gpu)
+    }
+
     /// As [`HostList::defer_fill`], for upload memory that only `slot` (a
     /// title heap's address, and the slot) shows.
     pub(crate) fn defer_constants(&self, dst: *mut u8, src: *const u8, len: usize, slot: (usize, u32)) {