Linux (Wine + vkd3d-proton), RTX 2080 Ti: reaches the opening cutscene; four fixes, a mesh-launch problem, and lighting at exact zero #14

Open
opened 2026-11-26 19:48:58 +00:00 by github-bot · 3 comments
Owner

@⁠arbelonson-source on GitHub · 2026-11-26 19:38 UTC · original

Environment

  • Arch Linux, NVIDIA driver 615.78.08, RTX 2080 Ti 11 GB (Turing, 32-lane waves, no Resizable BAR), i9-9900K (no CLZERO), 31 GB RAM
  • Wine 11.22, vkd3d-proton 3.1 (rebuilt, see 1), DXVK 3.2 dxgi
  • Kelvaroq 0.2.0. The engine is rebuilt from sources/native.zip with Rust 1.98.1 and cargo xwin. It has the same VICTORY_* switches as the shipped kelvaroq-engine.exe, plus the fix below.

Result

The title boots, the menus run at 30 fps, the story loads, and the opening cutscene plays: subtitles and credit cards show, and it ran 22+ minutes without a crash. But the 3D picture is black, at 0.1–0.3 fps.

What it took, in order

  1. Crash during the prologue load (exit code 3). vkd3d-proton 3.1's dxil-spirv (8b48f0e) emits invalid SPIR-V for several compute shaders: an unterminated merge block, or a merge block shared by two headers. NVIDIA's Linux compiler crashes on them (SIGILL in vkCreateComputePipelines), and winevulkan exits with code 3. I reproduced it natively with the dumped SPIR-V. dxil-spirv b540c8a (what vkd3d-proton master pins) converts all 112 shaders I saw to valid SPIR-V. Rebuilding vkd3d-proton 3.1 with it fixes the crash.
  2. CLZERO emulation (victory-loader/src/console_cpu.rs) declines guarded or uncommitted lines. When the safe write is refused, it returns 0, and the illegal instruction goes unhandled: 0xc000001d at the 12-byte loop 0f 01 fc 48 83 c0 40 4c 39 d0 72 f4, 22 minutes in. On the console the store faults into the runtime's front-of-chain handlers (write-watch guards, lazy commit), which open the page. The fix zeroes such a line with ordinary stores from the handler, so the same handlers resolve it. Free memory is still declined. A test fails without the fix and passes with it. In a 22-minute run, 77 lines went through the fault; each was a crash before. Diff below. Upstream victory-fork has the same early return in console_insn.rs: fxceless/victory-fork#1380.
  3. A mesh pipeline refused: blending enabled on an R8_UINT target (E_INVALIDARG). Upstream victory-fork already turns blending off on integer targets (pipeline/host.rs); f85101b predates that.
  4. Helper shaders compiled with D3DCompile (depth planes from their twins, the indirect argument clamp). Wine's built-in d3dcompiler_47 fails on them (E5005: Method 'InterlockedOr' is not defined on type 'RWByteAddressBuffer'). The one winetricks d3dcompiler_47 installs (6.3.9600, Windows 8.1 SDK) rejects the targets (X3506: unrecognized compiler target 'cs_5_1'). A Windows 10+ d3dcompiler_47.dll works. Without it: "no pipeline to draw a depth plane from its twin" and "no argument clamp: indirect execution dropped". A version check at startup would make this obvious.
  5. VICTORY_MESH_LAUNCH (on by default) draws no world geometry here. The log reports indirect mesh dispatches: the largest group count asked for 0, and the depth buffer and G-buffer of the cutscene's first 3D frames hold one character only. With VICTORY_MESH_LAUNCH=0, the records are non-zero (largest 493, about 12,000 groups a frame), and the world fills the depth buffer, G-buffer and shadow maps. The unit test mesh_records_are_launched_by_the_amplification_stage passes on this GPU under the same stack, so the shader itself works; the difference is in how a real run's records are reached. Not root-caused.

(The title's own hang watchdog also fired during the slow load; I worked around it outside the engine.)

Still open: the lighting writes exact zeros

Captured with the diagnostics build (VICTORY_CAPTURE_WORLD=1 VICTORY_DUMP_TARGETS=1; real values from the log's target values lines), with all of the above applied:

  • The HDR scene target holds values up to 1767, and the sky target up to 9984.
  • The deferred-lighting compute (df11dcd012cd7382, 320×180 groups) writes exactly 0 to its outputs. So does a full-screen composite (c19a0b6c544d5e78) that reads the sky target.
  • Auto-exposure reads a luminance of ~1e-6 and sits at 1024. There's no NaN in the exposure chain.
  • Unchanged with VICTORY_WAVE64_PAIRED=0, with --console series-s (1920×1080 internally), and with VICTORY_LEVELS_ON_DEMAND=1.
  • The bindless texture queue keeps about 19,000 of 24,000 slots due, about 8,000 of them "waiting for their memory". The DXGI budget is 8.7 GB.

Not tested yet: whether dxil-spirv b540c8a (needed for 1) mistranslates these two shaders. The older converter crashes the driver during the load (1), so that test needs replacement shaders.

Issue #11 (RTX 5070, Windows) sees the cell's window light, so this zero is probably specific to this stack.

Performance

The cutscene runs at 0.1–0.3 fps, almost all of it on the CPU. For example: about 8 s a frame of texture refreshes across threads, 2.9 s of that asking the write watch; copies of 130–200 MB a frame in 1.7–5.7 s; and about 100 million emulated console-CPU instructions in 20 minutes (CLWB, MONITORX/MWAITX, CLZERO).

Diff: CLZERO on guarded or uncommitted lines (against sources/native.zip of 0.2.0)
diff --git a/crates/victory-loader/src/console_cpu.rs b/crates/victory-loader/src/console_cpu.rs
index 1d5e317..41b6191 100644
--- a/crates/victory-loader/src/console_cpu.rs
+++ b/crates/victory-loader/src/console_cpu.rs
@@ -144,6 +144,8 @@ static COUNTS: [AtomicU64; 8] = [const { AtomicU64::new(0) }; 8];
 static TRAPS: AtomicU64 = AtomicU64::new(0);
 static LOOPS: AtomicU64 = AtomicU64::new(0);
 static BYTES: AtomicU64 = AtomicU64::new(0);
+/// CLZERO lines written with ordinary stores, for the runtime's fault handlers.
+static FAULTED: AtomicU64 = AtomicU64::new(0);
 static NEXT_REPORT: AtomicU64 = AtomicU64::new(0);
 
 fn count(kind: Kind, instructions: u64, bulk: u64) {
@@ -166,9 +168,10 @@ fn count(kind: Kind, instructions: u64, bulk: u64) {
     use std::io::Write;
     let _ = writeln!(
         std::io::stderr(),
-        "console_cpu traps={traps} clzero={z} clwb={w} rdpru={r} monitorx={m} mwaitx={h} rdpid={p} extrq={e} insertq={i} bulk_loops={} bulk_bytes={}",
+        "console_cpu traps={traps} clzero={z} clwb={w} rdpru={r} monitorx={m} mwaitx={h} rdpid={p} extrq={e} insertq={i} bulk_loops={} bulk_bytes={} clzero_faulting={}",
         LOOPS.load(Relaxed),
-        BYTES.load(Relaxed)
+        BYTES.load(Relaxed),
+        FAULTED.load(Relaxed)
     );
 }
 
@@ -242,8 +245,12 @@ unsafe fn emulate_with(ctx: &mut CONTEXT, options: Options) -> i32 {
                 } else {
                     ctx.Rax
                 };
-                if unsafe { memory::zero((address & !63) as usize, 64, options.ask) } != 64 {
-                    return 0;
+                let line = (address & !63) as usize;
+                if unsafe { memory::zero(line, 64, options.ask) } != 64 {
+                    if !unsafe { memory::zero_faulting(line) } {
+                        return 0;
+                    }
+                    FAULTED.fetch_add(1, Relaxed);
                 }
             }
             Kind::Clzero
diff --git a/crates/victory-loader/src/console_cpu/memory.rs b/crates/victory-loader/src/console_cpu/memory.rs
index 5a64509..caa09fd 100644
--- a/crates/victory-loader/src/console_cpu/memory.rs
+++ b/crates/victory-loader/src/console_cpu/memory.rs
@@ -2,7 +2,7 @@
 
 use std::{cell::Cell, ffi::c_void, mem::MaybeUninit};
 use windows_sys::Win32::System::Memory::{
-    MEM_COMMIT, MEMORY_BASIC_INFORMATION, PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE,
+    MEM_COMMIT, MEM_RESERVE, MEMORY_BASIC_INFORMATION, PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE,
     PAGE_EXECUTE_WRITECOPY, PAGE_GUARD, PAGE_READONLY, PAGE_READWRITE, PAGE_WRITECOPY,
     VirtualQuery,
 };
@@ -155,3 +155,42 @@ pub(super) unsafe fn zero(start: usize, bytes: usize, ask: bool) -> usize {
     }
     address - start
 }
+
+/// Zeroes one 64-byte line with ordinary stores, for a line that `zero` refused
+/// although it is reserved or committed: write-protected or not yet committed.
+/// The runtime keeps such memory on purpose (write-watch guards over host
+/// copies, pages committed on first touch), and its vectored handlers resolve
+/// the guest's own write faults there. CLZERO on the console faults the same
+/// way, so a store from here raises the access violation those handlers expect.
+/// They are registered at the front of the chain and see this nested fault
+/// before this handler does. Returns false, writing nothing, for free memory.
+///
+/// # Safety
+/// The caller must own the guest writes to this line. An access violation the
+/// runtime does not resolve ends the process, as the guest's write would.
+pub(super) unsafe fn zero_faulting(line: usize) -> bool {
+    debug_assert_eq!(line % 64, 0);
+    let mut info = MaybeUninit::<MEMORY_BASIC_INFORMATION>::uninit();
+    // SAFETY: the address is only queried. The output has the specified size.
+    if unsafe {
+        VirtualQuery(
+            line as _,
+            info.as_mut_ptr(),
+            size_of::<MEMORY_BASIC_INFORMATION>(),
+        )
+    } != size_of::<MEMORY_BASIC_INFORMATION>()
+    {
+        return false;
+    }
+    let info = unsafe { info.assume_init() };
+    if info.State != MEM_COMMIT && info.State != MEM_RESERVE {
+        return false;
+    }
+    DATA.set(Region::default());
+    let words = line as *mut u64;
+    for i in 0..8 {
+        // SAFETY: see the function's contract.
+        unsafe { words.add(i).write_volatile(0) };
+    }
+    true
+}
diff --git a/crates/victory-loader/src/crash.rs b/crates/victory-loader/src/crash.rs
index d69e436..3b89d52 100644
--- a/crates/victory-loader/src/crash.rs
+++ b/crates/victory-loader/src/crash.rs
@@ -764,6 +764,72 @@ mod tests {
         assert!(line.0[64..].iter().all(|&b| b == 0xff));
     }
 
+    /// A line the runtime keeps write-protected (a write-watch guard) or not yet
+    /// committed (a page committed on first touch) is zeroed through the
+    /// runtime's own fault handler, as the console's CLZERO would fault into it.
+    /// Free memory is still refused.
+    #[test]
+    fn emulated_clzero_reaches_guarded_and_uncommitted_lines() {
+        use windows_sys::Win32::System::Memory::{
+            MEM_COMMIT, MEM_RELEASE, MEM_RESERVE, PAGE_NOACCESS, PAGE_READONLY, PAGE_READWRITE,
+            VirtualAlloc, VirtualFree, VirtualProtect,
+        };
+        use windows_sys::Win32::System::Diagnostics::Debug::RemoveVectoredExceptionHandler;
+        static BASE: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
+        static RESOLVED: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
+        // Stands in for the runtime's guard and lazy-commit handlers: makes the
+        // faulting page of the test's reservation writable.
+        unsafe extern "system" fn open(info: *mut EXCEPTION_POINTERS) -> i32 {
+            let r = unsafe { &*(*info).ExceptionRecord };
+            let base = BASE.load(std::sync::atomic::Ordering::SeqCst);
+            if r.ExceptionCode != EXCEPTION_ACCESS_VIOLATION
+                || r.NumberParameters < 2
+                || r.ExceptionInformation[0] != 1
+                || !(base..base + 0x2000).contains(&r.ExceptionInformation[1])
+            {
+                return EXCEPTION_CONTINUE_SEARCH;
+            }
+            let page = r.ExceptionInformation[1] & !0xfff;
+            let mut old = 0;
+            // SAFETY: a page of the test's own reservation.
+            unsafe {
+                assert!(!VirtualAlloc(page as _, 0x1000, MEM_COMMIT, PAGE_READWRITE).is_null());
+                VirtualProtect(page as _, 0x1000, PAGE_READWRITE, &mut old);
+            }
+            RESOLVED.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
+            -1 // EXCEPTION_CONTINUE_EXECUTION
+        }
+        // SAFETY: page 0 committed read-only and filled first, page 1 only
+        // reserved; the handler is removed and the reservation released below.
+        let (base, handler) = unsafe {
+            let base = VirtualAlloc(std::ptr::null(), 0x2000, MEM_RESERVE, PAGE_NOACCESS) as usize;
+            assert_ne!(base, 0);
+            assert!(!VirtualAlloc(base as _, 0x1000, MEM_COMMIT, PAGE_READWRITE).is_null());
+            std::ptr::write_bytes(base as *mut u8, 0xff, 0x1000);
+            let mut old = 0;
+            VirtualProtect(base as _, 0x1000, PAGE_READONLY, &mut old);
+            BASE.store(base, std::sync::atomic::Ordering::SeqCst);
+            (base, AddVectoredExceptionHandler(1, Some(open)))
+        };
+        assert!(!handler.is_null());
+        let clzero = [0x0f, 0x01, 0xfc];
+        let mut xmm = [reg(0, 0); 16];
+        assert_eq!(emulate(&clzero, (base + 0x45) as u64, &mut xmm), Some(3));
+        assert_eq!(emulate(&clzero, (base + 0x1080) as u64, &mut xmm), Some(3));
+        assert_eq!(RESOLVED.load(std::sync::atomic::Ordering::SeqCst), 2);
+        // SAFETY: both pages are committed read-write now.
+        let bytes = unsafe { std::slice::from_raw_parts(base as *const u8, 0x2000) };
+        assert!(bytes[0x40..0x80].iter().all(|&b| b == 0));
+        assert!(bytes[..0x40].iter().chain(&bytes[0x80..0x1000]).all(|&b| b == 0xff));
+        assert!(bytes[0x1080..0x10c0].iter().all(|&b| b == 0));
+        // SAFETY: removes the handler and releases the reservation made above.
+        unsafe {
+            RemoveVectoredExceptionHandler(handler);
+            VirtualFree(base as _, 0, MEM_RELEASE);
+        }
+        assert_eq!(emulate(&clzero, (base + 0x40) as u64, &mut xmm), None);
+    }
+
     #[test]
     fn emulated_monitorx_and_mwaitx_are_skipped() {
         let mut xmm = [reg(1, 2); 16];

(Offered as a diff rather than a pull request: CONTRIBUTING asks for a Co-authored-by line on every commit that wouldn't be accurate here.)

**@⁠arbelonson-source** on GitHub · 2026-11-26 19:38 UTC · [original](https://github.com/stellarr-studio/kelvaroq/issues/14) ### Environment - Arch Linux, NVIDIA driver 615.78.08, **RTX 2080 Ti 11 GB** (Turing, 32-lane waves, no Resizable BAR), i9-9900K (no CLZERO), 31 GB RAM - Wine 11.22, vkd3d-proton 3.1 (rebuilt, see 1), DXVK 3.2 `dxgi` - Kelvaroq 0.2.0. The engine is rebuilt from `sources/native.zip` with Rust 1.98.1 and `cargo xwin`. It has the same `VICTORY_*` switches as the shipped `kelvaroq-engine.exe`, plus the fix below. ### Result The title boots, the menus run at 30 fps, the story loads, and the opening cutscene plays: subtitles and credit cards show, and it ran 22+ minutes without a crash. But **the 3D picture is black**, at **0.1–0.3 fps**. ### What it took, in order 1. **Crash during the prologue load (exit code 3).** vkd3d-proton 3.1's dxil-spirv (`8b48f0e`) emits invalid SPIR-V for several compute shaders: an unterminated merge block, or a merge block shared by two headers. NVIDIA's Linux compiler crashes on them (SIGILL in `vkCreateComputePipelines`), and winevulkan exits with code 3. I reproduced it natively with the dumped SPIR-V. dxil-spirv `b540c8a` (what vkd3d-proton master pins) converts all 112 shaders I saw to valid SPIR-V. Rebuilding vkd3d-proton 3.1 with it fixes the crash. 2. **CLZERO emulation (`victory-loader/src/console_cpu.rs`) declines guarded or uncommitted lines.** When the safe write is refused, it returns 0, and the illegal instruction goes unhandled: `0xc000001d` at the 12-byte loop `0f 01 fc 48 83 c0 40 4c 39 d0 72 f4`, 22 minutes in. On the console the store faults into the runtime's front-of-chain handlers (write-watch guards, lazy commit), which open the page. The fix zeroes such a line with ordinary stores from the handler, so the same handlers resolve it. Free memory is still declined. A test fails without the fix and passes with it. In a 22-minute run, 77 lines went through the fault; each was a crash before. **Diff below.** Upstream victory-fork has the same early return in `console_insn.rs`: fxceless/victory-fork#1380. 3. **A mesh pipeline refused**: blending enabled on an `R8_UINT` target (`E_INVALIDARG`). Upstream victory-fork already turns blending off on integer targets (`pipeline/host.rs`); `f85101b` predates that. 4. **Helper shaders compiled with `D3DCompile`** (depth planes from their twins, the indirect argument clamp). Wine's built-in `d3dcompiler_47` fails on them (`E5005: Method 'InterlockedOr' is not defined on type 'RWByteAddressBuffer'`). The one `winetricks d3dcompiler_47` installs (6.3.9600, Windows 8.1 SDK) rejects the targets (`X3506: unrecognized compiler target 'cs_5_1'`). A Windows 10+ `d3dcompiler_47.dll` works. Without it: "no pipeline to draw a depth plane from its twin" and "no argument clamp: indirect execution dropped". A version check at startup would make this obvious. 5. **`VICTORY_MESH_LAUNCH` (on by default) draws no world geometry here.** The log reports `indirect mesh dispatches: the largest group count asked for 0`, and the depth buffer and G-buffer of the cutscene's first 3D frames hold one character only. With `VICTORY_MESH_LAUNCH=0`, the records are non-zero (largest 493, about 12,000 groups a frame), and the world fills the depth buffer, G-buffer and shadow maps. The unit test `mesh_records_are_launched_by_the_amplification_stage` passes on this GPU under the same stack, so the shader itself works; the difference is in how a real run's records are reached. Not root-caused. (The title's own hang watchdog also fired during the slow load; I worked around it outside the engine.) ### Still open: the lighting writes exact zeros Captured with the diagnostics build (`VICTORY_CAPTURE_WORLD=1 VICTORY_DUMP_TARGETS=1`; real values from the log's `target values` lines), with all of the above applied: - The HDR scene target holds values up to 1767, and the sky target up to 9984. - The deferred-lighting compute (`df11dcd012cd7382`, 320×180 groups) writes **exactly 0** to its outputs. So does a full-screen composite (`c19a0b6c544d5e78`) that reads the sky target. - Auto-exposure reads a luminance of ~1e-6 and sits at 1024. There's no NaN in the exposure chain. - Unchanged with `VICTORY_WAVE64_PAIRED=0`, with `--console series-s` (1920×1080 internally), and with `VICTORY_LEVELS_ON_DEMAND=1`. - The bindless texture queue keeps about 19,000 of 24,000 slots due, about 8,000 of them "waiting for their memory". The DXGI budget is 8.7 GB. Not tested yet: whether dxil-spirv `b540c8a` (needed for 1) mistranslates these two shaders. The older converter crashes the driver during the load (1), so that test needs replacement shaders. Issue #11 (RTX 5070, Windows) sees the cell's window light, so this zero is probably specific to this stack. ### Performance The cutscene runs at 0.1–0.3 fps, almost all of it on the CPU. For example: about 8 s a frame of texture refreshes across threads, 2.9 s of that asking the write watch; copies of 130–200 MB a frame in 1.7–5.7 s; and about 100 million emulated console-CPU instructions in 20 minutes (CLWB, MONITORX/MWAITX, CLZERO). <details><summary>Diff: CLZERO on guarded or uncommitted lines (against <code>sources/native.zip</code> of 0.2.0)</summary> ```diff diff --git a/crates/victory-loader/src/console_cpu.rs b/crates/victory-loader/src/console_cpu.rs index 1d5e317..41b6191 100644 --- a/crates/victory-loader/src/console_cpu.rs +++ b/crates/victory-loader/src/console_cpu.rs @@ -144,6 +144,8 @@ static COUNTS: [AtomicU64; 8] = [const { AtomicU64::new(0) }; 8]; static TRAPS: AtomicU64 = AtomicU64::new(0); static LOOPS: AtomicU64 = AtomicU64::new(0); static BYTES: AtomicU64 = AtomicU64::new(0); +/// CLZERO lines written with ordinary stores, for the runtime's fault handlers. +static FAULTED: AtomicU64 = AtomicU64::new(0); static NEXT_REPORT: AtomicU64 = AtomicU64::new(0); fn count(kind: Kind, instructions: u64, bulk: u64) { @@ -166,9 +168,10 @@ fn count(kind: Kind, instructions: u64, bulk: u64) { use std::io::Write; let _ = writeln!( std::io::stderr(), - "console_cpu traps={traps} clzero={z} clwb={w} rdpru={r} monitorx={m} mwaitx={h} rdpid={p} extrq={e} insertq={i} bulk_loops={} bulk_bytes={}", + "console_cpu traps={traps} clzero={z} clwb={w} rdpru={r} monitorx={m} mwaitx={h} rdpid={p} extrq={e} insertq={i} bulk_loops={} bulk_bytes={} clzero_faulting={}", LOOPS.load(Relaxed), - BYTES.load(Relaxed) + BYTES.load(Relaxed), + FAULTED.load(Relaxed) ); } @@ -242,8 +245,12 @@ unsafe fn emulate_with(ctx: &mut CONTEXT, options: Options) -> i32 { } else { ctx.Rax }; - if unsafe { memory::zero((address & !63) as usize, 64, options.ask) } != 64 { - return 0; + let line = (address & !63) as usize; + if unsafe { memory::zero(line, 64, options.ask) } != 64 { + if !unsafe { memory::zero_faulting(line) } { + return 0; + } + FAULTED.fetch_add(1, Relaxed); } } Kind::Clzero diff --git a/crates/victory-loader/src/console_cpu/memory.rs b/crates/victory-loader/src/console_cpu/memory.rs index 5a64509..caa09fd 100644 --- a/crates/victory-loader/src/console_cpu/memory.rs +++ b/crates/victory-loader/src/console_cpu/memory.rs @@ -2,7 +2,7 @@ use std::{cell::Cell, ffi::c_void, mem::MaybeUninit}; use windows_sys::Win32::System::Memory::{ - MEM_COMMIT, MEMORY_BASIC_INFORMATION, PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE, + MEM_COMMIT, MEM_RESERVE, MEMORY_BASIC_INFORMATION, PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE, PAGE_EXECUTE_WRITECOPY, PAGE_GUARD, PAGE_READONLY, PAGE_READWRITE, PAGE_WRITECOPY, VirtualQuery, }; @@ -155,3 +155,42 @@ pub(super) unsafe fn zero(start: usize, bytes: usize, ask: bool) -> usize { } address - start } + +/// Zeroes one 64-byte line with ordinary stores, for a line that `zero` refused +/// although it is reserved or committed: write-protected or not yet committed. +/// The runtime keeps such memory on purpose (write-watch guards over host +/// copies, pages committed on first touch), and its vectored handlers resolve +/// the guest's own write faults there. CLZERO on the console faults the same +/// way, so a store from here raises the access violation those handlers expect. +/// They are registered at the front of the chain and see this nested fault +/// before this handler does. Returns false, writing nothing, for free memory. +/// +/// # Safety +/// The caller must own the guest writes to this line. An access violation the +/// runtime does not resolve ends the process, as the guest's write would. +pub(super) unsafe fn zero_faulting(line: usize) -> bool { + debug_assert_eq!(line % 64, 0); + let mut info = MaybeUninit::<MEMORY_BASIC_INFORMATION>::uninit(); + // SAFETY: the address is only queried. The output has the specified size. + if unsafe { + VirtualQuery( + line as _, + info.as_mut_ptr(), + size_of::<MEMORY_BASIC_INFORMATION>(), + ) + } != size_of::<MEMORY_BASIC_INFORMATION>() + { + return false; + } + let info = unsafe { info.assume_init() }; + if info.State != MEM_COMMIT && info.State != MEM_RESERVE { + return false; + } + DATA.set(Region::default()); + let words = line as *mut u64; + for i in 0..8 { + // SAFETY: see the function's contract. + unsafe { words.add(i).write_volatile(0) }; + } + true +} diff --git a/crates/victory-loader/src/crash.rs b/crates/victory-loader/src/crash.rs index d69e436..3b89d52 100644 --- a/crates/victory-loader/src/crash.rs +++ b/crates/victory-loader/src/crash.rs @@ -764,6 +764,72 @@ mod tests { assert!(line.0[64..].iter().all(|&b| b == 0xff)); } + /// A line the runtime keeps write-protected (a write-watch guard) or not yet + /// committed (a page committed on first touch) is zeroed through the + /// runtime's own fault handler, as the console's CLZERO would fault into it. + /// Free memory is still refused. + #[test] + fn emulated_clzero_reaches_guarded_and_uncommitted_lines() { + use windows_sys::Win32::System::Memory::{ + MEM_COMMIT, MEM_RELEASE, MEM_RESERVE, PAGE_NOACCESS, PAGE_READONLY, PAGE_READWRITE, + VirtualAlloc, VirtualFree, VirtualProtect, + }; + use windows_sys::Win32::System::Diagnostics::Debug::RemoveVectoredExceptionHandler; + static BASE: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); + static RESOLVED: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); + // Stands in for the runtime's guard and lazy-commit handlers: makes the + // faulting page of the test's reservation writable. + unsafe extern "system" fn open(info: *mut EXCEPTION_POINTERS) -> i32 { + let r = unsafe { &*(*info).ExceptionRecord }; + let base = BASE.load(std::sync::atomic::Ordering::SeqCst); + if r.ExceptionCode != EXCEPTION_ACCESS_VIOLATION + || r.NumberParameters < 2 + || r.ExceptionInformation[0] != 1 + || !(base..base + 0x2000).contains(&r.ExceptionInformation[1]) + { + return EXCEPTION_CONTINUE_SEARCH; + } + let page = r.ExceptionInformation[1] & !0xfff; + let mut old = 0; + // SAFETY: a page of the test's own reservation. + unsafe { + assert!(!VirtualAlloc(page as _, 0x1000, MEM_COMMIT, PAGE_READWRITE).is_null()); + VirtualProtect(page as _, 0x1000, PAGE_READWRITE, &mut old); + } + RESOLVED.fetch_add(1, std::sync::atomic::Ordering::SeqCst); + -1 // EXCEPTION_CONTINUE_EXECUTION + } + // SAFETY: page 0 committed read-only and filled first, page 1 only + // reserved; the handler is removed and the reservation released below. + let (base, handler) = unsafe { + let base = VirtualAlloc(std::ptr::null(), 0x2000, MEM_RESERVE, PAGE_NOACCESS) as usize; + assert_ne!(base, 0); + assert!(!VirtualAlloc(base as _, 0x1000, MEM_COMMIT, PAGE_READWRITE).is_null()); + std::ptr::write_bytes(base as *mut u8, 0xff, 0x1000); + let mut old = 0; + VirtualProtect(base as _, 0x1000, PAGE_READONLY, &mut old); + BASE.store(base, std::sync::atomic::Ordering::SeqCst); + (base, AddVectoredExceptionHandler(1, Some(open))) + }; + assert!(!handler.is_null()); + let clzero = [0x0f, 0x01, 0xfc]; + let mut xmm = [reg(0, 0); 16]; + assert_eq!(emulate(&clzero, (base + 0x45) as u64, &mut xmm), Some(3)); + assert_eq!(emulate(&clzero, (base + 0x1080) as u64, &mut xmm), Some(3)); + assert_eq!(RESOLVED.load(std::sync::atomic::Ordering::SeqCst), 2); + // SAFETY: both pages are committed read-write now. + let bytes = unsafe { std::slice::from_raw_parts(base as *const u8, 0x2000) }; + assert!(bytes[0x40..0x80].iter().all(|&b| b == 0)); + assert!(bytes[..0x40].iter().chain(&bytes[0x80..0x1000]).all(|&b| b == 0xff)); + assert!(bytes[0x1080..0x10c0].iter().all(|&b| b == 0)); + // SAFETY: removes the handler and releases the reservation made above. + unsafe { + RemoveVectoredExceptionHandler(handler); + VirtualFree(base as _, 0, MEM_RELEASE); + } + assert_eq!(emulate(&clzero, (base + 0x40) as u64, &mut xmm), None); + } + #[test] fn emulated_monitorx_and_mwaitx_are_skipped() { let mut xmm = [reg(1, 2); 16]; ``` </details> (Offered as a diff rather than a pull request: CONTRIBUTING asks for a `Co-authored-by` line on every commit that wouldn't be accurate here.)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:48:58 +00:00
Author
Owner

@⁠TeraByte38 on GitHub · 2026-11-26 21:15 UTC · original · edited 2026-11-26 21:18 UTC

how the hell did you get the exe to load? this is what i get: #13

**@⁠TeraByte38** on GitHub · 2026-11-26 21:15 UTC · [original](https://github.com/stellarr-studio/kelvaroq/issues/14#issuecomment-7203542382) · edited 2026-11-26 21:18 UTC how the hell did you get the exe to load? this is what i get: #13
Author
Owner

@⁠Suyash728 on GitHub · 2026-11-26 21:26 UTC · original

@⁠arbelonson-source I use CachyOS (arch btw too)... I'm still sourcing the game files. Do you run this repo's exe using wine/proton and that's it right? no additional setup required?

**@⁠Suyash728** on GitHub · 2026-11-26 21:26 UTC · [original](https://github.com/stellarr-studio/kelvaroq/issues/14#issuecomment-7203735858) @⁠arbelonson-source I use CachyOS (arch btw too)... I'm still sourcing the game files. Do you run this repo's exe using wine/proton and that's it right? no additional setup required?
Author
Owner

@⁠pickles976 on GitHub · 2026-11-27 21:08 UTC · original

A concrete shader identity cross-check from our local retail 1.0.2.1 shader-info output: your pixel hash c19a0b6c544d5e78 is MotionBlur / MotionBlur / pass 7 / PS_MotionBlurLowRes_6191104a_Wrapped, paired with VS 0d007b998ee2d8b2. That is a useful narrowing of “full-screen composite”; it does not establish that the effect name is its actual resource producer in this run. df11dcd012cd7382 did not match our extracted shaders.rpf effect listing, so I cannot identify that compute stage from this evidence.

Our RTX 4060 Laptop / Wine 11 mixed stack has a related but not identical observation: recognizable G-buffer/depth, yet exact-zero FP16 colour at the native FFX input boundary, with exact-zero output after a successful call. Your nonzero HDR/sky values therefore should not be treated as the same proven resource chain. Reference: https://github.com/Marvisak/VIctory/issues/841#issuecomment-7227226100 .

One diagnostic pitfall we corrected locally: bracketing a selected dispatch while always copying a global HDR texture did not prove that the dispatch bound that texture as its UAV. A real-GPU fixture now binds a different native texture through the descriptor slot, verifies every resulting pixel there, and verifies that the global/metadata texture stays zero. Actual-title measurement with that corrected probe is still pending; I am not claiming your capture has this defect.

Actionable next evidence would be command-ordered actual bound SRV/UAV identities, root/table offsets, dimensions/formats, and pre/post values for these two hashes, including original indirect arguments if applicable. This distinguishes zero inputs, an empty optional draw, and an executing shader producing zero without assuming every full-screen pass is the missing HDR producer. No asset/image uploads needed.

Local identity evidence: .compat-runtime/logs/verify-scene-shader-effects-20261127T081804Z/console.log:3774-3784. No new title run or gameplay claim. AI-assisted source/evidence review with OpenAI Codex / GPT-6 Astra.

**@⁠pickles976** on GitHub · 2026-11-27 21:08 UTC · [original](https://github.com/stellarr-studio/kelvaroq/issues/14#issuecomment-7228177657) A concrete shader identity cross-check from our local retail 1.0.2.1 shader-info output: your pixel hash `c19a0b6c544d5e78` is `MotionBlur / MotionBlur / pass 7 / PS_MotionBlurLowRes_6191104a_Wrapped`, paired with VS `0d007b998ee2d8b2`. That is a useful narrowing of “full-screen composite”; it does not establish that the effect name is its actual resource producer in this run. `df11dcd012cd7382` did not match our extracted shaders.rpf effect listing, so I cannot identify that compute stage from this evidence. Our RTX 4060 Laptop / Wine 11 mixed stack has a related but not identical observation: recognizable G-buffer/depth, yet exact-zero FP16 colour **at the native FFX input boundary**, with exact-zero output after a successful call. Your nonzero HDR/sky values therefore should not be treated as the same proven resource chain. Reference: https://github.com/Marvisak/VIctory/issues/841#issuecomment-7227226100 . One diagnostic pitfall we corrected locally: bracketing a selected dispatch while always copying a global HDR texture did not prove that the dispatch bound that texture as its UAV. A real-GPU fixture now binds a different native texture through the descriptor slot, verifies every resulting pixel there, and verifies that the global/metadata texture stays zero. Actual-title measurement with that corrected probe is still pending; I am not claiming your capture has this defect. Actionable next evidence would be command-ordered **actual bound SRV/UAV identities**, root/table offsets, dimensions/formats, and pre/post values for these two hashes, including original indirect arguments if applicable. This distinguishes zero inputs, an empty optional draw, and an executing shader producing zero without assuming every full-screen pass is the missing HDR producer. No asset/image uploads needed. Local identity evidence: `.compat-runtime/logs/verify-scene-shader-effects-20261127T081804Z/console.log:3774-3784`. No new title run or gameplay claim. AI-assisted source/evidence review with OpenAI Codex / GPT-6 Astra.
This discussion has been locked. Commenting is limited to contributors.
No description provided.