From 070a7378543b8efac3496e6a344393efadbe30b7 Mon Sep 17 00:00:00 2001 From: ShyVortex Date: Mon, 23 Nov 2026 19:24:31 +0100 Subject: [PATCH] D3D12.X: GetGPUVirtualAddress of a placed texture is its title address On the console a texture has a GPU address like any resource. A retail game turns a 256x256 R32_FLOAT texture's address into the CPU pointer it clears it through; on the PC GetGPUVirtualAddress of a texture is 0, so it wrote 256 KB at address 0. For a resource the title placed at its own address, the PC's answer 0 becomes that address (title_address); buffers and everything with a PC address are unchanged. Co-Authored-By: Claude Opus 5.5 --- crates/xcl/src/hle/d3d12x/real.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/xcl/src/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs index 408901615a..8053c994c6 100644 --- a/crates/xcl/src/hle/d3d12x/real.rs +++ b/crates/xcl/src/hle/d3d12x/real.rs @@ -1488,13 +1488,19 @@ fn forget_pso(pso: usize) { drop(gone); } -/// resource #11 GetGPUVirtualAddress for console code +/// resource #11 GetGPUVirtualAddress for console code. On the console a texture has an address +/// too: a texture the title placed at its own address answers with it (`title_address`) where +/// the PC's answer is 0 – a retail game turns a texture's address into the CPU pointer it +/// clears it through, and wrote 256 KB at address 0. unsafe extern "system" fn res_gpu_va_x(this: *mut c_void) -> u64 { if let Some((p, _)) = console_buffer(this as usize) { return p as u64; } let f: unsafe extern "system" fn(*mut c_void) -> u64 = std::mem::transmute(orig_fn(this, 11)); - f(this) + match f(this) { + 0 => title_address(this as usize).map_or(0, |va| va as u64), + va => va, + } } fn note_buffer_view() {