From 54221a06832467622d78af242796e4adf43414f8 Mon Sep 17 00:00:00 2001
From: Filip722 <37023444+Filip722@users.noreply.github.com>
Date: Tue, 24 Nov 2026 12:24:02 +0100
Subject: [PATCH 1/3] xcl run: report process memory under Wine
Wine leaves PrivateUsage unset, which makes the activity log report zero process memory. Reuse the existing title-memory fallback to PagefileUsage so pressure is visible during a run.
Assisted-by: OpenAI Codex (GPT-6.2-Sol high)
---
README.md | 2 ++
crates/xcl/src/hle/kernelx.rs | 2 +-
crates/xcl/src/host.rs | 10 ++--------
3 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index 0710608d4d..15c1e60a26 100644
--- a/README.md
+++ b/README.md
@@ -125,6 +125,8 @@ xcl rpf D:\data\shaders.rpf --extract NAME --out folder
- **The game folder is never modified** – writes go to the overlay.
- Translated shaders are reused across XCL rebuilds when the translator sources and DXC
toolchain are unchanged; `XCL_TRANSLATED_CACHE=0` disables that disk cache.
+- `XCL_ACTIVITY=1` logs rendering, streaming and memory activity every two seconds. Under Wine,
+ the process commit figure is Wine's estimate from anonymous resident memory and swap.
- Every run writes `report.json` (called stubs, unknown D3D12.X slots and interfaces, XGameRuntime
classes asked for, shader statistics, audio formats, crash).
`d3d12.presents` counts presentations, not visible content. With `XCL_FRAME_DUMP=N` (`N > 1`),
diff --git a/crates/xcl/src/hle/kernelx.rs b/crates/xcl/src/hle/kernelx.rs
index 8aa3bc2002..7c48d656f6 100644
--- a/crates/xcl/src/hle/kernelx.rs
+++ b/crates/xcl/src/hle/kernelx.rs
@@ -730,7 +730,7 @@ pub struct TitleMemoryStatusT {
pub title_page_table_used: u64,
}
-fn process_private_bytes() -> u64 {
+pub(crate) fn process_private_bytes() -> u64 {
use windows_sys::Win32::System::ProcessStatus::{K32GetProcessMemoryInfo, PROCESS_MEMORY_COUNTERS_EX};
unsafe {
let mut c: PROCESS_MEMORY_COUNTERS_EX = std::mem::zeroed();
diff --git a/crates/xcl/src/host.rs b/crates/xcl/src/host.rs
index ba5dcb4737..dcc7a25b2d 100644
--- a/crates/xcl/src/host.rs
+++ b/crates/xcl/src/host.rs
@@ -49,13 +49,7 @@ pub fn host_main(boot_path: &Path) -> i32 {
d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8], d[9], d[10]
);
// where the memory is: the process's commit, video memory, and XCL's parts of it
- let private = unsafe {
- use windows_sys::Win32::System::ProcessStatus::{K32GetProcessMemoryInfo, PROCESS_MEMORY_COUNTERS_EX};
- let mut c: PROCESS_MEMORY_COUNTERS_EX = std::mem::zeroed();
- c.cb = std::mem::size_of_val(&c) as u32;
- K32GetProcessMemoryInfo(windows_sys::Win32::System::Threading::GetCurrentProcess(), &mut c as *mut _ as *mut _, c.cb);
- c.PrivateUsage
- };
+ let private = crate::hle::kernelx::process_private_bytes();
let (local, non_local) = crate::hle::d3d12x::real::video_memory().unwrap_or((0, 0));
let (arenas, arenas_made) = crate::hle::d3d12x::vram::arena_bytes();
let (pools, pools_mapped) = crate::hle::d3d12x::sparse::pool_bytes();
@@ -63,7 +57,7 @@ pub fn host_main(boot_path: &Path) -> i32 {
let mb = |b: u64| b >> 20;
crate::xlog_info!(
"memory: {} MB committed by the process; video memory {} MB local, {} MB non-local; target pages {} MB (pools {} MB); arenas {} MB in use, {} MB made; sparse pools {} MB ({} MB mapped)",
- mb(private as u64),
+ mb(private),
mb(local),
mb(non_local),
mb(pages as u64),
From 2ba567b12f3baa9df58ff63577cd4da1601ffecd Mon Sep 17 00:00:00 2001
From: Filip722 <37023444+Filip722@users.noreply.github.com>
Date: Tue, 24 Nov 2026 17:52:18 +0100
Subject: [PATCH 2/3] Docs: move Wine memory notes below frame dumps
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 15c1e60a26..05f683f401 100644
--- a/README.md
+++ b/README.md
@@ -125,8 +125,6 @@ xcl rpf D:\data\shaders.rpf --extract NAME --out folder
- **The game folder is never modified** – writes go to the overlay.
- Translated shaders are reused across XCL rebuilds when the translator sources and DXC
toolchain are unchanged; `XCL_TRANSLATED_CACHE=0` disables that disk cache.
-- `XCL_ACTIVITY=1` logs rendering, streaming and memory activity every two seconds. Under Wine,
- the process commit figure is Wine's estimate from anonymous resident memory and swap.
- Every run writes `report.json` (called stubs, unknown D3D12.X slots and interfaces, XGameRuntime
classes asked for, shader statistics, audio formats, crash).
`d3d12.presents` counts presentations, not visible content. With `XCL_FRAME_DUMP=N` (`N > 1`),
@@ -136,6 +134,8 @@ xcl rpf D:\data\shaders.rpf --extract NAME --out folder
`null` if its format cannot be decoded. Intermediate render-target dumps do not update it.
Sampling uses every fourth pixel in each direction (`XCL_FRAME_DUMP_FULL=1`: every pixel).
A coarse sample can miss detail; a non-dark sample does not establish correct rendering or gameplay.
+- `XCL_ACTIVITY=1` logs rendering, streaming and memory activity every two seconds. Under Wine,
+ the process commit figure is Wine's estimate from anonymous resident memory and swap.
- Title data: `%LOCALAPPDATA%\XCL\
\` (`%XCL_DATA_ROOT%`): `xcl.toml`, `overlay\`, `saves\`,
`pls\` (the title's `S:\`), `temp\` (`T:\`), `cache\`, `logs\xcl.log`, `logs\report.json` (the
previous run's: `xcl.prev.log`, `report.prev.json`).
From bdf09130d7b416823c1207e6df1e46cb70259c15 Mon Sep 17 00:00:00 2001
From: Filip722 <37023444+Filip722@users.noreply.github.com>
Date: Wed, 25 Nov 2026 00:01:05 +0100
Subject: [PATCH 3/3] Limit the activity memory fallback to Wine on Linux
CrossOver on macOS includes uncommitted address space in PagefileUsage. Use that counter for activity reporting only when Wine identifies its host as Linux. Keep the guest title-memory API behavior.
Assisted-by: OpenAI Codex (GPT-6.2-astra)
---
README.md | 4 ++--
crates/xcl/src/hle/kernelx.rs | 24 ++++++++++++++++++++----
crates/xcl/src/host.rs | 2 +-
crates/xcl/src/util.rs | 17 +++++++++++++++++
4 files changed, 40 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 99a3b3d679..cc35496922 100644
--- a/README.md
+++ b/README.md
@@ -153,8 +153,8 @@ xcl rpf D:\data\shaders.rpf --extract NAME --out folder
`null` if its format cannot be decoded. Intermediate render-target dumps do not update it.
Sampling uses every fourth pixel in each direction (`XCL_FRAME_DUMP_FULL=1`: every pixel).
A coarse sample can miss detail; a non-dark sample does not establish correct rendering or gameplay.
-- `XCL_ACTIVITY=1` logs rendering, streaming and memory activity every two seconds. Under Wine,
- the process commit figure is Wine's estimate from anonymous resident memory and swap.
+- `XCL_ACTIVITY=1` logs rendering, streaming and memory activity every two seconds. Under Wine on Linux,
+ missing private usage falls back to an estimate from anonymous resident memory and swap.
- Title data: `%LOCALAPPDATA%\XCL\\` (`%XCL_DATA_ROOT%`): `xcl.toml`, `overlay\`, `saves\`,
`pls\` (the title's `S:\`), `temp\` (`T:\`), `cache\`, `logs\xcl.log`, `logs\report.json` (the
previous run's: `xcl.prev.log`, `report.prev.json`).
diff --git a/crates/xcl/src/hle/kernelx.rs b/crates/xcl/src/hle/kernelx.rs
index 317d04ea57..3d74082204 100644
--- a/crates/xcl/src/hle/kernelx.rs
+++ b/crates/xcl/src/hle/kernelx.rs
@@ -731,15 +731,22 @@ pub struct TitleMemoryStatusT {
pub title_page_table_used: u64,
}
-pub(crate) fn process_private_bytes() -> u64 {
+fn process_private_bytes() -> u64 {
+ // Keep the guest title-memory APIs' existing PagefileUsage fallback.
+ process_commit_bytes(true)
+}
+
+fn commit_bytes(private: usize, pagefile: usize, allow_pagefile: bool) -> u64 {
+ if private == 0 && allow_pagefile { pagefile as u64 } else { private as u64 }
+}
+
+pub(crate) fn process_commit_bytes(allow_pagefile: bool) -> u64 {
use windows_sys::Win32::System::ProcessStatus::{K32GetProcessMemoryInfo, PROCESS_MEMORY_COUNTERS_EX};
unsafe {
let mut c: PROCESS_MEMORY_COUNTERS_EX = std::mem::zeroed();
c.cb = std::mem::size_of::() as u32;
if K32GetProcessMemoryInfo(thr::GetCurrentProcess(), &mut c as *mut _ as *mut _, c.cb) != 0 {
- // Wine fills the fields before PrivateUsage only; PagefileUsage is the same number
- // on Windows (the commit charge)
- if c.PrivateUsage != 0 { c.PrivateUsage as u64 } else { c.PagefileUsage as u64 }
+ commit_bytes(c.PrivateUsage, c.PagefileUsage, allow_pagefile)
} else {
0
}
@@ -2653,6 +2660,15 @@ mod tests {
}
}
+ #[test]
+ fn activity_commit_uses_pagefile_only_when_allowed() {
+ assert_eq!(commit_bytes(123, 456, false), 123);
+ assert_eq!(commit_bytes(123, 456, true), 123);
+ assert_eq!(commit_bytes(0, 456, true), 456);
+ // CrossOver reports the virtual size, including uncommitted reservations.
+ assert_eq!(commit_bytes(0, 50169 << 20, false), 0);
+ }
+
#[test]
fn title_memory_status_reports_budget() {
let mut s: TitleMemoryStatusT = unsafe { std::mem::zeroed() };
diff --git a/crates/xcl/src/host.rs b/crates/xcl/src/host.rs
index dcc7a25b2d..664583f655 100644
--- a/crates/xcl/src/host.rs
+++ b/crates/xcl/src/host.rs
@@ -49,7 +49,7 @@ pub fn host_main(boot_path: &Path) -> i32 {
d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8], d[9], d[10]
);
// where the memory is: the process's commit, video memory, and XCL's parts of it
- let private = crate::hle::kernelx::process_private_bytes();
+ let private = crate::hle::kernelx::process_commit_bytes(crate::util::linux_wine());
let (local, non_local) = crate::hle::d3d12x::real::video_memory().unwrap_or((0, 0));
let (arenas, arenas_made) = crate::hle::d3d12x::vram::arena_bytes();
let (pools, pools_mapped) = crate::hle::d3d12x::sparse::pool_bytes();
diff --git a/crates/xcl/src/util.rs b/crates/xcl/src/util.rs
index e72db3ac44..94b6b5ed25 100644
--- a/crates/xcl/src/util.rs
+++ b/crates/xcl/src/util.rs
@@ -132,6 +132,23 @@ pub fn under_wine() -> bool {
})
}
+/// Wine on Linux reports anonymous resident bytes and swap in PagefileUsage.
+pub(crate) fn linux_wine() -> bool {
+ use std::ffi::{c_char, CStr};
+ use std::sync::OnceLock;
+ use windows_sys::Win32::System::LibraryLoader::{GetModuleHandleA, GetProcAddress};
+ static LINUX_WINE: OnceLock = OnceLock::new();
+ *LINUX_WINE.get_or_init(|| unsafe {
+ let ntdll = GetModuleHandleA(c"ntdll.dll".as_ptr().cast());
+ let Some(proc) = GetProcAddress(ntdll, c"wine_get_host_version".as_ptr().cast()) else { return false };
+ // Wine exports this C function and returns a pointer to a static host name.
+ let host_version: unsafe extern "C" fn(*mut *const c_char, *mut *const c_char) = std::mem::transmute(proc);
+ let mut name = std::ptr::null();
+ host_version(&mut name, std::ptr::null_mut());
+ !name.is_null() && CStr::from_ptr(name) == c"Linux"
+ })
+}
+
/// Normalised DLL key: lower-case file name, ".dll" appended when no extension.
pub fn dll_key(name: &str) -> String {
let base = name.rsplit(['\\', '/']).next().unwrap_or(name);