Browse Source

Merge pull request #21 from Nostyxx/fix/nvidia-view-heap-cap

GPU: make tables past a capped host view heap afresh (NVIDIA menu hang)
Marvis 3 ngày trước cách đây
mục cha
commit
97c78d1087
2 tập tin đã thay đổi với 38 bổ sung và 0 xóa
  1. 17 0
      crates/victory-gpu/src/descriptor/host.rs
  2. 21 0
      crates/victory-gpu/src/draw.rs

+ 17 - 0
crates/victory-gpu/src/descriptor/host.rs

@@ -234,6 +234,12 @@ impl HostHeap {
         Some(self.count + first as u32)
     }
 
+    /// The title slots this heap has host slots for; fewer than the title's
+    /// when the host caps its size.
+    pub(crate) fn count(&self) -> u32 {
+        self.count
+    }
+
     /// Gives back `n` dynamic slots from `first` (an index [`dynamic`]
     /// returned).
     ///
@@ -305,6 +311,17 @@ impl HostHeap {
     /// data: a host copy of a buffer is made on first use.
     pub(crate) fn mirror(&self, index: u32, handle: u64, for_draw: bool) -> Option<View> {
         if index >= self.count {
+            // Diagnostic (NVIDIA heap cap): the highest title slot past the
+            // host heap seen so far.
+            static HIGHEST: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0);
+            if HIGHEST.fetch_max(index, std::sync::atomic::Ordering::Relaxed) < index {
+                tracing::warn!(
+                    index,
+                    count = self.count,
+                    for_draw,
+                    "title slot past the host heap"
+                );
+            }
             return None;
         }
         // SAFETY: the handle is a descriptor slot in title memory.

+ 21 - 0
crates/victory-gpu/src/draw.rs

@@ -612,6 +612,27 @@ impl State {
             .filter(|u| u.kind == ResourceType::Cbv)
             .map(|u| u.slot)
             .collect();
+        // Tables reaching past a host heap smaller than the title's (the
+        // host's limit, 1,000,000 views on NVIDIA) are made afresh too: the
+        // title's slots there have no host slot of their own.
+        for u in used.iter().filter(tables) {
+            if fresh.contains(&u.slot) {
+                continue;
+            }
+            let Some(&Root::Table(table)) = self.roots_ref(compute).get(usize::from(u.slot)) else {
+                continue;
+            };
+            let end = table + u64::from(u.table_offset_dwords) * 4;
+            let Some(heap) = self.heap_of(table) else {
+                continue;
+            };
+            let (Some(host), Some(index)) = (heap.host(), heap.index(end)) else {
+                continue;
+            };
+            if index >= host.count() {
+                fresh.push(u.slot);
+            }
+        }
         fresh.sort_unstable();
         fresh.dedup();
         for u in used.iter().filter(tables) {