From 4d91d9d2cc49991e4fe5c12b11ec9b858718fe15 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 25 Nov 2026 09:02:22 +0200 Subject: [PATCH 01/12] fix: clamp shader heap indices to the host's view-heap cap (NVIDIA) NVIDIA caps shader-visible CBV/SRV/UAV heaps at 10^6 slots; the world indexes past that (slot 1,236,191 and up), and with shaders clamping only below HEAP_VIEWS (2^21) the device was removed (DXGI_ERROR_INVALID_CALL). The host probes a HEAP_VIEWS heap at device creation; where it is refused, emit::set_heap_views(PORTABLE_VIEWS) makes translated shaders clamp below the cap and put the null buffer views at its last slots. The capped host heap keeps the title slots below the dynamic range; title slots past it read null. The heap size keys the shader cache and the pipeline library. Co-Authored-By: Claude Opus 5.5 --- README.md | 7 ++++ crates/victory-gpu/src/descriptor/host.rs | 37 ++++++++++++---------- crates/victory-gpu/src/host.rs | 16 ++++++++++ crates/victory-gpu/src/pipeline/library.rs | 2 ++ crates/victory-gpu/src/shader_cache.rs | 26 +++++++++------ crates/victory-shader/src/emit/lower.rs | 4 +-- crates/victory-shader/src/emit/mod.rs | 35 +++++++++++++++++--- crates/victory-shader/src/emit/shader.rs | 2 +- 8 files changed, 95 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 4010879d7c..4ed992d375 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,13 @@ loads the world and shows it: slowly, and with rendering defects. Tested on one machine: Windows 11, AMD RX 6700 XT. +NVIDIA GPUs cap shader-visible view heaps at 10^6 slots, and the world uses +more (slot 1,236,191 and up). On such a GPU, shaders read the slots past the +cap as empty instead of faulting the device (until 2026-11-25 the run ended +with "device removed", DXGI_ERROR_INVALID_CALL). Expect missing or wrong +objects. The shader cache is kept per heap size, so run `translate --cache` +again after switching GPUs. + > **Warning.** Entering the world on a real GPU has hung it in earlier > builds, and Windows then resets the display driver (every monitor goes > black for a moment). The latest runs did not, but it is not ruled out; a diff --git a/crates/victory-gpu/src/descriptor/host.rs b/crates/victory-gpu/src/descriptor/host.rs index 8b1867ad8d..92a7763e42 100644 --- a/crates/victory-gpu/src/descriptor/host.rs +++ b/crates/victory-gpu/src/descriptor/host.rs @@ -83,8 +83,9 @@ pub(crate) fn near_heaps(va: u64) -> String { } /// The host's limit for shader-visible view heaps on resource binding -/// tiers 1 and 2; tier 3 hardware may take more. -const PORTABLE_VIEWS: u32 = 1_000_000; +/// tiers 1 and 2; tier 3 hardware may take more. Translated shaders clamp +/// to it where the host takes no heap of `HEAP_VIEWS` (`host::create`). +pub(crate) const PORTABLE_VIEWS: u32 = 1_000_000; /// Slots past the title's in a view heap, for tables a draw needs made /// afresh (constant buffers copied per draw). A list holds the slots it @@ -137,9 +138,9 @@ impl HostHeap { .flatten(); // The larger dynamic range only where the host takes it on top of // every title slot; else the smaller one, and the cap after that. - // Translated shaders clamp their indices below `HEAP_VIEWS` or + // Translated shaders clamp their indices below `heap_views` or // `HEAP_SAMPLERS`: slots up to there exist and stay null. - let (views, samplers) = (victory_shader::emit::HEAP_VIEWS, victory_shader::emit::HEAP_SAMPLERS); + let (views, samplers) = (victory_shader::emit::heap_views(), victory_shader::emit::HEAP_SAMPLERS); let (heap, count, extra) = if sampler { match make(count.max(samplers)) { Ok(heap) => (heap, count, 0), @@ -150,16 +151,18 @@ impl HostHeap { } } else if let Ok(heap) = make((count + DYNAMIC).max(views)) { (heap, count, DYNAMIC) + } else if let Ok(heap) = make((count + MIN_DYNAMIC).max(views)) { + (heap, count, MIN_DYNAMIC) } else { - // shortcut: a host that caps its heaps below `HEAP_VIEWS` (NVIDIA) - // faults on an index past them, as before the clamp. - match make(count + MIN_DYNAMIC) { - Ok(heap) => (heap, count, MIN_DYNAMIC), - Err(e) if count + MIN_DYNAMIC > PORTABLE_VIEWS => { - // shortcut: descriptors past the host's limit are left - // out; a title that reaches them needs remapping. - tracing::warn!(error = %e, count, "host view heap capped at {PORTABLE_VIEWS}"); - (make(PORTABLE_VIEWS).ok()?, PORTABLE_VIEWS - MIN_DYNAMIC, MIN_DYNAMIC) + // shortcut: title slots past the host's cap (NVIDIA) are left + // out; shaders clamp below `views` and read them null. A title + // that draws with them needs remapping. The dynamic slots, then + // the null buffer views, take the heap's last slots. + let title = views - MIN_DYNAMIC - 3; + match make(views) { + Ok(heap) => { + tracing::warn!(count, kept = title, "host view heap capped at {views}"); + (heap, count.min(title), MIN_DYNAMIC) } Err(e) => { tracing::warn!(error = %e, count, sampler, "no host descriptor heap"); @@ -196,7 +199,7 @@ impl HostHeap { kept: Mutex::new(vec![None; (count + extra) as usize]), next: Mutex::new((0, vec![false; extra as usize])), pairs: Mutex::new((count + extra, Vec::new())), - pairs_end: match victory_shader::emit::NULL_BUFFER_VIEW { + pairs_end: match victory_shader::emit::null_buffer_view() { null if !sampler && null > count + extra && null < total => null - 1, _ => total, }, @@ -220,7 +223,7 @@ impl HostHeap { // What shaders read instead of a slot without a buffer view where // they take one at a computed index (`victory_shader::emit`, "Buffer // views at computed heap indices"): a null raw SRV, and UAV below it. - let null = victory_shader::emit::NULL_BUFFER_VIEW; + let null = victory_shader::emit::null_buffer_view(); if !sampler && null > count + extra && null < total { h.raw_view_at(null, None, 0, 0, false); h.raw_view_at(null - 1, None, 0, 0, true); @@ -1480,10 +1483,10 @@ mod tests { return; // no host GPU }; // Every index a translated shader can reach exists (clamped below - // `HEAP_VIEWS`, `HEAP_SAMPLERS`). + // `heap_views`, `HEAP_SAMPLERS`). // SAFETY: plain queries of live heaps. unsafe { - assert!(heap.heap.GetDesc().NumDescriptors >= victory_shader::emit::HEAP_VIEWS); + assert!(heap.heap.GetDesc().NumDescriptors >= victory_shader::emit::heap_views()); let samplers = HostHeap::new(true, 128).unwrap(); assert!(samplers.heap.GetDesc().NumDescriptors >= victory_shader::emit::HEAP_SAMPLERS); } diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs index 09314c377c..714bd8e3d1 100644 --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -223,6 +223,22 @@ fn create() -> windows::core::Result { let cpu_view_size = device.GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); tracing::info!("host D3D12 device ready"); + // A host whose shader-visible view heaps stop below `HEAP_VIEWS` + // (NVIDIA): translated shaders clamp their heap indices below its + // cap instead, so a title slot past it reads null, not a fault. + let views = victory_shader::emit::HEAP_VIEWS; + if let Err(e) = device.CreateDescriptorHeap::( + &D3D12_DESCRIPTOR_HEAP_DESC { + Type: D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, + NumDescriptors: views, + Flags: D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, + NodeMask: 0, + }, + ) { + let cap = crate::descriptor::host::PORTABLE_VIEWS; + tracing::warn!(error = %e, views, cap, "host view heaps capped: shaders read slots past the cap as null"); + victory_shader::emit::set_heap_views(cap); + } // The console fuses its multiply-adds (`v_fma_f32`, `v_fmac_f32`, // `v_fma_mix*`); the lowering's DXIL `FMad` is fused only where the // host chooses (the RX 6700 XT does, WARP does not). diff --git a/crates/victory-gpu/src/pipeline/library.rs b/crates/victory-gpu/src/pipeline/library.rs index 9946221283..d9a923bac3 100644 --- a/crates/victory-gpu/src/pipeline/library.rs +++ b/crates/victory-gpu/src/pipeline/library.rs @@ -183,6 +183,7 @@ fn open(device: &ID3D12Device1, blob: Vec) -> Option { /// host descriptions). fn tag(blob: &[u8]) -> String { let limit = victory_shader::emit::loop_limit().to_le_bytes(); + let views = victory_shader::emit::heap_views().to_le_bytes(); let translator = victory_shader::SOURCE_HASH.as_bytes(); let mut h = blake3::Hasher::new(); for part in [ @@ -190,6 +191,7 @@ fn tag(blob: &[u8]) -> String { translator, include_bytes!("../shader_cache.rs"), &limit, + &views, include_bytes!("host.rs"), include_bytes!("library.rs"), ] { diff --git a/crates/victory-gpu/src/shader_cache.rs b/crates/victory-gpu/src/shader_cache.rs index 04af536ec7..77adc8948c 100644 --- a/crates/victory-gpu/src/shader_cache.rs +++ b/crates/victory-gpu/src/shader_cache.rs @@ -53,7 +53,8 @@ pub fn counts() -> (u64, u64) { /// (`victory_shader::SOURCE_HASH`: its sources, manifest, the lock file and /// the compiler), the entry's encoding (this file's text) and the /// translation settings (the loop limit, which a diagnostics build can -/// change at run time). +/// change at run time; the view-heap slots shaders index, smaller on a host +/// that caps its heaps). fn build() -> &'static [u8; 32] { static BUILD: OnceLock<[u8; 32]> = OnceLock::new(); BUILD.get_or_init(|| { @@ -64,24 +65,27 @@ fn build() -> &'static [u8; 32] { "VICTORY_SHADER_LOOP_LIMIT: translated loops stop sooner" ); } - key(victory_shader::SOURCE_HASH, ENCODING, limit) + key(victory_shader::SOURCE_HASH, ENCODING, limit, victory_shader::emit::heap_views()) }) } /// This file, whose `encode` and `decode` define the entries. const ENCODING: &[u8] = include_bytes!("shader_cache.rs"); -fn key(translator: &str, encoding: &[u8], limit: u32) -> [u8; 32] { +fn key(translator: &str, encoding: &[u8], limit: u32, views: u32) -> [u8; 32] { let mut h = blake3::Hasher::new(); h.update(translator.as_bytes()); h.update(blake3::hash(encoding).as_bytes()); h.update(&limit.to_le_bytes()); + h.update(&views.to_le_bytes()); *h.finalize().as_bytes() } /// The translation of a console shader container, from the cache when /// there is one, and whether it came from there. pub fn host_shader(container: &[u8]) -> (Result, bool) { + // The host's heap cap is a translation setting, set as it is made. + crate::host::host(); // Writes through views mark their pages: copy-backs compare only those // (`crate::shadow::copy_back_marks`). let options = victory_shader::emit::Options { view_marks: true }; @@ -431,21 +435,23 @@ mod tests { } /// The key's parts: a change to any of them (the translator's sources, - /// this file's encoding, the loop limit) makes another key, so no entry + /// this file's encoding, the loop limit, the heap size) makes another key, so no entry /// written before it is read. #[test] fn the_key_covers_translator_encoding_and_settings() { - let k = key("0123456789abcdef", b"encoding", 1 << 20); - assert_eq!(k, key("0123456789abcdef", b"encoding", 1 << 20)); - assert_ne!(k, key("0123456789abcdee", b"encoding", 1 << 20)); - assert_ne!(k, key("0123456789abcdef", b"encoding.", 1 << 20)); - assert_ne!(k, key("0123456789abcdef", b"encoding", 1 << 19)); + let k = key("0123456789abcdef", b"encoding", 1 << 20, 1 << 21); + assert_eq!(k, key("0123456789abcdef", b"encoding", 1 << 20, 1 << 21)); + assert_ne!(k, key("0123456789abcdee", b"encoding", 1 << 20, 1 << 21)); + assert_ne!(k, key("0123456789abcdef", b"encoding.", 1 << 20, 1 << 21)); + assert_ne!(k, key("0123456789abcdef", b"encoding", 1 << 19, 1 << 21)); + assert_ne!(k, key("0123456789abcdef", b"encoding", 1 << 20, 1_000_000)); assert_eq!( *build(), key( victory_shader::SOURCE_HASH, ENCODING, - victory_shader::emit::loop_limit() + victory_shader::emit::loop_limit(), + victory_shader::emit::heap_views() ) ); // The encoding part is this file as built. diff --git a/crates/victory-shader/src/emit/lower.rs b/crates/victory-shader/src/emit/lower.rs index caab7ead5c..519128801f 100644 --- a/crates/victory-shader/src/emit/lower.rs +++ b/crates/victory-shader/src/emit/lower.rs @@ -5037,7 +5037,7 @@ impl<'a> Lower<'a> { return index; } let c = self.cur; - let last = self.s.m.i32(super::HEAP_VIEWS - 1); + let last = self.s.m.i32(super::heap_views() - 1); let over = self.s.m.cmp(c, pred::IUGT, index, last); let index = self.s.m.select(c, over, last, index); let four = self.s.m.i32(4); @@ -5050,7 +5050,7 @@ impl<'a> Lower<'a> { let zero = self.s.m.i32(0); let none = self.s.m.cmp(c, pred::EQ, stride, zero); // The null unordered access view sits just below the null SRV. - let null = super::NULL_BUFFER_VIEW - u32::from(props.0 & 0x1000 != 0); + let null = super::null_buffer_view() - u32::from(props.0 & 0x1000 != 0); let null = self.s.m.i32(null); self.s.m.select(c, none, null, index) } diff --git a/crates/victory-shader/src/emit/mod.rs b/crates/victory-shader/src/emit/mod.rs index 4e1fb2f92c..8377528fa9 100644 --- a/crates/victory-shader/src/emit/mod.rs +++ b/crates/victory-shader/src/emit/mod.rs @@ -82,17 +82,19 @@ //! * **Rectangle lists** ([`rectangle_gs`]): a geometry shader made from a //! vertex shader's outputs completes each rectangle with its fourth //! corner `v0 + v2 - v1`, as the console's hardware does. -//! * **Heap indices** (added 2026-11-24) are clamped to [`HEAP_VIEWS`] − 1 +//! * **Heap indices** (added 2026-11-24) are clamped to [`heap_views`] − 1 //! (samplers [`HEAP_SAMPLERS`] − 1): the host's heaps have at least that //! many slots, those past its own null, so an index past the heap (data //! still wrong; the console would read whatever memory follows its heap) -//! reads nothing instead of faulting the device. +//! reads nothing instead of faulting the device. [`heap_views`] is +//! [`HEAP_VIEWS`], or the host's cap where its heaps stop below that +//! (NVIDIA, 10^6; 2026-11-25): title slots past the cap then read null. //! * **Buffer views at computed heap indices** (added 2026-11-24): a //! buffer read through a descriptor the shader takes from the resource //! heap itself first looks up the view-stride table (root SRV //! `t`[`VIEW_STRIDES`], which then covers every index below -//! [`HEAP_VIEWS`], dynamic slots too); where it holds 0 (no buffer view -//! there) the shader reads heap index [`NULL_BUFFER_VIEW`] instead (for +//! [`heap_views`], dynamic slots too); where it holds 0 (no buffer view +//! there) the shader reads heap index [`null_buffer_view`] instead (for //! unordered access the index below), which the host keeps a null raw //! buffer SRV (UAV). The index comes from data, and a texture descriptor //! read as a buffer one is a wild address (the texture's shifted 8 bits @@ -246,6 +248,31 @@ pub fn loop_limit() -> u32 { }) } +static HEAP_LIMIT: std::sync::OnceLock = std::sync::OnceLock::new(); + +/// The view-heap slots translated shaders index: heap indices are clamped +/// below this, and the null buffer views sit at its last slots +/// ([`null_buffer_view`]). [`HEAP_VIEWS`] unless the host set a smaller one +/// ([`set_heap_views`]) before the first translation. The value is part of +/// the translation, so the shader cache must key on it (`victory-gpu`'s +/// does). +pub fn heap_views() -> u32 { + *HEAP_LIMIT.get_or_init(|| HEAP_VIEWS) +} + +/// Sets [`heap_views`] for a host whose shader-visible view heaps stop +/// below [`HEAP_VIEWS`] (NVIDIA: 10^6), so an index past them reads a null +/// slot instead of faulting the device. Has no effect once read or set. +pub fn set_heap_views(views: u32) { + let _ = HEAP_LIMIT.set(views.min(HEAP_VIEWS)); +} + +/// The heap index of the host's null raw buffer SRV (the null raw UAV at +/// the index below): [`heap_views`] - 2. [`NULL_BUFFER_VIEW`] by default. +pub fn null_buffer_view() -> u32 { + heap_views() - 2 +} + /// `VICTORY_SHADER_LOOP_LIMIT`'s value; the default when it is unset, /// unreadable or 0. Pure, for testing. fn parse_loop_limit(value: Option<&str>) -> u32 { diff --git a/crates/victory-shader/src/emit/shader.rs b/crates/victory-shader/src/emit/shader.rs index e68e2627c9..70e143ec7b 100644 --- a/crates/victory-shader/src/emit/shader.rs +++ b/crates/victory-shader/src/emit/shader.rs @@ -520,7 +520,7 @@ impl Shader { self.nonuniform_handles += u32::from(nonuniform); // An index past the host's heap faults the device (a console shader // reads whatever memory follows its heap): the last slot instead. - let last = self.m.i32(if sampler { HEAP_SAMPLERS } else { HEAP_VIEWS } - 1); + let last = self.m.i32(if sampler { HEAP_SAMPLERS } else { super::heap_views() } - 1); let over = self.m.cmp(block, pred::IUGT, index, last); let index = self.m.select(block, over, last, index); let (s, n) = (self.m.bool(sampler), self.m.bool(nonuniform)); From 8d5eaaab839c2c62a186ca3badb4c3af5a1101f6 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 25 Nov 2026 14:05:09 +0200 Subject: [PATCH 02/12] fix: set the host view-heap cap before the shader cache key reads it use_shader_cache hashed heap_views() before the host was made, so the OnceLock locked at HEAP_VIEWS (2M) and the GTX 1660's 1M cap never took: no shader-visible view heap, and shaders indexed past it (MMU fault, nvlddmkm event 13). Make the host first; set_heap_views now reports whether the cap applied, and the host logs if it came too late. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr --- crates/victory-gpu/src/host.rs | 4 +++- crates/victory-gpu/src/shader_cache.rs | 2 ++ crates/victory-shader/src/emit/mod.rs | 9 ++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs index 714bd8e3d1..158b0e0a04 100644 --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -237,7 +237,9 @@ fn create() -> windows::core::Result { ) { let cap = crate::descriptor::host::PORTABLE_VIEWS; tracing::warn!(error = %e, views, cap, "host view heaps capped: shaders read slots past the cap as null"); - victory_shader::emit::set_heap_views(cap); + if !victory_shader::emit::set_heap_views(cap) { + tracing::error!(cap, "view-heap cap set after shaders read it"); + } } // The console fuses its multiply-adds (`v_fma_f32`, `v_fmac_f32`, // `v_fma_mix*`); the lowering's DXIL `FMad` is fused only where the diff --git a/crates/victory-gpu/src/shader_cache.rs b/crates/victory-gpu/src/shader_cache.rs index 77adc8948c..5a86fafc4d 100644 --- a/crates/victory-gpu/src/shader_cache.rs +++ b/crates/victory-gpu/src/shader_cache.rs @@ -30,6 +30,8 @@ static MISSES: AtomicU64 = AtomicU64::new(0); /// Keeps translated shaders in a folder of `dir` from now on: the folder /// of this translator, `None` if it cannot be opened. pub fn use_shader_cache(dir: PathBuf) -> Option { + // The folder's key holds the host's heap cap, set as the host is made. + crate::host::host(); let dir = dir.join(&blake3::Hash::from(*build()).to_hex()[..16]); match Cache::open(&dir) { Ok(cache) => { diff --git a/crates/victory-shader/src/emit/mod.rs b/crates/victory-shader/src/emit/mod.rs index 8377528fa9..6611501c73 100644 --- a/crates/victory-shader/src/emit/mod.rs +++ b/crates/victory-shader/src/emit/mod.rs @@ -262,9 +262,12 @@ pub fn heap_views() -> u32 { /// Sets [`heap_views`] for a host whose shader-visible view heaps stop /// below [`HEAP_VIEWS`] (NVIDIA: 10^6), so an index past them reads a null -/// slot instead of faulting the device. Has no effect once read or set. -pub fn set_heap_views(views: u32) { - let _ = HEAP_LIMIT.set(views.min(HEAP_VIEWS)); +/// slot instead of faulting the device. Has no effect once read or set: +/// whether [`heap_views`] is now `views` (capped at [`HEAP_VIEWS`]). +pub fn set_heap_views(views: u32) -> bool { + let views = views.min(HEAP_VIEWS); + let _ = HEAP_LIMIT.set(views); + heap_views() == views } /// The heap index of the host's null raw buffer SRV (the null raw UAV at From 9252c34dc61f7f291e2b3b91efde5446d6a1ec64 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 25 Nov 2026 14:29:58 +0200 Subject: [PATCH 03/12] test: skip the null-buffer heap read where the device's view heaps stop below HEAP_VIEWS NVIDIA caps shader-visible view heaps at 10^6 slots; the test host's View::NullBuffers needs HEAP_VIEWS (2^21), so the hardware run failed with E_INVALIDARG instead of testing anything. WARP still runs it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr --- crates/victory-shader/src/emit/host.rs | 17 +++++++++++++++++ crates/victory-shader/src/emit/stride_tests.rs | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/crates/victory-shader/src/emit/host.rs b/crates/victory-shader/src/emit/host.rs index 76f2455004..56ac3591db 100644 --- a/crates/victory-shader/src/emit/host.rs +++ b/crates/victory-shader/src/emit/host.rs @@ -129,6 +129,23 @@ impl Host { } } + /// Whether the device takes a shader-visible view heap of + /// [`super::HEAP_VIEWS`] slots, as [`View::NullBuffers`] needs (NVIDIA + /// stops at 10^6). + pub fn takes_full_view_heap(&self) -> bool { + // SAFETY: a plain heap creation on a live device. + unsafe { + self.device + .CreateDescriptorHeap::(&D3D12_DESCRIPTOR_HEAP_DESC { + Type: D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, + NumDescriptors: super::HEAP_VIEWS, + Flags: D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, + ..Default::default() + }) + .is_ok() + } + } + /// The root signature translated shaders expect: user data per stage /// at `b0`, immediate samplers per stage at `s`, heaps directly /// indexed. diff --git a/crates/victory-shader/src/emit/stride_tests.rs b/crates/victory-shader/src/emit/stride_tests.rs index fc160f5f98..7331cc845f 100644 --- a/crates/victory-shader/src/emit/stride_tests.rs +++ b/crates/victory-shader/src/emit/stride_tests.rs @@ -325,6 +325,10 @@ fn a_heap_buffer_read_where_no_buffer_view_is_reads_zeros() { eprintln!("no SM 6.6 {label} device; skipped"); continue; }; + if !host.takes_full_view_heap() { + eprintln!("{label} view heaps stop below HEAP_VIEWS; skipped"); + continue; + } let (root, pso) = host .compute_pipeline(&shader) .unwrap_or_else(|e| panic!("{label}: compute_pipeline failed: {e}")); From 16580cd71bc78ab830dc3b74125ff594270e9a5f Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 25 Nov 2026 14:55:42 +0200 Subject: [PATCH 04/12] fix: make structured buffer views raw on the host (NVIDIA) Translated shaders read every structured buffer through a raw handle at index * stride + offset. NVIDIA reads a structured view through a raw handle wrongly. So structured views with a stride that is a multiple of 4 are now made as R32_TYPELESS raw views, with their range scaled to 4-byte words. Their host copy starts on 16 bytes, which is the raw-view alignment. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr --- crates/victory-gpu/src/descriptor/host.rs | 75 ++++++++++++++++++----- crates/victory-gpu/src/draw.rs | 5 +- crates/victory-shader/src/emit/host.rs | 10 +-- crates/victory-shader/src/emit/lower.rs | 34 +++++++--- 4 files changed, 95 insertions(+), 29 deletions(-) diff --git a/crates/victory-gpu/src/descriptor/host.rs b/crates/victory-gpu/src/descriptor/host.rs index 92a7763e42..4509313bec 100644 --- a/crates/victory-gpu/src/descriptor/host.rs +++ b/crates/victory-gpu/src/descriptor/host.rs @@ -755,40 +755,47 @@ fn uav_desc(words: &[u32; 10]) -> D3D12_UNORDERED_ACCESS_VIEW_DESC { /// The byte stride of a buffer view (its element size, at least 1), 0 for /// other views: what the view-stride table holds for it. fn view_stride(view: &View) -> u32 { + // Nonzero: shaders taking views at computed indices read the null buffer + // view where the table holds 0 (`victory_shader::emit`). + buffer_element(view).map_or(0, |(element, _)| element.max(1) as u32) +} + +/// A buffer view's element size and structure stride. +fn buffer_element(view: &View) -> Option<(u64, u32)> { let (unordered, words): (bool, &[u32; 10]) = match view { // Read as raw buffers (`make`). - View::Constant(..) => return 4, + View::Constant(..) => return Some((4, 0)), View::Shader(_, Some(desc)) => (false, desc), View::Unordered(_, _, Some(desc)) => (true, desc), View::Placed(unordered, resource, desc) if resource[0] == 1 => { match desc[..10].try_into() { Ok(words) => (*unordered, words), - Err(_) => return 0, + Err(_) => return None, } } - _ => return 0, + _ => return None, }; // The view dimension: buffer (1) for shader and unordered views alike. if words[1] != 1 { - return 0; + return None; } - let element = if unordered { + Some(if unordered { let desc = uav_desc(words); // SAFETY: a buffer view's union member. let buffer = unsafe { desc.Anonymous.Buffer }; - if buffer.StructureByteStride > 0 { + let element = if buffer.StructureByteStride > 0 { u64::from(buffer.StructureByteStride) } else if buffer.Flags.0 & D3D12_BUFFER_UAV_FLAG_RAW.0 != 0 { 4 } else { crate::resource::element(desc.Format.0 as u32).map_or(0, |(bytes, _)| bytes) - } + }; + (element, buffer.StructureByteStride) } else { - element_size(&srv_desc(words)) - }; - // Nonzero: shaders taking views at computed indices read the null buffer - // view where the table holds 0 (`victory_shader::emit`). - element.max(1) as u32 + let desc = srv_desc(words); + // SAFETY: a buffer view's union member. + (element_size(&desc), unsafe { desc.Anonymous.Buffer }.StructureByteStride) + }) } /// A buffer view of title memory at `address` on its host copy: the first @@ -852,7 +859,8 @@ pub(crate) fn buffer_range(view: &View) -> Option<(u64, u64)> { /// reads, [`crate::shadow::for_view`]) and the view's title range. pub(crate) fn view_copy(view: &View) -> Option<(std::sync::Arc, u64, u64)> { let (address, len) = buffer_range(view)?; - let (shadow, _) = crate::shadow::for_view(address, len, u64::from(view_stride(view)))?; + let (element, stride) = buffer_element(view)?; + let (shadow, _) = crate::shadow::for_view(address, len, copy_align(element, stride))?; Some((shadow, address, len)) } @@ -898,8 +906,9 @@ fn buffer_srv( } // The copy its own bytes are in, its first element counted from there. let start = address + buffer.FirstElement * element; + let align = copy_align(element, buffer.StructureByteStride); let Some((shadow, own)) = - crate::shadow::for_view(start, u64::from(buffer.NumElements) * element, element) + crate::shadow::for_view(start, u64::from(buffer.NumElements) * element, align) else { #[cfg(feature = "diagnostics")] if REFUSED.fetch_add(1, std::sync::atomic::Ordering::Relaxed) < 200 { @@ -917,6 +926,12 @@ fn buffer_srv( once!(first, count, element, "buffer view empty or past its host copy"); return None; } + if let Some((first, count)) = as_raw(first, count, buffer.StructureByteStride) { + (buffer.FirstElement, buffer.NumElements) = (first, count); + buffer.StructureByteStride = 0; + buffer.Flags |= D3D12_BUFFER_SRV_FLAG_RAW; + desc.Format = DXGI_FORMAT_R32_TYPELESS; + } let host = host()?; // SAFETY: a live buffer and a slot of our heap. unsafe { @@ -926,6 +941,29 @@ fn buffer_srv( Some(Some((shadow.buffer.clone(), own.then_some(shadow)))) } +/// A structured view's range as a raw view's (4-byte words): translated +/// shaders read every structured buffer through a raw handle at byte +/// `index * stride + offset` (the stride may only be known at run time, from +/// the view-stride table), and some drivers (NVIDIA) read a structured view +/// through a raw handle wrongly. +fn as_raw(first: u64, count: u32, stride: u32) -> Option<(u64, u32)> { + (stride > 0 && stride.is_multiple_of(4)).then(|| { + let words = u64::from(stride / 4); + (first * words, (u64::from(count) * words).min(u64::from(u32::MAX)) as u32) + }) +} + +/// Where in its host copy a view of `element`-byte elements must start: on +/// an element, and a structured view (made raw, [`as_raw`]) also on 16 bytes +/// (`D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT`). +fn copy_align(element: u64, stride: u32) -> u64 { + if as_raw(0, 0, stride).is_some() { + element << (4 - element.trailing_zeros().min(4)) + } else { + element + } +} + /// Whether `count` elements of `element` bytes from element `first` lie in /// `buffer`. The console takes a view that is empty or runs past its /// memory; the host removes the device for one. @@ -963,7 +1001,8 @@ fn buffer_uav( return None; } let start = address + buffer.FirstElement * element; - let (shadow, own) = crate::shadow::for_view(start, u64::from(buffer.NumElements) * element, element)?; + let align = copy_align(element, buffer.StructureByteStride); + let (shadow, own) = crate::shadow::for_view(start, u64::from(buffer.NumElements) * element, align)?; // SAFETY: a live buffer. let flags = unsafe { shadow.buffer.GetDesc() }.Flags; if flags.0 & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS.0 == 0 { @@ -977,6 +1016,12 @@ fn buffer_uav( once!(first, count, element, "unordered buffer view empty or past its host copy"); return None; } + if let Some((first, count)) = as_raw(first, count, buffer.StructureByteStride) { + (buffer.FirstElement, buffer.NumElements) = (first, count); + buffer.StructureByteStride = 0; + buffer.Flags |= D3D12_BUFFER_UAV_FLAG_RAW; + desc.Format = DXGI_FORMAT_R32_TYPELESS; + } let host = host()?; // SAFETY: a live buffer and a slot of our heap. unsafe { diff --git a/crates/victory-gpu/src/draw.rs b/crates/victory-gpu/src/draw.rs index 3172caf810..6eda3e24ff 100644 --- a/crates/victory-gpu/src/draw.rs +++ b/crates/victory-gpu/src/draw.rs @@ -2465,7 +2465,10 @@ void main(uint3 id : SV_DispatchThreadID) { // SAFETY: a live buffer. unsafe { made.GetDesc() }.Width }; - assert_eq!(width(start + 456), 1 << 16, "on an element: the buffer's copy"); + // Host views of structured buffers are raw: on an element 16 bytes + // in (912), the buffer's copy; on one that is not (456), its own. + assert_eq!(width(start + 912), 1 << 16, "on an element: the buffer's copy"); + assert_eq!(width(start + 456), (4 * 456u64).next_multiple_of(256), "off 16 bytes: its own bytes"); assert_eq!(width(start + 100), (4 * 456u64).next_multiple_of(256), "off: its own bytes"); let (copy, address, len) = crate::descriptor::host::view_copy(&view(start + 100)).unwrap(); assert_eq!((copy.range(), address, len), ((start + 100, 4 * 456), start + 100, 4 * 456)); diff --git a/crates/victory-shader/src/emit/host.rs b/crates/victory-shader/src/emit/host.rs index 56ac3591db..b9d8c535d8 100644 --- a/crates/victory-shader/src/emit/host.rs +++ b/crates/victory-shader/src/emit/host.rs @@ -1659,11 +1659,13 @@ impl Host { 0, D3D12_BUFFER_SRV_FLAG_NONE, ), + // Raw, as the runtime makes a structured view + // (its stride is in the view-stride table). Stride::Structured(s) => ( - DXGI_FORMAT_UNKNOWN, - data.len() * 4 / s as usize, - s, - D3D12_BUFFER_SRV_FLAG_NONE, + DXGI_FORMAT_R32_TYPELESS, + data.len() * 4 / s as usize * s as usize / 4, + 0, + D3D12_BUFFER_SRV_FLAG_RAW, ), Stride::Format(f, bytes) => ( f, diff --git a/crates/victory-shader/src/emit/lower.rs b/crates/victory-shader/src/emit/lower.rs index 519128801f..acedfa4418 100644 --- a/crates/victory-shader/src/emit/lower.rs +++ b/crates/victory-shader/src/emit/lower.rs @@ -4067,6 +4067,8 @@ impl<'a> Lower<'a> { || un.contains("atomic") || used.is_some_and(|u| u.kind == ResourceType::Uav); let u = if uav { 0x1000 } else { 0 }; + // The bytes of a record, for a buffer counted in records. + let mut per = 0; let (props, image) = match &ui.fields { Fields::Image { dim, .. } => { let kind = match dim { @@ -4086,7 +4088,9 @@ impl<'a> Lower<'a> { { (10 | u, 0x409) } else if *idxen && format.is_none() && stride >= 4 && stride.is_multiple_of(4) { - (12 | u, stride) + // Host buffer views are raw: bytes, counted in records below. + per = stride; + (11 | u, 0) } else { (11 | u, 0) }; @@ -4105,7 +4109,10 @@ impl<'a> Lower<'a> { } let props = match used.stride { 0 | 1 => (11 | u, 0), - s if s.is_multiple_of(4) => (12 | u, s), + s if s.is_multiple_of(4) => { + per = s; + (11 | u, 0) + } _ => return Err("a scalar-loaded buffer of odd stride read as data"), }; (props, None) @@ -4162,6 +4169,11 @@ impl<'a> Lower<'a> { let d3 = self.s.m.bin(c, Bin::Or, base, last); vec![(1, d1), (2, d2), (3, d3), (4, depth)] } + None if per > 0 => { + let per = self.s.m.i32(per); + let bytes = field(self, 0); + vec![(2, self.s.m.bin(c, Bin::UDiv, bytes, per))] + } None => vec![(2, field(self, 0))], }; for k in 0..count { @@ -8812,11 +8824,11 @@ impl<'a> Lower<'a> { if stride < 4 || !stride.is_multiple_of(4) { return Err("a structured buffer of unknown stride"); } - let h = self.handle(site, src, false, (12 | u, stride))?; + let h = self.handle(site, src, false, (11 | u, 0))?; let s = self.s.m.i32(stride); let row = self.s.m.bin(self.cur, Bin::Mul, index, s); let byte = self.s.m.bin(self.cur, Bin::Add, row, off); - (h, [index, off, iu], byte) + (h, [byte, iu, iu], byte) } None => { let (h, off) = self.raw_view(site, src, off, 4, (11 | u, 0), true, guard)?; @@ -8946,11 +8958,12 @@ impl<'a> Lower<'a> { if stride < 4 || !stride.is_multiple_of(4) { return Err("a structured buffer of unknown stride"); } - args.push(self.handle(site, src, false, (12 | u, stride))?); - args.extend([index, off]); + args.push(self.handle(site, src, false, (11 | u, 0))?); let s = self.s.m.i32(stride); let row = self.s.m.bin(self.cur, Bin::Mul, index, s); - (byte, bytes) = (self.s.m.bin(self.cur, Bin::Add, row, off), 4 * count); + byte = self.s.m.bin(self.cur, Bin::Add, row, off); + args.extend([byte, iu]); + bytes = 4 * count; } None => { let n = 4 * count; @@ -9054,14 +9067,17 @@ impl<'a> Lower<'a> { if stride < 4 || !stride.is_multiple_of(4) { return Err("a structured buffer of unknown stride"); } - let h = self.handle(site, src, false, (12 | u, stride))?; + let h = self.handle(site, src, false, (11 | u, 0))?; + let s = self.s.m.i32(stride); + let row = self.s.m.bin(c, Bin::Mul, index, s); + let byte = self.s.m.bin(c, Bin::Add, row, off); self.s.op( c, "rawBufferLoad.f32", Attr::ReadOnly, self.s.t.res_ret, 139, - &[h, index, off, mask, align], + &[h, byte, iu, mask, align], ) } None => { From a81ee21f432f680b957cfff4fd1612aff43f01f1 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 25 Nov 2026 14:55:42 +0200 Subject: [PATCH 05/12] fix: refuse texture UAVs in formats the host cannot store (NVIDIA removal) The GTX 1660 has no typed UAV support for B5G5R5A1_UNORM (86). CreateUnorderedAccessView on an 86 texture removed the device with DXGI_ERROR_INVALID_CALL about 8 s into the title. Only cross-family casts were checked. Now every unordered view's final format is checked: the title's format, or the texture's own. If the host cannot store to it, the slot stays null. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr --- crates/victory-gpu/src/descriptor/host.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/victory-gpu/src/descriptor/host.rs b/crates/victory-gpu/src/descriptor/host.rs index 4509313bec..45aeef5e25 100644 --- a/crates/victory-gpu/src/descriptor/host.rs +++ b/crates/victory-gpu/src/descriptor/host.rs @@ -1087,15 +1087,15 @@ fn fits(texture: &ID3D12Resource, castable: &[u32], mut format: Option<&mut DXGI } let view = format.as_ref().map_or(0, |f| f.0 as u32); if view == 0 { - return !typeless; + return !typeless && (!unordered || stores(own, own)); } let cast = castable.contains(&view); if family(view) != family(own) && !cast { once!(view, own, "view format of another family"); return false; } - if cast && family(view) != family(own) && unordered && !typed_store(view) { - once!(view, own, "an unordered view in a format the host cannot store"); + // The format the view gets (below): the title's, or the texture's own. + if unordered && !stores(if typeless || cast { view } else { own }, own) { return false; } if let Some(format) = format @@ -1121,6 +1121,17 @@ fn default_view(resource: crate::object::This) -> bool { other.is_none() } +/// Whether the host makes typed unordered views of `format` on a texture of +/// `own`: an optional feature for some formats (16-bit packed ones such as +/// B5G5R5A1 on NVIDIA), whose view without it removes the device. +fn stores(format: u32, own: u32) -> bool { + let ok = typed_store(format); + if !ok { + once!(format, own, "an unordered view in a format the host cannot store"); + } + ok +} + /// Whether the host stores to typed unordered views of `format`. fn typed_store(format: u32) -> bool { static KNOWN: Mutex> = Mutex::new(Vec::new()); From 852b207a35784f84ee7c20cd4cf82c767442259d Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 25 Nov 2026 16:06:10 +0200 Subject: [PATCH 06/12] fix: address review findings on the capped heap and raw views - Reserve the 3 null-buffer-view slots in every view-heap size, so a title count just under the NVIDIA cap falls through to the capped heap instead of overlapping the null views. - Clamp structured-as-raw views to the host's 2^27 buffer elements. - Refuse typed UAVs unless the format also reports UAV_TYPED_STORE. - Correct the docs: title indices past the kept slots on a capped heap read dynamic or null views, not always empty ones. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr --- README.md | 5 ++-- crates/victory-gpu/src/descriptor/host.rs | 31 ++++++++++++++++++----- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4ed992d375..ead407d881 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,9 @@ loads the world and shows it: slowly, and with rendering defects. Tested on one machine: Windows 11, AMD RX 6700 XT. NVIDIA GPUs cap shader-visible view heaps at 10^6 slots, and the world uses -more (slot 1,236,191 and up). On such a GPU, shaders read the slots past the -cap as empty instead of faulting the device (until 2026-11-25 the run ended +more (slot 1,236,191 and up). On such a GPU, shaders clamp indices below the +cap instead of faulting the device, and a slot past the kept ones reads an +empty or unrelated view (until 2026-11-25 the run ended with "device removed", DXGI_ERROR_INVALID_CALL). Expect missing or wrong objects. The shader cache is kept per heap size, so run `translate --cache` again after switching GPUs. diff --git a/crates/victory-gpu/src/descriptor/host.rs b/crates/victory-gpu/src/descriptor/host.rs index 45aeef5e25..720d7c6af9 100644 --- a/crates/victory-gpu/src/descriptor/host.rs +++ b/crates/victory-gpu/src/descriptor/host.rs @@ -140,6 +140,8 @@ impl HostHeap { // every title slot; else the smaller one, and the cap after that. // Translated shaders clamp their indices below `heap_views` or // `HEAP_SAMPLERS`: slots up to there exist and stay null. + // Each view heap also has room past the dynamic slots for the null + // buffer views (the 3 slots below `views`, `null_buffer_view`). let (views, samplers) = (victory_shader::emit::heap_views(), victory_shader::emit::HEAP_SAMPLERS); let (heap, count, extra) = if sampler { match make(count.max(samplers)) { @@ -149,15 +151,17 @@ impl HostHeap { return None; } } - } else if let Ok(heap) = make((count + DYNAMIC).max(views)) { + } else if let Ok(heap) = make((count + DYNAMIC + 3).max(views)) { (heap, count, DYNAMIC) - } else if let Ok(heap) = make((count + MIN_DYNAMIC).max(views)) { + } else if let Ok(heap) = make((count + MIN_DYNAMIC + 3).max(views)) { (heap, count, MIN_DYNAMIC) } else { // shortcut: title slots past the host's cap (NVIDIA) are left - // out; shaders clamp below `views` and read them null. A title - // that draws with them needs remapping. The dynamic slots, then - // the null buffer views, take the heap's last slots. + // out. The dynamic slots, then the null buffer views, take the + // heap's last slots: shaders clamp below `views`, so a title + // index past the kept ones reads a dynamic slot's view (another + // draw's) or a null one. A title that draws with them needs + // remapping. let title = views - MIN_DYNAMIC - 3; match make(views) { Ok(heap) => { @@ -949,7 +953,8 @@ fn buffer_srv( fn as_raw(first: u64, count: u32, stride: u32) -> Option<(u64, u32)> { (stride > 0 && stride.is_multiple_of(4)).then(|| { let words = u64::from(stride / 4); - (first * words, (u64::from(count) * words).min(u64::from(u32::MAX)) as u32) + // The host's most elements in a buffer view (as `raw_view_at`). + (first * words, (u64::from(count) * words).min(1 << 27) as u32) }) } @@ -1154,6 +1159,7 @@ fn typed_store(format: u32) -> bool { } .is_ok() && support.Support1.0 & D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW.0 != 0 + && support.Support2.0 & D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE.0 != 0 }); known.push((format, ok)); ok @@ -1497,6 +1503,19 @@ mod tests { assert!(!within(64, u64::MAX, 1, 16)); } + /// Structured views become raw ones in words, at most the host's 2^27 + /// elements; other views stay as they are. + #[test] + fn structured_views_become_raw_within_the_element_limit() { + assert_eq!(as_raw(3, 10, 16), Some((12, 40))); + assert_eq!(as_raw(0, 1 << 24, 64), Some((0, 1 << 27))); + assert_eq!(as_raw(0, 10, 0), None); + assert_eq!(as_raw(0, 10, 6), None); + assert_eq!(copy_align(4, 4), 16); + assert_eq!(copy_align(24, 24), 48); + assert_eq!(copy_align(4, 0), 4); + } + /// A null texture UAV keeps the title's dimension (3D for the world's /// wind field), and is 2D when the title names none. #[test] From 739a58951be78eb96d0314ea5a8db45f532fc98b Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 25 Nov 2026 16:06:51 +0200 Subject: [PATCH 07/12] docs: record the open GPU hang investigation (Series X and Series S) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr --- docs/gpu-hang-investigation.md | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 docs/gpu-hang-investigation.md diff --git a/docs/gpu-hang-investigation.md b/docs/gpu-hang-investigation.md new file mode 100644 index 0000000000..a2471267d6 --- /dev/null +++ b/docs/gpu-hang-investigation.md @@ -0,0 +1,35 @@ +# GPU hang in the world (DEVICE_HUNG), Series X and Series S + +Status: **open**, cause unconfirmed. Last updated 2026-11-25 (GTX 1660 Super). + +Branch fix/nvidia-heap-clamp (PR #2185). Fixed and committed there: the NVIDIA +INVALID_CALL removals (heap clamp 4d91d9d/8d5eaaa, raw structured views 16580cd, +unstorable texture UAVs a81ee21, review fixes 852b207). Still open: the DEVICE_HUNG below. + +## Series S +- The old exit-139 segfault does not reproduce (`run --console series-s`). +- It now stops at frame ~1515 with the same DEVICE_HUNG as Series X. It is the same bug, + not a Series S-only one. + +## The hang +- 0x887A0006 between frames ~1340 and ~1530. +- DRED: the hung command is `indirect kind 2 max 1 [compute f607780aa8e502d0]` + (args at title 0xd9358fe80). +- Skipping only f607780aa8e502d0: no removal through frame 1699. + Skipping 741447eb077ae6d3 (the voxel grid writer) also avoids it. +- f607 is a BVH traversal (emulated image_bvh64_intersect_ray, LDS short stack, two + loops each capped at 0xffff by the shader). +- **Loop count ruled out**: with VICTORY_SHADER_LOOP_LIMIT=16 plus DRED it still hangs on + the same command at frame 1341. +- In captured frames that did not hang, the dispatch args are [0,1,1] or [1,1,1]. + +## Leading hypothesis (unconfirmed) +In the hang frame the indirect args hold a large group count, perhaps written wrongly +or not yet written by the 741447 pass. The clamp in crates/victory-gpu/src/indirect.rs +allows up to 2^20 groups per dispatch and a 2^27-thread budget per list. That is +enough f607 work to pass the TDR. + +## To confirm +One run with VICTORY_D3D12_DRED=1, VICTORY_DUMP_TARGETS=1, VICTORY_CAPTURE and +VICTORY_CAPTURE_FRAMES covering the hang window. Then read the `indirect kind 2 … f607780…` +trace lines. Each run takes about 14 GB of RAM. From 9518df8cf796a7f364a226179ddcf25d4082c3af Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 25 Nov 2026 16:36:47 +0200 Subject: [PATCH 08/12] docs: rule out the indirect group count as the GPU hang's cause Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr --- docs/gpu-hang-investigation.md | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/docs/gpu-hang-investigation.md b/docs/gpu-hang-investigation.md index a2471267d6..a7a80b0801 100644 --- a/docs/gpu-hang-investigation.md +++ b/docs/gpu-hang-investigation.md @@ -23,13 +23,21 @@ unstorable texture UAVs a81ee21, review fixes 852b207). Still open: the DEVICE_H the same command at frame 1341. - In captured frames that did not hang, the dispatch args are [0,1,1] or [1,1,1]. -## Leading hypothesis (unconfirmed) -In the hang frame the indirect args hold a large group count, perhaps written wrongly -or not yet written by the 741447 pass. The clamp in crates/victory-gpu/src/indirect.rs -allows up to 2^20 groups per dispatch and a 2^27-thread budget per list. That is -enough f607 work to pass the TDR. +- **Group count ruled out**: with the indirect clamp's GROUPS set to 1 (every indirect + dispatch runs one group or none) it still hangs on the same command, at frame 1467. + No DRED page fault is reported, so it is a real hang inside a single group. +- A plain args capture cannot show the hang frame: `read_indirect` logs only after the + list completes, and a hung list never completes. +- f607's disassembly has no `s_barrier`. The two loops are wave-uniform back edges + (`s_cbranch_scc1` on the s20 and s6 masks). The BVH lowering (emit/lower/bvh.rs) has + no loops of its own. -## To confirm -One run with VICTORY_D3D12_DRED=1, VICTORY_DUMP_TARGETS=1, VICTORY_CAPTURE and -VICTORY_CAPTURE_FRAMES covering the hang window. Then read the `indirect kind 2 … f607780…` -trace lines. Each run takes about 14 GB of RAM. +## Open leads +1. Loops the per-lane counter misses. Check that both f607 back edges get a counter in + the translated DXIL, and that the wave-uniform exit (the scc mask built from exec) + still ends once lanes take the abort block. +2. A wave-op or convergence livelock on NVIDIA, such as ballot-based exec emulation + inside the loop with lanes that have returned. +3. Data written by 741447 (the voxel grid writer). Skipping it avoids the hang, so the + BVH or LDS stack input may be what traps a lane. Dump 741447's output buffers in the + frame before the hang (VICTORY_DUMP_WRITERS=741447eb077ae6d3). From 982d655ea94195fc7784f5445ae74f70b777d912 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 25 Nov 2026 17:16:35 +0200 Subject: [PATCH 09/12] fix: size the view-address table for every index shaders read (NVIDIA hang) On a capped heap (GTX 1660: 10^6 views, 934461 title slots kept) the view-addresses table held only the kept title slots. Translated shaders read it through a root SRV, which has no bounds, at indices clamped only below heap_views, up to ~524 KB past the buffer. That hung the BVH traversal f607780aa8e502d0 (DEVICE_HUNG, no page fault) between frames ~1340 and ~1603 on Series X and Series S. The strides, marks and view-address tables now share indexed_slots(). Heap-direct title indices past the kept slots go to the null last slot (title_guard). After review: a capped host keeps a heap of exactly heap_views unless everything fits under it, and the uncapped fallback keeps room for the dynamic and null slots again. Verified on GTX 1660 Super: Series X runs to frame 1699 and Series S to frame 1929 with no removal. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr --- crates/victory-gpu/src/descriptor/host.rs | 50 +++++++++++---- crates/victory-shader/src/emit/lower.rs | 40 ++++++++++-- crates/victory-shader/src/emit/mod.rs | 26 ++++++++ docs/gpu-hang-investigation.md | 77 ++++++++++++++--------- 4 files changed, 149 insertions(+), 44 deletions(-) diff --git a/crates/victory-gpu/src/descriptor/host.rs b/crates/victory-gpu/src/descriptor/host.rs index 720d7c6af9..2ddb218fb6 100644 --- a/crates/victory-gpu/src/descriptor/host.rs +++ b/crates/victory-gpu/src/descriptor/host.rs @@ -50,7 +50,8 @@ pub(crate) struct HostHeap { /// view there, `VIEW_MARK_NONE` for none. Mapped at the address kept /// beside it. marks: Option<(ID3D12Resource, usize)>, - /// Per title slot, the title address of the buffer view it holds, as a + /// Per slot (`indexed_slots`), the title address of the buffer view it + /// holds (0 past the title's slots), as a /// buffer descriptor's dwords 0 and 1 (shaders reading a descriptor's /// address as data, `crate::memory`): the buffer, its mapping and host /// address, made on first use. @@ -94,9 +95,18 @@ pub(crate) const PORTABLE_VIEWS: u32 = 1_000_000; /// each a device removal shortly after; #59). const DYNAMIC: u32 = 1 << 18; +/// Entries in a per-slot table translated shaders read as a root view +/// (strides, marks, view addresses): every index they can compute. A root +/// view has no bounds, and they clamp indices below `heap_views`, at most +/// `HEAP_VIEWS`, which may pass the title's `count` (a capped heap keeps +/// fewer). A read past the table read past its buffer, and hung NVIDIA. +fn indexed_slots(count: u32) -> u32 { + count.max(victory_shader::emit::HEAP_VIEWS) +} + /// The dynamic slots of a heap whose host would not take [`DYNAMIC`] more /// (a capped heap, NVIDIA): the title's slots keep their room first. -const MIN_DYNAMIC: u32 = 1 << 16; +const MIN_DYNAMIC: u32 = victory_shader::emit::CAPPED_DYNAMIC; impl HostHeap { pub(crate) fn new(sampler: bool, count: u32) -> Option { @@ -122,12 +132,12 @@ impl HostHeap { // heap, and dynamic ones): shaders read the table as a root view, // which has no bounds, at indices clamped below `HEAP_VIEWS`. let strides = (!sampler) - .then(|| host.upload_buffer(u64::from(count.max(victory_shader::emit::HEAP_VIEWS)) * 4)) + .then(|| host.upload_buffer(u64::from(indexed_slots(count)) * 4)) .flatten() .map(|(buffer, data)| (buffer, data as usize)); let marks = (!sampler) .then(|| { - let bytes = u64::from(count.max(victory_shader::emit::HEAP_VIEWS)) * 8; + let bytes = u64::from(indexed_slots(count)) * 8; let (buffer, data) = host.upload_buffer(bytes)?; crate::host::name(&buffer, || "view marks".into()); // Every slot unmarked (all ones) until a view is made there. @@ -143,6 +153,10 @@ impl HostHeap { // Each view heap also has room past the dynamic slots for the null // buffer views (the 3 slots below `views`, `null_buffer_view`). let (views, samplers) = (victory_shader::emit::heap_views(), victory_shader::emit::HEAP_SAMPLERS); + // A capped host: shaders clamp below `views`, so the heap is exactly + // that, its last slots null (a larger one would put title views + // where shaders expect null ones). + let fits = |extra: u32| views == victory_shader::emit::HEAP_VIEWS || count + extra + 3 <= views; let (heap, count, extra) = if sampler { match make(count.max(samplers)) { Ok(heap) => (heap, count, 0), @@ -151,17 +165,19 @@ impl HostHeap { return None; } } - } else if let Ok(heap) = make((count + DYNAMIC + 3).max(views)) { + } else if fits(DYNAMIC) && let Ok(heap) = make((count + DYNAMIC + 3).max(views)) { (heap, count, DYNAMIC) - } else if let Ok(heap) = make((count + MIN_DYNAMIC + 3).max(views)) { + } else if fits(MIN_DYNAMIC) && let Ok(heap) = make((count + MIN_DYNAMIC + 3).max(views)) { (heap, count, MIN_DYNAMIC) } else { // shortcut: title slots past the host's cap (NVIDIA) are left // out. The dynamic slots, then the null buffer views, take the - // heap's last slots: shaders clamp below `views`, so a title - // index past the kept ones reads a dynamic slot's view (another - // draw's) or a null one. A title that draws with them needs - // remapping. + // heap's last slots. Shaders read a title index past the kept + // ones from the null last slot (`title_views`), not a dynamic + // slot's view (another draw's, a hang on NVIDIA). A title that + // draws with them needs remapping. + // `title_views()` where the host is capped; uncapped, the title + // still keeps room for the dynamic and null slots. let title = views - MIN_DYNAMIC - 3; match make(views) { Ok(heap) => { @@ -548,7 +564,7 @@ impl HostHeap { /// on first use from the slots made so far. pub(crate) fn view_addresses(&self) -> Option { let made = self.addresses.get_or_init(|| { - let (buffer, data) = host()?.upload_buffer(u64::from(self.count) * 8)?; + let (buffer, data) = host()?.upload_buffer(u64::from(indexed_slots(self.count)) * 8)?; crate::host::name(&buffer, || "view addresses".into()); let data = data as usize; let made = self.made.lock().unwrap_or_else(|e| e.into_inner()); @@ -1493,6 +1509,18 @@ fn null_view(at: D3D12_CPU_DESCRIPTOR_HANDLE) { mod tests { use super::*; + /// f607780aa8e502d0 read the view addresses at a table index past a + /// capped heap's title slots: past the buffer (DEVICE_HUNG, GTX 1660). + #[test] + fn per_slot_tables_cover_every_index_a_shader_reads() { + use victory_shader::emit::HEAP_VIEWS; + // GTX 1660: heap capped at 10^6, 934461 title slots kept. + for (count, views) in [(934_461, 1_000_000), (1_245_184, HEAP_VIEWS), (10, HEAP_VIEWS)] { + assert!(indexed_slots(count) >= views, "{count} {views}"); + assert!(indexed_slots(count) >= count); + } + } + /// The world's 16-byte view of 0 elements removed the device. #[test] fn empty_and_overlong_buffer_views_are_refused() { diff --git a/crates/victory-shader/src/emit/lower.rs b/crates/victory-shader/src/emit/lower.rs index acedfa4418..504ccaab9e 100644 --- a/crates/victory-shader/src/emit/lower.rs +++ b/crates/victory-shader/src/emit/lower.rs @@ -5044,6 +5044,7 @@ impl<'a> Lower<'a> { /// buffer one (a wild address: the texture's address shifted 8 bits /// down) and faulted the device. fn buffer_guard(&mut self, src: &Source, index: V, sampler: bool, props: (u32, u32)) -> V { + let index = self.title_guard(src, index, sampler); // Typed, raw and structured buffers (DXIL resource kinds 10-12). if sampler || !(10..=12).contains(&(props.0 & 0xFF)) || !self.is_heap_direct(src) { return index; @@ -5067,17 +5068,46 @@ impl<'a> Lower<'a> { self.s.m.select(c, none, null, index) } - /// Whether a descriptor comes from the resource heap itself (root type - /// 5, not a table) on some path. - fn is_heap_direct(&self, src: &Source) -> bool { - src.leaves().iter().any(|l| match l { + /// `index`, or the heap's last slot (null) where a capped host heap + /// keeps no title slot there (module notes, "Heap indices"): for a + /// view taken from the resource heap itself on every path, an index at + /// or past [`super::title_views`] would read a dynamic slot, another + /// draw's view, perhaps of another kind (a GPU hang on NVIDIA, with no + /// page fault). Tables hold dynamic slots' indices and are left alone. + fn title_guard(&mut self, src: &Source, index: V, sampler: bool) -> V { + let title = super::title_views(); + if sampler || title == super::heap_views() || !self.all_heap_direct(src) { + return index; + } + let c = self.cur; + let first = self.s.m.i32(title); + let past = self.s.m.cmp(c, pred::IUGE, index, first); + let null = self.s.m.i32(super::heap_views() - 1); + self.s.m.select(c, past, null, index) + } + + /// Whether a descriptor comes from the resource heap itself on every + /// path. + fn all_heap_direct(&self, src: &Source) -> bool { + let leaves = src.leaves(); + !leaves.is_empty() && leaves.iter().all(|l| self.leaf_heap_direct(l)) + } + + fn leaf_heap_direct(&self, l: &Source) -> bool { + match l { Source::Loaded { load, .. } | Source::Fetched { load, .. } => self .scalar .get(load) .and_then(|a| self.x.native.layout.get(a.param)) .is_some_and(|p| p.root == RootType::ResourceHeap), _ => false, - }) + } + } + + /// Whether a descriptor comes from the resource heap itself (root type + /// 5, not a table) on some path. + fn is_heap_direct(&self, src: &Source) -> bool { + src.leaves().iter().any(|l| self.leaf_heap_direct(l)) } /// The heap index of a descriptor that may differ between lanes, diff --git a/crates/victory-shader/src/emit/mod.rs b/crates/victory-shader/src/emit/mod.rs index 6611501c73..de6418e9cc 100644 --- a/crates/victory-shader/src/emit/mod.rs +++ b/crates/victory-shader/src/emit/mod.rs @@ -270,6 +270,22 @@ pub fn set_heap_views(views: u32) -> bool { heap_views() == views } +/// The dynamic slots of a host view heap capped below [`HEAP_VIEWS`]: they +/// and the three null slots ([`null_buffer_view`]) follow the title's. +pub const CAPPED_DYNAMIC: u32 = 1 << 16; + +/// The title view slots a host heap keeps: [`heap_views`], or where the +/// host capped it below [`HEAP_VIEWS`], those before the +/// [`CAPPED_DYNAMIC`] dynamic slots and the null ones. Translated shaders +/// read a title index past them from the null last slot. +pub fn title_views() -> u32 { + capped_title(heap_views()) +} + +fn capped_title(views: u32) -> u32 { + if views < HEAP_VIEWS { views - CAPPED_DYNAMIC - 3 } else { views } +} + /// The heap index of the host's null raw buffer SRV (the null raw UAV at /// the index below): [`heap_views`] - 2. [`NULL_BUFFER_VIEW`] by default. pub fn null_buffer_view() -> u32 { @@ -649,6 +665,16 @@ mod tests { use super::lower::LOOP_LIMIT; use super::parse_loop_limit; + /// A capped heap (NVIDIA, 10^6 views) keeps 934461 title slots: its + /// last 2^16 + 3 are the dynamic and null ones, which a title index + /// must not reach. An uncapped heap keeps every slot below it. + #[test] + fn a_capped_heap_keeps_title_slots_below_its_dynamic_ones() { + assert_eq!(super::capped_title(1_000_000), 934_461); + assert_eq!(super::capped_title(1_000_000) + super::CAPPED_DYNAMIC + 3, 1_000_000); + assert_eq!(super::capped_title(super::HEAP_VIEWS), super::HEAP_VIEWS); + } + #[test] fn the_loop_limit_switch_parses_or_falls_back() { assert_eq!(parse_loop_limit(None), LOOP_LIMIT); diff --git a/docs/gpu-hang-investigation.md b/docs/gpu-hang-investigation.md index a7a80b0801..2f93f1a863 100644 --- a/docs/gpu-hang-investigation.md +++ b/docs/gpu-hang-investigation.md @@ -1,43 +1,64 @@ # GPU hang in the world (DEVICE_HUNG), Series X and Series S -Status: **open**, cause unconfirmed. Last updated 2026-11-25 (GTX 1660 Super). +Status: **fixed** (GTX 1660 Super). Last updated 2026-11-25. Branch fix/nvidia-heap-clamp (PR #2185). Fixed and committed there: the NVIDIA INVALID_CALL removals (heap clamp 4d91d9d/8d5eaaa, raw structured views 16580cd, -unstorable texture UAVs a81ee21, review fixes 852b207). Still open: the DEVICE_HUNG below. +unstorable texture UAVs a81ee21, review fixes 852b207), and this DEVICE_HUNG. + +## Cause and fix +The 1660 caps the view heap at 10^6 (`host view heap capped at 1000000 count=1245184 +kept=934461`). The per-slot view-addresses table (`HostHeap::view_addresses`, +crates/victory-gpu/src/descriptor/host.rs) was sized for `count` = 934461 slots. +Translated shaders read it through a root SRV, which has no bounds checks, at a heap +index clamped only below `heap_views` (10^6). That index can reach 999999, so a read +can land up to ~524 KB past the buffer. On NVIDIA that hung f607 with no DRED page fault. + +The strides and marks tables were already sized `count.max(HEAP_VIEWS)`. All three now +use `indexed_slots(count)`. Test: `per_slot_tables_cover_every_index_a_shader_reads`. + +Verified with the diag build plus DRED: +- Series X: no removal through frame 1699 (the end of the run). Every unfixed run hung + between frames 1340 and 1603. +- Series S: no removal through frame 1929. ## Series S - The old exit-139 segfault does not reproduce (`run --console series-s`). -- It now stops at frame ~1515 with the same DEVICE_HUNG as Series X. It is the same bug, - not a Series S-only one. +- Before the fix it stopped at frame ~1515 with the same DEVICE_HUNG as Series X. + It is the same bug, not a Series S-only one. +- After the fix: no removal through frame 1929 (the 480 s run ended by timeout). -## The hang -- 0x887A0006 between frames ~1340 and ~1530. +## The hang (before the fix) +- 0x887A0006 between frames ~1340 and ~1603. - DRED: the hung command is `indirect kind 2 max 1 [compute f607780aa8e502d0]` (args at title 0xd9358fe80). - Skipping only f607780aa8e502d0: no removal through frame 1699. Skipping 741447eb077ae6d3 (the voxel grid writer) also avoids it. - f607 is a BVH traversal (emulated image_bvh64_intersect_ray, LDS short stack, two loops each capped at 0xffff by the shader). -- **Loop count ruled out**: with VICTORY_SHADER_LOOP_LIMIT=16 plus DRED it still hangs on - the same command at frame 1341. -- In captured frames that did not hang, the dispatch args are [0,1,1] or [1,1,1]. - -- **Group count ruled out**: with the indirect clamp's GROUPS set to 1 (every indirect - dispatch runs one group or none) it still hangs on the same command, at frame 1467. - No DRED page fault is reported, so it is a real hang inside a single group. -- A plain args capture cannot show the hang frame: `read_indirect` logs only after the - list completes, and a hung list never completes. -- f607's disassembly has no `s_barrier`. The two loops are wave-uniform back edges - (`s_cbranch_scc1` on the s20 and s6 masks). The BVH lowering (emit/lower/bvh.rs) has - no loops of its own. - -## Open leads -1. Loops the per-lane counter misses. Check that both f607 back edges get a counter in - the translated DXIL, and that the wave-uniform exit (the scc mask built from exec) - still ends once lanes take the abort block. -2. A wave-op or convergence livelock on NVIDIA, such as ballot-based exec emulation - inside the loop with lanes that have returned. -3. Data written by 741447 (the voxel grid writer). Skipping it avoids the hang, so the - BVH or LDS stack input may be what traps a lane. Dump 741447's output buffers in the - frame before the hang (VICTORY_DUMP_WRITERS=741447eb077ae6d3). + +## Leads ruled out +1. **Loop count.** With VICTORY_SHADER_LOOP_LIMIT=16 it still hung on the same command + at frame 1341. +2. **Group count.** With every indirect dispatch clamped to one group it still hung at + frame 1467. No DRED page fault was reported. +3. **Uncounted loops.** f607's only back edges both carry the per-lane counter. There is + no `s_barrier`. +4. **Wave-op or atomic spin.** waveReadLaneFirst appears only outside the loops. LDS uses + only store and atomicrmw xchg. +5. **Dirty-bitmap atomics.** Skipping the memory-dirty OR still hung (frame 1455). +6. **LDS out of range.** The groupshared array is 512 dwords and every address is masked + with `and 2044`. +7. **BVH node data.** Zeroing every node dword still hung on the same command (frame 1463). +8. **Title indices reaching dynamic slots.** `title_guard` (emit/lower.rs) sends a title + index at or past `title_views()` to the null last slot. It still hung at frame 1603, + so this was not the cause. It is kept as a correctness fix: such an index read + another draw's view, perhaps of another kind. + +## Open, not addressed +- `heap_handle` clamps an index to the last slot, which holds a Texture2D null SRV. + A buffer or UAV handle clamped there is a type mismatch. No hang has been seen from it. +- Review follow-up: on a capped host the heap is now exactly `heap_views()` slots unless + the title plus its dynamic and null slots fit under it. A larger heap would put title + views at the null slots shaders clamp to. The uncapped fallback keeps + `views - MIN_DYNAMIC - 3` title slots again. From 009277bc74567080bcc4eaee181de8927f3cb10a Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 25 Nov 2026 17:27:38 +0200 Subject: [PATCH 10/12] docs: record the crashes that end runs after the hang fix Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr --- docs/gpu-hang-investigation.md | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/docs/gpu-hang-investigation.md b/docs/gpu-hang-investigation.md index 2f93f1a863..45d0e81dcb 100644 --- a/docs/gpu-hang-investigation.md +++ b/docs/gpu-hang-investigation.md @@ -17,16 +17,27 @@ can land up to ~524 KB past the buffer. On NVIDIA that hung f607 with no DRED pa The strides and marks tables were already sized `count.max(HEAP_VIEWS)`. All three now use `indexed_slots(count)`. Test: `per_slot_tables_cover_every_index_a_shader_reads`. -Verified with the diag build plus DRED: -- Series X: no removal through frame 1699 (the end of the run). Every unfixed run hung - between frames 1340 and 1603. -- Series S: no removal through frame 1929. +Verified with the diag build plus DRED. No run after the fix had a device removal. +Every unfixed run hung between frames 1340 and 1603. +- Series X (vaddr1): no removal. At frame 1699 the run ended in a title crash: seven + int3s (0x80000003 at victory-image+0x5149aec), then WER. +- Series X (final1, the build after the review fixes): no removal. At frame 1797 it + ended with exit 139: an AV executing unmapped memory inside the NVIDIA driver + (nvwgf2umx.dll), called from victory.exe through D3D12Core. The log line before it + was `slow host submission ms=1684`, followed by mesh pipeline creation. +- Series S (vaddrS): no removal through frame 1929, when the 480 s run timed out. It + logged one first-chance AV in nvwgf2umx.dll+0x122db1c (read 0x0); the title + survived it. + +## New crashes past the old hang point (open) +These are separate from the hang and not yet triaged: the title int3s, and the driver +AV. Neither run produced DRED data, and the victory.exe frames are not symbolized. ## Series S - The old exit-139 segfault does not reproduce (`run --console series-s`). - Before the fix it stopped at frame ~1515 with the same DEVICE_HUNG as Series X. It is the same bug, not a Series S-only one. -- After the fix: no removal through frame 1929 (the 480 s run ended by timeout). +- After the fix: no removal through frame 1929, when the 480 s run timed out. ## The hang (before the fix) - 0x887A0006 between frames ~1340 and ~1603. From 9e79bfc672657e004d8539ec6ad39cc501c64aa0 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 25 Nov 2026 18:14:13 +0200 Subject: [PATCH 11/12] docs: triage the two crashes past the old hang point The frame-1797 driver AV jumped to a valid nvwgf2umx address with one bit flipped (bit 43), which points at hardware rather than a pipeline. An offline build of all 28164 pack pipelines did not crash. The frame-1699 int3 is the title pool allocator's empty-pool trap; a run that polled both pools reached frame 1928 with them under 45% full and not growing. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr --- docs/gpu-hang-investigation.md | 40 +++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/docs/gpu-hang-investigation.md b/docs/gpu-hang-investigation.md index 45d0e81dcb..d11c4f21c6 100644 --- a/docs/gpu-hang-investigation.md +++ b/docs/gpu-hang-investigation.md @@ -29,9 +29,43 @@ Every unfixed run hung between frames 1340 and 1603. logged one first-chance AV in nvwgf2umx.dll+0x122db1c (read 0x0); the title survived it. -## New crashes past the old hang point (open) -These are separate from the hang and not yet triaged: the title int3s, and the driver -AV. Neither run produced DRED data, and the victory.exe frames are not symbolized. +## New crashes past the old hang point (triaged: not reproduced, no emulator fault found) +Neither crash repeats, and neither points at emulator code. + +**Driver AV at frame 1797 (final1).** The stack runs from `pipeline::library::pipeline` +(the `create()` call, library.rs) through D3D12Core into nvwgf2umx.dll, on a pipeline +worker making a mesh pipeline. +- It executed 0x77fc4bd42980. nvwgf2umx.dll was mapped at 0x7ffc4bb70000 that boot + (same boot as the run). 0x7ffc4bd42980 is nvwgf2umx+0x1d2980. +- The bad target differs from that valid driver address in exactly one bit (bit 43). + A single flipped bit in a code pointer is the mark of a memory or CPU error, not of a + bad pipeline description. No WHEA event was logged, which non-ECC RAM would not + report anyway. +- Making every one of the title's 28164 pack pipelines offline (`translate --cache + --pipelines`) did not crash. The first pass stalled with 3 jobs for over 4 minutes + until its timeout. A rerun made the remaining 1098 jobs, those 3 included, in 40 s. + So the stall did not repeat. +- Suggested check on this host: a memory test, and stock CPU/RAM settings if any + overclock or curve offset is set. + +**Title int3 at frame 1699 (vaddr1).** victory-image+0x5149aec is the fatal trap of a +lock-free pool allocator. It fires when the free list is empty (head index 0x1fffe) or +the pool has no storage. The function picks one of two pools by a type byte: +| pool (title global) | entry | capacity | +|---|---|---| +| 0x14a9ec938 | 0xe0 bytes | 22500 | +| 0x14abbe2e8 | 0x110 bytes | 27500 | + +Pool header: +0x0 storage, +0x8 entry size, +0xc capacity, +0x10 live count, +0x20 free +head, +0x28 links. A run polled both pools every 2 s (pool1, Series X, 480 s). It +reached frame 1928 with no crash. Pool A peaked at 9714 live entries and pool B +at 4901. Both rose and fell with the scene and leveled off at the end, with no +growth trend and under 45% of capacity. A leak that the emulator causes would show as +steady growth. Exhausting the pool from there in one frame is unlikely; a corrupted +head index (see the bit flip above) would also hit this trap. + +Runs past the old hang point: vaddr1 (int3, 1699), final1 (AV, 1797), vaddrS (none, +1929), pool1 (none, 1928). ## Series S - The old exit-139 segfault does not reproduce (`run --console series-s`). From fdb18fb426fafcffa8502456ace650970a5de5fb Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 25 Nov 2026 18:31:55 +0200 Subject: [PATCH 12/12] docs: record the Series S pass and the frame-6942 title crash Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr --- docs/gpu-hang-investigation.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/gpu-hang-investigation.md b/docs/gpu-hang-investigation.md index d11c4f21c6..7d8b2d05ce 100644 --- a/docs/gpu-hang-investigation.md +++ b/docs/gpu-hang-investigation.md @@ -64,8 +64,17 @@ growth trend and under 45% of capacity. A leak that the emulator causes would sh steady growth. Exhausting the pool from there in one frame is unlikely; a corrupted head index (see the bit flip above) would also hit this trap. +**Title AV at frame 6942 (manual run, open).** A long manual run (the title's crash +report says `Xbox Series X`) faulted at victory-image+0x7b61a7, reading 0x8. The +code is `mov (%rdi),%r15; call *0x8(%r15)`: a virtual call on the object at +0x6ca4e1220, whose first qword (its vtable) is 0. The object was freed, zeroed or +never set up. This is a different site from the two crashes above, and no flipped bit +shows in the registers. One crash so far does not tell a title bug from the emulator +writing over title memory. The next step is to find what writes zeros there. + Runs past the old hang point: vaddr1 (int3, 1699), final1 (AV, 1797), vaddrS (none, -1929), pool1 (none, 1928). +1929), pool1 (none, 1928), finalS (none, 1937, Series S, 400 s, clean HEAD), manual +(AV, 6942). ## Series S - The old exit-139 segfault does not reproduce (`run --console series-s`).