From 78e753ef524bf5495365420127817858511f3eae Mon Sep 17 00:00:00 2001 From: Gliniak Date: Sun, 30 Nov 2025 13:10:53 +0100 Subject: [PATCH] [GPU] Added config option to enable/disable invalid memory uploads --- src/xenia/gpu/d3d12/d3d12_shared_memory.cc | 10 ++++++---- src/xenia/gpu/gpu_flags.cc | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/xenia/gpu/d3d12/d3d12_shared_memory.cc b/src/xenia/gpu/d3d12/d3d12_shared_memory.cc index 1adc9db40..24a4d12b9 100644 --- a/src/xenia/gpu/d3d12/d3d12_shared_memory.cc +++ b/src/xenia/gpu/d3d12/d3d12_shared_memory.cc @@ -25,6 +25,8 @@ DEFINE_bool(d3d12_tiled_shared_memory, true, "to work.", "D3D12"); +DECLARE_bool(gpu_allow_invalid_upload_range); + namespace xe { namespace gpu { namespace d3d12 { @@ -419,15 +421,15 @@ bool D3D12SharedMemory::UploadRanges( trace_writer_.WriteMemoryRead(upload_range_start << page_size_log2(), upload_range_length << page_size_log2()); - if (upload_range_length > 0) { + if (upload_range_length > 0 && !cvars::gpu_allow_invalid_upload_range) { const uint32_t upload_range_last_page = upload_range_start + upload_range_length - 1; - memory::PageAccess page_access = + const memory::PageAccess page_access = memory().GetPhysicalHeap()->QueryRangeAccess( upload_range_last_page << page_size_log2(), - (upload_range_last_page - << page_size_log2())); // Check only last page + upload_range_last_page + << page_size_log2()); // Check only last page if (page_access == xe::memory::PageAccess::kNoAccess) { XELOGE("Invalid upload range for GPU: {:08X}", upload_range_start); diff --git a/src/xenia/gpu/gpu_flags.cc b/src/xenia/gpu/gpu_flags.cc index 311715fad..c0cc3f290 100644 --- a/src/xenia/gpu/gpu_flags.cc +++ b/src/xenia/gpu/gpu_flags.cc @@ -33,6 +33,10 @@ DEFINE_bool( "may be used to bypass fetch constant type errors in certain games until " "the real reason why they're invalid is found.", "GPU"); +DEFINE_bool( + gpu_allow_invalid_upload_range, false, + "Allows games to read data from pages that are marked as no access.", + "GPU"); DEFINE_bool( non_seamless_cube_map, true,