upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/main.cpp
diff options
context:
space:
mode:
authorRaavve <184497748+Raavve@users.noreply.github.com>2026-11-23 17:56:23 -0300
committerRaavve <184497748+Raavve@users.noreply.github.com>2026-11-23 18:51:49 -0300
commitcb29a2b88f9f538f70c70575bdc9183b469fba9b (patch)
tree27ce206b93d4573ab2dbc6a8c2b9c84be7b0c090 /runtime/src/main.cpp
parent664aff24f136a3cf2206930051d24f1a224d1795 (diff)
d3d12_xs: slot 133 commits the buffer's xmem pages before the host-pointer import
xmem commits physical pages on first touch (#7556), so a range the title has mapped but not written yet is still MEM_RESERVE when it places a buffer on it through device slot 133, and the Vulkan layer's import (#7218) refuses reserved pages and answers with its fallback buffer, which the title's writes never reach. Slot 133 now calls a registered pages hook (set_placed_at_va_pages_hook, next to set_placed_at_va_handler) with the buffer's range before the handler; gta6rt registers rt::xmem::commit_physical_range. A failed commit is logged once and the handler still runs. Textures don't call it. The Vulkan layer doesn't link xmem. Tests: xs_proxy_mock_test checks the hook order, arguments, failure and texture cases; the new d3d12_xmem_placed_test places a buffer on untouched xmem physical pages and checks the fallback without the hook, and with it the import and a GPU copy reading the CPU's writes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/main.cpp')
-rw-r--r--runtime/src/main.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp
index 71a5b44e1..39b362a01 100644
--- a/runtime/src/main.cpp
+++ b/runtime/src/main.cpp
@@ -32,10 +32,12 @@
32#include "mods.h" 32#include "mods.h"
33#include "pe_loader.h" 33#include "pe_loader.h"
34#include "../shims/d3d12_trace.h" 34#include "../shims/d3d12_trace.h"
35#include "../shims/d3d12_xs_device.h"
35#include "../shims/file_system.h" 36#include "../shims/file_system.h"
36#include "../shims/process_shim.h" 37#include "../shims/process_shim.h"
37#include "../shims/shims.h" 38#include "../shims/shims.h"
38#include "../shims/startup_trace.h" 39#include "../shims/startup_trace.h"
40#include "../shims/xmem.h"
39 41
40namespace { 42namespace {
41 43
@@ -147,6 +149,8 @@ int wmain(int argc, wchar_t** argv) {
147 "this executable (docs/modding.md)\n", leonida::mods::active().size()); 149 "this executable (docs/modding.md)\n", leonida::mods::active().size());
148 } 150 }
149 rt::d3d12_trace::set_enabled(trace_d3d12); 151 rt::d3d12_trace::set_enabled(trace_d3d12);
152 // Slot 133 imports the title's pages; xmem commits them on first touch, so they are committed first.
153 rt::d3d12_xs::set_placed_at_va_pages_hook(&rt::xmem::commit_physical_range);
150 if (int trace_error = 0; !trace_file.empty() && !rt::startup_trace::open(trace_file.c_str(), &trace_error)) { 154 if (int trace_error = 0; !trace_file.empty() && !rt::startup_trace::open(trace_file.c_str(), &trace_error)) {
151 std::fprintf(stderr, trace_error == EEXIST ? "error: the trace file already exists; --trace only creates a new file\n" 155 std::fprintf(stderr, trace_error == EEXIST ? "error: the trace file already exists; --trace only creates a new file\n"
152 : "error: cannot create the trace file\n"); 156 : "error: cannot create the trace file\n");