From 2dbf6e82c65d987a99ecbee7e67bfc0593b38730 Mon Sep 17 00:00:00 2001
From: bmjask <>
Date: Thu, 26 Nov 2026 11:18:43 -0800
Subject: [PATCH] D3D12.X: measure write-watch range costs
Choosing between more GetWriteWatch calls and scanning gap bytes needs Windows measurements. Keep the existing 8 MiB production policy, add opt-in exact coverage and call timing, and provide a deterministic allocation-safe planner plus a manual threshold benchmark for a later measured activation.
Cross-checked debug tests and release all-target builds for x86_64-pc-windows-gnu; the Windows benchmark, runtime tests, GPU tests, and smoke run were not run here.
Assisted-by: Codex (GPT-5.6-sol)
---
crates/xcl/src/hle/d3d12x/title_textures.rs | 262 ++++++++++++++++++--
1 file changed, 243 insertions(+), 19 deletions(-)
diff --git a/crates/xcl/src/hle/d3d12x/title_textures.rs b/crates/xcl/src/hle/d3d12x/title_textures.rs
index ae8eeff4a7..e7fdaa7d44 100644
--- a/crates/xcl/src/hle/d3d12x/title_textures.rs
+++ b/crates/xcl/src/hle/d3d12x/title_textures.rs
@@ -346,8 +346,15 @@ static REFRESH: Mutex<()> = Mutex::new(());
static TEXTURES_GEN: AtomicU64 = AtomicU64::new(0);
static TEXTURES_LEN: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
static CPU_TEXTURES_LEN: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
+
+struct WatchRanges {
+ ranges: Vec<(usize, usize)>,
+ wanted_bytes: usize,
+ excess_bytes: usize,
+}
+
/// cached `watch_ranges` keyed by `(sparse::mapped_gen, TEXTURES_GEN, graphics_reservations_gen)`
-static WATCH_CACHE: Mutex